Skip to content

Commit 5422f20

Browse files
committed
Merge branch 'trunk' of https://github.com/AdamPDotty/selenium into pr/14482
2 parents 71ca31a + e1fa883 commit 5422f20

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+1382
-930
lines changed

.github/workflows/ci-python.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@ jobs:
2020
steps:
2121
- name: Checkout source tree
2222
uses: actions/checkout@v4
23-
- name: Set up Python 3.8
23+
- name: Set up Python 3.9
2424
uses: actions/setup-python@v4
2525
with:
26-
python-version: 3.8
26+
python-version: 3.9
2727
- name: Install dependencies
2828
run: |
2929
python -m pip install --upgrade pip
@@ -40,10 +40,10 @@ jobs:
4040
steps:
4141
- name: Checkout source tree
4242
uses: actions/checkout@v4
43-
- name: Set up Python 3.8
43+
- name: Set up Python 3.9
4444
uses: actions/setup-python@v4
4545
with:
46-
python-version: 3.8
46+
python-version: 3.9
4747
- name: Install dependencies
4848
run: |
4949
python -m pip install --upgrade pip
@@ -62,10 +62,10 @@ jobs:
6262
steps:
6363
- name: Checkout source tree
6464
uses: actions/checkout@v4
65-
- name: Set up Python 3.8
65+
- name: Set up Python 3.9
6666
uses: actions/setup-python@v4
6767
with:
68-
python-version: 3.8
68+
python-version: 3.9
6969
- name: Install dependencies
7070
run: |
7171
python -m pip install --upgrade pip

.github/workflows/nightly.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ jobs:
172172
with:
173173
name: Nightly JavaScript Release
174174
cache-key: javascript-nightly
175-
node-version: '18.x'
175+
node-version: '22.x'
176176
run: |
177177
sed -i 's|https://registry.npmjs.org/|https://npm.pkg.github.com|g' javascript/node/selenium-webdriver/package.json
178178
sed -i 's|"name": "selenium-webdriver"|"name": "@seleniumhq/selenium-webdriver"|g' javascript/node/selenium-webdriver/package.json

.github/workflows/update-documentation.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,10 @@ jobs:
107107
run: |
108108
git config --local user.email "[email protected]"
109109
git config --local user.name "Selenium CI Bot"
110-
- name: Set up Python 3.8
110+
- name: Set up Python 3.9
111111
uses: actions/setup-python@v5
112112
with:
113-
python-version: 3.8
113+
python-version: 3.9
114114
- name: Install dependencies
115115
run: |
116116
python -m pip install --upgrade pip

MODULE.bazel

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,11 @@ use_repo(oci, "chrome_standalone", "firefox_standalone", "java_image_base")
111111
python = use_extension("@rules_python//python/extensions:python.bzl", "python")
112112
python.toolchain(
113113
is_default = True,
114-
python_version = "3.8",
114+
python_version = "3.9",
115115
)
116-
python.toolchain(python_version = "3.9")
117116
python.toolchain(python_version = "3.10")
118117
python.toolchain(python_version = "3.11")
118+
python.toolchain(python_version = "3.12")
119119
use_repo(python, "pythons_hub")
120120

121121
pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip")
@@ -127,10 +127,10 @@ pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip")
127127
requirements_lock = "//py:requirements_lock.txt",
128128
)
129129
for version in [
130-
"3.8",
131130
"3.9",
132131
"3.10",
133132
"3.11",
133+
"3.12",
134134
]
135135
]
136136

