Skip to content

Commit

Permalink
Update examples
Browse files Browse the repository at this point in the history
  • Loading branch information
mdmintz committed Apr 26, 2024
1 parent e214132 commit cd3f13f
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 3 deletions.
3 changes: 2 additions & 1 deletion examples/raw_cdp_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@

driver = Driver(uc=True, log_cdp=True)
try:
driver.uc_open_with_reconnect("https://seleniumbase.io/apps/turnstile")
url = "seleniumbase.io/apps/turnstile"
driver.uc_open_with_reconnect(url, 2)
driver.switch_to_frame("iframe")
driver.uc_click("span.mark")
driver.sleep(3)
Expand Down
19 changes: 19 additions & 0 deletions examples/raw_cookies.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
"""A SeleniumBase test that loads cookies to bypass login."""
from seleniumbase import SB

# Log in to Swag Labs and save cookies
with SB(test=True) as sb:
sb.open("https://www.saucedemo.com")
sb.wait_for_element("div.login_logo")
sb.type("#user-name", "standard_user")
sb.type("#password", "secret_sauce")
sb.click('input[type="submit"]')
sb.highlight("div.inventory_list", loops=6)
sb.save_cookies(name="cookies.txt")

# Load previously saved cookies to bypass login
with SB(test=True) as sb:
sb.open("https://www.saucedemo.com")
sb.load_cookies(name="cookies.txt")
sb.open("https://www.saucedemo.com/inventory.html")
sb.highlight("div.inventory_list", loops=12)
2 changes: 1 addition & 1 deletion examples/test_geolocation.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ def test_geolocation(self):
self.assert_url_contains("48.87645/2.26340")
self.save_screenshot_to_logs()
if self.headed:
self.sleep(2.5)
self.sleep(4)
3 changes: 2 additions & 1 deletion examples/uc_cdp_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ def click_turnstile_and_verify(sb):
def test_display_cdp_events(self):
if not (self.undetectable and self.uc_cdp_events):
self.get_new_driver(undetectable=True, uc_cdp_events=True)
self.driver.uc_open_with_reconnect("seleniumbase.io/apps/turnstile")
url = "seleniumbase.io/apps/turnstile"
self.driver.uc_open_with_reconnect(url, 2)
self.add_cdp_listener()
self.click_turnstile_and_verify()
self.sleep(1)
Expand Down

0 comments on commit cd3f13f

Please sign in to comment.