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
+12-10Lines changed: 12 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -35,6 +35,7 @@ from seleniumbase import Driver
35
35
driver = Driver(uc=True)
36
36
url ="https://gitlab.com/users/sign_in"
37
37
driver.uc_open_with_reconnect(url, 4)
38
+
driver.uc_gui_click_captcha()
38
39
driver.quit()
39
40
```
40
41
@@ -48,11 +49,12 @@ from seleniumbase import SB
48
49
with SB(uc=True) as sb:
49
50
url ="https://gitlab.com/users/sign_in"
50
51
sb.uc_open_with_reconnect(url, 4)
52
+
sb.uc_gui_click_captcha()
51
53
```
52
54
53
55
(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.)
54
56
55
-
👤 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:
57
+
👤 Here's a longer example: (Note that <codetranslate="no">sb.uc_gui_click_captcha()</code> performs a special click using <b><codetranslate="no">PyAutoGUI</code></b> if a CAPTCHA is detected.)
56
58
57
59
```python
58
60
from seleniumbase importSB
@@ -88,7 +90,7 @@ with SB(uc=True, test=True) as sb:
88
90
89
91
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.
90
92
91
-
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.)
93
+
Sometimes you need to add <codetranslate="no">incognito=True</code> with <codetranslate="no">uc=True</code> to maximize your anti-detection abilities. (Some websites can detect you if you don't do that.)
92
94
93
95
👤 Here's an example <b>where the CAPTCHA appears after submitting a form</b>:
94
96
@@ -136,7 +138,7 @@ with SB(uc=True, test=True) as sb:
136
138
url ="https://www.virtualmanager.com/en/login"
137
139
sb.uc_open_with_reconnect(url, 4)
138
140
print(sb.get_page_title())
139
-
sb.uc_gui_click_captcha() # Only if needed
141
+
sb.uc_gui_click_captcha() # Only used if needed
140
142
print(sb.get_page_title())
141
143
sb.assert_element('input[name*="email"]')
142
144
sb.assert_element('input[name*="login"]')
@@ -146,7 +148,7 @@ with SB(uc=True, test=True) as sb:
146
148
147
149
<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>
148
150
149
-
The 2nd `print()` should output "Virtual Manager", which means that the automation successfully passed the Turnstile.
151
+
The 2nd <codetranslate="no">print()</code> should output <codetranslate="no">Virtual Manager</code>, which means that the automation successfully passed the Turnstile.
150
152
151
153
--------
152
154
@@ -191,7 +193,7 @@ with SB(uc=True, incognito=True, test=True) as sb:
191
193
192
194
--------
193
195
194
-
### 👤 Here are the <b><codetranslate="no">driver</code></b>-specific methods added by SeleniumBase for UC Mode: `--uc` / <b><codetranslate="no">uc=True</code></b>
196
+
### 👤 Here are the SeleniumBase UC Mode methods: (`--uc` / **`uc=True`**)
👤 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.
268
+
👤 On Linux, you may need to use <codetranslate="no">uc_gui_click_captcha()</code> 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 <codetranslate="no">uc_gui_click_captcha()</code>. This method uses <codetranslate="no">pyautogui</code>. In order for <codetranslate="no">pyautogui</code> to focus on the correct element, use <codetranslate="no">xvfb=True</code> / <codetranslate="no">--xvfb</code> to activate a special virtual display on Linux.
267
269
268
-
👤 `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.
270
+
👤 <codetranslate="no">uc_gui_click_captcha()</code> 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 <codetranslate="no">uc_gui_click_cf()</code> and <codetranslate="no">uc_gui_click_rc()</code> as needed.
269
271
270
-
👤 `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.
272
+
👤 <codetranslate="no">uc_gui_click_cf(frame="iframe", retry=False, blind=False)</code> has three args. (All optional). The first one, <codetranslate="no">frame</code>, lets you specify the selector above the <codetranslate="no">iframe</code> in case the CAPTCHA is not located in the first <codetranslate="no">iframe</code> on the page. (In the case of Shadow-DOM, specify the selector of an element that's above the Shadow-DOM.) The second one, <codetranslate="no">retry</code>, 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, <codetranslate="no">blind</code>, (if <codetranslate="no">True</code>), 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.
271
273
272
-
👤 `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.
274
+
👤 <codetranslate="no">uc_gui_click_rc(frame="iframe", retry=False, blind=False)</code> 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.
273
275
274
276
--------
275
277
@@ -288,7 +290,7 @@ with SB(uc=True) as sb:
288
290
289
291
👤 <b>Multithreaded UC Mode:</b>
290
292
291
-
If you're using <b><codetranslate="no">pytest</code></b> for multithreaded <btranslate="no">UC Mode</b> (which requires using one of the <b><codetranslate="no">pytest</code></b> [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:
293
+
If you're using <b><codetranslate="no">pytest</code></b> for multithreaded <btranslate="no">UC Mode</b> (which requires using one of the <b><codetranslate="no">pytest</code></b> [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. (<codetranslate="no">-n NUM</code>) Eg:
0 commit comments