@@ -216,7 +216,7 @@ maven.install(
216216
"org.junit.platform:junit-platform-reporting",
217217
"org.junit.platform:junit-platform-commons",
218218
"org.junit.platform:junit-platform-engine",
219-
"org.mockito:mockito-core:5.14.2",
219+
"org.mockito:mockito-core:5.15.2",
220220
"org.redisson:redisson:3.41.0",
221221
"org.slf4j:slf4j-api:2.0.16",
222222
"org.slf4j:slf4j-jdk14:2.0.16",

dotnet/src/webdriver/CookieJar.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,16 +74,16 @@ public void AddCookie(Cookie cookie)
7474
/// Delete the cookie by passing in the name of the cookie
7575
/// </summary>
7676
/// <param name="name">The name of the cookie that is in the browser</param>
77-
/// <exception cref="ArgumentNullException">If <paramref name="name"/> is <see langword="null"/>.</exception>
77+
/// <exception cref="ArgumentException">If <paramref name="name"/> is <see langword="null"/> or <see cref="string.Empty"/>.</exception>
7878
public void DeleteCookieNamed(string name)
7979
{
80-
if (name is null)
80+
if (string.IsNullOrWhiteSpace(name))
8181
{
82-
throw new ArgumentNullException(nameof(name));
82+
throw new ArgumentException("Cookie name cannot be null or empty", nameof(name));
8383
}
8484

85-
Dictionary<string, object> parameters = new Dictionary<string, object>();
86-
parameters.Add("name", name);
85+
Dictionary<string, object> parameters = new() { { "name", name } };
86+
8787
driver.InternalExecute(DriverCommand.DeleteCookie, parameters);
8888
}
8989

@@ -115,11 +115,12 @@ public void DeleteAllCookies()
115115
/// </summary>
116116
/// <param name="name">name of the cookie that needs to be returned</param>
117117
/// <returns>A Cookie from the name; or <see langword="null"/> if not found.</returns>
118+
/// <exception cref="ArgumentException">If <paramref name="name"/> is <see langword="null"/> or <see cref="string.Empty"/>.</exception>
118119
public Cookie? GetCookieNamed(string name)
119120
{
120121
if (string.IsNullOrWhiteSpace(name))
121122
{
122-
throw new ArgumentException("Cookie name cannot be empty", nameof(name));
123+
throw new ArgumentException("Cookie name cannot be null or empty", nameof(name));
123124
}
124125

125126
try

dotnet/src/webdriver/Firefox/FirefoxExtension.cs

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
using System.Text.Json.Nodes;
2626
using System.Xml;
2727

28-
28+
#nullable enable
2929

3030
namespace OpenQA.Selenium.Firefox
3131
{
@@ -38,8 +38,8 @@ public class FirefoxExtension
3838
private const string RdfManifestFileName = "install.rdf";
3939
private const string JsonManifestFileName = "manifest.json";
4040

41-
private string extensionFileName;
42-
private string extensionResourceId;
41+
private readonly string extensionFileName;
42+
private readonly string extensionResourceId;
4343

4444
/// <summary>
4545
/// Initializes a new instance of the <see cref="FirefoxExtension"/> class.
@@ -48,6 +48,7 @@ public class FirefoxExtension
4848
/// <remarks>WebDriver attempts to resolve the <paramref name="fileName"/> parameter
4949
/// by looking first for the specified file in the directory of the calling assembly,
5050
/// then using the full path to the file, if a full path is provided.</remarks>
51+
/// <exception cref="ArgumentNullException">If <paramref name="fileName"/> is <see langword="null"/>.</exception>
5152
public FirefoxExtension(string fileName)
5253
: this(fileName, string.Empty)
5354
{
@@ -65,16 +66,18 @@ public FirefoxExtension(string fileName)
6566
/// not found in the file system, WebDriver attempts to locate a resource in the
6667
/// executing assembly with the name specified by the <paramref name="resourceId"/>
6768
/// parameter.</remarks>
69+
/// <exception cref="ArgumentNullException">If <paramref name="fileName"/> or <paramref name="resourceId"/> are <see langword="null"/>.</exception>
6870
internal FirefoxExtension(string fileName, string resourceId)
6971
{
70-
this.extensionFileName = fileName;
71-
this.extensionResourceId = resourceId;
72+
this.extensionFileName = fileName ?? throw new ArgumentNullException(nameof(fileName));
73+
this.extensionResourceId = resourceId ?? throw new ArgumentNullException(nameof(resourceId));
7274
}
7375

7476
/// <summary>
7577
/// Installs the extension into a profile directory.
7678
/// </summary>
7779
/// <param name="profileDirectory">The Firefox profile directory into which to install the extension.</param>
80+
/// <exception cref="ArgumentNullException">If <paramref name="profileDirectory"/> is <see langword="null"/>.</exception>
7881
public void Install(string profileDirectory)
7982
{
8083
DirectoryInfo info = new DirectoryInfo(profileDirectory);
@@ -132,7 +135,7 @@ private static string GetExtensionId(string root)
132135

133136
private static string ReadIdFromInstallRdf(string root)
134137
{
135-
string id = null;
138+
string id;
136139
string installRdf = Path.Combine(root, "install.rdf");
137140
try
138141
{
@@ -143,11 +146,11 @@ private static string ReadIdFromInstallRdf(string root)
143146
rdfNamespaceManager.AddNamespace("em", EmNamespaceUri);
144147
rdfNamespaceManager.AddNamespace("RDF", "http://www.w3.org/1999/02/22-rdf-syntax-ns#");
145148

146-
XmlNode node = rdfXmlDocument.SelectSingleNode("//em:id", rdfNamespaceManager);
149+
XmlNode? node = rdfXmlDocument.SelectSingleNode("//em:id", rdfNamespaceManager);
147150
if (node == null)
148151
{
149-
XmlNode descriptionNode = rdfXmlDocument.SelectSingleNode("//RDF:Description", rdfNamespaceManager);
150-
XmlAttribute attribute = descriptionNode.Attributes["id", EmNamespaceUri];
152+
XmlNode? descriptionNode = rdfXmlDocument.SelectSingleNode("//RDF:Description", rdfNamespaceManager);
153+
XmlAttribute? attribute = descriptionNode?.Attributes?["id", EmNamespaceUri];
151154
if (attribute == null)
152155
{
153156
throw new WebDriverException("Cannot locate node containing extension id: " + installRdf);
@@ -175,26 +178,19 @@ private static string ReadIdFromInstallRdf(string root)
175178

176179
private static string ReadIdFromManifestJson(string root)
177180
{
178-
string id = null;
181+
string id = string.Empty;
179182
string manifestJsonPath = Path.Combine(root, JsonManifestFileName);
183+
180184
var manifestObject = JsonNode.Parse(File.ReadAllText(manifestJsonPath));
181-
if (manifestObject["applications"] != null)
185+
if (manifestObject!["applications"]?["gecko"]?["id"] is { } idNode)
182186
{
183-
var applicationObject = manifestObject["applications"];
184-
if (applicationObject["gecko"] != null)
185-
{
186-
var geckoObject = applicationObject["gecko"];
187-
if (geckoObject["id"] != null)
188-
{
189-
id = geckoObject["id"].ToString().Trim();
190-
}
191-
}
187+
id = idNode.ToString().Trim();
192188
}
193189

194190
if (string.IsNullOrEmpty(id))
195191
{
196-
string addInName = manifestObject["name"].ToString().Replace(" ", "");
197-
string addInVersion = manifestObject["version"].ToString();
192+
string addInName = manifestObject["name"]!.ToString().Replace(" ", "");
193+
string addInVersion = manifestObject["version"]!.ToString();
198194
id = string.Format(CultureInfo.InvariantCulture, "{0}@{1}", addInName, addInVersion);
199195
}
200196

dotnet/src/webdriver/Firefox/FirefoxProfile.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,14 @@ public static FirefoxProfile FromBase64String(string base64)
114114
/// Adds a Firefox Extension to this profile
115115
/// </summary>
116116
/// <param name="extensionToInstall">The path to the new extension</param>
117+
/// <exception cref="ArgumentNullException">If <paramref name="extensionToInstall"/> is <see langword="null"/>.</exception>
117118
public void AddExtension(string extensionToInstall)
118119
{
120+
if (extensionToInstall is null)
121+
{
122+
throw new ArgumentNullException(nameof(extensionToInstall));
123+
}
124+
119125
this.extensions.Add(Path.GetFileNameWithoutExtension(extensionToInstall), new FirefoxExtension(extensionToInstall));
120126
}
121127

dotnet/src/webdriver/ICookieJar.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public interface ICookieJar
6161
/// Deletes the cookie with the specified name from the page.
6262
/// </summary>
6363
/// <param name="name">The name of the cookie to be deleted.</param>
64-
/// <exception cref="ArgumentNullException">If <paramref name="name"/> is <see langword="null"/>.</exception>
64+
/// <exception cref="ArgumentException">If <paramref name="name"/> is <see langword="null"/> or <see cref="string.Empty"/>.</exception>
6565
void DeleteCookieNamed(string name);
6666

6767
/// <summary>

dotnet/test/common/CookieImplementationTest.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,28 @@ public void DeleteAllCookiesDifferentUrls()
620620
AssertCookieIsPresentWithName(cookie2.Name);
621621
}
622622

623+
[Test]
624+
[TestCase(null)]
625+
[TestCase("")]
626+
[TestCase(" ")]
627+
public void ShouldThrowWhenGetInvalidCookieByName(string cookieName)
628+
{
629+
var getCookieAction = () => driver.Manage().Cookies.GetCookieNamed(cookieName);
630+
631+
Assert.That(getCookieAction, Throws.ArgumentException);
632+
}
633+
634+
[Test]
635+
[TestCase(null)]
636+
[TestCase("")]
637+
[TestCase(" ")]
638+
public void ShouldThrowWhenDeleteInvalidCookieByName(string cookieName)
639+
{
640+
var deleteCookieAction = () => driver.Manage().Cookies.DeleteCookieNamed(cookieName);
641+
642+
Assert.That(deleteCookieAction, Throws.ArgumentException);
643+
}
644+
623645
//------------------------------------------------------------------
624646
// Tests below here are not included in the Java test suite
625647
//------------------------------------------------------------------

java/maven_install.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"__AUTOGENERATED_FILE_DO_NOT_MODIFY_THIS_FILE_MANUALLY": "THERE_IS_NO_DATA_ONLY_ZUUL",
3-
"__INPUT_ARTIFACTS_HASH": 1132645732,
4-
"__RESOLVED_ARTIFACTS_HASH": 1947623231,
3+
"__INPUT_ARTIFACTS_HASH": 1220324005,
4+
"__RESOLVED_ARTIFACTS_HASH": 1655871984,
55
"artifacts": {
66
"com.beust:jcommander": {
77
"shasums": {
@@ -459,10 +459,10 @@
459459
},
460460
"net.bytebuddy:byte-buddy-agent": {
461461
"shasums": {
462-
"jar": "1d76defd159a564b9cb7a968d0dea27367b8b70ebde75a968e7ef1921bc75ee4",
463-
"sources": "8a7e537a5c2a932a6d73dcec9aa8d5388d33ab3aa91ea410aeea5228dcfe9745"
462+
"jar": "316d2c0795c2a4d4c4756f2e6f9349837c7430ac34e0477ead874d05f5cc19e5",
463+
"sources": "a73d2869afd79b63396a0a07ac037bbfa184eb7306916343c030feb5335ac940"
464464
},
465-
"version": "1.15.4"
465+
"version": "1.15.11"
466466
},
467467
"net.sf.saxon:Saxon-HE": {
468468
"shasums": {
@@ -676,10 +676,10 @@
676676
},
677677
"org.mockito:mockito-core": {
678678
"shasums": {
679-
"jar": "2296141c1e1f2e1ae35c08d36a9ab4563ecd66e03533fe82630a764e7aa49182",
680-
"sources": "32f318184ab3795885743f23d8be0da7fe856e3e360b518083f8b366a44d2b33"
679+
"jar": "bf48b7372d9491d5ec8aebb4cdd187d15663931599c0fbe7410166ce0e1e58ff",
680+
"sources": "bc0ee4bc1d8d43a9bd5e5b49dc479566c28db0740284524140aa264e57e8e27e"
681681
},
682-
"version": "5.14.2"
682+
"version": "5.15.2"
683683
},
684684
"org.objenesis:objenesis": {
685685
"shasums": {

0 commit comments

Comments
 (0)