Skip to content

Commit 6693bb3

Browse files
authored
Merge branch 'trunk' into feat-14045/nodejs-env-var-driver-location
2 parents 683ed01 + f243aee commit 6693bb3

File tree

19 files changed

+288
-390
lines changed

19 files changed

+288
-390
lines changed

.github/workflows/bazel.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,8 @@ jobs:
126126
with:
127127
bazelisk-cache: true
128128
bazelrc: common --color=yes
129+
# Workaround for long path issues: https://github.com/bazelbuild/bazel/pull/22532
130+
output-base: ${{ inputs.os == 'windows' && 'D://b' || '' }}
129131
cache-version: 2
130132
disk-cache: ${{ inputs.cache-key }}
131133
external-cache: |

.github/workflows/ci-python.yml

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -99,18 +99,13 @@ jobs:
9999
os: ubuntu
100100
- browser: firefox
101101
os: ubuntu
102-
- browser: chrome
103-
os: windows
104-
- browser: edge
105-
os: windows
106102
with:
107103
name: Integration Tests (${{ matrix.browser }}, ${{ matrix.os }})
108104
browser: ${{ matrix.browser }}
109105
os: ${{ matrix.os }}
110106
cache-key: py-browser-${{ matrix.browser }}
111107
run: |
112-
bazel test --local_test_jobs 1 --flaky_test_attempts 3 --pin_browsers=true //py:common-${{ matrix.browser }}-bidi
113-
bazel test --local_test_jobs 1 --flaky_test_attempts 3 --pin_browsers=true //py:test-${{ matrix.browser }}
108+
bazel test --local_test_jobs 1 --flaky_test_attempts 3 --pin_browsers=true //py:common-${{ matrix.browser }}-bidi //py:test-${{ matrix.browser }}
114109
115110
safari-tests:
116111
name: Browser Tests
@@ -128,5 +123,4 @@ jobs:
128123
os: ${{ matrix.os }}
129124
cache-key: py-browser-${{ matrix.browser }}
130125
run: |
131-
bazel test --local_test_jobs 1 --flaky_test_attempts 3 --pin_browsers=true //py:common-${{ matrix.browser }}
132-
bazel test --local_test_jobs 1 --flaky_test_attempts 3 --pin_browsers=true //py:test-${{ matrix.browser }}
126+
bazel test --local_test_jobs 1 --flaky_test_attempts 3 --pin_browsers=true //py:common-${{ matrix.browser }} //py:test-${{ matrix.browser }}

common/repositories.bzl

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ def pin_browsers():
1111

