Skip to content

Commit e48940f

Browse files
authored
Merge pull request #4032 from seleniumbase/cdp-mode-patch-66
CDP Mode: Patch 66
2 parents c3f15d0 + 504a42b commit e48940f

File tree

8 files changed

+29
-54
lines changed

8 files changed

+29
-54
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<p align="center" class="hero__title"><b>Automate, test, and scrape the web — on your own terms.<br /></b></p>
1515

1616
<p align="center"><a href="https://pypi.python.org/pypi/seleniumbase" target="_blank"><img src="https://img.shields.io/pypi/v/seleniumbase.svg?color=3399EE" alt="PyPI version" /></a> <a href="https://github.com/seleniumbase/SeleniumBase/releases" target="_blank"><img src="https://img.shields.io/github/v/release/seleniumbase/SeleniumBase.svg?color=22AAEE" alt="GitHub version" /></a> <a href="https://seleniumbase.io"><img src="https://img.shields.io/badge/docs-seleniumbase.io-11BBAA.svg" alt="SeleniumBase Docs" /></a></p>
17-
<p align="center"><a href="https://github.com/seleniumbase/SeleniumBase/actions" target="_blank"><img src="https://github.com/seleniumbase/SeleniumBase/workflows/CI%20build/badge.svg" alt="SeleniumBase GitHub Actions" /></a> <a href="https://github.com/seleniumbase/SeleniumBase/stargazers"><img src="https://img.shields.io/github/stars/seleniumbase/SeleniumBase?style=social"></a> <a href="https://discord.gg/EdhQTn3EyE" target="_blank"><img src="https://img.shields.io/discord/727927627830001734?color=7289DA&label=Discord&logo=discord&logoColor=white"/></a></p>
17+
<p align="center"><a href="https://github.com/seleniumbase/SeleniumBase/actions" target="_blank"><img src="https://github.com/seleniumbase/SeleniumBase/workflows/CI%20build/badge.svg" alt="SeleniumBase GitHub Actions" /></a> <a href="https://github.com/seleniumbase/SeleniumBase/stargazers"><img src="https://img.shields.io/github/stars/seleniumbase/SeleniumBase?style=social"></a> <a href="https://pepy.tech/projects/seleniumbase?timeRange=threeMonths&category=version&includeCIDownloads=true&granularity=daily&viewType=line&versions=*" target="_blank"><img src="https://static.pepy.tech/badge/seleniumbase" alt="SeleniumBase PyPI downloads" /></a> <a href="https://discord.gg/EdhQTn3EyE" target="_blank"><img src="https://img.shields.io/discord/727927627830001734?color=7289DA&label=Discord&logo=discord&logoColor=white"/></a></p>
1818

1919
<p align="center">
2020
<a href="#python_installation">🚀 Start</a> |
@@ -54,7 +54,7 @@
5454
<br />
5555
</p>
5656

57-
<p>SeleniumBase is a browser automation framework for the modern web. Whether you're new or experienced in Python, SeleniumBase makes it easy to get started. With special features like Stealth Mode (UC Mode / CDP Mode), you'll be evading bot-detection and bypassing CAPTCHAs in minutes.</p>
57+
<p>SeleniumBase is a browser automation framework for the modern web. Both new and experienced Python users alike can easily get started. With special stealth features like UC Mode and CDP Mode, you'll be evading bot-detection and bypassing CAPTCHAs in minutes.</p>
5858

5959
--------
6060

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ websocket-client~=1.8.0;python_version<"3.9"
5252
websocket-client~=1.9.0;python_version>="3.9"
5353
selenium==4.27.1;python_version<"3.9"
5454
selenium==4.32.0;python_version>="3.9" and python_version<"3.10"
55-
selenium==4.36.0;python_version>="3.10"
55+
selenium==4.37.0;python_version>="3.10"
5656
cssselect==1.2.0;python_version<"3.9"
5757
cssselect==1.3.0;python_version>="3.9"
5858
sortedcontainers==2.4.0

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.42.6"
2+
__version__ = "4.43.0"

seleniumbase/console_scripts/sb_mkdir.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -636,17 +636,12 @@ def main():
636636
data.append("")
637637
data.append("class GoogleTests(BaseCase):")
638638
data.append(" def test_google_dot_com(self):")
639+
data.append(" if self.headless:")
640+
data.append(' self.skip("Skipping test in headless mode.")')
639641
data.append(" if not self.undetectable:")
640642
data.append(" self.get_new_driver(undetectable=True)")
641643
data.append(' self.open("https://google.com/ncr")')
642644
data.append(' self.assert_title_contains("Google")')
643-
data.append(" self.sleep(0.05)")
644-
data.append(" self.save_screenshot_to_logs()")
645-
data.append(
646-
" self.wait_for_element('iframe[role=\"presentation\"]')"
647-
)
648-
data.append(" self.hide_elements('iframe')")
649-
data.append(" self.sleep(0.05)")
650645
data.append(" self.save_screenshot_to_logs()")
651646
data.append(' self.type(HomePage.search_box, "github.com")')
652647
data.append(" self.assert_element(HomePage.search_button)")

seleniumbase/core/sb_cdp.py

