diff --git a/dotnet/src/webdriver/Alert.cs b/dotnet/src/webdriver/Alert.cs
index 11e860af922a7..d7637b7465a6b 100644
--- a/dotnet/src/webdriver/Alert.cs
+++ b/dotnet/src/webdriver/Alert.cs
@@ -20,6 +20,8 @@
using System;
using System.Collections.Generic;
+#nullable enable
+
namespace OpenQA.Selenium
{
///
@@ -27,7 +29,7 @@ namespace OpenQA.Selenium
///
internal class Alert : IAlert
{
- private WebDriver driver;
+ private readonly WebDriver driver;
///
/// Initializes a new instance of the class.
@@ -41,12 +43,12 @@ public Alert(WebDriver driver)
///
/// Gets the text of the alert.
///
- public string Text
+ public string? Text
{
get
{
Response commandResponse = this.driver.InternalExecute(DriverCommand.GetAlertText, null);
- return commandResponse.Value.ToString();
+ return (string?)commandResponse.Value;
}
}
@@ -70,9 +72,10 @@ public void Accept()
/// Sends keys to the alert.
///
/// The keystrokes to send.
+ /// If is .
public void SendKeys(string keysToSend)
{
- if (keysToSend == null)
+ if (keysToSend is null)
{
throw new ArgumentNullException(nameof(keysToSend), "Keys to send must not be null.");
}
diff --git a/dotnet/src/webdriver/Cookie.cs b/dotnet/src/webdriver/Cookie.cs
index 693012815d699..b15dca6d196fe 100644
--- a/dotnet/src/webdriver/Cookie.cs
+++ b/dotnet/src/webdriver/Cookie.cs
@@ -351,14 +351,12 @@ public override string ToString()
public override bool Equals(object obj)
{
// Two cookies are equal if the name and value match
- Cookie cookie = obj as Cookie;
-
if (this == obj)
{
return true;
}
- if (cookie == null)
+ if (obj is not Cookie cookie)
{
return false;
}
@@ -368,7 +366,7 @@ public override bool Equals(object obj)
return false;
}
- return !(this.cookieValue != null ? !this.cookieValue.Equals(cookie.cookieValue) : cookie.Value != null);
+ return string.Equals(this.cookieValue, cookie.cookieValue);
}
///
diff --git a/dotnet/src/webdriver/IAlert.cs b/dotnet/src/webdriver/IAlert.cs
index 6dd0c8db63e99..78c15d992c1b3 100644
--- a/dotnet/src/webdriver/IAlert.cs
+++ b/dotnet/src/webdriver/IAlert.cs
@@ -17,6 +17,10 @@
// under the License.
//
+using System;
+
+#nullable enable
+
namespace OpenQA.Selenium
{
///
@@ -27,7 +31,7 @@ public interface IAlert
///
/// Gets the text of the alert.
///
- string Text { get; }
+ string? Text { get; }
///
/// Dismisses the alert.
@@ -43,6 +47,7 @@ public interface IAlert
/// Sends keys to the alert.
///
/// The keystrokes to send.
+ /// If is .
void SendKeys(string keysToSend);
}
}