1212
http_archive(
1313
name = "linux_firefox",
14-
url = "https://ftp.mozilla.org/pub/firefox/releases/143.0.3/linux-x86_64/en-US/firefox-143.0.3.tar.xz",
15-
sha256 = "c0d70d6e4f2026f0e677addd595b58e0f898a991b0fd9e6ca0cafb048d10f442",
14+
url = "https://ftp.mozilla.org/pub/firefox/releases/143.0.4/linux-x86_64/en-US/firefox-143.0.4.tar.xz",
15+
sha256 = "2cb91bd5c8755a83d65e4ef46a2ce99cfcc0b94e04673669e5e5384320384339",
1616
build_file_content = """
1717
load("@aspect_rules_js//js:defs.bzl", "js_library")
1818
package(default_visibility = ["//visibility:public"])
@@ -33,8 +33,8 @@ js_library(
3333

3434
dmg_archive(
3535
name = "mac_firefox",
36-
url = "https://ftp.mozilla.org/pub/firefox/releases/143.0.3/mac/en-US/Firefox%20143.0.3.dmg",
37-
sha256 = "ca889a4ae53b93c65a54130b81eca818a08e38d15dd0efe9d06217f899530beb",
36+
url = "https://ftp.mozilla.org/pub/firefox/releases/143.0.4/mac/en-US/Firefox%20143.0.4.dmg",
37+
sha256 = "332ab6fdde189325a8118a401ae445c3caf72d7a696ec3ffd96323a9c11bc8ed",
3838
build_file_content = """
3939
load("@aspect_rules_js//js:defs.bzl", "js_library")
4040
package(default_visibility = ["//visibility:public"])
@@ -50,8 +50,8 @@ js_library(
5050

5151
http_archive(
5252
name = "linux_beta_firefox",
53-
url = "https://ftp.mozilla.org/pub/firefox/releases/144.0b8/linux-x86_64/en-US/firefox-144.0b8.tar.xz",
54-
sha256 = "861c173c83ffbb1a89fd94f0a7ab69a731b6ac491300d3381bff126f46331ee0",
53+
url = "https://ftp.mozilla.org/pub/firefox/releases/144.0b9/linux-x86_64/en-US/firefox-144.0b9.tar.xz",
54+
sha256 = "e0911a670d058cd5ca9cdf1929ff006aaf047cdac7cdfd66e70d752a1643df95",
5555
build_file_content = """
5656
load("@aspect_rules_js//js:defs.bzl", "js_library")
5757
package(default_visibility = ["//visibility:public"])
@@ -72,8 +72,8 @@ js_library(
7272

7373
dmg_archive(
7474
name = "mac_beta_firefox",
75-
url = "https://ftp.mozilla.org/pub/firefox/releases/144.0b8/mac/en-US/Firefox%20144.0b8.dmg",
76-
sha256 = "8a209de4f8fa51990c3b4d0cbc2100fef12d83a95320093f07168b26fc0dc8a1",
75+
url = "https://ftp.mozilla.org/pub/firefox/releases/144.0b9/mac/en-US/Firefox%20144.0b9.dmg",
76+
sha256 = "187cbf68493ad11041c47759fd2da68f79174a2317c171513324aff461c30664",
7777
build_file_content = """
7878
load("@aspect_rules_js//js:defs.bzl", "js_library")
7979
package(default_visibility = ["//visibility:public"])
@@ -123,10 +123,10 @@ js_library(
123123

124124
pkg_archive(
125125
name = "mac_edge",
126-
url = "https://msedge.sf.dl.delivery.mp.microsoft.com/filestreamingservice/files/e75ee320-4211-4086-95b2-8f05ef301b70/MicrosoftEdge-140.0.3485.94.pkg",
127-
sha256 = "fc4de819d43dd96e35fa275d10bdd1b8d9e514070e4cd42dbdafe59312e46487",
126+
url = "https://msedge.sf.dl.delivery.mp.microsoft.com/filestreamingservice/files/2aa012fa-b45e-4235-8fcf-9d42087a962c/MicrosoftEdge-141.0.3537.57.pkg",
127+
sha256 = "af6ae5d5fe1d4ff9113168817d1c0f4edd1b2499ca58b4f92ae5172516d4d79f",
128128
move = {
129-
"MicrosoftEdge-140.0.3485.94.pkg/Payload/Microsoft Edge.app": "Edge.app",
129+
"MicrosoftEdge-141.0.3537.57.pkg/Payload/Microsoft Edge.app": "Edge.app",
130130
},
131131
build_file_content = """
132132
load("@aspect_rules_js//js:defs.bzl", "js_library")
@@ -165,8 +165,8 @@ js_library(
165165

166166
http_archive(
167167
name = "linux_edgedriver",
168-
url = "https://msedgedriver.microsoft.com/140.0.3485.94/edgedriver_linux64.zip",
169-
sha256 = "18dde03c75b6a12ac75c907fe2cf17889b969ad93eba256f827d331bc19c5740",
168+
url = "https://msedgedriver.microsoft.com/141.0.3537.57/edgedriver_linux64.zip",
169+
sha256 = "54536daa3e18ba9504cd85c5b2a02f8d963dfba0c90208b9a46f4b59e0de50ae",
170170
build_file_content = """
171171
load("@aspect_rules_js//js:defs.bzl", "js_library")
172172
package(default_visibility = ["//visibility:public"])
@@ -182,8 +182,8 @@ js_library(
182182

183183
http_archive(
184184
name = "mac_edgedriver",
185-
url = "https://msedgedriver.microsoft.com/140.0.3485.94/edgedriver_mac64.zip",
186-
sha256 = "01e6d28ddcc5cfb15ee6885c8980fb38e57e2f3c5a3a72b7a4e189d29d788a8e",
185+
url = "https://msedgedriver.microsoft.com/141.0.3537.57/edgedriver_mac64.zip",
186+
sha256 = "d939d0c08797db9510ca5b1022cb3cfe0aafeb11a4e4195ec65cae7bc791fb44",
187187
build_file_content = """
188188
load("@aspect_rules_js//js:defs.bzl", "js_library")
189189
package(default_visibility = ["//visibility:public"])

dotnet/src/webdriver/BiDi/BiDi.cs

Lines changed: 46 additions & 129 deletions
Original file line numberDiff line numberDiff line change
@@ -18,164 +18,81 @@
1818
// </copyright>
1919

2020
using System;
21+
using System.Collections.Concurrent;
22+
using System.Text.Json;
23+
using System.Text.Json.Serialization;
2124
using System.Threading;
2225
using System.Threading.Tasks;
2326
using OpenQA.Selenium.BiDi.Communication;
27+
using OpenQA.Selenium.BiDi.Communication.Json;
28+
using OpenQA.Selenium.BiDi.Communication.Json.Converters;
2429

2530
namespace OpenQA.Selenium.BiDi;
2631

2732
public sealed class BiDi : IAsyncDisposable
2833
{
2934
private readonly Broker _broker;
35+
private readonly JsonSerializerOptions _jsonOptions;
36+
private readonly BiDiJsonSerializerContext _jsonContext;
3037

31-
private Session.SessionModule? _sessionModule;
32-
private BrowsingContext.BrowsingContextModule? _browsingContextModule;
33-
private Browser.BrowserModule? _browserModule;
34-
private Network.NetworkModule? _networkModule;
35-
private Input.InputModule? _inputModule;
36-
private Script.ScriptModule? _scriptModule;
37-
private Log.LogModule? _logModule;
38-
private Storage.StorageModule? _storageModule;
39-
private WebExtension.WebExtensionModule? _webExtensionModule;
40-
private Emulation.EmulationModule? _emulationModule;
41-
42-
private readonly object _moduleLock = new();
38+
private readonly ConcurrentDictionary<Type, Module> _modules = [];
4339

4440
private BiDi(string url)
4541
{
4642
var uri = new Uri(url);
4743

48-
_broker = new Broker(this, uri);
49-
}
50-
51-
internal Session.SessionModule SessionModule
52-
{
53-
get
44+
_jsonOptions = new JsonSerializerOptions
5445
{
55-
if (_sessionModule is not null) return _sessionModule;
56-
lock (_moduleLock)
46+
PropertyNameCaseInsensitive = true,
47+
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
48+
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,
49+
50+
// BiDi returns special numbers such as "NaN" as strings
51+
// Additionally, -0 is returned as a string "-0"
52+
NumberHandling = JsonNumberHandling.AllowNamedFloatingPointLiterals | JsonNumberHandling.AllowReadingFromString,
53+
Converters =
5754
{
58-
_sessionModule ??= new Session.SessionModule(_broker);
55+
new BrowsingContextConverter(this),
56+
new BrowserUserContextConverter(this),
57+
new CollectorConverter(this),
58+
new InterceptConverter(this),
59+
new HandleConverter(this),
60+
new InternalIdConverter(this),
61+
new PreloadScriptConverter(this),
62+
new RealmConverter(this),
63+
new DateTimeOffsetConverter(),
64+
new WebExtensionConverter(this),
5965
}
60-
return _sessionModule;
61-
}
62-
}
66+
};
6367

64-
public BrowsingContext.BrowsingContextModule BrowsingContext
65-
{
66-
get
67-
{
68-
if (_browsingContextModule is not null) return _browsingContextModule;
69-
lock (_moduleLock)
70-
{
71-
_browsingContextModule ??= new BrowsingContext.BrowsingContextModule(_broker);
72-
}
73-
return _browsingContextModule;
74-
}
75-
}
68+
_jsonContext = new BiDiJsonSerializerContext(_jsonOptions);
7669

77-
public Browser.BrowserModule Browser
78-
{
79-
get
80-
{
81-
if (_browserModule is not null) return _browserModule;
82-
lock (_moduleLock)
83-
{
84-
_browserModule ??= new Browser.BrowserModule(_broker);
85-
}
86-
return _browserModule;
87-
}
70+
_broker = new Broker(this, uri, _jsonOptions);
8871
}
8972

90-
public Network.NetworkModule Network
91-
{
92-
get
93-
{
94-
if (_networkModule is not null) return _networkModule;
95-
lock (_moduleLock)
96-
{
97-
_networkModule ??= new Network.NetworkModule(_broker);
98-
}
99-
return _networkModule;
100-
}
101-
}
73+
internal Session.SessionModule SessionModule => AsModule<Session.SessionModule>();
10274

103-
internal Input.InputModule InputModule
104-
{
105-
get
106-
{
107-
if (_inputModule is not null) return _inputModule;
108-
lock (_moduleLock)
109-
{
110-
_inputModule ??= new Input.InputModule(_broker);
111-
}
112-
return _inputModule;
113-
}
114-
}
75+
public BrowsingContext.BrowsingContextModule BrowsingContext => AsModule<BrowsingContext.BrowsingContextModule>();
11576

116-
public Script.ScriptModule Script
117-
{
118-
get
119-
{
120-
if (_scriptModule is not null) return _scriptModule;
121-
lock (_moduleLock)
122-
{
123-
_scriptModule ??= new Script.ScriptModule(_broker);
124-
}
125-
return _scriptModule;
126-
}
127-
}
77+
public Browser.BrowserModule Browser => AsModule<Browser.BrowserModule>();
12878

129-
public Log.LogModule Log
130-
{
131-
get
132-
{
133-
if (_logModule is not null) return _logModule;
134-
lock (_moduleLock)
135-
{
136-
_logModule ??= new Log.LogModule(_broker);
137-
}
138-
return _logModule;
139-
}
140-
}
79+
public Network.NetworkModule Network => AsModule<Network.NetworkModule>();
14180

142-
public Storage.StorageModule Storage
143-
{
144-
get
145-
{
146-
if (_storageModule is not null) return _storageModule;
147-
lock (_moduleLock)
148-
{
149-
_storageModule ??= new Storage.StorageModule(_broker);
150-
}
151-
return _storageModule;
152-
}
153-
}
81+
internal Input.InputModule InputModule => AsModule<Input.InputModule>();
15482

155-
public WebExtension.WebExtensionModule WebExtension
156-
{
157-
get
158-
{
159-
if (_webExtensionModule is not null) return _webExtensionModule;
160-
lock (_moduleLock)
161-
{
162-
_webExtensionModule ??= new WebExtension.WebExtensionModule(_broker);
163-
}
164-
return _webExtensionModule;
165-
}
166-
}
83+
public Script.ScriptModule Script => AsModule<Script.ScriptModule>();
84+
85+
public Log.LogModule Log => AsModule<Log.LogModule>();
16786

168-
public Emulation.EmulationModule Emulation
87+
public Storage.StorageModule Storage => AsModule<Storage.StorageModule>();
88+
89+
public WebExtension.WebExtensionModule WebExtension => AsModule<WebExtension.WebExtensionModule>();
90+
91+
public Emulation.EmulationModule Emulation => AsModule<Emulation.EmulationModule>();
92+
93+
public TModule AsModule<TModule>() where TModule : Module, new()
16994
{
170-
get
171-
{
172-
if (_emulationModule is not null) return _emulationModule;
173-
lock (_moduleLock)
174-
{
175-
_emulationModule ??= new Emulation.EmulationModule(_broker);
176-
}
177-
return _emulationModule;
178-
}
95+
return (TModule)_modules.GetOrAdd(typeof(TModule), _ => Module.Create<TModule>(this, _broker, _jsonOptions, _jsonContext));
17996
}
18097

18198
public Task<Session.StatusResult> StatusAsync()

dotnet/src/webdriver/BiDi/Browser/BrowserModule.cs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,60 +17,61 @@
1717
// under the License.
1818
// </copyright>
1919

20-
using System.Threading.Tasks;
2120
using OpenQA.Selenium.BiDi.Communication;
21+
using System.Threading.Tasks;
2222

2323
namespace OpenQA.Selenium.BiDi.Browser;
2424

25-
public sealed class BrowserModule(Broker broker) : Module(broker)
25+
public sealed class BrowserModule : Module
2626
{
2727
public async Task<EmptyResult> CloseAsync(CloseOptions? options = null)
2828
{
29-
return await Broker.ExecuteCommandAsync<CloseCommand, EmptyResult>(new CloseCommand(), options).ConfigureAwait(false);
29+
return await Broker.ExecuteCommandAsync(new CloseCommand(), options, JsonContext.Browser_CloseCommand, JsonContext.EmptyResult).ConfigureAwait(false);
3030
}
3131

3232
public async Task<UserContextInfo> CreateUserContextAsync(CreateUserContextOptions? options = null)
3333
{
3434
var @params = new CreateUserContextParameters(options?.AcceptInsecureCerts, options?.Proxy, options?.UnhandledPromptBehavior);
3535

36-
return await Broker.ExecuteCommandAsync<CreateUserContextCommand, UserContextInfo>(new CreateUserContextCommand(@params), options).ConfigureAwait(false);
36+
return await Broker.ExecuteCommandAsync(new CreateUserContextCommand(@params), options, JsonContext.CreateUserContextCommand, JsonContext.UserContextInfo).ConfigureAwait(false);
3737
}
3838

3939
public async Task<GetUserContextsResult> GetUserContextsAsync(GetUserContextsOptions? options = null)
4040
{
41-
return await Broker.ExecuteCommandAsync<GetUserContextsCommand, GetUserContextsResult>(new GetUserContextsCommand(), options).ConfigureAwait(false);
41+
return await Broker.ExecuteCommandAsync(new GetUserContextsCommand(), options, JsonContext.GetUserContextsCommand, JsonContext.GetUserContextsResult).ConfigureAwait(false);
4242
}
4343

4444
public async Task<EmptyResult> RemoveUserContextAsync(UserContext userContext, RemoveUserContextOptions? options = null)
4545
{
4646
var @params = new RemoveUserContextParameters(userContext);
4747

48-
return await Broker.ExecuteCommandAsync<RemoveUserContextCommand, EmptyResult>(new RemoveUserContextCommand(@params), options).ConfigureAwait(false);
48+
return await Broker.ExecuteCommandAsync(new RemoveUserContextCommand(@params), options, JsonContext.RemoveUserContextCommand, JsonContext.EmptyResult).ConfigureAwait(false);
4949
}
5050

5151
public async Task<GetClientWindowsResult> GetClientWindowsAsync(GetClientWindowsOptions? options = null)
5252
{
53-
return await Broker.ExecuteCommandAsync<GetClientWindowsCommand, GetClientWindowsResult>(new(), options).ConfigureAwait(false);
53+
return await Broker.ExecuteCommandAsync(new(), options, JsonContext.GetClientWindowsCommand, JsonContext.GetClientWindowsResult
54+
).ConfigureAwait(false);
5455
}
5556

5657
public async Task<EmptyResult> SetDownloadBehaviorAllowedAsync(string destinationFolder, SetDownloadBehaviorOptions? options = null)
5758
{
5859
var @params = new SetDownloadBehaviorParameters(new DownloadBehaviorAllowed(destinationFolder), options?.UserContexts);
5960

60-
return await Broker.ExecuteCommandAsync<SetDownloadBehaviorCommand, EmptyResult>(new SetDownloadBehaviorCommand(@params), options).ConfigureAwait(false);
61+
return await Broker.ExecuteCommandAsync(new SetDownloadBehaviorCommand(@params), options, JsonContext.SetDownloadBehaviorCommand, JsonContext.EmptyResult).ConfigureAwait(false);
6162
}
6263

6364
public async Task<EmptyResult> SetDownloadBehaviorAllowedAsync(SetDownloadBehaviorOptions? options = null)
6465
{
6566
var @params = new SetDownloadBehaviorParameters(null, options?.UserContexts);
6667

67-
return await Broker.ExecuteCommandAsync<SetDownloadBehaviorCommand, EmptyResult>(new SetDownloadBehaviorCommand(@params), options).ConfigureAwait(false);
68+
return await Broker.ExecuteCommandAsync(new SetDownloadBehaviorCommand(@params), options, JsonContext.SetDownloadBehaviorCommand, JsonContext.EmptyResult).ConfigureAwait(false);
6869
}
6970

7071
public async Task<EmptyResult> SetDownloadBehaviorDeniedAsync(SetDownloadBehaviorOptions? options = null)
7172
{
7273
var @params = new SetDownloadBehaviorParameters(new DownloadBehaviorDenied(), options?.UserContexts);
7374

74-
return await Broker.ExecuteCommandAsync<SetDownloadBehaviorCommand, EmptyResult>(new SetDownloadBehaviorCommand(@params), options).ConfigureAwait(false);
75+
return await Broker.ExecuteCommandAsync(new SetDownloadBehaviorCommand(@params), options, JsonContext.SetDownloadBehaviorCommand, JsonContext.EmptyResult).ConfigureAwait(false);
7576
}
7677
}

0 commit comments

Comments
 (0)