Skip to content

Commit e456f89

Browse files
authored
Merge pull request #4087 from seleniumbase/cdp-mode-patch-72
CDP Mode: Patch 72
2 parents 115bb62 + 64fb818 commit e456f89

File tree

15 files changed

+96
-42
lines changed

15 files changed

+96
-42
lines changed

examples/cdp_mode/ReadMe.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ with SB(uc=True, test=True, locale="en", ad_block=True) as sb:
139139
url = "https://www.pokemon.com/us"
140140
sb.activate_cdp_mode(url)
141141
sb.sleep(3.2)
142-
sb.click("button#onetrust-accept-btn-handler")
142+
sb.click_if_visible("button#onetrust-accept-btn-handler")
143143
sb.sleep(1.2)
144144
sb.click("a span.icon_pokeball")
145145
sb.sleep(2.5)
@@ -188,10 +188,10 @@ with SB(uc=True, test=True, locale="en", ad_block=True) as sb:
188188
```python
189189
from seleniumbase import SB
190190

191-
with SB(uc=True, test=True, locale="en", ad_block=True) as sb:
191+
with SB(uc=True, test=True, locale="en") as sb:
192192
url = "https://www.hyatt.com/"
193193
sb.activate_cdp_mode(url)
194-
sb.sleep(3.5)
194+
sb.sleep(3.8)
195195
sb.click_if_visible('button[aria-label="Close"]')
196196
sb.sleep(0.1)
197197
sb.click_if_visible("#onetrust-reject-all-handler")

examples/cdp_mode/raw_cdp_copilot.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,20 @@
99
sb.sleep(0.5)
1010
sb.click('button[data-testid*="chat-mode-"]')
1111
sb.sleep(1.1)
12-
sb.click('button[title="Think Deeper"]')
12+
sb.click_if_visible('button[title="Think Deeper"]')
1313
sb.sleep(1.1)
1414
query = "How to start automating with SeleniumBase?"
1515
sb.press_keys(textarea, query)
1616
sb.sleep(1.1)
17+
seen_text = sb.get_text(textarea)
18+
if seen_text != query and seen_text in query:
19+
# When CAPTCHA appears while typing text
20+
sb.sleep(1.1)
21+
sb.solve_captcha()
22+
sb.sleep(2.2)
23+
sb.type(textarea, "")
24+
sb.press_keys(textarea, query)
25+
sb.sleep(0.5)
1726
sb.click('button[data-testid="submit-button"]')
1827
sb.sleep(2.5)
1928
sb.solve_captcha()

examples/cdp_mode/raw_cf_clearance.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ def get_cf_clearance_cookie(sb):
1010

1111

1212
url = "https://gitlab.com/users/sign_in"
13-
sb = sb_cdp.Chrome(url, incognito=True)
14-
sb.sleep(2.2) # Wait for CAPTCHA to load
13+
sb = sb_cdp.Chrome(url)
14+
sb.sleep(2.5) # Wait for CAPTCHA to load
1515
sb.solve_captcha() # (Only if found)
1616
sb.sleep(2.2) # Wait for CAPTCHA success
1717
cf_cookie = get_cf_clearance_cookie(sb)

examples/cdp_mode/raw_copilot.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,20 @@
1010
sb.sleep(0.5)
1111
sb.click('button[data-testid*="chat-mode-"]')
1212
sb.sleep(1.1)
13-
sb.click('button[title="Think Deeper"]')
13+
sb.click_if_visible('button[title="Think Deeper"]')
1414
sb.sleep(1.1)
1515
query = "How to start automating with SeleniumBase?"
1616
sb.press_keys(textarea, query)
1717
sb.sleep(1.1)
18+
seen_text = sb.get_text(textarea)
19+
if seen_text != query and seen_text in query:
20+
# When CAPTCHA appears while typing text
21+
sb.sleep(1.1)
22+
sb.solve_captcha()
23+
sb.sleep(2.2)
24+
sb.type(textarea, "")
25+
sb.press_keys(textarea, query)
26+
sb.sleep(0.5)
1827
sb.click('button[data-testid="submit-button"]')
1928
sb.sleep(2.5)
2029
sb.solve_captcha()

examples/cdp_mode/raw_hyatt.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
from seleniumbase import SB
22

3-
with SB(uc=True, test=True, locale="en", ad_block=True) as sb:
3+
with SB(uc=True, test=True, locale="en") as sb:
44
url = "https://www.hyatt.com/"
55
sb.activate_cdp_mode(url)
6-
sb.sleep(3.5)
6+
sb.sleep(3.8)
77
sb.click_if_visible('button[aria-label="Close"]')
88
sb.sleep(0.1)
99
sb.click_if_visible("#onetrust-reject-all-handler")

examples/cdp_mode/raw_pokemon.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
url = "https://www.pokemon.com/us"
55
sb.activate_cdp_mode(url)
66
sb.sleep(3.2)
7-
sb.click("button#onetrust-accept-btn-handler")
7+
sb.click_if_visible("button#onetrust-accept-btn-handler")
88
sb.sleep(1.2)
99
sb.click("a span.icon_pokeball")
1010
sb.sleep(2.5)

examples/cdp_mode/raw_timezone_sb.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""An example of changing settings during CDP Mode"""
22
from seleniumbase import SB
33

4-
with SB(uc=True, test=True, pls="eager") as sb:
4+
with SB(uc=True, test=True, pls="eager", ad_block=True) as sb:
55
url = "https://www.randymajors.org/what-time-zone-am-i-in"
66
sb.activate_cdp_mode(url, tzone="Asia/Kolkata", geoloc=(26.863, 80.94))
77
sb.remove_elements("#right-sidebar")

examples/cdp_mode/raw_united.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,25 +3,29 @@
33
with SB(uc=True, test=True, locale="en", ad_block=True) as sb:
44
url = "https://www.united.com/en/us"
55
sb.activate_cdp_mode(url)
6-
sb.sleep(2.5)
6+
sb.sleep(2.6)
77
origin_input = 'input[placeholder="Origin"]'
88
origin = "New York, NY"
99
destination_input = 'input[placeholder="Destination"]'
1010
destination = "Orlando, FL"
11-
sb.cdp.gui_click_element(origin_input)
11+
sb.click(origin_input)
1212
sb.sleep(0.5)
1313
sb.type(origin_input, origin)
1414
sb.sleep(1.2)
1515
sb.click('strong:contains("%s")' % origin)
16-
sb.sleep(1.2)
17-
sb.cdp.gui_click_element(destination_input)
16+
sb.sleep(0.6)
17+
sb.click_if_visible('button[class*="__close--"]')
18+
sb.sleep(0.6)
19+
sb.click(destination_input)
1820
sb.sleep(0.5)
1921
sb.type(destination_input, destination)
2022
sb.sleep(1.2)
2123
sb.click('strong:contains("%s")' % destination)
2224
sb.sleep(1.2)
2325
sb.click('button[aria-label="Find flights"]')
24-
sb.sleep(6)
26+
sb.sleep(4)
27+
sb.click_if_visible('button[class*="__close--"]')
28+
sb.sleep(2)
2529
flights = sb.find_elements('div[class*="CardContainer__block"]')
2630
print("**** Flights from %s to %s ****" % (origin, destination))
2731
print(" (" + sb.get_text("h2.atm-c-heading") + ")")

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ rich>=14.2.0,<15
9090

9191
coverage>=7.6.1;python_version<"3.9"
9292
coverage>=7.10.7;python_version>="3.9" and python_version<"3.10"
93-
coverage>=7.11.0;python_version>="3.10"
93+
coverage>=7.11.1;python_version>="3.10"
9494
pytest-cov>=5.0.0;python_version<"3.9"
9595
pytest-cov>=7.0.0;python_version>="3.9"
9696
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.44.7"
2+
__version__ = "4.44.8"

0 commit comments

Comments
 (0)