Skip to content

Commit 4c455c4

Browse files
committed
Update the UC Mode docs
1 parent 4c745d2 commit 4c455c4

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

help_docs/uc_mode.md

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ from seleniumbase import Driver
3535
driver = Driver(uc=True)
3636
url = "https://gitlab.com/users/sign_in"
3737
driver.uc_open_with_reconnect(url, 4)
38+
driver.uc_gui_click_captcha()
3839
driver.quit()
3940
```
4041

@@ -48,11 +49,12 @@ from seleniumbase import SB
4849
with SB(uc=True) as sb:
4950
url = "https://gitlab.com/users/sign_in"
5051
sb.uc_open_with_reconnect(url, 4)
52+
sb.uc_gui_click_captcha()
5153
```
5254

5355
(Note: If running UC Mode scripts on headless Linux machines, then you'll need to use the <b><code translate="no">SB</code></b> manager instead of the <b><code translate="no">Driver</code></b> manager because the <b><code translate="no">SB</code></b> manager includes a special virtual display that allows for <b><code translate="no">PyAutoGUI</code></b> actions.)
5456

55-
👤 Here's a longer example, which includes a special <b><code translate="no">PyAutoGUI</code></b> click if the CAPTCHA isn't bypassed on the initial page load:
57+
👤 Here's a longer example: (Note that <code translate="no">sb.uc_gui_click_captcha()</code> performs a special click using <b><code translate="no">PyAutoGUI</code></b> if a CAPTCHA is detected.)
5658

5759
```python
5860
from seleniumbase import SB
@@ -88,7 +90,7 @@ with SB(uc=True, test=True) as sb:
8890

8991
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.
9092

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 <code translate="no">incognito=True</code> with <code translate="no">uc=True</code> to maximize your anti-detection abilities. (Some websites can detect you if you don't do that.)
9294

9395
👤 Here's an example <b>where the CAPTCHA appears after submitting a form</b>:
9496

@@ -136,7 +138,7 @@ with SB(uc=True, test=True) as sb:
136138
url = "https://www.virtualmanager.com/en/login"
137139
sb.uc_open_with_reconnect(url, 4)
138140
print(sb.get_page_title())
139-
sb.uc_gui_click_captcha() # Only if needed
141+
sb.uc_gui_click_captcha() # Only used if needed
140142
print(sb.get_page_title())
141143
sb.assert_element('input[name*="email"]')
142144
sb.assert_element('input[name*="login"]')
@@ -146,7 +148,7 @@ with SB(uc=True, test=True) as sb:
146148

147149
<a href="https://github.com/mdmintz/undetected-testing/actions/runs/9637461606/job/26576722411"><img width="540" alt="uc_gui_click_captcha on Linux" src="https://github.com/seleniumbase/SeleniumBase/assets/6788579/6aceb2a3-2a32-4521-b30a-f79446d2ce28"></a>
148150

149-
The 2nd `print()` should output "Virtual Manager", which means that the automation successfully passed the Turnstile.
151+
The 2nd <code translate="no">print()</code> should output <code translate="no">Virtual Manager</code>, which means that the automation successfully passed the Turnstile.
150152

151153
--------
152154

@@ -191,7 +193,7 @@ with SB(uc=True, incognito=True, test=True) as sb:
191193

192194
--------
193195

194-
### 👤 Here are the <b><code translate="no">driver</code></b>-specific methods added by SeleniumBase for UC Mode: `--uc` / <b><code translate="no">uc=True</code></b>
196+
### 👤 Here are the SeleniumBase UC Mode methods: (`--uc` / **`uc=True`**)
195197

196198
```python
197199
driver.uc_open(url)
@@ -263,13 +265,13 @@ driver.reconnect("breakpoint")
263265

264266
--------
265267

266-
👤 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 <code translate="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 <code translate="no">uc_gui_click_captcha()</code>. This method uses <code translate="no">pyautogui</code>. In order for <code translate="no">pyautogui</code> to focus on the correct element, use <code translate="no">xvfb=True</code> / <code translate="no">--xvfb</code> to activate a special virtual display on Linux.
267269

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+
👤 <code translate="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 <code translate="no">uc_gui_click_cf()</code> and <code translate="no">uc_gui_click_rc()</code> as needed.
269271

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+
👤 <code translate="no">uc_gui_click_cf(frame="iframe", retry=False, blind=False)</code> has three args. (All optional). The first one, <code translate="no">frame</code>, lets you specify the selector above the <code translate="no">iframe</code> in case the CAPTCHA is not located in the first <code translate="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, <code translate="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, <code translate="no">blind</code>, (if <code translate="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.
271273

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+
👤 <code translate="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.
273275

274276
--------
275277

@@ -288,7 +290,7 @@ with SB(uc=True) as sb:
288290

289291
👤 <b>Multithreaded UC Mode:</b>
290292

291-
If you're using <b><code translate="no">pytest</code></b> for multithreaded <b translate="no">UC Mode</b> (which requires using one of the <b><code translate="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><code translate="no">pytest</code></b> for multithreaded <b translate="no">UC Mode</b> (which requires using one of the <b><code translate="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. (<code translate="no">-n NUM</code>) Eg:
292294

293295
```bash
294296
pytest --uc -n 4

0 commit comments

Comments
 (0)