diff --git a/help_docs/uc_mode.md b/help_docs/uc_mode.md index 2cb24a48..706178df 100644 --- a/help_docs/uc_mode.md +++ b/help_docs/uc_mode.md @@ -35,6 +35,7 @@ from seleniumbase import Driver driver = Driver(uc=True) url = "https://gitlab.com/users/sign_in" driver.uc_open_with_reconnect(url, 4) +driver.uc_gui_click_captcha() driver.quit() ``` @@ -48,11 +49,12 @@ from seleniumbase import SB with SB(uc=True) as sb: url = "https://gitlab.com/users/sign_in" sb.uc_open_with_reconnect(url, 4) + sb.uc_gui_click_captcha() ``` (Note: If running UC Mode scripts on headless Linux machines, then you'll need to use the SB manager instead of the Driver manager because the SB manager includes a special virtual display that allows for PyAutoGUI actions.) -👤 Here's a longer example, which includes a special PyAutoGUI click if the CAPTCHA isn't bypassed on the initial page load: +👤 Here's a longer example: (Note that sb.uc_gui_click_captcha() performs a special click using PyAutoGUI if a CAPTCHA is detected.) ```python from seleniumbase import SB @@ -88,7 +90,7 @@ with SB(uc=True, test=True) as sb: If running on a Linux server, `uc_gui_handle_captcha()` might not be good enough. Switch to `uc_gui_click_captcha()` to be more stealthy. Note that these methods auto-detect between CF Turnstile and Google reCAPTCHA. -Sometimes you need to add `incognito=True` with `uc=True` to maximize your anti-detection abilities. (Some websites can detect you if you don't do that.) +Sometimes you need to add incognito=True with uc=True to maximize your anti-detection abilities. (Some websites can detect you if you don't do that.) 👤 Here's an example where the CAPTCHA appears after submitting a form: @@ -136,7 +138,7 @@ with SB(uc=True, test=True) as sb: url = "https://www.virtualmanager.com/en/login" sb.uc_open_with_reconnect(url, 4) print(sb.get_page_title()) - sb.uc_gui_click_captcha() # Only if needed + sb.uc_gui_click_captcha() # Only used if needed print(sb.get_page_title()) sb.assert_element('input[name*="email"]') sb.assert_element('input[name*="login"]') @@ -146,7 +148,7 @@ with SB(uc=True, test=True) as sb: uc_gui_click_captcha on Linux -The 2nd `print()` should output "Virtual Manager", which means that the automation successfully passed the Turnstile. +The 2nd print() should output Virtual Manager, which means that the automation successfully passed the Turnstile. -------- @@ -191,7 +193,7 @@ with SB(uc=True, incognito=True, test=True) as sb: -------- -### 👤 Here are the driver-specific methods added by SeleniumBase for UC Mode: `--uc` / uc=True +### 👤 Here are the SeleniumBase UC Mode methods: (`--uc` / **`uc=True`**) ```python driver.uc_open(url) @@ -263,13 +265,13 @@ driver.reconnect("breakpoint") -------- -👤 On Linux, you may need to use `uc_gui_click_captcha()` to successfully bypass a Cloudflare CAPTCHA. If there's more than one Cloudflare iframe on that website, then put the CSS Selector of an element that's above the iframe as the first arg to `uc_gui_click_captcha()`. This method uses `pyautogui`. In order for `pyautogui` to focus on the correct element, use `xvfb=True` / `--xvfb` to activate a special virtual display on Linux. +👤 On Linux, you may need to use uc_gui_click_captcha() to successfully bypass a CAPTCHA. If there's more than one CAPTCHA on a website, then put the CSS Selector of an element that's above the CAPTCHA as the first arg to uc_gui_click_captcha(). This method uses pyautogui. In order for pyautogui to focus on the correct element, use xvfb=True / --xvfb to activate a special virtual display on Linux. -👤 `uc_gui_click_captcha()` auto-detects the CAPTCHA type before trying to click it. This is a generic method for both CF Turnstile and Google reCAPTCHA. It will use the code from `uc_gui_click_cf()` and `uc_gui_click_rc()` as needed. +👤 uc_gui_click_captcha() auto-detects the CAPTCHA type before trying to click it. This is a generic method for both CF Turnstile and Google reCAPTCHA. It will use the code from uc_gui_click_cf() and uc_gui_click_rc() as needed. -👤 `uc_gui_click_cf(frame="iframe", retry=False, blind=False)` has three args. (All optional). The first one, `frame`, lets you specify the selector above the iframe in case the CAPTCHA is not located in the first iframe on the page. The second one, `retry`, lets you retry the click after reloading the page if the first one didn't work (and a CAPTCHA is still present after the page reload). The third arg, `blind`, (if `True`), will retry after a page reload (if the first click failed) by clicking at the last known coordinates of the CAPTCHA checkbox without confirming first with Selenium that a CAPTCHA is still on the page. +👤 uc_gui_click_cf(frame="iframe", retry=False, blind=False) has three args. (All optional). The first one, frame, lets you specify the selector above the iframe in case the CAPTCHA is not located in the first iframe on the page. (In the case of Shadow-DOM, specify the selector of an element that's above the Shadow-DOM.) The second one, retry, lets you retry the click after reloading the page if the first one didn't work (and a CAPTCHA is still present after the page reload). The third arg, blind, (if True), will retry after a page reload (if the first click failed) by clicking at the last known coordinates of the CAPTCHA checkbox without confirming first with Selenium that a CAPTCHA is still on the page. -👤 `uc_gui_click_rc(frame="iframe", retry=False, blind=False)` is for reCAPTCHA. This may only work a few times before not working anymore... not because Selenium was detected, but because reCAPTCHA uses advanced AI to detect unusual activity, unlike the CF Turnstile, which only uses basic detection. +👤 uc_gui_click_rc(frame="iframe", retry=False, blind=False) is for reCAPTCHA. This may only work a few times before not working anymore... not because Selenium was detected, but because reCAPTCHA uses advanced AI to detect unusual activity, unlike the CF Turnstile, which only uses basic detection. -------- @@ -288,7 +290,7 @@ with SB(uc=True) as sb: 👤 Multithreaded UC Mode: -If you're using pytest for multithreaded UC Mode (which requires using one of the pytest [syntax formats](https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/syntax_formats.md)), then all you have to do is set the number of threads when your script runs. (`-n NUM`) Eg: +If you're using pytest for multithreaded UC Mode (which requires using one of the pytest [syntax formats](https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/syntax_formats.md)), then all you have to do is set the number of threads when your script runs. (-n NUM) Eg: ```bash pytest --uc -n 4