Lines changed: 16 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -187,46 +187,23 @@ def find_element_by_text(self, text, tag_name=None, timeout=None):
187187
element with the given tag. (Eg: a, button, div, script, span)"""
188188
if not timeout:
189189
timeout = settings.SMALL_TIMEOUT
190-
self.__add_light_pause()
191-
time_now = time.time()
192-
self.assert_text(text, timeout=timeout)
193-
spent = int(time.time() - time_now)
194-
remaining = 1 + timeout - spent
195-
if tag_name:
196-
self.assert_element(tag_name, timeout=remaining)
197-
elements = self.loop.run_until_complete(
198-
self.page.find_elements_by_text(text=text)
199-
)
200190
if tag_name:
201-
tag_name = tag_name.lower().strip()
202-
for element in elements:
203-
if element and not tag_name:
204-
element = self.__add_sync_methods(element)
205-
return self.__add_sync_methods(element)
206-
elif (
207-
element
208-
and tag_name in element.tag_name.lower()
209-
and text.strip() in element.text
210-
):
211-
element = self.__add_sync_methods(element)
212-
return self.__add_sync_methods(element)
213-
elif (
214-
element
215-
and element.parent
216-
and tag_name in element.parent.tag_name.lower()
217-
and text.strip() in element.parent.text
218-
):
219-
element = self.__add_sync_methods(element.parent)
220-
return self.__add_sync_methods(element)
221-
elif (
222-
element
223-
and element.parent
224-
and element.parent.parent
225-
and tag_name in element.parent.parent.tag_name.lower()
226-
and text.strip() in element.parent.parent.text
227-
):
228-
element = self.__add_sync_methods(element.parent.parent)
229-
return self.__add_sync_methods(element)
191+
try:
192+
return self.find_element(
193+
'%s:contains("%s")' % (tag_name, text), timeout=timeout
194+
)
195+
except Exception:
196+
pass # The exception will be raised later
197+
else:
198+
self.__add_light_pause()
199+
self.assert_text(text, timeout=timeout)
200+
elements = self.loop.run_until_complete(
201+
self.page.find_elements_by_text(text=text)
202+
)
203+
for element in elements:
204+
if element:
205+
element = self.__add_sync_methods(element)
206+
return self.__add_sync_methods(element)
230207
plural = "s"
231208
if timeout == 1:
232209
plural = ""

seleniumbase/fixtures/base_case.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10173,7 +10173,7 @@ def wait_for_text_visible(
1017310173
text = self.__get_type_checked_text(text)
1017410174
selector, by = self.__recalculate_selector(selector, by)
1017510175
if self.__is_cdp_swap_needed():
10176-
return self.cdp.find_element(selector, timeout=timeout)
10176+
return self.cdp.wait_for_text(text, selector, timeout=timeout)
1017710177
elif self.__is_shadow_selector(selector):
1017810178
return self.__wait_for_shadow_text_visible(text, selector, timeout)
1017910179
return page_actions.wait_for_text_visible(
@@ -10530,6 +10530,8 @@ def wait_for_link_text_visible(self, link_text, timeout=None):
1053010530
timeout = settings.LARGE_TIMEOUT
1053110531
if self.timeout_multiplier and timeout == settings.LARGE_TIMEOUT:
1053210532
timeout = self.__get_new_timeout(timeout)
10533+
if self.__is_cdp_swap_needed():
10534+
return self.cdp.find_element_by_text(text=link_text, tag_name="a")
1053310535
return self.wait_for_element_visible(
1053410536
link_text, by="link text", timeout=timeout
1053510537
)

seleniumbase/undetected/cdp_driver/browser.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,8 @@ async def get(
369369
proxy_user = username_and_password.split(":")[0]
370370
proxy_pass = username_and_password.split(":")[1]
371371
await connection.set_auth(proxy_user, proxy_pass, self.tabs[0])
372-
time.sleep(0.25)
372+
time.sleep(0.22)
373+
await connection.sleep(0.05)
373374
frame_id, loader_id, *_ = await connection.send(
374375
cdp.page.navigate(url)
375376
)

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@
199199
'websocket-client~=1.9.0;python_version>="3.9"',
200200
'selenium==4.27.1;python_version<"3.9"',
201201
'selenium==4.32.0;python_version>="3.9" and python_version<"3.10"',
202-
'selenium==4.36.0;python_version>="3.10"',
202+
'selenium==4.37.0;python_version>="3.10"',
203203
'cssselect==1.2.0;python_version<"3.9"',
204204
'cssselect==1.3.0;python_version>="3.9"',
205205
"sortedcontainers==2.4.0",
@@ -277,7 +277,7 @@
277277
'pdfminer.six==20250324;python_version<"3.9"',
278278
'pdfminer.six==20250506;python_version>="3.9"',
279279
'cryptography==39.0.2;python_version<"3.9"',
280-
'cryptography==46.0.2;python_version>="3.9"',
280+
'cryptography==46.0.3;python_version>="3.9"',
281281
'cffi==1.17.1;python_version<"3.9"',
282282
'cffi==2.0.0;python_version>="3.9"',
283283
'pycparser==2.22;python_version<"3.9"',

0 commit comments

Comments
 (0)