Skip to content

Commit d907d7e

Browse files
authored
Merge branch 'SeleniumHQ:trunk' into py-fix-error-handler
2 parents 1acce14 + 9be77c1 commit d907d7e

File tree

13 files changed

+292
-82
lines changed

13 files changed

+292
-82
lines changed

MODULE.bazel

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -370,13 +370,17 @@ use_repo(
370370
pin_browsers_extension = use_extension("//common:repositories.bzl", "pin_browsers_extension")
371371
use_repo(
372372
pin_browsers_extension,
373+
"linux_beta_chrome",
374+
"linux_beta_chromedriver",
373375
"linux_beta_firefox",
374376
"linux_chrome",
375377
"linux_chromedriver",
376378
"linux_edge",
377379
"linux_edgedriver",
378380
"linux_firefox",
379381
"linux_geckodriver",
382+
"mac_beta_chrome",
383+
"mac_beta_chromedriver",
380384
"mac_beta_firefox",
381385
"mac_chrome",
382386
"mac_chromedriver",

common/browsers.bzl

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,25 @@ firefox_beta_data = select({
8383
],
8484
"//conditions:default": [],
8585
}) + geckodriver_data
86+
87+
chromedriver_beta_data = select({
88+
"@selenium//common:use_pinned_linux_chrome": [
89+
"@linux_beta_chromedriver//:chromedriver",
90+
],
91+
"@selenium//common:use_pinned_macos_chrome": [
92+
"@mac_beta_chromedriver//:chromedriver",
93+
],
94+
"@selenium//common:use_local_chromedriver": ["@selenium//common:chromedriver"],
95+
"//conditions:default": [],
96+
})
97+
98+
chrome_beta_data = select({
99+
"@selenium//common:use_pinned_linux_chrome": [
100+
"@linux_beta_chrome//:files",
101+
"@linux_beta_chrome//:chrome-linux64/chrome",
102+
],
103+
"@selenium//common:use_pinned_macos_chrome": [
104+
"@mac_beta_chrome//:Chrome.app",
105+
],
106+
"//conditions:default": [],
107+
}) + chromedriver_beta_data

common/repositories.bzl

Lines changed: 82 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ js_library(
5050

5151
http_archive(
5252
name = "linux_beta_firefox",
53-
url = "https://ftp.mozilla.org/pub/firefox/releases/140.0b7/linux-x86_64/en-US/firefox-140.0b7.tar.xz",
54-
sha256 = "a6e232e676e9b1490d673745da8221614e7cab68ed73003e41d6a07d91062af8",
53+
url = "https://ftp.mozilla.org/pub/firefox/releases/140.0b8/linux-x86_64/en-US/firefox-140.0b8.tar.xz",
54+
sha256 = "1fa8bcb1e242ffbad091b3ee7067ece582d34508db394e656832ab07b058e96e",
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/140.0b7/mac/en-US/Firefox%20140.0b7.dmg",
76-
sha256 = "24a756a979ef4c23e223002e8cb748ad69236f023f0ba0168d98add4f5d0cb8e",
75+
url = "https://ftp.mozilla.org/pub/firefox/releases/140.0b8/mac/en-US/Firefox%20140.0b8.dmg",
76+
sha256 = "7e648f5e0305a6abedb698ea5b29971cd1eb58225b998baa85a82d94bcf75342",
7777
build_file_content = """
7878
load("@aspect_rules_js//js:defs.bzl", "js_library")
7979
package(default_visibility = ["//visibility:public"])
@@ -218,7 +218,6 @@ js_library(
218218
)
219219
""",
220220
)
221-
222221
http_archive(
223222
name = "mac_chrome",
224223
url = "https://storage.googleapis.com/chrome-for-testing-public/137.0.7151.70/mac-x64/chrome-mac-x64.zip",
@@ -240,7 +239,6 @@ js_library(
240239
)
241240
""",
242241
)
243-
244242
http_archive(
245243
name = "linux_chromedriver",
246244
url = "https://storage.googleapis.com/chrome-for-testing-public/137.0.7151.70/linux64/chromedriver-linux64.zip",
@@ -270,6 +268,84 @@ package(default_visibility = ["//visibility:public"])
270268
271269
exports_files(["chromedriver"])
272270
271+
js_library(
272+
name = "chromedriver-js",
273+
data = ["chromedriver"],
274+
)
275+
""",
276+
)
277+
278+
http_archive(
279+
name = "linux_beta_chrome",
280+
url = "https://storage.googleapis.com/chrome-for-testing-public/138.0.7204.15/linux64/chrome-linux64.zip",
281+
sha256 = "e4bb8769b613eacd7cc40e48f3f63d96de9e9ee642360b4a79bedd502291c544",
282+
build_file_content = """
283+
load("@aspect_rules_js//js:defs.bzl", "js_library")
284+
package(default_visibility = ["//visibility:public"])
285+
286+
filegroup(
287+
name = "files",
288+
srcs = glob(["**/*"]),
289+
)
290+
291+
exports_files(["chrome-linux64/chrome"])
292+
293+
js_library(
294+
name = "chrome-js",
295+
data = [":files"],
296+
)
297+
""",
298+
)
299+
http_archive(
300+
name = "mac_beta_chrome",
301+
url = "https://storage.googleapis.com/chrome-for-testing-public/138.0.7204.15/mac-x64/chrome-mac-x64.zip",
302+
sha256 = "46dbfe39930cd3a2a45bc85a70bb49c291c258fde5be4d3d4deecc8e3181ae2f",
303+
strip_prefix = "chrome-mac-x64",
304+
patch_cmds = [
305+
"mv 'Google Chrome for Testing.app' Chrome.app",
306+
"mv 'Chrome.app/Contents/MacOS/Google Chrome for Testing' Chrome.app/Contents/MacOS/Chrome",
307+
],
308+
build_file_content = """
309+
load("@aspect_rules_js//js:defs.bzl", "js_library")
310+
package(default_visibility = ["//visibility:public"])
311+
312+
exports_files(["Chrome.app"])
313+
314+
js_library(
315+
name = "chrome-js",
316+
data = glob(["Chrome.app/**/*"]),
317+
)
318+
""",
319+
)
320+
http_archive(
321+
name = "linux_beta_chromedriver",
322+
url = "https://storage.googleapis.com/chrome-for-testing-public/138.0.7204.15/linux64/chromedriver-linux64.zip",
323+
sha256 = "b180e7569aa10a10e5b112b2b6cc21d126499122eaba0e90d264713285cc9104",
324+
strip_prefix = "chromedriver-linux64",
325+
build_file_content = """
326+
load("@aspect_rules_js//js:defs.bzl", "js_library")
327+
package(default_visibility = ["//visibility:public"])
328+
329+
exports_files(["chromedriver"])
330+
331+
js_library(
332+
name = "chromedriver-js",
333+
data = ["chromedriver"],
334+
)
335+
""",
336+
)
337+
338+
http_archive(
339+
name = "mac_beta_chromedriver",
340+
url = "https://storage.googleapis.com/chrome-for-testing-public/138.0.7204.15/mac-x64/chromedriver-mac-x64.zip",
341+
sha256 = "fda50dbab46115e2185cae0f3eeb8526c3f95175b0d4f7f7871aaf1e63590d5c",
342+
strip_prefix = "chromedriver-mac-x64",
343+
build_file_content = """
344+
load("@aspect_rules_js//js:defs.bzl", "js_library")
345+
package(default_visibility = ["//visibility:public"])
346+
347+
exports_files(["chromedriver"])
348+
273349
js_library(
274350
name = "chromedriver-js",
275351
data = ["chromedriver"],

py/selenium/webdriver/common/bidi/browsing_context.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,9 +335,11 @@ class HistoryUpdatedParams:
335335
def __init__(
336336
self,
337337
context: str,
338+
timestamp: int,
338339
url: str,
339340
):
340341
self.context = context
342+
self.timestamp = timestamp
341343
self.url = url
342344

343345
@classmethod
@@ -356,12 +358,17 @@ def from_json(cls, json: dict) -> "HistoryUpdatedParams":
356358
if context is None or not isinstance(context, str):
357359
raise ValueError("context is required and must be a string")
358360

361+
timestamp = json.get("timestamp")
362+
if timestamp is None or not isinstance(timestamp, int) or timestamp < 0:
363+
raise ValueError("timestamp is required and must be a non-negative integer")
364+
359365
url = json.get("url")
360366
if url is None or not isinstance(url, str):
361367
raise ValueError("url is required and must be a string")
362368

363369
return cls(
364370
context=context,
371+
timestamp=timestamp,
365372
url=url,
366373
)
367374

py/selenium/webdriver/remote/server.py

Lines changed: 42 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -57,49 +57,73 @@ def __init__(self, host=None, port=4444, path=None, version=None, log_level="INF
5757
raise TypeError("Not allowed to specify a version when using an existing server path")
5858

5959
self.host = host
60-
self.port = self._validate_port(port)
61-
self.path = self._validate_path(path)
62-
self.version = self._validate_version(version)
63-
self.log_level = self._validate_log_level(log_level)
64-
self.env = self._validate_env(env)
65-
60+
self.port = port
61+
self.path = path
62+
self.version = version
63+
self.log_level = log_level
64+
self.env = env
6665
self.process = None
67-
self.status_url = self._get_status_url()
6866

69-
def _get_status_url(self):
67+
@property
68+
def status_url(self):
7069
host = self.host if self.host is not None else "localhost"
7170
return f"http://{host}:{self.port}/status"
7271

73-
def _validate_path(self, path):
72+
@property
73+
def path(self):
74+
return self._path
75+
76+
@path.setter
77+
def path(self, path):
7478
if path and not os.path.exists(path):
7579
raise OSError(f"Can't find server .jar located at {path}")
76-
return path
80+
self._path = path
81+
82+
@property
83+
def port(self):
84+
return self._port
7785

78-
def _validate_port(self, port):
86+
@port.setter
87+
def port(self, port):
7988
try:
8089
port = int(port)
8190
except ValueError:
8291
raise TypeError(f"{__class__.__name__}.__init__() got an invalid port: '{port}'")
8392
if not (0 <= port <= 65535):
8493
raise ValueError("port must be 0-65535")
85-
return port
94+
self._port = port
8695

87-
def _validate_version(self, version):
96+
@property
97+
def version(self):
98+
return self._version
99+
100+
@version.setter
101+
def version(self, version):
88102
if version:
89103
if not re.match(r"^\d+\.\d+\.\d+$", str(version)):
90104
raise TypeError(f"{__class__.__name__}.__init__() got an invalid version: '{version}'")
91-
return version
105+
self._version = version
106+
107+
@property
108+
def log_level(self):
109+
return self._log_level
92110

93-
def _validate_log_level(self, log_level):
111+
@log_level.setter
112+
def log_level(self, log_level):
94113
levels = ("SEVERE", "WARNING", "INFO", "CONFIG", "FINE", "FINER", "FINEST")
95114
if log_level not in levels:
96115
raise TypeError(f"log_level must be one of: {', '.join(levels)}")
97-
return log_level
116+
self._log_level = log_level
117+
118+
@property
119+
def env(self):
120+
return self._env
98121

99-
def _validate_env(self, env):
122+
@env.setter
123+
def env(self, env):
100124
if env is not None and not isinstance(env, collections.abc.Mapping):
101125
raise TypeError("env must be a mapping of environment variables")
102-
return env
126+
self._env = env
103127

104128
def _wait_for_server(self, timeout=10):
105129
start = time.time()

py/selenium/webdriver/support/expected_conditions.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,8 @@ def text_to_be_present_in_element_value(
428428
def _predicate(driver: WebDriverOrWebElement):
429429
try:
430430
element_text = driver.find_element(*locator).get_attribute("value")
431+
if element_text is None:
432+
return False
431433
return text_ in element_text
432434
except StaleElementReferenceException:
433435
return False

rb/lib/selenium/webdriver/common/child_process.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,14 @@ def terminate_and_wait_else_kill(timeout)
122122

123123
def terminate(pid)
124124
Process.kill(SIGTERM, pid)
125+
rescue Errno::ECHILD, Errno::ESRCH
126+
# Process does not exist, nothing to terminate
125127
end
126128

127129
def kill(pid)
128130
Process.kill(SIGKILL, pid)
131+
rescue Errno::ECHILD, Errno::ESRCH
132+
# Process does not exist, nothing to kill
129133
end
130134

131135
def waitpid2(pid, flags = 0)

rb/spec/integration/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package(default_visibility = ["//rb/spec/integration:__subpackages__"])
22

33
BROWSERS = [
44
"chrome",
5+
"chrome-beta",
56
"edge",
67
"firefox",
78
"ie",

rb/spec/integration/selenium/webdriver/chrome/BUILD.bazel

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,12 @@ load("//rb/spec:tests.bzl", "rb_integration_test")
44
rb_integration_test(
55
name = file[:-8],
66
srcs = [file],
7-
browsers = ["chrome"], # No need to run in other browsers.
7+
# No need to run in other browsers.
8+
browsers = [
9+
"chrome",
10+
"chrome-beta",
11+
],
12+
data = ["//common/extensions"],
813
)
914
for file in glob(["*_spec.rb"])
1015
]

rb/spec/tests.bzl

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ load("@rules_ruby//ruby:defs.bzl", "rb_library", "rb_test")
22
load(
33
"//common:browsers.bzl",
44
"COMMON_TAGS",
5+
"chrome_beta_data",
56
"chrome_data",
67
"edge_data",
78
"firefox_beta_data",
@@ -32,6 +33,30 @@ BROWSERS = {
3233
"//conditions:default": {},
3334
}),
3435
},
36+
"chrome-beta": {
37+
"data": chrome_beta_data,
38+
"deps": ["//rb/lib/selenium/webdriver:chrome"],
39+
"tags": [],
40+
"target_compatible_with": [],
41+
"env": {
42+
"WD_REMOTE_BROWSER": "chrome",
43+
"WD_SPEC_DRIVER": "chrome",
44+
"WD_BROWSER_VERSION": "beta",
45+
} | select({
46+
"@selenium//common:use_pinned_linux_chrome": {
47+
"CHROME_BINARY": "$(location @linux_beta_chrome//:chrome-linux64/chrome)",
48+
"CHROMEDRIVER_BINARY": "$(location @linux_beta_chromedriver//:chromedriver)",
49+
},
50+
"@selenium//common:use_pinned_macos_chrome": {
51+
"CHROME_BINARY": "$(location @mac_beta_chrome//:Chrome.app)/Contents/MacOS/Chrome",
52+
"CHROMEDRIVER_BINARY": "$(location @mac_beta_chromedriver//:chromedriver)",
53+
},
54+
"//conditions:default": {},
55+
}) | select({
56+
"@selenium//common:use_headless_browser": {"HEADLESS": "true"},
57+
"//conditions:default": {},
58+
}),
59+
},
3560
"edge": {
3661
"data": edge_data,
3762
"deps": ["//rb/lib/selenium/webdriver:edge"],

0 commit comments

Comments
 (0)