Skip to content

Commit b6d617e

Browse files
authored
Merge pull request #3407 from seleniumbase/cdp-mode-patch-24
CDP Mode - Patch 24
2 parents 5911c5d + 81afcb9 commit b6d617e

File tree

6 files changed

+27
-15
lines changed

6 files changed

+27
-15
lines changed

examples/cdp_mode/ReadMe.md

+4-2
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ with SB(uc=True, test=True, locale_code="en", ad_block=True) as sb:
235235
url = "https://www.bestwestern.com/en_US.html"
236236
sb.activate_cdp_mode(url)
237237
sb.sleep(2.5)
238-
sb.cdp.click_if_visible("div.onetrust-close-btn-handler")
238+
sb.cdp.click_if_visible(".onetrust-close-btn-handler")
239239
sb.sleep(1)
240240
sb.cdp.click("input#destination-input")
241241
sb.sleep(2)
@@ -250,7 +250,9 @@ with SB(uc=True, test=True, locale_code="en", ad_block=True) as sb:
250250
sb.sleep(2.5)
251251
print("Best Western Hotels in %s:" % location)
252252
summary_details = sb.cdp.get_text("#summary-details-column")
253-
dates = summary_details.split("ROOM")[0].split("DATES")[-1].strip()
253+
dates = summary_details.split("DESTINATION")[-1]
254+
dates = dates.split(" CHECK-OUT")[0].strip() + " CHECK-OUT"
255+
dates = dates.replace(" ", " ")
254256
print("(Dates: %s)" % dates)
255257
flip_cards = sb.cdp.select_all(".flipCard")
256258
for i, flip_card in enumerate(flip_cards):

examples/cdp_mode/raw_bestwestern.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
url = "https://www.bestwestern.com/en_US.html"
55
sb.activate_cdp_mode(url)
66
sb.sleep(2.5)
7-
sb.cdp.click_if_visible("div.onetrust-close-btn-handler")
7+
sb.cdp.click_if_visible(".onetrust-close-btn-handler")
88
sb.sleep(1)
99
sb.cdp.click("input#destination-input")
1010
sb.sleep(2)
@@ -19,7 +19,9 @@
1919
sb.sleep(2.5)
2020
print("Best Western Hotels in %s:" % location)
2121
summary_details = sb.cdp.get_text("#summary-details-column")
22-
dates = summary_details.split("ROOM")[0].split("DATES")[-1].strip()
22+
dates = summary_details.split("DESTINATION")[-1]
23+
dates = dates.split(" CHECK-OUT")[0].strip() + " CHECK-OUT"
24+
dates = dates.replace(" ", " ")
2325
print("(Dates: %s)" % dates)
2426
flip_cards = sb.cdp.select_all(".flipCard")
2527
for i, flip_card in enumerate(flip_cards):

examples/presenter/uc_presentation_4.py

+11-6
Original file line numberDiff line numberDiff line change
@@ -516,17 +516,19 @@ def test_presentation_4(self):
516516
)
517517
self.begin_presentation(filename="uc_presentation.html")
518518

