You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: help_docs/uc_mode.md
+18-16Lines changed: 18 additions & 16 deletions
Original file line number
Diff line number
Diff line change
@@ -45,7 +45,9 @@ with SB(uc=True) as sb:
45
45
sb.uc_open_with_reconnect(url, 4)
46
46
```
47
47
48
-
👤 Here's a longer example, which includes a special click if the CAPTCHA isn't bypassed on the initial page load:
48
+
(Note: If running UC Mode scripts on headless Linux machines, then you'll need to use the <b><codetranslate="no">SB</code></b> manager instead of the <b><codetranslate="no">Driver</code></b> manager because the <b><codetranslate="no">SB</code></b> manager includes a special virtual display that allows for <b><codetranslate="no">PyAutoGUI</code></b> actions.)
49
+
50
+
👤 Here's a longer example, which includes a special <b><codetranslate="no">PyAutoGUI</code></b> click if the CAPTCHA isn't bypassed on the initial page load:
If running on a Linux server, `uc_gui_handle_cf()` might not be good enough. Switch to `uc_gui_click_cf()` to be more stealthy. You can also use `uc_gui_click_captcha()` as a generic CAPTCHA-clicker, which auto-detects between CF Turnstile and Google reCAPTCHA.
84
+
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.
83
85
84
86
👤 Here's an example <b>where the CAPTCHA appears after submitting a form</b>:
85
87
@@ -118,7 +120,7 @@ with SB(uc=True, test=True, ad_block=True) as sb:
👤 <b>On Linux</b>, use `sb.uc_gui_click_cf()` to handle Cloudflare Turnstiles:
123
+
👤 <b>On Linux</b>, use `sb.uc_gui_click_captcha()` to handle CAPTCHAs (Cloudflare Turnstiles):
122
124
123
125
```python
124
126
from seleniumbase importSB
@@ -127,15 +129,15 @@ with SB(uc=True, test=True) as sb:
127
129
url ="https://www.virtualmanager.com/en/login"
128
130
sb.uc_open_with_reconnect(url, 4)
129
131
print(sb.get_page_title())
130
-
sb.uc_gui_click_cf() #Ready if needed!
132
+
sb.uc_gui_click_captcha() #Only if needed
131
133
print(sb.get_page_title())
132
134
sb.assert_element('input[name*="email"]')
133
135
sb.assert_element('input[name*="login"]')
134
136
sb.set_messenger_theme(location="bottom_center")
135
137
sb.post_message("SeleniumBase wasn't detected!")
136
138
```
137
139
138
-
<ahref="https://github.com/mdmintz/undetected-testing/actions/runs/9637461606/job/26576722411"><imgwidth="540"alt="uc_gui_click_cf on Linux"src="https://github.com/seleniumbase/SeleniumBase/assets/6788579/6aceb2a3-2a32-4521-b30a-f79446d2ce28"></a>
140
+
<ahref="https://github.com/mdmintz/undetected-testing/actions/runs/9637461606/job/26576722411"><imgwidth="540"alt="uc_gui_click_captcha on Linux"src="https://github.com/seleniumbase/SeleniumBase/assets/6788579/6aceb2a3-2a32-4521-b30a-f79446d2ce28"></a>
139
141
140
142
The 2nd `print()` should output "Virtual Manager", which means that the automation successfully passed the Turnstile.
(Note that while the special <b><codetranslate="no">UC Mode</code></b> breakpoint is active, you can't use <b><codetranslate="no">Selenium</code></b> commands in the browser, and the browser can't detect <b><codetranslate="no">Selenium</code></b>.)
235
237
236
-
👤 On Linux, you may need to use `driver.uc_gui_click_cf()` 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 `driver.uc_gui_click_cf()`. 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.
238
+
👤 On Linux, you may need to use `driver.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 `driver.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.
239
+
240
+
👤 `driver.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.
237
241
238
242
👤 `driver.uc_gui_click_cf(frame="iframe", retry=False, blind=False)` has three args. (All optional). The first one, `frame`, lets you specify 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`, 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.
239
243
240
244
👤 `driver.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.
241
245
242
-
👤 `driver.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.
243
-
244
246
👤 To find out if <btranslate="no">UC Mode</b> will work at all on a specific site (before adjusting for timing), load your site with the following script:
245
247
246
248
```python
@@ -334,11 +336,11 @@ The above JS method is used within the <b><code translate="no">SeleniumBase</cod
334
336
335
337
🛠️ <b>Troubleshooting UC Mode</b>
336
338
337
-
On Windows, the `uc_gui_click_cf()` and `uc_gui_click_captcha()`methods require "Scaling" to be set at "100%". (Note that "100%" may be different from the system's "Recommended" percent, which can be higher depending on your screen resolution and monitor size.)
339
+
On Windows, the `uc_gui_click_captcha()`method requires "Scaling" to be set at "100%". (Note that "100%" may be different from the system's "Recommended" percent, which can be higher depending on your screen resolution and monitor size.)
338
340
339
341
<imgsrc="https://seleniumbase.github.io/other/ts_uc_1.jpg"title="Make sure Scaling is set to 100%"width="410">
340
342
341
-
As an alternative to using the `uc_gui_click_cf()` or `uc_gui_click_captcha()`methods on Windows, you can use `sb.uc_gui_handle_cf()`, which does not require "Scaling" to be set to a specific value. Instead of using the mouse to click a CAPTCHA, `sb.uc_gui_handle_cf()` uses a combination of the `TAB` key and the `SPACEBAR`.
343
+
As an alternative to using the `uc_gui_click_captcha()`method on Windows, you can use `sb.uc_gui_handle_captcha()`, which does not require "Scaling" to be set to a specific value. Instead of using the mouse to click a CAPTCHA, `sb.uc_gui_handle_captcha()` uses a combination of the `TAB` key and the `SPACEBAR`.
0 commit comments