Skip to content

Commit

Permalink
Add more examples
Browse files Browse the repository at this point in the history
  • Loading branch information
mdmintz committed Jun 23, 2024
1 parent 57a52c3 commit 3e5a2c2
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 0 deletions.
15 changes: 15 additions & 0 deletions examples/raw_antibot_login.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
"""UC Mode has PyAutoGUI methods for CAPTCHA-bypass."""
from seleniumbase import SB

with SB(uc=True, test=True) as sb:
url = "https://seleniumbase.io/antibot/login"
sb.uc_open_with_disconnect(url, 2.15)
sb.uc_gui_write("\t" + "demo_user")
sb.uc_gui_write("\t" + "secret_pass")
sb.uc_gui_press_keys("\t" + " ") # For Single-char keys
sb.sleep(1.5)
sb.uc_gui_press_keys(["\t", "ENTER"]) # Multi-char keys
sb.reconnect(1.8)
sb.assert_text("Welcome!", "h1")
sb.set_messenger_theme(location="bottom_center")
sb.post_message("SeleniumBase wasn't detected!")
11 changes: 11 additions & 0 deletions examples/raw_block.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
"""If Brotector catches you, Gandalf blocks you!"""
from seleniumbase import SB

with SB(test=True) as sb:
url = "https://seleniumbase.io/hobbit/login"
sb.open(url)
sb.click_if_visible("button")
sb.assert_text("Gandalf blocked you!", "h1")
sb.click("img")
sb.highlight("h1")
sb.sleep(3) # Gandalf: "You Shall Not Pass!"
9 changes: 9 additions & 0 deletions examples/raw_brotector_captcha.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
"""UC Mode has PyAutoGUI methods for CAPTCHA-bypass."""
from seleniumbase import SB

with SB(uc=True, test=True) as sb:
url = "https://seleniumbase.io/apps/brotector"
sb.uc_open_with_disconnect(url, 2.2)
sb.uc_gui_press_key("\t")
sb.uc_gui_press_key(" ")
sb.reconnect(2.2)
12 changes: 12 additions & 0 deletions examples/raw_detection.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
"""The Brotector CAPTCHA in action."""
from seleniumbase import SB

with SB(test=True) as sb:
sb.open("https://seleniumbase.io/antibot/login")
sb.highlight("h4", loops=6)
sb.type("#username", "demo_user")
sb.type("#password", "secret_pass")
sb.click_if_visible("button span")
sb.highlight("label#pText")
sb.highlight("table#detections")
sb.sleep(4.4) # Add time to read the table
13 changes: 13 additions & 0 deletions examples/raw_hobbit.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
"""UC Mode has PyAutoGUI methods for CAPTCHA-bypass."""
from seleniumbase import SB

with SB(uc=True, test=True) as sb:
url = "https://seleniumbase.io/hobbit/login"
sb.uc_open_with_disconnect(url, 2.2)
sb.uc_gui_press_keys("\t ")
sb.reconnect(1.5)
sb.assert_text("Welcome to Middle Earth!", "h1")
sb.set_messenger_theme(location="bottom_center")
sb.post_message("SeleniumBase wasn't detected!")
sb.click("img")
sb.sleep(5.888) # Cool animation happening now!
19 changes: 19 additions & 0 deletions examples/raw_pyautogui.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
"""
UC Mode now has uc_gui_handle_cf(), which uses PyAutoGUI.
An incomplete UserAgent is used to force CAPTCHA-solving.
"""
import sys
from seleniumbase import SB

agent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) Chrome/126.0.0.0"
if "linux" in sys.platform:
agent = None # Use the default UserAgent

with SB(uc=True, test=True, rtf=True, agent=agent) as sb:
url = "https://www.virtualmanager.com/en/login"
sb.uc_open_with_reconnect(url, 4)
sb.uc_gui_handle_cf() # Ready if needed!
sb.assert_element('input[name*="email"]')
sb.assert_element('input[name*="login"]')
sb.set_messenger_theme(location="bottom_center")
sb.post_message("SeleniumBase wasn't detected!")

0 comments on commit 3e5a2c2

Please sign in to comment.