Skip to content

Commit 71da231

Browse files
authored
Merge branch 'trunk' into add_response_handler
2 parents 5596a53 + d2ab626 commit 71da231

38 files changed

+442
-435
lines changed

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/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/src/org/openqa/selenium/chromium/AddHasCdp.java

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -47,20 +47,15 @@ public Class<HasCdp> getDescribedInterface() {
4747

4848
@Override
4949
public HasCdp getImplementation(Capabilities capabilities, ExecuteMethod executeMethod) {
50-
return new HasCdp() {
51-
@Override
52-
public Map<String, Object> executeCdpCommand(
53-
String commandName, Map<String, Object> parameters) {
54-
Require.nonNull("Command name", commandName);
55-
Require.nonNull("Parameters", parameters);
50+
return (commandName, parameters) -> {
51+
Require.nonNull("Command name", commandName);
52+
Require.nonNull("Parameters", parameters);
5653

57-
Map<String, Object> toReturn =
58-
(Map<String, Object>)
59-
executeMethod.execute(
60-
EXECUTE_CDP, Map.of("cmd", commandName, "params", parameters));
54+
Map<String, Object> toReturn =
55+
(Map<String, Object>)
56+
executeMethod.execute(EXECUTE_CDP, Map.of("cmd", commandName, "params", parameters));
6157

62-
return Map.copyOf(toReturn);
63-
}
58+
return Map.copyOf(toReturn);
6459
};
6560
}
6661
}

java/src/org/openqa/selenium/chromium/AddHasLaunchApp.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,13 +57,9 @@ public Class<HasLaunchApp> getDescribedInterface() {
5757

5858
@Override
5959
public HasLaunchApp getImplementation(Capabilities capabilities, ExecuteMethod executeMethod) {
60-
return new HasLaunchApp() {
61-
@Override
62-
public void launchApp(String id) {
63-
Require.nonNull("id of Chromium App", id);
64-
65-
executeMethod.execute(LAUNCH_APP, Map.of("id", id));
66-
}
60+
return id -> {
61+
Require.nonNull("id of Chromium App", id);
62+
executeMethod.execute(LAUNCH_APP, Map.of("id", id));
6763
};
6864
}
6965
}

java/src/org/openqa/selenium/chromium/AddHasPermissions.java

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,11 @@ public Class<HasPermissions> getDescribedInterface() {
5757

5858
@Override
5959
public HasPermissions getImplementation(Capabilities capabilities, ExecuteMethod executeMethod) {
60-
return new HasPermissions() {
61-
@Override
62-
public void setPermission(String name, String value) {
63-
Require.nonNull("Permission name", name);
64-
Require.nonNull("Permission value", value);
65-
66-
executeMethod.execute(
67-
SET_PERMISSION, Map.of("descriptor", Map.of("name", name), "state", value));
68-
}
60+
return (name, value) -> {
61+
Require.nonNull("Permission name", name);
62+
Require.nonNull("Permission value", value);
63+
executeMethod.execute(
64+
SET_PERMISSION, Map.of("descriptor", Map.of("name", name), "state", value));
6965
};
7066
}
7167
}

java/src/org/openqa/selenium/safari/AddHasDebugger.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,6 @@ public Class<HasDebugger> getDescribedInterface() {
5555

5656
@Override
5757
public HasDebugger getImplementation(Capabilities capabilities, ExecuteMethod executeMethod) {
58-
return new HasDebugger() {
59-
@Override
60-
public void attachDebugger() {
61-
executeMethod.execute(ATTACH_DEBUGGER, null);
62-
}
63-
};
58+
return () -> executeMethod.execute(ATTACH_DEBUGGER, null);
6459
}
6560
}

javascript/grid-ui/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"private": true,
55
"type": "module",
66
"dependencies": {
7-
"@apollo/client": "3.12.4",
7+
"@apollo/client": "3.12.5",
88
"@emotion/react": "11.14.0",
99
"@emotion/styled": "11.14.0",
1010
"@mui/icons-material": "5.15.18",

javascript/node/selenium-webdriver/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@
2929
"ws": "^8.18.0"
3030
},
3131
"devDependencies": {
32-
"@eslint/js": "^9.17.0",
32+
"@eslint/js": "^9.18.0",
3333
"clean-jsdoc-theme": "^4.3.0",
34-
"eslint": "^9.17.0",
35-
"eslint-config-prettier": "^9.1.0",
34+
"eslint": "^9.18.0",
35+
"eslint-config-prettier": "^10.0.1",
3636
"eslint-plugin-mocha": "^10.5.0",
3737
"eslint-plugin-n": "^17.15.1",
3838
"eslint-plugin-no-only-tests": "^3.3.0",

javascript/node/selenium-webdriver/safari.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,19 @@ class Options extends Capabilities {
7878
this.options_[TECHNOLOGY_PREVIEW_OPTIONS_KEY] = !!useTechnologyPreview
7979
return this
8080
}
81+
82+
/**
83+
* Enables diagnostic logging for Safari.
84+
*
85+
* This method sets the `safari:diagnose` option to `true` in the current configuration.
86+
* It is used to enable additional logging or diagnostic features specific to Safari.
87+
*
88+
* @returns {Options} Returns the current instance
89+
*/
90+
enableLogging() {
91+
this.set('safari:diagnose', true)
92+
return this
93+
}
8194
}
8295

8396
/**

0 commit comments

Comments
 (0)