diff --git a/Rakefile b/Rakefile
index 7ee7099acb1357..24bb5ace8e78bb 100644
--- a/Rakefile
+++ b/Rakefile
@@ -585,8 +585,7 @@ namespace :py do
nightly = ".#{Time.now.strftime('%Y%m%d%H%M')}"
new_version = updated_version(old_version, arguments[:version], nightly)
- ['py/setup.py',
- 'py/pyproject.toml',
+ ['py/pyproject.toml',
'py/BUILD.bazel',
'py/selenium/__init__.py',
'py/selenium/webdriver/__init__.py',
@@ -1048,7 +1047,6 @@ namespace :all do
'py/selenium/webdriver/__init__.py',
'py/selenium/__init__.py',
'py/BUILD.bazel',
- 'py/setup.py',
'rb/lib/selenium/webdriver/version.rb',
'rb/Gemfile.lock'])
@@ -1110,7 +1108,6 @@ namespace :all do
'py/selenium/webdriver/__init__.py',
'py/BUILD.bazel',
'py/CHANGES',
- 'py/setup.py',
'rb/lib/selenium/webdriver/version.rb',
'rb/CHANGES',
'rb/Gemfile.lock',
diff --git a/WORKSPACE b/WORKSPACE
index 98cec87d366b7c..d3487546d89cb4 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -34,8 +34,8 @@ rules_closure_toolchains()
http_archive(
name = "rules_rust",
- integrity = "sha256-Zx3bP+Xrz53TTQUeynNS+68z+lO/Ye7Qt1pMNIKeVIA=",
- urls = ["https://github.com/bazelbuild/rules_rust/releases/download/0.52.2/rules_rust-v0.52.2.tar.gz"],
+ integrity = "sha256-eEXiHXSGUH6qD1bdI5KXZ/B04m0wIUeoyM7pmujzbbQ=",
+ urls = ["https://github.com/bazelbuild/rules_rust/releases/download/0.55.5/rules_rust-0.55.5.tar.gz"],
)
load("@rules_rust//rust:repositories.bzl", "rules_rust_dependencies", "rust_register_toolchains")
diff --git a/common/repositories.bzl b/common/repositories.bzl
index ba420b18bf293f..e2e1c00e048fcc 100644
--- a/common/repositories.bzl
+++ b/common/repositories.bzl
@@ -11,8 +11,8 @@ def pin_browsers():
http_archive(
name = "linux_firefox",
- url = "https://ftp.mozilla.org/pub/firefox/releases/132.0.2/linux-x86_64/en-US/firefox-132.0.2.tar.bz2",
- sha256 = "777d47f8b8710ab450582dc0dc0cdf8f43c2291249b3eaf740ee28ee34cda139",
+ url = "https://ftp.mozilla.org/pub/firefox/releases/133.0/linux-x86_64/en-US/firefox-133.0.tar.bz2",
+ sha256 = "63cb097174d429043ad128341358d14cdb5d4c9d05d035d9e3094634ceaf22c2",
build_file_content = """
load("@aspect_rules_js//js:defs.bzl", "js_library")
package(default_visibility = ["//visibility:public"])
@@ -33,8 +33,8 @@ js_library(
dmg_archive(
name = "mac_firefox",
- url = "https://ftp.mozilla.org/pub/firefox/releases/132.0.2/mac/en-US/Firefox%20132.0.2.dmg",
- sha256 = "233251c46eb4964868d815a9233cab855ac6160736310771a67af93a9b78224d",
+ url = "https://ftp.mozilla.org/pub/firefox/releases/133.0/mac/en-US/Firefox%20133.0.dmg",
+ sha256 = "02c76e21d64f21d4e45b1205717ccd0736a75f2a50b01c74b25b17e374447a76",
build_file_content = """
load("@aspect_rules_js//js:defs.bzl", "js_library")
package(default_visibility = ["//visibility:public"])
@@ -50,8 +50,8 @@ js_library(
http_archive(
name = "linux_beta_firefox",
- url = "https://ftp.mozilla.org/pub/firefox/releases/133.0b9/linux-x86_64/en-US/firefox-133.0b9.tar.bz2",
- sha256 = "5c9f79912bfbf892d2b676973a26ffc078ee9b8fd9b791bfa856db030e657750",
+ url = "https://ftp.mozilla.org/pub/firefox/releases/134.0b5/linux-x86_64/en-US/firefox-134.0b5.tar.bz2",
+ sha256 = "9688f50d2bba71c7781e7f46100e97223d469d37197cf99511a2b2e27efd50a2",
build_file_content = """
load("@aspect_rules_js//js:defs.bzl", "js_library")
package(default_visibility = ["//visibility:public"])
@@ -72,8 +72,8 @@ js_library(
dmg_archive(
name = "mac_beta_firefox",
- url = "https://ftp.mozilla.org/pub/firefox/releases/133.0b9/mac/en-US/Firefox%20133.0b9.dmg",
- sha256 = "0eb0fabe9216dc80c2ca403dd2eba935d71f2bdc1dea1d1cc37f03666ef094d1",
+ url = "https://ftp.mozilla.org/pub/firefox/releases/134.0b5/mac/en-US/Firefox%20134.0b5.dmg",
+ sha256 = "5c6d02d149637e963c55c741ebed98a8dacfa93c90e99065981bbdd9d511a0f1",
build_file_content = """
load("@aspect_rules_js//js:defs.bzl", "js_library")
package(default_visibility = ["//visibility:public"])
@@ -123,10 +123,10 @@ js_library(
pkg_archive(
name = "mac_edge",
- url = "https://msedge.sf.dl.delivery.mp.microsoft.com/filestreamingservice/files/08b226c9-fbe8-43c0-94fe-ed9c3eeb8f59/MicrosoftEdge-131.0.2903.51.pkg",
- sha256 = "5bc1eab86bb315aa9f2cd2b7d9afe072df35280f6e6d1a9ca9c108d95bda8acd",
+ url = "https://msedge.sf.dl.delivery.mp.microsoft.com/filestreamingservice/files/a310bc51-4dc2-4780-9677-41f3ecf37e31/MicrosoftEdge-131.0.2903.86.pkg",
+ sha256 = "77dc0bf6d465815d3414a1b52d506323619c9debb12f9feb85ec4ad2c7e58585",
move = {
- "MicrosoftEdge-131.0.2903.51.pkg/Payload/Microsoft Edge.app": "Edge.app",
+ "MicrosoftEdge-131.0.2903.86.pkg/Payload/Microsoft Edge.app": "Edge.app",
},
build_file_content = """
load("@aspect_rules_js//js:defs.bzl", "js_library")
@@ -143,8 +143,8 @@ js_library(
deb_archive(
name = "linux_edge",
- url = "https://packages.microsoft.com/repos/edge/pool/main/m/microsoft-edge-stable/microsoft-edge-stable_131.0.2903.51-1_amd64.deb",
- sha256 = "8aad12c97bcae417ff9cc4251b75211eeda7f1513312dc57b2f744e824e028c0",
+ url = "https://packages.microsoft.com/repos/edge/pool/main/m/microsoft-edge-stable/microsoft-edge-stable_131.0.2903.86-1_amd64.deb",
+ sha256 = "4c7844e51ffefbf5a595f3d93e633481c6081f0fd954d15cc08066ea23ddacf3",
build_file_content = """
load("@aspect_rules_js//js:defs.bzl", "js_library")
package(default_visibility = ["//visibility:public"])
@@ -165,8 +165,8 @@ js_library(
http_archive(
name = "linux_edgedriver",
- url = "https://msedgedriver.azureedge.net/131.0.2903.52/edgedriver_linux64.zip",
- sha256 = "ddbeda7cec5ed16b96c3cf0f6759de30e4f3726da9da31bfba1371ccd8fcfd14",
+ url = "https://msedgedriver.azureedge.net/131.0.2903.84/edgedriver_linux64.zip",
+ sha256 = "13b8024056a2ae72dfc45907213212756ffaf52567fa2b367acadd20badfb4bb",
build_file_content = """
load("@aspect_rules_js//js:defs.bzl", "js_library")
package(default_visibility = ["//visibility:public"])
@@ -182,8 +182,8 @@ js_library(
http_archive(
name = "mac_edgedriver",
- url = "https://msedgedriver.azureedge.net/131.0.2903.56/edgedriver_mac64.zip",
- sha256 = "4f4d1d5b45849677f8d8e706f7b5ca9ebb99f40ed3b4ee203c2535a3429e0d5b",
+ url = "https://msedgedriver.azureedge.net/131.0.2903.84/edgedriver_mac64.zip",
+ sha256 = "288c7b38d24a0650ca60e9e2a231c0c71976adc37be9e11e777e0596c40b3878",
build_file_content = """
load("@aspect_rules_js//js:defs.bzl", "js_library")
package(default_visibility = ["//visibility:public"])
@@ -199,8 +199,8 @@ js_library(
http_archive(
name = "linux_chrome",
- url = "https://storage.googleapis.com/chrome-for-testing-public/131.0.6778.85/linux64/chrome-linux64.zip",
- sha256 = "3a6d928b0002ec012a53b6bb65dcaf95add008adc223c961d566d824982a767e",
+ url = "https://storage.googleapis.com/chrome-for-testing-public/131.0.6778.87/linux64/chrome-linux64.zip",
+ sha256 = "5ed0d25537b964cdf826224165a80d125ae67bbb980065c2f1e665dae6686904",
build_file_content = """
load("@aspect_rules_js//js:defs.bzl", "js_library")
package(default_visibility = ["//visibility:public"])
@@ -221,8 +221,8 @@ js_library(
http_archive(
name = "mac_chrome",
- url = "https://storage.googleapis.com/chrome-for-testing-public/131.0.6778.85/mac-x64/chrome-mac-x64.zip",
- sha256 = "e26a606e2a3da403c6e1e93617a7b51ee010706614eb88de5b16470276e0896b",
+ url = "https://storage.googleapis.com/chrome-for-testing-public/131.0.6778.87/mac-x64/chrome-mac-x64.zip",
+ sha256 = "a9ab895b3ab102973f224f35bef6f0336b690f03cc5fbb73110bf448fe30ce70",
strip_prefix = "chrome-mac-x64",
patch_cmds = [
"mv 'Google Chrome for Testing.app' Chrome.app",
@@ -243,8 +243,8 @@ js_library(
http_archive(
name = "linux_chromedriver",
- url = "https://storage.googleapis.com/chrome-for-testing-public/131.0.6778.85/linux64/chromedriver-linux64.zip",
- sha256 = "33910b16568feabd2b50a26a2c4456d154c760d6e28347427f99c025661a4f3e",
+ url = "https://storage.googleapis.com/chrome-for-testing-public/131.0.6778.87/linux64/chromedriver-linux64.zip",
+ sha256 = "bb0c5ee6594453258b328b838adc194ed0df000f2a6e5ead306b637a995e387b",
strip_prefix = "chromedriver-linux64",
build_file_content = """
load("@aspect_rules_js//js:defs.bzl", "js_library")
@@ -261,8 +261,8 @@ js_library(
http_archive(
name = "mac_chromedriver",
- url = "https://storage.googleapis.com/chrome-for-testing-public/131.0.6778.85/mac-x64/chromedriver-mac-x64.zip",
- sha256 = "ee194eba1d52dea61dfbf08b05a2ce139660e9c7d20d15024c3a0757ac4a5fcb",
+ url = "https://storage.googleapis.com/chrome-for-testing-public/131.0.6778.87/mac-x64/chromedriver-mac-x64.zip",
+ sha256 = "9fa91a7b7e969cbd6edb089e14b8db2189353519640dcc84c067369918bfb04f",
strip_prefix = "chromedriver-mac-x64",
build_file_content = """
load("@aspect_rules_js//js:defs.bzl", "js_library")
diff --git a/dotnet/src/webdriver/CookieJar.cs b/dotnet/src/webdriver/CookieJar.cs
index e4f681e11908a6..8ae324fa6961f1 100644
--- a/dotnet/src/webdriver/CookieJar.cs
+++ b/dotnet/src/webdriver/CookieJar.cs
@@ -21,64 +21,92 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
+#nullable enable
+
namespace OpenQA.Selenium
{
- ///
- /// Defines an interface allowing the user to manipulate cookies on the current page.
- ///
- internal class CookieJar : ICookieJar
+ internal sealed class CookieJar(WebDriver driver) : ICookieJar
{
- private WebDriver driver;
-
- ///
- /// Initializes a new instance of the class.
- ///
- /// The driver that is currently in use
- public CookieJar(WebDriver driver)
- {
- this.driver = driver;
- }
-
///
/// Gets all cookies defined for the current page.
///
public ReadOnlyCollection AllCookies
{
- get { return this.GetAllCookies(); }
+ get
+ {
+ Response response = driver.InternalExecute(DriverCommand.GetAllCookies, new Dictionary());
+
+ try
+ {
+ List toReturn = new List();
+ if (response.Value is object?[] cookies)
+ {
+ foreach (object? rawCookie in cookies)
+ {
+ if (rawCookie != null)
+ {
+ Cookie newCookie = Cookie.FromDictionary((Dictionary)rawCookie);
+ toReturn.Add(newCookie);
+ }
+ }
+ }
+
+ return new ReadOnlyCollection(toReturn);
+ }
+ catch (Exception e)
+ {
+ throw new WebDriverException("Unexpected problem getting cookies", e);
+ }
+ }
}
///
/// Method for creating a cookie in the browser
///
/// that represents a cookie in the browser
+ /// If is .
public void AddCookie(Cookie cookie)
{
+ if (cookie is null)
+ {
+ throw new ArgumentNullException(nameof(cookie));
+ }
+
Dictionary parameters = new Dictionary();
parameters.Add("cookie", cookie);
- this.driver.InternalExecute(DriverCommand.AddCookie, parameters);
+ driver.InternalExecute(DriverCommand.AddCookie, parameters);
}
///
/// Delete the cookie by passing in the name of the cookie
///
/// The name of the cookie that is in the browser
+ /// If is .
public void DeleteCookieNamed(string name)
{
+ if (name is null)
+ {
+ throw new ArgumentNullException(nameof(name));
+ }
+
Dictionary parameters = new Dictionary();
parameters.Add("name", name);
- this.driver.InternalExecute(DriverCommand.DeleteCookie, parameters);
+ driver.InternalExecute(DriverCommand.DeleteCookie, parameters);
}
///
/// Delete a cookie in the browser by passing in a copy of a cookie
///
/// An object that represents a copy of the cookie that needs to be deleted
+ /// If is .
public void DeleteCookie(Cookie cookie)
{
- if (cookie != null)
+ if (cookie is null)
{
- this.DeleteCookieNamed(cookie.Name);
+ throw new ArgumentNullException(nameof(cookie));
}
+
+ this.DeleteCookieNamed(cookie.Name);
}
///
@@ -86,63 +114,32 @@ public void DeleteCookie(Cookie cookie)
///
public void DeleteAllCookies()
{
- this.driver.InternalExecute(DriverCommand.DeleteAllCookies, null);
+ driver.InternalExecute(DriverCommand.DeleteAllCookies, null);
}
///
/// Method for returning a getting a cookie by name
///
/// name of the cookie that needs to be returned
- /// A Cookie from the name
- public Cookie GetCookieNamed(string name)
+ /// A Cookie from the name; or if not found.
+ public Cookie? GetCookieNamed(string name)
{
- Cookie cookieToReturn = null;
- if (name != null)
+ if (name is null)
{
- ReadOnlyCollection allCookies = this.AllCookies;
- foreach (Cookie currentCookie in allCookies)
- {
- if (name.Equals(currentCookie.Name))
- {
- cookieToReturn = currentCookie;
- break;
- }
- }
+ throw new ArgumentNullException(nameof(name));
}
- return cookieToReturn;
- }
- ///
- /// Method for getting a Collection of Cookies that are present in the browser
- ///
- /// ReadOnlyCollection of Cookies in the browser
- private ReadOnlyCollection GetAllCookies()
- {
- List toReturn = new List();
- object returned = this.driver.InternalExecute(DriverCommand.GetAllCookies, new Dictionary()).Value;
-
- try
+ foreach (Cookie currentCookie in this.AllCookies)
{
- object[] cookies = returned as object[];
- if (cookies != null)
+ if (name.Equals(currentCookie.Name))
{
- foreach (object rawCookie in cookies)
- {
- Dictionary cookieDictionary = rawCookie as Dictionary;
- if (rawCookie != null)
- {
- toReturn.Add(Cookie.FromDictionary(cookieDictionary));
- }
- }
+ return currentCookie;
}
- return new ReadOnlyCollection(toReturn);
- }
- catch (Exception e)
- {
- throw new WebDriverException("Unexpected problem getting cookies", e);
}
+
+ return null;
}
}
}
diff --git a/dotnet/src/webdriver/ICookieJar.cs b/dotnet/src/webdriver/ICookieJar.cs
index a27c472a78c41b..07594bf8f31736 100644
--- a/dotnet/src/webdriver/ICookieJar.cs
+++ b/dotnet/src/webdriver/ICookieJar.cs
@@ -17,8 +17,11 @@
// under the License.
//
+using System;
using System.Collections.ObjectModel;
+#nullable enable
+
namespace OpenQA.Selenium
{
///
@@ -35,6 +38,7 @@ public interface ICookieJar
/// Adds a cookie to the current page.
///
/// The object to be added.
+ /// If is .
void AddCookie(Cookie cookie);
///
@@ -43,18 +47,21 @@ public interface ICookieJar
/// The name of the cookie to retrieve.
/// The containing the name. Returns
/// if no cookie with the specified name is found.
- Cookie GetCookieNamed(string name);
+ /// If is .
+ Cookie? GetCookieNamed(string name);
///
/// Deletes the specified cookie from the page.
///
/// The to be deleted.
+ /// If is .
void DeleteCookie(Cookie cookie);
///
/// Deletes the cookie with the specified name from the page.
///
/// The name of the cookie to be deleted.
+ /// If is .
void DeleteCookieNamed(string name);
///
diff --git a/dotnet/src/webdriver/ILogs.cs b/dotnet/src/webdriver/ILogs.cs
index 1224f6d4f36666..d3f236f36c05eb 100644
--- a/dotnet/src/webdriver/ILogs.cs
+++ b/dotnet/src/webdriver/ILogs.cs
@@ -17,8 +17,11 @@
// under the License.
//
+using System;
using System.Collections.ObjectModel;
+#nullable enable
+
namespace OpenQA.Selenium
{
///
@@ -37,6 +40,7 @@ public interface ILogs
/// The log for which to retrieve the log entries.
/// Log types can be found in the class.
/// The list of objects for the specified log.
+ /// If is .
ReadOnlyCollection GetLog(string logKind);
}
}
diff --git a/dotnet/src/webdriver/Interactions/ActionSequence.cs b/dotnet/src/webdriver/Interactions/ActionSequence.cs
index 6b60496e37fc19..2ad1576a084d58 100644
--- a/dotnet/src/webdriver/Interactions/ActionSequence.cs
+++ b/dotnet/src/webdriver/Interactions/ActionSequence.cs
@@ -72,6 +72,7 @@ public int Count
/// Gets the input device for this Action sequence.
///
[Obsolete("This property has been renamed to InputDevice and will be removed in a future version")]
+ [CLSCompliant(false)]
public InputDevice inputDevice => InputDevice;
///
diff --git a/dotnet/src/webdriver/Interactions/Actions.cs b/dotnet/src/webdriver/Interactions/Actions.cs
index 4fc3307982a83f..e3672dd5a5c7a2 100644
--- a/dotnet/src/webdriver/Interactions/Actions.cs
+++ b/dotnet/src/webdriver/Interactions/Actions.cs
@@ -138,7 +138,7 @@ private InputDevice FindDeviceById(string name)
if (id == name)
{
- return sequence.inputDevice;
+ return sequence.InputDevice;
}
}
diff --git a/dotnet/src/webdriver/LogEntry.cs b/dotnet/src/webdriver/LogEntry.cs
index 1f43ac5df8a7e4..d10a2f34929303 100644
--- a/dotnet/src/webdriver/LogEntry.cs
+++ b/dotnet/src/webdriver/LogEntry.cs
@@ -21,6 +21,8 @@
using System.Collections.Generic;
using System.Globalization;
+#nullable enable
+
namespace OpenQA.Selenium
{
///
@@ -28,9 +30,6 @@ namespace OpenQA.Selenium
///
public class LogEntry
{
- private LogLevel level = LogLevel.All;
- private DateTime timestamp = DateTime.MinValue;
- private string message = string.Empty;
///
/// Initializes a new instance of the class.
@@ -42,26 +41,19 @@ private LogEntry()
///
/// Gets the timestamp value of the log entry.
///
- public DateTime Timestamp
- {
- get { return this.timestamp; }
- }
+ public DateTime Timestamp { get; private set; } = DateTime.MinValue;
///
/// Gets the logging level of the log entry.
///
- public LogLevel Level
- {
- get { return this.level; }
- }
+ public LogLevel Level { get; private set; } = LogLevel.All;
///
/// Gets the message of the log entry.
///
- public string Message
- {
- get { return this.message; }
- }
+ public string Message { get; private set; } = string.Empty;
+
+ private static readonly DateTime UnixEpoch = new(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
///
/// Returns a string that represents the current .
@@ -69,7 +61,7 @@ public string Message
/// A string that represents the current .
public override string ToString()
{
- return string.Format(CultureInfo.InvariantCulture, "[{0:yyyy-MM-ddTHH:mm:ssZ}] [{1}] {2}", this.timestamp, this.level, this.message);
+ return string.Format(CultureInfo.InvariantCulture, "[{0:yyyy-MM-ddTHH:mm:ssZ}] [{1}] {2}", this.Timestamp, this.Level, this.Message);
}
///
@@ -78,32 +70,31 @@ public override string ToString()
/// The from
/// which to create the .
/// A with the values in the dictionary.
- internal static LogEntry FromDictionary(Dictionary entryDictionary)
+ internal static LogEntry FromDictionary(Dictionary entryDictionary)
{
LogEntry entry = new LogEntry();
- if (entryDictionary.ContainsKey("message"))
+ if (entryDictionary.TryGetValue("message", out object? message))
{
- entry.message = entryDictionary["message"].ToString();
+ entry.Message = message?.ToString() ?? string.Empty;
}
- if (entryDictionary.ContainsKey("timestamp"))
+ if (entryDictionary.TryGetValue("timestamp", out object? timestamp))
{
- DateTime zeroDate = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc);
- double timestampValue = Convert.ToDouble(entryDictionary["timestamp"], CultureInfo.InvariantCulture);
- entry.timestamp = zeroDate.AddMilliseconds(timestampValue);
+ double timestampValue = Convert.ToDouble(timestamp, CultureInfo.InvariantCulture);
+ entry.Timestamp = UnixEpoch.AddMilliseconds(timestampValue);
}
- if (entryDictionary.ContainsKey("level"))
+ if (entryDictionary.TryGetValue("level", out object? level))
{
- string levelValue = entryDictionary["level"].ToString();
- try
+ if (Enum.TryParse(level?.ToString(), ignoreCase: true, out LogLevel result))
{
- entry.level = (LogLevel)Enum.Parse(typeof(LogLevel), levelValue, true);
+ entry.Level = result;
}
- catch (ArgumentException)
+ else
{
// If the requested log level string is not a valid log level,
// ignore it and use LogLevel.All.
+ entry.Level = LogLevel.All;
}
}
diff --git a/dotnet/src/webdriver/LogLevel.cs b/dotnet/src/webdriver/LogLevel.cs
index 962d32cae682e0..fd5c291c3a165b 100644
--- a/dotnet/src/webdriver/LogLevel.cs
+++ b/dotnet/src/webdriver/LogLevel.cs
@@ -17,6 +17,8 @@
// under the License.
//
+#nullable enable
+
namespace OpenQA.Selenium
{
///
diff --git a/dotnet/src/webdriver/Logs.cs b/dotnet/src/webdriver/Logs.cs
index 74fa3102977d54..91afcc03eb6cd4 100644
--- a/dotnet/src/webdriver/Logs.cs
+++ b/dotnet/src/webdriver/Logs.cs
@@ -21,6 +21,8 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
+#nullable enable
+
namespace OpenQA.Selenium
{
///
@@ -28,15 +30,16 @@ namespace OpenQA.Selenium
///
public class Logs : ILogs
{
- private WebDriver driver;
+ private readonly WebDriver driver;
///
/// Initializes a new instance of the class.
///
/// Instance of the driver currently in use
+ /// If is .
public Logs(WebDriver driver)
{
- this.driver = driver;
+ this.driver = driver ?? throw new ArgumentNullException(nameof(driver));
}
///
@@ -50,12 +53,11 @@ public ReadOnlyCollection AvailableLogTypes
try
{
Response commandResponse = this.driver.InternalExecute(DriverCommand.GetAvailableLogTypes, null);
- object[] responseValue = commandResponse.Value as object[];
- if (responseValue != null)
+ if (commandResponse.Value is object[] responseValue)
{
foreach (object logKind in responseValue)
{
- availableLogTypes.Add(logKind.ToString());
+ availableLogTypes.Add(logKind.ToString()!);
}
}
}
@@ -74,21 +76,25 @@ public ReadOnlyCollection AvailableLogTypes
/// The log for which to retrieve the log entries.
/// Log types can be found in the class.
/// The list of objects for the specified log.
+ /// If is .
public ReadOnlyCollection GetLog(string logKind)
{
+ if (logKind is null)
+ {
+ throw new ArgumentNullException(nameof(logKind));
+ }
+
List entries = new List();
Dictionary parameters = new Dictionary();
parameters.Add("type", logKind);
Response commandResponse = this.driver.InternalExecute(DriverCommand.GetLog, parameters);
- object[] responseValue = commandResponse.Value as object[];
- if (responseValue != null)
+ if (commandResponse.Value is object?[] responseValue)
{
- foreach (object rawEntry in responseValue)
+ foreach (object? rawEntry in responseValue)
{
- Dictionary entryDictionary = rawEntry as Dictionary;
- if (entryDictionary != null)
+ if (rawEntry is Dictionary entryDictionary)
{
entries.Add(LogEntry.FromDictionary(entryDictionary));
}
diff --git a/dotnet/src/webdriver/Proxy.cs b/dotnet/src/webdriver/Proxy.cs
index 0216c50105ce8d..fbbf55a3b9c975 100644
--- a/dotnet/src/webdriver/Proxy.cs
+++ b/dotnet/src/webdriver/Proxy.cs
@@ -23,6 +23,8 @@
using System.Globalization;
using System.Text.Json.Serialization;
+#nullable enable
+
namespace OpenQA.Selenium
{
///
@@ -72,13 +74,13 @@ public class Proxy
{
private ProxyKind proxyKind = ProxyKind.Unspecified;
private bool isAutoDetect;
- private string ftpProxyLocation;
- private string httpProxyLocation;
- private string proxyAutoConfigUrl;
- private string sslProxyLocation;
- private string socksProxyLocation;
- private string socksUserName;
- private string socksPassword;
+ private string? ftpProxyLocation;
+ private string? httpProxyLocation;
+ private string? proxyAutoConfigUrl;
+ private string? sslProxyLocation;
+ private string? socksProxyLocation;
+ private string? socksUserName;
+ private string? socksPassword;
private int? socksVersion;
private List noProxyAddresses = new List();
@@ -93,6 +95,8 @@ public Proxy()
/// Initializes a new instance of the class with the given proxy settings.
///
/// A dictionary of settings to use with the proxy.
+ /// If is .
+ /// If The "noProxy" value is a list with a element.
public Proxy(Dictionary settings)
{
if (settings == null)
@@ -100,46 +104,44 @@ public Proxy(Dictionary settings)
throw new ArgumentNullException(nameof(settings), "settings dictionary cannot be null");
}
- if (settings.ContainsKey("proxyType") && settings["proxyType"] != null)
+ if (settings.TryGetValue("proxyType", out object? proxyTypeObj) && proxyTypeObj?.ToString() is string proxyType)
{
// Special-case "PAC" since that is the correct serialization.
- if (settings["proxyType"].ToString().ToLowerInvariant() == "pac")
+ if (proxyType.Equals("pac", StringComparison.InvariantCultureIgnoreCase))
{
this.Kind = ProxyKind.ProxyAutoConfigure;
}
else
{
- ProxyKind rawType = (ProxyKind)Enum.Parse(typeof(ProxyKind), settings["proxyType"].ToString(), true);
+ ProxyKind rawType = (ProxyKind)Enum.Parse(typeof(ProxyKind), proxyType, ignoreCase: true);
this.Kind = rawType;
}
}
- if (settings.ContainsKey("ftpProxy") && settings["ftpProxy"] != null)
+ if (settings.TryGetValue("ftpProxy", out object? ftpProxyObj) && ftpProxyObj?.ToString() is string ftpProxy)
{
- this.FtpProxy = settings["ftpProxy"].ToString();
+ this.FtpProxy = ftpProxy;
}
- if (settings.ContainsKey("httpProxy") && settings["httpProxy"] != null)
+ if (settings.TryGetValue("httpProxy", out object? httpProxyObj) && httpProxyObj?.ToString() is string httpProxy)
{
- this.HttpProxy = settings["httpProxy"].ToString();
+ this.HttpProxy = httpProxy;
}
- if (settings.ContainsKey("noProxy") && settings["noProxy"] != null)
+ if (settings.TryGetValue("noProxy", out object? noProxy) && noProxy != null)
{
List bypassAddresses = new List();
- string addressesAsString = settings["noProxy"] as string;
- if (addressesAsString != null)
+ if (noProxy is string addressesAsString)
{
bypassAddresses.AddRange(addressesAsString.Split(';'));
}
else
{
- object[] addressesAsArray = settings["noProxy"] as object[];
- if (addressesAsArray != null)
+ if (noProxy is object?[] addressesAsArray)
{
- foreach (object address in addressesAsArray)
+ foreach (object? address in addressesAsArray)
{
- bypassAddresses.Add(address.ToString());
+ bypassAddresses.Add(address?.ToString() ?? throw new ArgumentException("Proxy bypass address list \"noProxy\" contained a null element", nameof(settings)));
}
}
}
@@ -147,39 +149,39 @@ public Proxy(Dictionary settings)
this.AddBypassAddresses(bypassAddresses);
}
- if (settings.ContainsKey("proxyAutoconfigUrl") && settings["proxyAutoconfigUrl"] != null)
+ if (settings.TryGetValue("proxyAutoconfigUrl", out object? proxyAutoconfigUrlObj) && proxyAutoconfigUrlObj?.ToString() is string proxyAutoconfigUrl)
{
- this.ProxyAutoConfigUrl = settings["proxyAutoconfigUrl"].ToString();
+ this.ProxyAutoConfigUrl = proxyAutoconfigUrl;
}
- if (settings.ContainsKey("sslProxy") && settings["sslProxy"] != null)
+ if (settings.TryGetValue("sslProxy", out object? sslProxyObj) && sslProxyObj?.ToString() is string sslProxy)
{
- this.SslProxy = settings["sslProxy"].ToString();
+ this.SslProxy = sslProxy;
}
- if (settings.ContainsKey("socksProxy") && settings["socksProxy"] != null)
+ if (settings.TryGetValue("socksProxy", out object? socksProxyObj) && socksProxyObj?.ToString() is string socksProxy)
{
- this.SocksProxy = settings["socksProxy"].ToString();
+ this.SocksProxy = socksProxy;
}
- if (settings.ContainsKey("socksUsername") && settings["socksUsername"] != null)
+ if (settings.TryGetValue("socksUsername", out object? socksUsernameObj) && socksUsernameObj?.ToString() is string socksUsername)
{
- this.SocksUserName = settings["socksUsername"].ToString();
+ this.SocksUserName = socksUsername;
}
- if (settings.ContainsKey("socksPassword") && settings["socksPassword"] != null)
+ if (settings.TryGetValue("socksPassword", out object? socksPasswordObj) && socksPasswordObj?.ToString() is string socksPassword)
{
- this.SocksPassword = settings["socksPassword"].ToString();
+ this.SocksPassword = socksPassword;
}
- if (settings.ContainsKey("socksVersion") && settings["socksVersion"] != null)
+ if (settings.TryGetValue("socksVersion", out object? socksVersion) && socksVersion != null)
{
- this.SocksVersion = Convert.ToInt32(settings["socksVersion"]);
+ this.SocksVersion = Convert.ToInt32(socksVersion);
}
- if (settings.ContainsKey("autodetect") && settings["autodetect"] != null)
+ if (settings.TryGetValue("autodetect", out object? autodetect) && autodetect != null)
{
- this.IsAutoDetect = (bool)settings["autodetect"];
+ this.IsAutoDetect = Convert.ToBoolean(autodetect);
}
}
@@ -189,10 +191,7 @@ public Proxy(Dictionary settings)
[JsonIgnore]
public ProxyKind Kind
{
- get
- {
- return this.proxyKind;
- }
+ get => this.proxyKind;
set
{
@@ -224,10 +223,7 @@ public string SerializableProxyKind
[JsonIgnore]
public bool IsAutoDetect
{
- get
- {
- return this.isAutoDetect;
- }
+ get => this.isAutoDetect;
set
{
@@ -247,12 +243,9 @@ public bool IsAutoDetect
///
[JsonPropertyName("ftpProxy")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
- public string FtpProxy
+ public string? FtpProxy
{
- get
- {
- return this.ftpProxyLocation;
- }
+ get => this.ftpProxyLocation;
set
{
@@ -267,12 +260,9 @@ public string FtpProxy
///
[JsonPropertyName("httpProxy")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
- public string HttpProxy
+ public string? HttpProxy
{
- get
- {
- return this.httpProxyLocation;
- }
+ get => this.httpProxyLocation;
set
{
@@ -287,7 +277,7 @@ public string HttpProxy
///
[JsonPropertyName("noProxy")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
- public ReadOnlyCollection BypassProxyAddresses
+ public ReadOnlyCollection? BypassProxyAddresses
{
get
{
@@ -305,12 +295,9 @@ public ReadOnlyCollection BypassProxyAddresses
///
[JsonPropertyName("proxyAutoconfigUrl")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
- public string ProxyAutoConfigUrl
+ public string? ProxyAutoConfigUrl
{
- get
- {
- return this.proxyAutoConfigUrl;
- }
+ get => this.proxyAutoConfigUrl;
set
{
@@ -325,12 +312,9 @@ public string ProxyAutoConfigUrl
///
[JsonPropertyName("sslProxy")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
- public string SslProxy
+ public string? SslProxy
{
- get
- {
- return this.sslProxyLocation;
- }
+ get => this.sslProxyLocation;
set
{
@@ -345,12 +329,9 @@ public string SslProxy
///
[JsonPropertyName("socksProxy")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
- public string SocksProxy
+ public string? SocksProxy
{
- get
- {
- return this.socksProxyLocation;
- }
+ get => this.socksProxyLocation;
set
{
@@ -365,12 +346,9 @@ public string SocksProxy
///
[JsonPropertyName("socksUsername")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
- public string SocksUserName
+ public string? SocksUserName
{
- get
- {
- return this.socksUserName;
- }
+ get => this.socksUserName;
set
{
@@ -388,10 +366,7 @@ public string SocksUserName
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
public int? SocksVersion
{
- get
- {
- return this.socksVersion;
- }
+ get => this.socksVersion;
set
{
@@ -403,7 +378,7 @@ public int? SocksVersion
{
if (value.Value <= 0)
{
- throw new ArgumentException("SocksVersion must be a positive integer");
+ throw new ArgumentOutOfRangeException(nameof(value), "SocksVersion must be a positive integer");
}
this.VerifyProxyTypeCompatilibily(ProxyKind.Manual);
@@ -418,12 +393,9 @@ public int? SocksVersion
///
[JsonPropertyName("socksPassword")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)]
- public string SocksPassword
+ public string? SocksPassword
{
- get
- {
- return this.socksPassword;
- }
+ get => this.socksPassword;
set
{
@@ -453,7 +425,7 @@ public void AddBypassAddress(string address)
/// An array of addresses to add.
public void AddBypassAddresses(params string[] addressesToAdd)
{
- this.AddBypassAddresses(new List(addressesToAdd));
+ this.AddBypassAddresses((IEnumerable)addressesToAdd);
}
///
@@ -478,7 +450,7 @@ public void AddBypassAddresses(IEnumerable addressesToAdd)
///
/// A dictionary suitable for serializing to the W3C Specification
/// dialect of the wire protocol.
- internal Dictionary ToCapability()
+ internal Dictionary? ToCapability()
{
return this.AsDictionary(true);
}
@@ -489,17 +461,17 @@ internal Dictionary ToCapability()
///
/// A dictionary suitable for serializing to the OSS dialect of the
/// wire protocol.
- internal Dictionary ToLegacyCapability()
+ internal Dictionary? ToLegacyCapability()
{
return this.AsDictionary(false);
}
- private Dictionary AsDictionary(bool isSpecCompliant)
+ private Dictionary? AsDictionary(bool isSpecCompliant)
{
- Dictionary serializedDictionary = null;
+ Dictionary? serializedDictionary = null;
if (this.proxyKind != ProxyKind.Unspecified)
{
- serializedDictionary = new Dictionary();
+ serializedDictionary = new Dictionary();
if (this.proxyKind == ProxyKind.ProxyAutoConfigure)
{
serializedDictionary["proxyType"] = "pac";
@@ -556,17 +528,12 @@ private Dictionary AsDictionary(bool isSpecCompliant)
return serializedDictionary;
}
- private object GetNoProxyAddressList(bool isSpecCompliant)
+ private object? GetNoProxyAddressList(bool isSpecCompliant)
{
- object addresses = null;
+ object? addresses = null;
if (isSpecCompliant)
{
- List