Open
Description
There's a new UC Mode video showing how it works, and how it fixes bugs with undetected-chromedriver:
https://www.youtube.com/watch?v=5dMFI3e85ig
Note the improvements made:
- Driver version-detection & management.
- Allowing mismatched browser/driver versions.
- Automatically changing the user agent to prevent detection. (
HeadlessChrome
toChrome
) - Automatically disconnecting chromedriver from Chrome as needed. (And reconnecting)
- Multithreading tests in parallel via
pytest-xdist
. - Adjusting configuration based on the environment. (Linux/Ubuntu vs Windows vs macOS)
- Explaining how to set a custom
user-data-dir
correctly. - Has options for setting proxy and proxy-with-auth.
Many of these fixes can be back-ported easily to undetected-chromedriver. (Explanation in the video of how to do that, such as using requests.get(url)
before navigating to a URL to know if you need to disconnect/reconnect the driver from Chrome.)
Here's a script with retries and a captcha-click failsafe for bypassing detection:
from seleniumbase import SB
with SB(uc=True) as sb:
sb.driver.get("https://nowsecure.nl/#relax")
sb.sleep(1)
if not sb.is_text_visible("OH YEAH, you passed!", "h1"):
sb.get_new_driver(undetectable=True)
sb.driver.get("https://nowsecure.nl/#relax")
sb.sleep(1)
if not sb.is_text_visible("OH YEAH, you passed!", "h1"):
if sb.is_element_visible('iframe[src*="challenge"]'):
with sb.frame_switch('iframe[src*="challenge"]'):
sb.click("span.mark")
sb.sleep(2)
sb.activate_demo_mode()
sb.assert_text("OH YEAH, you passed!", "h1", timeout=3)
The presentation slides were autogenerated by running: https://github.com/seleniumbase/SeleniumBase/blob/master/examples/presenter/uc_presentation.py