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/index.html
+12-9Lines changed: 12 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -2657,11 +2657,11 @@ <h2 id="uc-mode"><a href="https://github.com/seleniumbase/SeleniumBase/"><img sr
2657
2657
<p>(<b><ahref="https://www.youtube.com/watch?v=-EpZlhGWo9k">Watch the 3rd UC Mode tutorial on YouTube! ▶️</a></b>)</p>
2658
2658
2659
2659
<hr/>
2660
-
<p>👤 <btranslate="no">UC Mode</b> is based on <ahref="https://github.com/ultrafunkamsterdam/undetected-chromedriver">undetected-chromedriver</a>, but includes multiple updates, fixes, and improvements, such as:</p>
2660
+
<p>👤 <btranslate="no">UC Mode</b> is based on <ahref="https://github.com/ultrafunkamsterdam/undetected-chromedriver">undetected-chromedriver</a>. <spantranslate="no">UC Mode</span> includes multiple updates, fixes, and improvements, such as:</p>
2661
2661
<ul>
2662
-
<li>Automatically changing useragents to prevent detection.</li>
2663
-
<li>Automatically setting various chromium args as needed.</li>
2664
-
<li>Has special <code>uc_*()</code> methods.</li>
2662
+
<li>Automatically changing user-agents to prevent detection.</li>
2663
+
<li>Automatically setting various Chromium args as needed.</li>
2664
+
<li>Has special <code>uc_*()</code> methods for bypassing CAPTCHAs.</li>
2665
2665
</ul>
2666
2666
<p>👤 Here's a simple example with the <b><codetranslate="no">Driver</code></b> manager:</p>
@@ -2755,6 +2756,7 @@ <h2 id="uc-mode"><a href="https://github.com/seleniumbase/SeleniumBase/"><img sr
2755
2756
</code></pre></div>
2756
2757
<p><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></p>
2757
2758
<p>The 2nd <codetranslate="no">print()</code> should output <codetranslate="no">Virtual Manager</code>, which means that the automation successfully passed the Turnstile.</p>
2759
+
<p>(Note: <spantranslate="no">UC Mode</span> is detectable in Headless Mode, so don't combine those options. Instead, use <codetranslate="no">xvfb=True</code> / <code>--xvfb</code>on Linux for the special virtual display, which is enabled by default when not changing headed/headless settings.)</p>
2758
2760
<hr/>
2759
2761
<p>👤 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>.</p>
2760
2762
<hr/>
@@ -2766,7 +2768,7 @@ <h3 id="here-are-some-examples-that-use-uc-mode">👤 Here are some examples tha
<h3id="here-are-the-seleniumbase-uc-mode-methods-uc-uctrue">👤 Here are the SeleniumBase UC Mode methods: (<code>--uc</code> / <strong><code>uc=True</code></strong>)<aclass="headerlink" href="#here-are-the-seleniumbase-uc-mode-methods-uc-uctrue" title="Permanent link">¶</a></h3>
2795
+
<h3id="here-are-the-seleniumbase-uc-mode-methods-uc-uctrue">👤 Here are the SeleniumBase UC Mode methods: (<strong><code>--uc</code></strong> / <strong><code>uc=True</code></strong>)<aclass="headerlink" href="#here-are-the-seleniumbase-uc-mode-methods-uc-uctrue" title="Permanent link">¶</a></h3>
<p>(Note that the <b><codetranslate="no">reconnect_time</code></b> is used to specify how long the driver should be disconnected from Chrome to prevent detection before reconnecting again.)</p>
2829
-
<p>👤 Since <b><codetranslate="no">driver.get(url)</code></b> is slower in UC Mode for bypassing detection, use <b><codetranslate="no">driver.default_get(url)</code></b> for a standard page load instead:</p>
2831
+
<p>👤 Since <b><codetranslate="no">driver.get(url)</code></b> is slower in <spantranslate="no">UC Mode</span> for bypassing detection, use <b><codetranslate="no">driver.default_get(url)</code></b> for a standard page load instead:</p>
2830
2832
<divclass="highlight"><pre><span></span><code><spanclass="n">driver</span><spanclass="o">.</span><spanclass="n">default_get</span><spanclass="p">(</span><spanclass="n">url</span><spanclass="p">)</span><spanclass="c1"># Faster, but Selenium can be detected</span>
2831
2833
</code></pre></div>
2832
2834
<p>👤 Here are some examples of using those special <btranslate="no">UC Mode</b> methods: (Use <b><codetranslate="no">self.driver</code></b> for <b><codetranslate="no">BaseCase</code></b> formats. Use <b><codetranslate="no">sb.driver</code></b> for <b><codetranslate="no">SB()</code></b> formats):</p>
@@ -2847,7 +2849,8 @@ <h3 id="here-are-the-seleniumbase-uc-mode-methods-uc-uctrue">👤 Here are the S
2847
2849
</code></pre></div>
2848
2850
<p>(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>.)</p>
2849
2851
<hr/>
2850
-
<p>👤 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.</p>
2852
+
<p>👤 <b>On Linux</b>, use <codetranslate="no">xvfb=True</code> / <code>--xvfb</code> to activate a special virtual display. This allows you to run a regular browser in an environment that has no GUI. This is important for two reasons: One: <spantranslate="no">UC Mode</span> is detectable in headless mode. Two: <codetranslate="no">pyautogui</code> doesn't work in headless mode. (Note that some methods such as <codetranslate="no">uc_gui_click_captcha()</code> require <codetranslate="no">pyautogui</code> for performing special actions.)</p>
2853
+
<hr/>
2851
2854
<p>👤 <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.</p>
2852
2855
<p>👤 <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.</p>
2853
2856
<p>👤 <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.</p>
@@ -2898,7 +2901,7 @@ <h3 id="here-are-the-seleniumbase-uc-mode-methods-uc-uctrue">👤 Here are the S
<p>(If those variables are still there, then websites can easily detect your bots.)</p>
2900
2903
<p>If you launch <btranslate="no">Chrome</b> using <b><codetranslate="no">chromedriver</code></b>, then there will be settings that make your browser look like a bot. (Instead, <btranslate="no">UC Mode</b> connects <b><codetranslate="no">chromedriver</code></b> to <btranslate="no">Chrome</b> after the browser is launched, which makes <btranslate="no">Chrome</b> look like a normal, human-controlled web browser.)</p>
2901
-
<p>While <b><codetranslate="no">chromedriver</code></b> is connected to <btranslate="no">Chrome</b>, website services can detect it. Thankfully, raw <b><codetranslate="no">selenium</code></b> already includes <b><codetranslate="no">driver.service.stop()</code></b> for stopping the <b><codetranslate="no">chromedriver</code></b> service, <b><codetranslate="no">driver.service.start()</code></b> for starting the <b><codetranslate="no">chromedriver</code></b> service, and <b><codetranslate="no">driver.start_session(capabilities)</code></b> for reviving the active browser session with the given capabilities. (<btranslate="no"><code>SeleniumBase</code> UC Mode</b> methods automatically use those raw <b><codetranslate="no">selenium</code></b> methods as needed.)</p>
2904
+
<p>While <b><codetranslate="no">chromedriver</code></b> is connected to <btranslate="no">Chrome</b>, website services can detect it. Thankfully, raw <b><codetranslate="no">selenium</code></b> already includes <b><codetranslate="no">driver.service.stop()</code></b> for stopping the <b><codetranslate="no">chromedriver</code></b> service, <b><codetranslate="no">driver.service.start()</code></b> for starting the <b><codetranslate="no">chromedriver</code></b> service, and <b><codetranslate="no">driver.start_session(capabilities)</code></b> for reviving the active browser session with the given capabilities. (<btranslate="no"><code>SeleniumBase</code><spantranslate="no">UC Mode</span></b> methods automatically use those raw <b><codetranslate="no">selenium</code></b> methods as needed.)</p>
2902
2905
<p>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):</p>
0 commit comments