Skip to content

Commit b4a4fe7

Browse files
committed
Merge remote-tracking branch 'origin/add_response_handler' into add_response_handler
2 parents ae80832 + b2cea1d commit b4a4fe7

37 files changed

+243
-91
lines changed

.github/workflows/bazel.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ jobs:
8282
steps:
8383
- name: Checkout source tree
8484
uses: actions/checkout@v4
85+
- name: Pull latest changes
86+
if: startsWith(github.head_ref, 'renovate/')
87+
run: git pull origin ${{ github.head_ref }}
8588
- name: Free space
8689
if: inputs.os != 'windows'
8790
run: ./scripts/github-actions/free-disk-space.sh

.github/workflows/ci-rbe.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ on:
1010
jobs:
1111
format:
1212
name: Format
13-
if: github.repository_owner == 'seleniumhq'
13+
if: github.repository_owner == 'seleniumhq' && startsWith(github.head_ref, 'renovate/') != true
1414
uses: ./.github/workflows/bazel.yml
1515
with:
1616
name: Check format script run
@@ -20,7 +20,7 @@ jobs:
2020

2121
test:
2222
name: Test
23-
if: github.repository_owner == 'seleniumhq'
23+
if: github.repository_owner == 'seleniumhq' && startsWith(github.head_ref, 'renovate/') != true
2424
uses: ./.github/workflows/bazel.yml
2525
with:
2626
name: All RBE tests
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: CI - Renovate - RBE
2+
3+
on:
4+
push:
5+
branches:
6+
- renovate/*
7+
workflow_dispatch:
8+
9+
jobs:
10+
format:
11+
runs-on: ubuntu-latest
12+
if: github.repository_owner == 'seleniumhq'
13+
steps:
14+
- name: Checkout Repository
15+
uses: actions/checkout@v4
16+
- name: java - repin dependencies
17+
if: contains(join(github.event.commits.*.message), '[java]')
18+
run: REPIN=1 bazel run @maven//:pin
19+
- name: rust - repin dependencies
20+
if: contains(join(github.event.commits.*.message), '[rust]')
21+
run: CARGO_BAZEL_REPIN=true bazel sync --only=crates
22+
- name: js - repin dependencies
23+
if: contains(join(github.event.commits.*.message), '[js]')
24+
run: bazel run -- @pnpm//:pnpm install --dir $PWD --lockfile-only
25+
- name: dotnet - repin dependencies
26+
if: contains(join(github.event.commits.*.message), '[dotnet]')
27+
run: ./dotnet/update-deps.sh
28+
- name: py - repin dependencies
29+
if: contains(join(github.event.commits.*.message), '[py]')
30+
run: bazel run //py:requirements.update
31+
- name: Commit files
32+
run: |
33+
export CHANGES=$(git status -s)
34+
if [ -n "$CHANGES" ]; then
35+
git config --local user.email "[email protected]"
36+
git config --local user.name "Selenium CI Bot"
37+
git add .
38+
git commit -m 'Repin dependencies'
39+
git push
40+
fi
41+
42+
check-format:
43+
needs: format
44+
name: Check format
45+
if: github.repository_owner == 'seleniumhq'
46+
uses: ./.github/workflows/bazel.yml
47+
with:
48+
name: Check format script run
49+
caching: false
50+
ruby-version: jruby-9.4.8.0
51+
run: ./scripts/github-actions/check-format.sh
52+
53+
test:
54+
name: Test
55+
if: github.repository_owner == 'seleniumhq'
56+
uses: ./.github/workflows/bazel.yml
57+
with:
58+
name: All RBE tests
59+
caching: false
60+
ruby-version: jruby-9.4.8.0
61+
run: ./scripts/github-actions/ci-build.sh

dotnet/src/webdriver/SessionId.cs

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,22 +17,27 @@
1717
// under the License.
1818
// </copyright>
1919

20+
using System;
21+
22+
#nullable enable
23+
2024
namespace OpenQA.Selenium
2125
{
2226
/// <summary>
2327
/// Provides a mechanism for maintaining a session for a test
2428
/// </summary>
2529
public class SessionId
2630
{
27-
private string sessionOpaqueKey;
31+
private readonly string sessionOpaqueKey;
2832

2933
/// <summary>
3034
/// Initializes a new instance of the <see cref="SessionId"/> class
3135
/// </summary>
3236
/// <param name="opaqueKey">Key for the session in use</param>
37+
/// <exception cref="ArgumentNullException">If <paramref name="opaqueKey"/> is <see langword="null"/>.</exception>
3338
public SessionId(string opaqueKey)
3439
{
35-
this.sessionOpaqueKey = opaqueKey;
40+
this.sessionOpaqueKey = opaqueKey ?? throw new ArgumentNullException(nameof(opaqueKey));
3641
}
3742

3843
/// <summary>
@@ -54,20 +59,13 @@ public override int GetHashCode()
5459
}
5560

5661
/// <summary>
57-
/// Compares two Sessions
62+
/// Indicates whether the current session ID value is the same as <paramref name="obj"/>.
5863
/// </summary>
59-
/// <param name="obj">Session to compare</param>
60-
/// <returns>True if they are equal or False if they are not</returns>
61-
public override bool Equals(object obj)
64+
/// <param name="obj">The session to compare to.</param>
65+
/// <returns><see langword="true"/> if the values are equal; otherwise, <see langword="false"/>.</returns>
66+
public override bool Equals(object? obj)
6267
{
63-
bool objectsAreEqual = false;
64-
SessionId other = obj as SessionId;
65-
if (other != null)
66-
{
67-
objectsAreEqual = this.sessionOpaqueKey.Equals(other.sessionOpaqueKey);
68-
}
69-
70-
return objectsAreEqual;
68+
return obj is SessionId otherSession && this.sessionOpaqueKey.Equals(otherSession.sessionOpaqueKey);
7169
}
7270
}
7371
}

dotnet/src/webdriver/WebDriver.cs

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
using System.Collections;
2525
using System.Collections.Generic;
2626
using System.Collections.ObjectModel;
27+
using System.Diagnostics.CodeAnalysis;
2728
using System.Globalization;
2829
using System.Threading.Tasks;
2930

@@ -44,7 +45,7 @@ public class WebDriver : IWebDriver, ISearchContext, IJavaScriptExecutor, IFinds
4445
private IFileDetector fileDetector = new DefaultFileDetector();
4546
private NetworkManager network;
4647
private WebElementFactory elementFactory;
47-
private SessionId sessionId;
48+
4849
private List<string> registeredCommands = new List<string>();
4950

5051
/// <summary>
@@ -191,10 +192,7 @@ public bool IsActionExecutor
191192
/// <summary>
192193
/// Gets the <see cref="SessionId"/> for the current session of this driver.
193194
/// </summary>
194-
public SessionId SessionId
195-
{
196-
get { return this.sessionId; }
197-
}
195+
public SessionId SessionId { get; private set; }
198196

199197
/// <summary>
200198
/// Gets or sets the <see cref="IFileDetector"/> responsible for detecting
@@ -612,7 +610,7 @@ protected virtual Response Execute(string driverCommandToExecute,
612610
/// <returns>A <see cref="Response"/> containing information about the success or failure of the command and any data returned by the command.</returns>
613611
protected virtual async Task<Response> ExecuteAsync(string driverCommandToExecute, Dictionary<string, object> parameters)
614612
{
615-
Command commandToExecute = new Command(this.sessionId, driverCommandToExecute, parameters);
613+
Command commandToExecute = new Command(SessionId, driverCommandToExecute, parameters);
616614

617615
Response commandResponse;
618616

@@ -641,6 +639,7 @@ protected virtual async Task<Response> ExecuteAsync(string driverCommandToExecut
641639
/// Starts a session with the driver
642640
/// </summary>
643641
/// <param name="capabilities">Capabilities of the browser</param>
642+
[MemberNotNull(nameof(SessionId))]
644643
protected void StartSession(ICapabilities capabilities)
645644
{
646645
Dictionary<string, object> parameters = new Dictionary<string, object>();
@@ -679,7 +678,9 @@ protected void StartSession(ICapabilities capabilities)
679678

680679
ReturnedCapabilities returnedCapabilities = new ReturnedCapabilities(rawCapabilities);
681680
this.capabilities = returnedCapabilities;
682-
this.sessionId = new SessionId(response.SessionId);
681+
682+
string sessionId = response.SessionId ?? throw new WebDriverException($"The remote end did not respond with ID of a session when it was required. {response.Value}");
683+
this.SessionId = new SessionId(sessionId);
683684
}
684685

685686
/// <summary>
@@ -723,7 +724,7 @@ protected virtual void Dispose(bool disposing)
723724
{
724725
try
725726
{
726-
if (this.sessionId is not null)
727+
if (this.SessionId is not null)
727728
{
728729
this.Execute(DriverCommand.Quit, null);
729730
}
@@ -739,7 +740,7 @@ protected virtual void Dispose(bool disposing)
739740
}
740741
finally
741742
{
742-
this.sessionId = null;
743+
this.SessionId = null;
743744
}
744745
this.executor.Dispose();
745746
}

dotnet/test/common/DevTools/DevToolsProfilerTest.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,12 +131,12 @@ private void ValidateProfile(CurrentCdpVersion.Profiler.Profile profiler)
131131
{
132132
Assert.That(profiler, Is.Not.Null);
133133
Assert.That(profiler.Nodes, Is.Not.Null);
134-
Assert.That(profiler.StartTime, Is.Not.Null);
135-
Assert.That(profiler.EndTime, Is.Not.Null);
134+
Assert.That(profiler.StartTime, Is.Not.Zero);
135+
Assert.That(profiler.EndTime, Is.Not.Zero);
136136
Assert.That(profiler.TimeDeltas, Is.Not.Null);
137137
foreach (var delta in profiler.TimeDeltas)
138138
{
139-
Assert.That(delta, Is.Not.Null);
139+
Assert.That(delta, Is.Not.Zero);
140140
}
141141

142142
foreach (var node in profiler.Nodes)

dotnet/test/common/DevTools/DevToolsTestFixture.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public void Setup()
3939
devTools = driver as IDevTools;
4040
if (devTools == null)
4141
{
42-
Assert.Ignore("{0} does not support Chrome DevTools Protocol", EnvironmentManager.Instance.Browser);
42+
Assert.Ignore($"{EnvironmentManager.Instance.Browser} does not support Chrome DevTools Protocol");
4343
return;
4444
}
4545

java/src/org/openqa/selenium/Architecture.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717

1818
package org.openqa.selenium;
1919

20+
import java.util.Locale;
21+
2022
/**
2123
* Represents the known architectures used in WebDriver. It attempts to smooth over some of Java's
2224
* rough edges when dealing with microprocessor architectures by, for instance, allowing you to
@@ -98,7 +100,7 @@ public int getDataModel() {
98100

99101
@Override
100102
public String toString() {
101-
return name().toLowerCase();
103+
return name().toLowerCase(Locale.ENGLISH);
102104
}
103105

104106
/**
@@ -121,7 +123,7 @@ public static Architecture getCurrent() {
121123
*/
122124
public static Architecture extractFromSysProperty(String arch) {
123125
if (arch != null) {
124-
arch = arch.toLowerCase();
126+
arch = arch.toLowerCase(Locale.ENGLISH);
125127
}
126128

127129
// Some architectures are basically the same even though they have different names. ia32, x86,

java/src/org/openqa/selenium/Platform.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
package org.openqa.selenium;
1919

2020
import java.util.Arrays;
21+
import java.util.Locale;
2122
import java.util.regex.Matcher;
2223
import java.util.regex.Pattern;
2324

@@ -414,7 +415,7 @@ public static Platform extractFromSysProperty(String osName) {
414415
* @return the most likely platform based on given operating system name and version
415416
*/
416417
public static Platform extractFromSysProperty(String osName, String osVersion) {
417-
osName = osName.toLowerCase();
418+
osName = osName.toLowerCase(Locale.ENGLISH);
418419
// os.name for android is linux
419420
if ("dalvik".equalsIgnoreCase(System.getProperty("java.vm.name"))) {
420421
return Platform.ANDROID;
@@ -434,7 +435,7 @@ public static Platform extractFromSysProperty(String osName, String osVersion) {
434435
if ("".equals(matcher)) {
435436
continue;
436437
}
437-
matcher = matcher.toLowerCase();
438+
matcher = matcher.toLowerCase(Locale.ENGLISH);
438439
if (os.isExactMatch(osName, matcher)) {
439440
return os;
440441
}

java/src/org/openqa/selenium/Proxy.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import java.util.Arrays;
2121
import java.util.HashMap;
2222
import java.util.List;
23+
import java.util.Locale;
2324
import java.util.Map;
2425
import java.util.Objects;
2526
import java.util.Optional;
@@ -93,7 +94,8 @@ public Proxy() {
9394
public Proxy(Map<String, ?> raw) {
9495
Map<String, Consumer<Object>> setters = new HashMap<>();
9596
setters.put(
96-
PROXY_TYPE, value -> setProxyType(ProxyType.valueOf(((String) value).toUpperCase())));
97+
PROXY_TYPE,
98+
value -> setProxyType(ProxyType.valueOf(((String) value).toUpperCase(Locale.ENGLISH))));
9799
setters.put(FTP_PROXY, value -> setFtpProxy((String) value));
98100
setters.put(HTTP_PROXY, value -> setHttpProxy((String) value));
99101
setters.put(
@@ -448,7 +450,7 @@ public String toString() {
448450
case DIRECT:
449451
case MANUAL:
450452
case SYSTEM:
451-
builder.append(getProxyType().toString().toLowerCase());
453+
builder.append(getProxyType().toString().toLowerCase(Locale.ENGLISH));
452454
break;
453455

454456
case PAC:

0 commit comments

Comments
 (0)