519-
with SB(uc=True, test=True, locale_code="en", ad_block=True) as sb:
519+
with SB(uc=True, test=True, ad_block=True) as sb:
520520
url = "https://www.walmart.com/"
521521
sb.activate_cdp_mode(url)
522522
sb.sleep(2.5)
523+
sb.cdp.click_if_visible('[data-automation-id*="close-mark"]')
523524
sb.cdp.mouse_click('input[aria-label="Search"]')
524525
sb.sleep(1.2)
525526
search = "Settlers of Catan Board Game"
526527
required_text = "Catan"
527528
sb.cdp.press_keys('input[aria-label="Search"]', search + "\n")
528529
sb.sleep(3.8)
529-
print('\n\n*** Walmart Search for "%s":' % search)
530+
sb.cdp.remove_elements('[data-testid="skyline-ad"]')
531+
print('*** Walmart Search for "%s":' % search)
530532
print(' (Results must contain "%s".)' % required_text)
531533
unique_item_text = []
532534
items = sb.cdp.find_elements('div[data-testid="list-view"]')
@@ -642,7 +644,7 @@ def test_presentation_4(self):
642644
sb.cdp.click('button[data-testid="submit"]')
643645
sb.sleep(3.5)
644646
sb.connect()
645-
sb.sleep(2.5)
647+
sb.sleep(4.2)
646648
for window in sb.driver.window_handles:
647649
sb.switch_to_window(window)
648650
if "/buy/flights" in sb.get_current_url():
@@ -708,6 +710,7 @@ def test_presentation_4(self):
708710
if "Avg/Night" in info and not info.startswith("Rates from"):
709711
name = info.split(" (")[0]
710712
name = name.split(" + ")[0].split(" Award Cat")[0]
713+
name = name.split(" Rates from :")[0]
711714
price = "?"
712715
if "Rates from : " in info:
713716
price = info.split("Rates from : ")[1]
@@ -728,7 +731,7 @@ def test_presentation_4(self):
728731
url = "https://www.bestwestern.com/en_US.html"
729732
sb.activate_cdp_mode(url)
730733
sb.sleep(2.5)
731-
sb.cdp.click_if_visible("div.onetrust-close-btn-handler")
734+
sb.cdp.click_if_visible(".onetrust-close-btn-handler")
732735
sb.sleep(1)
733736
sb.cdp.click("input#destination-input")
734737
sb.sleep(2)
@@ -741,9 +744,11 @@ def test_presentation_4(self):
741744
sb.sleep(4)
742745
sb.cdp.click("label#available-label")
743746
sb.sleep(2.5)
744-
print("\n\nBest Western Hotels in %s:" % location)
747+
print("Best Western Hotels in %s:" % location)
745748
summary_details = sb.cdp.get_text("#summary-details-column")
746-
dates = summary_details.split("ROOM")[0].split("DATES")[-1].strip()
749+
dates = summary_details.split("DESTINATION")[-1]
750+
dates = dates.split(" CHECK-OUT")[0].strip() + " CHECK-OUT"
751+
dates = dates.replace(" ", " ")
747752
print("(Dates: %s)" % dates)
748753
flip_cards = sb.cdp.select_all(".flipCard")
749754
for i, flip_card in enumerate(flip_cards):

seleniumbase/__version__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# seleniumbase package
2-
__version__ = "4.33.13"
2+
__version__ = "4.33.14"

seleniumbase/core/browser_launcher.py

+3
Original file line numberDiff line numberDiff line change
@@ -1544,6 +1544,9 @@ def _uc_gui_handle_captcha_(driver, frame="iframe", ctype=None):
15441544
for i in range(10):
15451545
pyautogui.hotkey("shift", "tab")
15461546
time.sleep(0.027)
1547+
if ctype == "g_rc":
1548+
if js_utils.get_active_element_css(driver) == "body":
1549+
break
15471550
tab_count = 0
15481551
for i in range(34):
15491552
pyautogui.press("\t")

seleniumbase/undetected/patcher.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ def is_binary_patched(self, executable_path=None):
187187
with io.open(executable_path, "rb") as fh:
188188
if re.search(
189189
b"window.cdc_adoQpoasnfa76pfcZLmcfl_"
190-
b"(Array|Promise|Symbol|Object|Proxy|JSON)",
190+
b"(Array|Promise|Symbol|Object|Proxy|JSON|Window)",
191191
fh.read()
192192
):
193193
return False
@@ -210,14 +210,14 @@ def gen_call_function_js_cache_name(match):
210210
file_bin = fh.read()
211211
file_bin = re.sub(
212212
b"window\\.cdc_[a-zA-Z0-9]{22}_"
213-
b"(Array|Promise|Symbol|Object|Proxy|JSON)"
214-
b" = window\\.(Array|Promise|Symbol|Object|Proxy|JSON);",
213+
b"(Array|Promise|Symbol|Object|Proxy|JSON|Window) "
214+
b"= window\\.(Array|Promise|Symbol|Object|Proxy|JSON|Window);",
215215
gen_js_whitespaces,
216216
file_bin,
217217
)
218218
file_bin = re.sub(
219219
b"window\\.cdc_[a-zA-Z0-9]{22}_"
220-
b"(Array|Promise|Symbol|Object|Proxy|JSON) \\|\\|",
220+
b"(Array|Promise|Symbol|Object|Proxy|JSON|Window) \\|\\|",
221221
gen_js_whitespaces,
222222
file_bin,
223223
)

0 commit comments

Comments
 (0)