-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Expand file tree
/
Copy pathraw_uc_events.py
More file actions
29 lines (23 loc) · 942 Bytes
/
Copy pathraw_uc_events.py
File metadata and controls
29 lines (23 loc) · 942 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
"""NOTE: This uses plain UC Mode, which was replaced by UC + CDP Mode.
PyAutoGUI is installed automatically for uc_gui methods if not already."""
from rich.pretty import pprint
from seleniumbase import SB
def add_cdp_listener(sb):
# (To print everything, use "*". Otherwise select specific headers.)
# self.driver.add_cdp_listener("*", lambda data: print(pformat(data)))
sb.driver.add_cdp_listener(
"Network.requestWillBeSentExtraInfo",
lambda data: pprint(data)
)
def click_turnstile_and_verify(sb):
sb.uc_gui_handle_captcha()
sb.assert_element("img#captcha-success", timeout=3)
sb.highlight("img#captcha-success", loops=8)
with SB(uc_cdp_events=True, test=True) as sb:
url = "seleniumbase.io/apps/turnstile"
sb.uc_open_with_reconnect(url, 2)
add_cdp_listener(sb)
click_turnstile_and_verify(sb)
sb.sleep(1)
sb.refresh()
sb.sleep(1.2)

