-
Notifications
You must be signed in to change notification settings - Fork 44
Expand file tree
/
Copy pathraw_cdp_drivers.py
More file actions
28 lines (27 loc) · 923 Bytes
/
Copy pathraw_cdp_drivers.py
File metadata and controls
28 lines (27 loc) · 923 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
# An example of switching between multiple drivers
from seleniumbase import SB
with SB(uc=True, test=True) as sb:
url1 = "https://seleniumbase.io/antibot/login"
sb.activate_cdp_mode(url1)
url2 = "https://seleniumbase.io/hobbit/login"
driver2 = sb.get_new_driver(undetectable=True)
sb.activate_cdp_mode(url2)
sb.sleep(1)
sb.switch_to_default_driver()
sb.assert_url_contains("antibot")
print(sb.get_current_url())
sb.type("input#username", "demo_user")
sb.type("input#password", "secret_pass")
sb.click("button")
sb.sleep(1)
sb.click("a#log-in")
sb.assert_text("Welcome!", "h1")
sb.sleep(2)
sb.switch_to_driver(driver2)
sb.assert_url_contains("hobbit")
print(sb.get_current_url())
sb.click("button")
sb.assert_text("Welcome to Middle Earth!")
sb.click("img")
sb.sleep(3)
sb.save_screenshot_to_logs()