Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions examples/cdp_mode/ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ with SB(uc=True, test=True, locale_code="en", ad_block=True) as sb:
url = "https://www.bestwestern.com/en_US.html"
sb.activate_cdp_mode(url)
sb.sleep(2.5)
sb.cdp.click_if_visible("div.onetrust-close-btn-handler")
sb.cdp.click_if_visible(".onetrust-close-btn-handler")
sb.sleep(1)
sb.cdp.click("input#destination-input")
sb.sleep(2)
Expand All @@ -250,7 +250,9 @@ with SB(uc=True, test=True, locale_code="en", ad_block=True) as sb:
sb.sleep(2.5)
print("Best Western Hotels in %s:" % location)
summary_details = sb.cdp.get_text("#summary-details-column")
dates = summary_details.split("ROOM")[0].split("DATES")[-1].strip()
dates = summary_details.split("DESTINATION")[-1]
dates = dates.split(" CHECK-OUT")[0].strip() + " CHECK-OUT"
dates = dates.replace(" ", " ")
print("(Dates: %s)" % dates)
flip_cards = sb.cdp.select_all(".flipCard")
for i, flip_card in enumerate(flip_cards):
Expand Down
6 changes: 4 additions & 2 deletions examples/cdp_mode/raw_bestwestern.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
url = "https://www.bestwestern.com/en_US.html"
sb.activate_cdp_mode(url)
sb.sleep(2.5)
sb.cdp.click_if_visible("div.onetrust-close-btn-handler")
sb.cdp.click_if_visible(".onetrust-close-btn-handler")
sb.sleep(1)
sb.cdp.click("input#destination-input")
sb.sleep(2)
Expand All @@ -19,7 +19,9 @@
sb.sleep(2.5)
print("Best Western Hotels in %s:" % location)
summary_details = sb.cdp.get_text("#summary-details-column")
dates = summary_details.split("ROOM")[0].split("DATES")[-1].strip()
dates = summary_details.split("DESTINATION")[-1]
dates = dates.split(" CHECK-OUT")[0].strip() + " CHECK-OUT"
dates = dates.replace(" ", " ")
print("(Dates: %s)" % dates)
flip_cards = sb.cdp.select_all(".flipCard")
for i, flip_card in enumerate(flip_cards):
Expand Down
17 changes: 11 additions & 6 deletions examples/presenter/uc_presentation_4.py
Original file line number Diff line number Diff line change
Expand Up @@ -516,17 +516,19 @@ def test_presentation_4(self):
)
self.begin_presentation(filename="uc_presentation.html")

with SB(uc=True, test=True, locale_code="en", ad_block=True) as sb:
with SB(uc=True, test=True, ad_block=True) as sb:
url = "https://www.walmart.com/"
sb.activate_cdp_mode(url)
sb.sleep(2.5)
sb.cdp.click_if_visible('[data-automation-id*="close-mark"]')
sb.cdp.mouse_click('input[aria-label="Search"]')
sb.sleep(1.2)
search = "Settlers of Catan Board Game"
required_text = "Catan"
sb.cdp.press_keys('input[aria-label="Search"]', search + "\n")
sb.sleep(3.8)
print('\n\n*** Walmart Search for "%s":' % search)
sb.cdp.remove_elements('[data-testid="skyline-ad"]')
print('*** Walmart Search for "%s":' % search)
print(' (Results must contain "%s".)' % required_text)
unique_item_text = []
items = sb.cdp.find_elements('div[data-testid="list-view"]')
Expand Down Expand Up @@ -642,7 +644,7 @@ def test_presentation_4(self):
sb.cdp.click('button[data-testid="submit"]')
sb.sleep(3.5)
sb.connect()
sb.sleep(2.5)
sb.sleep(4.2)
for window in sb.driver.window_handles:
sb.switch_to_window(window)
if "/buy/flights" in sb.get_current_url():
Expand Down Expand Up @@ -708,6 +710,7 @@ def test_presentation_4(self):
if "Avg/Night" in info and not info.startswith("Rates from"):
name = info.split(" (")[0]
name = name.split(" + ")[0].split(" Award Cat")[0]
name = name.split(" Rates from :")[0]
price = "?"
if "Rates from : " in info:
price = info.split("Rates from : ")[1]
Expand All @@ -728,7 +731,7 @@ def test_presentation_4(self):
url = "https://www.bestwestern.com/en_US.html"
sb.activate_cdp_mode(url)
sb.sleep(2.5)
sb.cdp.click_if_visible("div.onetrust-close-btn-handler")
sb.cdp.click_if_visible(".onetrust-close-btn-handler")
sb.sleep(1)
sb.cdp.click("input#destination-input")
sb.sleep(2)
Expand All @@ -741,9 +744,11 @@ def test_presentation_4(self):
sb.sleep(4)
sb.cdp.click("label#available-label")
sb.sleep(2.5)
print("\n\nBest Western Hotels in %s:" % location)
print("Best Western Hotels in %s:" % location)
summary_details = sb.cdp.get_text("#summary-details-column")
dates = summary_details.split("ROOM")[0].split("DATES")[-1].strip()
dates = summary_details.split("DESTINATION")[-1]
dates = dates.split(" CHECK-OUT")[0].strip() + " CHECK-OUT"
dates = dates.replace(" ", " ")
print("(Dates: %s)" % dates)
flip_cards = sb.cdp.select_all(".flipCard")
for i, flip_card in enumerate(flip_cards):
Expand Down
2 changes: 1 addition & 1 deletion seleniumbase/__version__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# seleniumbase package
__version__ = "4.33.13"
__version__ = "4.33.14"
3 changes: 3 additions & 0 deletions seleniumbase/core/browser_launcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -1544,6 +1544,9 @@ def _uc_gui_handle_captcha_(driver, frame="iframe", ctype=None):
for i in range(10):
pyautogui.hotkey("shift", "tab")
time.sleep(0.027)
if ctype == "g_rc":
if js_utils.get_active_element_css(driver) == "body":
break
tab_count = 0
for i in range(34):
pyautogui.press("\t")
Expand Down
8 changes: 4 additions & 4 deletions seleniumbase/undetected/patcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def is_binary_patched(self, executable_path=None):
with io.open(executable_path, "rb") as fh:
if re.search(
b"window.cdc_adoQpoasnfa76pfcZLmcfl_"
b"(Array|Promise|Symbol|Object|Proxy|JSON)",
b"(Array|Promise|Symbol|Object|Proxy|JSON|Window)",
fh.read()
):
return False
Expand All @@ -210,14 +210,14 @@ def gen_call_function_js_cache_name(match):
file_bin = fh.read()
file_bin = re.sub(
b"window\\.cdc_[a-zA-Z0-9]{22}_"
b"(Array|Promise|Symbol|Object|Proxy|JSON)"
b" = window\\.(Array|Promise|Symbol|Object|Proxy|JSON);",
b"(Array|Promise|Symbol|Object|Proxy|JSON|Window) "
b"= window\\.(Array|Promise|Symbol|Object|Proxy|JSON|Window);",
gen_js_whitespaces,
file_bin,
)
file_bin = re.sub(
b"window\\.cdc_[a-zA-Z0-9]{22}_"
b"(Array|Promise|Symbol|Object|Proxy|JSON) \\|\\|",
b"(Array|Promise|Symbol|Object|Proxy|JSON|Window) \\|\\|",
gen_js_whitespaces,
file_bin,
)
Expand Down
Loading