File tree Expand file tree Collapse file tree 3 files changed +15
-9
lines changed Expand file tree Collapse file tree 3 files changed +15
-9
lines changed Original file line number Diff line number Diff line change 2020using System ;
2121using System . Collections . Generic ;
2222
23+ #nullable enable
24+
2325namespace OpenQA . Selenium
2426{
2527 /// <summary>
2628 /// Defines the interface through which the user can manipulate JavaScript alerts.
2729 /// </summary>
2830 internal class Alert : IAlert
2931 {
30- private WebDriver driver ;
32+ private readonly WebDriver driver ;
3133
3234 /// <summary>
3335 /// Initializes a new instance of the <see cref="Alert"/> class.
@@ -41,12 +43,12 @@ public Alert(WebDriver driver)
4143 /// <summary>
4244 /// Gets the text of the alert.
4345 /// </summary>
44- public string Text
46+ public string ? Text
4547 {
4648 get
4749 {
4850 Response commandResponse = this . driver . InternalExecute ( DriverCommand . GetAlertText , null ) ;
49- return commandResponse . Value . ToString ( ) ;
51+ return ( string ? ) commandResponse . Value ;
5052 }
5153 }
5254
@@ -70,9 +72,10 @@ public void Accept()
7072 /// Sends keys to the alert.
7173 /// </summary>
7274 /// <param name="keysToSend">The keystrokes to send.</param>
75+ /// <exception cref="ArgumentNullException">If <paramref name="keysToSend" /> is <see langword="null"/>.</exception>
7376 public void SendKeys ( string keysToSend )
7477 {
75- if ( keysToSend == null )
78+ if ( keysToSend is null )
7679 {
7780 throw new ArgumentNullException ( nameof ( keysToSend ) , "Keys to send must not be null." ) ;
7881 }
Original file line number Diff line number Diff line change @@ -351,14 +351,12 @@ public override string ToString()
351351 public override bool Equals ( object obj )
352352 {
353353 // Two cookies are equal if the name and value match
354- Cookie cookie = obj as Cookie ;
355-
356354 if ( this == obj )
357355 {
358356 return true ;
359357 }
360358
361- if ( cookie == null )
359+ if ( obj is not Cookie cookie )
362360 {
363361 return false ;
364362 }
@@ -368,7 +366,7 @@ public override bool Equals(object obj)
368366 return false ;
369367 }
370368
371- return ! ( this . cookieValue != null ? ! this . cookieValue . Equals ( cookie . cookieValue ) : cookie . Value != null ) ;
369+ return string . Equals ( this . cookieValue , cookie . cookieValue ) ;
372370 }
373371
374372 /// <summary>
Original file line number Diff line number Diff line change 1717// under the License.
1818// </copyright>
1919
20+ using System ;
21+
22+ #nullable enable
23+
2024namespace OpenQA . Selenium
2125{
2226 /// <summary>
@@ -27,7 +31,7 @@ public interface IAlert
2731 /// <summary>
2832 /// Gets the text of the alert.
2933 /// </summary>
30- string Text { get ; }
34+ string ? Text { get ; }
3135
3236 /// <summary>
3337 /// Dismisses the alert.
@@ -43,6 +47,7 @@ public interface IAlert
4347 /// Sends keys to the alert.
4448 /// </summary>
4549 /// <param name="keysToSend">The keystrokes to send.</param>
50+ /// <exception cref="ArgumentNullException">If <paramref name="keysToSend"/> is <see langword="null"/>.</exception>
4651 void SendKeys ( string keysToSend ) ;
4752 }
4853}
You can’t perform that action at this time.
0 commit comments