Skip to content

Commit 6f9a5fc

Browse files
authored
Merge pull request #3766 from seleniumbase/cdp-mode-patch-48
CDP Mode: Patch 48
2 parents d9b33dc + 63d0964 commit 6f9a5fc

File tree

7 files changed

+58
-27
lines changed

7 files changed

+58
-27
lines changed

mkdocs_build/requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@ pymdown-extensions>=10.15
66
pipdeptree>=2.26.1
77
python-dateutil>=2.8.2
88
Markdown==3.8
9-
click==8.2.0
9+
click==8.2.1
1010
ghp-import==2.1.0
1111
watchdog==6.0.0
1212
cairocffi==1.7.1
1313
pathspec==0.12.1
1414
Babel==2.17.0
1515
paginate==0.5.7
1616
mkdocs==1.6.1
17-
mkdocs-material==9.6.13
17+
mkdocs-material==9.6.14
1818
mkdocs-exclude-search==0.6.6
1919
mkdocs-simple-hooks==0.1.5
2020
mkdocs-material-extensions==1.3.1

requirements.txt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ pip>=25.0.1;python_version<"3.9"
22
pip>=25.1.1;python_version>="3.9"
33
packaging>=25.0
44
setuptools~=70.2;python_version<"3.10"
5-
setuptools>=80.4.0;python_version>="3.10"
5+
setuptools>=80.8.0;python_version>="3.10"
66
wheel>=0.45.1
77
attrs>=25.3.0
88
certifi>=2025.4.26
@@ -51,7 +51,8 @@ cssselect==1.3.0;python_version>="3.9"
5151
sortedcontainers==2.4.0
5252
execnet==2.1.1
5353
iniconfig==2.1.0
54-
pluggy==1.5.0
54+
pluggy==1.5.0;python_version<"3.9"
55+
pluggy==1.6.0;python_version>="3.9"
5556
pytest==8.3.5
5657
pytest-html==4.0.2
5758
pytest-metadata==3.1.1
@@ -73,7 +74,7 @@ rich>=14.0.0,<15
7374
# ("pip install -r requirements.txt" also installs this, but "pip install -e ." won't.)
7475

7576
coverage>=7.6.1;python_version<"3.9"
76-
coverage>=7.8.0;python_version>="3.9"
77+
coverage>=7.8.1;python_version>="3.9"
7778
pytest-cov>=5.0.0;python_version<"3.9"
7879
pytest-cov>=6.1.1;python_version>="3.9"
7980
flake8==5.0.4;python_version<"3.9"

seleniumbase/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# seleniumbase package
2-
__version__ = "4.38.2"
2+
__version__ = "4.38.3"

