Skip to content

Commit 092b963

Browse files
committed
Merge branch 'trunk' into py-314
2 parents d157fa6 + 2e0159a commit 092b963

File tree

19 files changed

+300
-380
lines changed

19 files changed

+300
-380
lines changed

.github/workflows/ci-python.yml

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ jobs:
1111
with:
1212
name: Build
1313
cache-key: py-build
14-
run: bazel build //py:selenium-wheel //py:selenium-sdist
14+
run: |
15+
bazel build //py:selenium-wheel //py:selenium-sdist
1516
1617
docs:
1718
name: Documentation
@@ -29,7 +30,8 @@ jobs:
2930
python -m pip install --upgrade pip
3031
pip install tox
3132
- name: Generate docs
32-
run: tox -c py/tox.ini
33+
run: |
34+
tox -c py/tox.ini
3335
env:
3436
TOXENV: docs
3537

@@ -68,7 +70,8 @@ jobs:
6870
name: Unit Tests (${{ matrix.os }})
6971
os: ${{ matrix.os }}
7072
cache-key: python-unit-test-${{ matrix.os }}
71-
run: bazel test //py:unit
73+
run: |
74+
bazel test //py:unit
7275
7376
remote-tests:
7477
name: Remote Tests
@@ -83,7 +86,8 @@ jobs:
8386
name: Integration Tests (remote, ${{ matrix.browser }})
8487
browser: ${{ matrix.browser }}
8588
cache-key: py-remote-${{ matrix.browser }}
86-
run: bazel test --local_test_jobs 1 --flaky_test_attempts 3 //py:test-remote
89+
run: |
90+
bazel test --local_test_jobs 1 --flaky_test_attempts 3 //py:test-remote
8791
8892
browser-tests:
8993
name: Browser Tests
@@ -107,7 +111,28 @@ jobs:
107111
run: |
108112
bazel test --local_test_jobs 1 --flaky_test_attempts 3 --pin_browsers=true //py:common-${{ matrix.browser }}-bidi //py:test-${{ matrix.browser }}
109113
110-
safari-tests:
114+
browser-tests-windows:
115+
name: Browser Tests
116+
needs: build
117+
uses: ./.github/workflows/bazel.yml
118+
strategy:
119+
fail-fast: false
120+
matrix:
121+
include:
122+
- browser: chrome
123+
os: windows
124+
- browser: edge
125+
os: windows
126+
with:
127+
name: Integration Tests (${{ matrix.browser }}, ${{ matrix.os }})
128+
browser: ${{ matrix.browser }}
129+
os: ${{ matrix.os }}
130+
cache-key: py-browser-${{ matrix.browser }}
131+
run: |
132+
fsutil 8dot3name set 0
133+
bazel test --local_test_jobs 1 --flaky_test_attempts 3 --pin_browsers=true //py:common-${{ matrix.browser }}-bidi //py:test-${{ matrix.browser }}
134+
135+
browser-tests-macos:
111136
name: Browser Tests
112137
needs: build
113138
uses: ./.github/workflows/bazel.yml

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: 51 additions & 132 deletions
Original file line numberDiff line numberDiff line change
@@ -18,165 +18,84 @@
1818
// </copyright>
1919

2020
using System;
21+
using System.Text.Json;
22+
using System.Text.Json.Serialization;
2123
using System.Threading;
2224
using System.Threading.Tasks;
2325
using OpenQA.Selenium.BiDi.Communication;
26+
using OpenQA.Selenium.BiDi.Communication.Json;
27+
using OpenQA.Selenium.BiDi.Communication.Json.Converters;
2428

2529
namespace OpenQA.Selenium.BiDi;
2630

2731
public sealed class BiDi : IAsyncDisposable
2832
{
2933
private readonly Broker _broker;
30-
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();
34+
private readonly JsonSerializerOptions _jsonOptions;
35+
private readonly BiDiJsonSerializerContext _jsonContext;
4336

4437
private BiDi(string url)
4538
{
4639
var uri = new Uri(url);
4740

48-
_broker = new Broker(this, uri);
49-
}
50-
51-
internal Session.SessionModule SessionModule
52-
{
53-
get
41+
_jsonOptions = new JsonSerializerOptions
5442
{
55-
if (_sessionModule is not null) return _sessionModule;
56-
lock (_moduleLock)
43+
PropertyNameCaseInsensitive = true,
44+
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
45+
DefaultIgnoreCondition = JsonIgnoreCondition.WhenWritingNull,
46+
47+
// BiDi returns special numbers such as "NaN" as strings
48+
// Additionally, -0 is returned as a string "-0"
49+
NumberHandling = JsonNumberHandling.AllowNamedFloatingPointLiterals | JsonNumberHandling.AllowReadingFromString,
50+
Converters =
5751
{
58-
_sessionModule ??= new Session.SessionModule(_broker);
52+
new BrowsingContextConverter(this),
53+
new BrowserUserContextConverter(this),
54+
new CollectorConverter(this),
55+
new InterceptConverter(this),
56+
new HandleConverter(this),
57+
new InternalIdConverter(this),
58+
new PreloadScriptConverter(this),
59+
new RealmConverter(this),
60+
new DateTimeOffsetConverter(),
61+
new WebExtensionConverter(this),
5962
}
60-
return _sessionModule;
61-
}
63+
};
64+
65+
_jsonContext = new BiDiJsonSerializerContext(_jsonOptions);
66+
67+
_broker = new Broker(this, uri, _jsonOptions);
68+
SessionModule = Module.Create<Session.SessionModule>(this, _broker, _jsonOptions, _jsonContext);
69+
BrowsingContext = Module.Create<BrowsingContext.BrowsingContextModule>(this, _broker, _jsonOptions, _jsonContext);
70+
Browser = Module.Create<Browser.BrowserModule>(this, _broker, _jsonOptions, _jsonContext);
71+
Network = Module.Create<Network.NetworkModule>(this, _broker, _jsonOptions, _jsonContext);
72+
InputModule = Module.Create<Input.InputModule>(this, _broker, _jsonOptions, _jsonContext);
73+
Script = Module.Create<Script.ScriptModule>(this, _broker, _jsonOptions, _jsonContext);
74+
Log = Module.Create<Log.LogModule>(this, _broker, _jsonOptions, _jsonContext);
75+
Storage = Module.Create<Storage.StorageModule>(this, _broker, _jsonOptions, _jsonContext);
76+
WebExtension = Module.Create<WebExtension.WebExtensionModule>(this, _broker, _jsonOptions, _jsonContext);
77+
Emulation = Module.Create<Emulation.EmulationModule>(this, _broker, _jsonOptions, _jsonContext);
6278
}
6379

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-
}
80+
internal Session.SessionModule SessionModule { get; }
7681

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-
}
88-
}
82+
public BrowsingContext.BrowsingContextModule BrowsingContext { get; }
8983

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-
}
84+
public Browser.BrowserModule Browser { get; }
10285

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-
}
86+
public Network.NetworkModule Network { get; }
11587

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-
}
88+
internal Input.InputModule InputModule { get; }
12889

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-
}
90+
public Script.ScriptModule Script { get; }
14191

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-
}
92+
public Log.LogModule Log { get; }
15493

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-
}
94+
public Storage.StorageModule Storage { get; }
16795

168-
public Emulation.EmulationModule Emulation
169-
{
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-
}
179-
}
96+
public WebExtension.WebExtensionModule WebExtension { get; }
97+
98+
public Emulation.EmulationModule Emulation { get; }
18099

181100
public Task<Session.StatusResult> StatusAsync()
182101
{

0 commit comments

Comments
 (0)