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
👤 <b>On Linux</b>, use `sb.uc_gui_handle_cf()` to handle Cloudflare Turnstiles:
122
+
123
+
```python
124
+
from seleniumbase importSB
125
+
126
+
with SB(uc=True, test=True) as sb:
127
+
url ="https://www.virtualmanager.com/en/login"
128
+
sb.uc_open_with_reconnect(url, 4)
129
+
print(sb.get_page_title())
130
+
sb.uc_gui_handle_cf() # Ready if needed!
131
+
print(sb.get_page_title())
132
+
sb.assert_element('input[name*="email"]')
133
+
sb.assert_element('input[name*="login"]')
134
+
sb.set_messenger_theme(location="bottom_center")
135
+
sb.post_message("SeleniumBase wasn't detected!")
136
+
```
137
+
138
+
<ahref="https://github.com/mdmintz/undetected-testing/actions/runs/9637461606/job/26576722411"><imgwidth="540"alt="uc_gui_handle_cf on Linux"src="https://github.com/seleniumbase/SeleniumBase/assets/6788579/6aceb2a3-2a32-4521-b30a-f79446d2ce28"></a>
139
+
140
+
The 2nd `print()` should output "Virtual Manager", which means that the automation successfully passed the Turnstile.
141
+
132
142
--------
133
143
134
144
👤 In <btranslate="no">UC Mode</b>, <codetranslate="no">driver.get(url)</code> has been modified from its original version: If anti-bot services are detected from a <codetranslate="no">requests.get(url)</code> call that's made before navigating to the website, then <codetranslate="no">driver.uc_open_with_reconnect(url)</code> will be used instead. To open a URL normally in <btranslate="no">UC Mode</b>, use <codetranslate="no">driver.default_get(url)</code>.
@@ -144,6 +154,7 @@ with SB(uc=True, test=True, ad_block_on=True) as sb:
(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>.)
216
227
217
-
👤 The two main causes of getting detected in <btranslate="no">UC Mode</b> (which are both easily handled) are:
218
-
219
-
<li>Timing. (<btranslate="no">UC Mode</b> methods let you customize default values that aren't good enough for your environment.)</li>
220
-
<li>Not using <b><codetranslate="no">driver.uc_click(selector)</code></b> when you need to remain undetected while clicking something.</li>
221
-
222
228
👤 On Linux, you may need to use `driver.uc_gui_handle_cf()` to successfully bypass a Cloudflare CAPTCHA. If there's more than one iframe on that website (and Cloudflare isn't the first one) then put the CSS Selector of that iframe as the first arg to `driver.uc_gui_handle_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.
223
229
224
230
👤 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:
@@ -268,46 +274,15 @@ with ThreadPoolExecutor(max_workers=len(urls)) as executor:
268
274
269
275
--------
270
276
271
-
👥 <b>Double Duty:</b> Here's an example of handling two CAPTCHAs on one page:
Here are the 3 primary things that <btranslate="no">UC Mode</b> does to make bots appear human:
307
280
281
+
<ul>
308
282
<li>Modifies <b><codetranslate="no">chromedriver</code></b> to rename <btranslate="no">Chrome DevTools Console</b> variables.</li>
309
283
<li>Launches <btranslate="no">Chrome</b> browsers before attaching <b><codetranslate="no">chromedriver</code></b> to them.</li>
310
284
<li>Disconnects <b><codetranslate="no">chromedriver</code></b> from <btranslate="no">Chrome</b> during stealthy actions.</li>
285
+
</ul>
311
286
312
287
For example, if the <btranslate="no">Chrome DevTools Console</b> variables aren't renamed, you can expect to find them easily when using <b><codetranslate="no">selenium</code></b> for browser automation:
313
288
@@ -321,13 +296,17 @@ While <b><code translate="no">chromedriver</code></b> is connected to <b transla
321
296
322
297
Links to those <ahref="https://github.com/SeleniumHQ/selenium">raw <b>Selenium</b></a> method definitions have been provided for reference (but you don't need to call those methods directly):
Also note that <b><codetranslate="no">chromedriver</code></b> isn't detectable in a browser tab if it never touches that tab. Here's a JS command that lets you open a URL in a new tab (from your current tab):
The above JS method is used within <btranslate="no"><code>SeleniumBase</code></b> <btranslate="no">UC Mode</b> methods for opening URLs in a stealthy way. Since some websites try to detect if your browser is a bot on the initial page load, this allows you to bypass detection in those situations. After a few seconds (customizable), <btranslate="no">UC Mode</b> tells <b><codetranslate="no">chromedriver</code></b> to connect to that tab so that automated commands can now be issued. At that point, <b><codetranslate="no">chromedriver</code></b> could be detected if websites are looking for it (but generally websites only look for it during specific events, such as page loads, form submissions, and button clicks).
0 commit comments