SeleniumBase/examples/raw_pyautogui.py

18 lines
726 B
Python
Raw Normal View History

2024-06-24 01:49:34 +08:00
import sys
from seleniumbase import SB
2024-08-03 06:46:50 +08:00
# An incomplete UserAgent forces CAPTCHA-solving on macOS
2024-06-24 01:49:34 +08:00
agent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) Chrome/126.0.0.0"
2024-08-01 02:39:43 +08:00
if "linux" in sys.platform or "win32" in sys.platform:
2024-06-24 01:49:34 +08:00
agent = None # Use the default UserAgent
with SB(uc=True, test=True, rtf=True, agent=agent) as sb:
2024-07-25 03:55:04 +08:00
url = "https://gitlab.com/users/sign_in"
2024-06-24 01:49:34 +08:00
sb.uc_open_with_reconnect(url, 4)
2024-08-03 06:46:50 +08:00
sb.uc_gui_handle_captcha() # Only if needed
2024-07-25 03:55:04 +08:00
sb.assert_element('label[for="user_login"]')
sb.assert_element('input[data-testid*="username"]')
sb.assert_element('input[data-testid*="password"]')
2024-06-24 01:49:34 +08:00
sb.set_messenger_theme(location="bottom_center")
sb.post_message("SeleniumBase wasn't detected!")