seleniumbase/core/browser_launcher.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ def uc_special_open_if_cf(
404404
special = True
405405
if status_str == "403" or status_str == "429":
406406
time.sleep(0.06) # Forbidden / Blocked! (Wait first!)
407-
if special:
407+
if special and not hasattr(driver, "cdp_base"):
408408
time.sleep(0.05)
409409
with driver:
410410
driver.execute_script('window.open("%s","_blank");' % url)
@@ -472,9 +472,12 @@ def uc_open_with_tab(driver, url):
472472
time.sleep(0.3)
473473
return
474474
if (url.startswith("http:") or url.startswith("https:")):
475-
with driver:
476-
driver.execute_script('window.open("%s","_blank");' % url)
477-
driver.close()
475+
if not hasattr(driver, "cdp_base"):
476+
with driver:
477+
driver.execute_script('window.open("%s","_blank");' % url)
478+
driver.close()
479+
else:
480+
driver.cdp.open(url)
478481
page_actions.switch_to_window(driver, driver.window_handles[-1], 2)
479482
else:
480483
driver.default_get(url) # The original one
@@ -492,9 +495,12 @@ def uc_open_with_reconnect(driver, url, reconnect_time=None):
492495
reconnect_time = constants.UC.RECONNECT_TIME
493496
if (url.startswith("http:") or url.startswith("https:")):
494497
script = 'window.open("%s","_blank");' % url
495-
driver.execute_script(script)
496-
time.sleep(0.05)
497-
driver.close()
498+
if not hasattr(driver, "cdp_base"):
499+
driver.execute_script(script)
500+
time.sleep(0.05)
501+
driver.close()
502+
else:
503+
driver.cdp.open(url)
498504
if reconnect_time == "disconnect":
499505
driver.disconnect()
500506
time.sleep(0.008)

seleniumbase/fixtures/base_case.py

Lines changed: 29 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7678,10 +7678,13 @@ def assert_downloaded_file(self, file, timeout=None, browser=False):
76787678
break
76797679
time.sleep(1)
76807680
if not found and not os.path.exists(downloaded_file_path):
7681+
plural = "s"
7682+
if timeout == 1:
7683+
plural = ""
76817684
message = (
76827685
"File {%s} was not found in the downloads folder {%s} "
7683-
"after %s seconds! (Or the download didn't complete!)"
7684-
% (file, df, timeout)
7686+
"after %s second%s! (Or the download didn't complete!)"
7687+
% (file, df, timeout, plural)
76857688
)
76867689
page_actions.timeout_exception("NoSuchFileException", message)
76877690
if self.recorder_mode and self.__current_url_is_recordable():
@@ -7735,10 +7738,13 @@ def assert_downloaded_file_regex(self, regex, timeout=None, browser=False):
77357738
break
77367739
time.sleep(1)
77377740
if not found:
7741+
plural = "s"
7742+
if timeout == 1:
7743+
plural = ""
77387744
message = (
77397745
"Regex {%s} was not found in the downloads folder {%s} "
7740-
"after %s seconds! (Or the download didn't complete!)"
7741-
% (regex, df, timeout)
7746+
"after %s second%s! (Or the download didn't complete!)"
7747+
% (regex, df, timeout, plural)
77427748
)
77437749
page_actions.timeout_exception("NoSuchFileException", message)
77447750
if self.demo_mode:
@@ -8262,7 +8268,10 @@ def is_connected(self):
82628268
In CDP Mode, the CDP-Driver controls the web browser.
82638269
The CDP-Driver can be connected while WebDriver isn't.
82648270
"""
8265-
return self.driver.is_connected()
8271+
if hasattr(self.driver, "is_connected"):
8272+
return self.driver.is_connected()
8273+
else:
8274+
return True
82668275

82678276
def is_chromium(self):
82688277
"""Return True if the browser is Chrome or Edge."""
@@ -10174,9 +10183,13 @@ def wait_for_link_text_present(self, link_text, timeout=None):
1017410183
if now_ms >= stop_ms:
1017510184
break
1017610185
time.sleep(0.2)
10177-
message = "Link text {%s} was not found after %s seconds!" % (
10186+
plural = "s"
10187+
if timeout == 1:
10188+
plural = ""
10189+
message = "Link text {%s} was not found after %s second%s!" % (
1017810190
link_text,
1017910191
timeout,
10192+
plural,
1018010193
)
1018110194
page_actions.timeout_exception("LinkTextNotFoundException", message)
1018210195

@@ -10199,9 +10212,12 @@ def wait_for_partial_link_text_present(self, link_text, timeout=None):
1019910212
if now_ms >= stop_ms:
1020010213
break
1020110214
time.sleep(0.2)
10215+
plural = "s"
10216+
if timeout == 1:
10217+
plural = ""
1020210218
message = (
10203-
"Partial Link text {%s} was not found after %s seconds!"
10204-
"" % (link_text, timeout)
10219+
"Partial Link text {%s} was not found after %s second%s!"
10220+
"" % (link_text, timeout, plural)
1020510221
)
1020610222
page_actions.timeout_exception("LinkTextNotFoundException", message)
1020710223

@@ -14409,9 +14425,12 @@ def __get_shadow_element(
1440914425
if must_be_visible and is_present:
1441014426
error = "not visible"
1441114427
the_exception = "ElementNotVisibleException"
14428+
plural = "s"
14429+
if timeout == 1:
14430+
plural = ""
1441214431
msg = (
14413-
"Shadow DOM Element {%s} was %s after %s seconds!"
14414-
% (selector_chain, error, timeout)
14432+
"Shadow DOM Element {%s} was %s after %s second%s!"
14433+
% (selector_chain, error, timeout, plural)
1441514434
)
1441614435
page_actions.timeout_exception(the_exception, msg)
1441714436
return element

seleniumbase/undetected/cdp_driver/tab.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -493,6 +493,8 @@ async def find_elements_by_text(
493493
search_id, nresult = await self.send(
494494
cdp.dom.perform_search(text, True)
495495
)
496+
if not nresult:
497+
return []
496498
if nresult:
497499
node_ids = await self.send(
498500
cdp.dom.get_search_results(search_id, 0, nresult)
@@ -584,6 +586,8 @@ async def find_element_by_text(
584586
search_id, nresult = await self.send(
585587
cdp.dom.perform_search(text, True)
586588
)
589+
if not nresult:
590+
return
587591
node_ids = await self.send(
588592
cdp.dom.get_search_results(search_id, 0, nresult)
589593
)

setup.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@
151151
'pip>=25.1.1;python_version>="3.9"',
152152
'packaging>=25.0',
153153
'setuptools~=70.2;python_version<"3.10"', # Newer ones had issues
154-
'setuptools>=80.4.0;python_version>="3.10"',
154+
'setuptools>=80.8.0;python_version>="3.10"',
155155
'wheel>=0.45.1',
156156
'attrs>=25.3.0',
157157
"certifi>=2025.4.26",
@@ -200,7 +200,8 @@
200200
"sortedcontainers==2.4.0",
201201
'execnet==2.1.1',
202202
'iniconfig==2.1.0',
203-
'pluggy==1.5.0',
203+
'pluggy==1.5.0;python_version<"3.9"',
204+
'pluggy==1.6.0;python_version>="3.9"',
204205
'pytest==8.3.5',
205206
"pytest-html==4.0.2", # Newer ones had issues
206207
'pytest-metadata==3.1.1',
@@ -231,7 +232,7 @@
231232
# Usage: coverage run -m pytest; coverage html; coverage report
232233
"coverage": [
233234
'coverage>=7.6.1;python_version<"3.9"',
234-
'coverage>=7.8.0;python_version>="3.9"',
235+
'coverage>=7.8.1;python_version>="3.9"',
235236
'pytest-cov>=5.0.0;python_version<"3.9"',
236237
'pytest-cov>=6.1.1;python_version>="3.9"',
237238
],
@@ -264,7 +265,7 @@
264265
'pdfminer.six==20250324;python_version<"3.9"',
265266
'pdfminer.six==20250506;python_version>="3.9"',
266267
'cryptography==39.0.2;python_version<"3.9"',
267-
'cryptography==44.0.3;python_version>="3.9"',
268+
'cryptography==45.0.2;python_version>="3.9"',
268269
'cffi==1.17.1',
269270
"pycparser==2.22",
270271
],

0 commit comments

Comments
 (0)