File tree 3 files changed +15
-9
lines changed
3 files changed +15
-9
lines changed Original file line number Diff line number Diff line change 20
20
using System ;
21
21
using System . Collections . Generic ;
22
22
23
+ #nullable enable
24
+
23
25
namespace OpenQA . Selenium
24
26
{
25
27
/// <summary>
26
28
/// Defines the interface through which the user can manipulate JavaScript alerts.
27
29
/// </summary>
28
30
internal class Alert : IAlert
29
31
{
30
- private WebDriver driver ;
32
+ private readonly WebDriver driver ;
31
33
32
34
/// <summary>
33
35
/// Initializes a new instance of the <see cref="Alert"/> class.
@@ -41,12 +43,12 @@ public Alert(WebDriver driver)
41
43
/// <summary>
42
44
/// Gets the text of the alert.
43
45
/// </summary>
44
- public string Text
46
+ public string ? Text
45
47
{
46
48
get
47
49
{
48
50
Response commandResponse = this . driver . InternalExecute ( DriverCommand . GetAlertText , null ) ;
49
- return commandResponse . Value . ToString ( ) ;
51
+ return ( string ? ) commandResponse . Value ;
50
52
}
51
53
}
52
54
@@ -70,9 +72,10 @@ public void Accept()
70
72
/// Sends keys to the alert.
71
73
/// </summary>
72
74
/// <param name="keysToSend">The keystrokes to send.</param>
75
+ /// <exception cref="ArgumentNullException">If <paramref name="keysToSend" /> is <see langword="null"/>.</exception>
73
76
public void SendKeys ( string keysToSend )
74
77
{
75
- if ( keysToSend == null )
78
+ if ( keysToSend is null )
76
79
{
77
80
throw new ArgumentNullException ( nameof ( keysToSend ) , "Keys to send must not be null." ) ;
78
81
}
Original file line number Diff line number Diff line change @@ -351,14 +351,12 @@ public override string ToString()
351
351
public override bool Equals ( object obj )
352
352
{
353
353
// Two cookies are equal if the name and value match
354
- Cookie cookie = obj as Cookie ;
355
-
356
354
if ( this == obj )
357
355
{
358
356
return true ;
359
357
}
360
358
361
- if ( cookie == null )
359
+ if ( obj is not Cookie cookie )
362
360
{
363
361
return false ;
364
362
}
@@ -368,7 +366,7 @@ public override bool Equals(object obj)
368
366
return false ;
369
367
}
370
368
371
- return ! ( this . cookieValue != null ? ! this . cookieValue . Equals ( cookie . cookieValue ) : cookie . Value != null ) ;
369
+ return string . Equals ( this . cookieValue , cookie . cookieValue ) ;
372
370
}
373
371
374
372
/// <summary>
Original file line number Diff line number Diff line change 17
17
// under the License.
18
18
// </copyright>
19
19
20
+ using System ;
21
+
22
+ #nullable enable
23
+
20
24
namespace OpenQA . Selenium
21
25
{
22
26
/// <summary>
@@ -27,7 +31,7 @@ public interface IAlert
27
31
/// <summary>
28
32
/// Gets the text of the alert.
29
33
/// </summary>
30
- string Text { get ; }
34
+ string ? Text { get ; }
31
35
32
36
/// <summary>
33
37
/// Dismisses the alert.
@@ -43,6 +47,7 @@ public interface IAlert
43
47
/// Sends keys to the alert.
44
48
/// </summary>
45
49
/// <param name="keysToSend">The keystrokes to send.</param>
50
+ /// <exception cref="ArgumentNullException">If <paramref name="keysToSend"/> is <see langword="null"/>.</exception>
46
51
void SendKeys ( string keysToSend ) ;
47
52
}
48
53
}
You can’t perform that action at this time.
0 commit comments