Skip to content

Commit 15b85f1

Browse files
committed
Update the docs
1 parent d3cff00 commit 15b85f1

File tree

3 files changed

+69
-67
lines changed

3 files changed

+69
-67
lines changed

help_docs/uc_mode/index.html

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -876,9 +876,9 @@
876876
</li>
877877

878878
<li class="md-nav__item">
879-
<a href="#here-are-the-driver-specific-methods-added-by-seleniumbase-for-uc-mode-uc-uctrue" class="md-nav__link">
879+
<a href="#here-are-the-seleniumbase-uc-mode-methods-uc-uctrue" class="md-nav__link">
880880
<span class="md-ellipsis">
881-
👤 Here are the driver-specific methods added by SeleniumBase for UC Mode: --uc / uc=True
881+
👤 Here are the SeleniumBase UC Mode methods: (--uc / uc=True)
882882
</span>
883883
</a>
884884

@@ -2612,9 +2612,9 @@
26122612
</li>
26132613

26142614
<li class="md-nav__item">
2615-
<a href="#here-are-the-driver-specific-methods-added-by-seleniumbase-for-uc-mode-uc-uctrue" class="md-nav__link">
2615+
<a href="#here-are-the-seleniumbase-uc-mode-methods-uc-uctrue" class="md-nav__link">
26162616
<span class="md-ellipsis">
2617-
👤 Here are the driver-specific methods added by SeleniumBase for UC Mode: --uc / uc=True
2617+
👤 Here are the SeleniumBase UC Mode methods: (--uc / uc=True)
26182618
</span>
26192619
</a>
26202620

@@ -2669,6 +2669,7 @@ <h2 id="uc-mode"><a href="https://github.com/seleniumbase/SeleniumBase/"><img sr
26692669
<span class="n">driver</span> <span class="o">=</span> <span class="n">Driver</span><span class="p">(</span><span class="n">uc</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
26702670
<span class="n">url</span> <span class="o">=</span> <span class="s2">&quot;https://gitlab.com/users/sign_in&quot;</span>
26712671
<span class="n">driver</span><span class="o">.</span><span class="n">uc_open_with_reconnect</span><span class="p">(</span><span class="n">url</span><span class="p">,</span> <span class="mi">4</span><span class="p">)</span>
2672+
<span class="n">driver</span><span class="o">.</span><span class="n">uc_gui_click_captcha</span><span class="p">()</span>
26722673
<span class="n">driver</span><span class="o">.</span><span class="n">quit</span><span class="p">()</span>
26732674
</code></pre></div>
26742675
<p><img src="https://seleniumbase.github.io/other/gitlab_bypass.png" title="SeleniumBase" width="370"></p>
@@ -2678,9 +2679,10 @@ <h2 id="uc-mode"><a href="https://github.com/seleniumbase/SeleniumBase/"><img sr
26782679
<span class="k">with</span> <span class="n">SB</span><span class="p">(</span><span class="n">uc</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> <span class="k">as</span> <span class="n">sb</span><span class="p">:</span>
26792680
<span class="n">url</span> <span class="o">=</span> <span class="s2">&quot;https://gitlab.com/users/sign_in&quot;</span>
26802681
<span class="n">sb</span><span class="o">.</span><span class="n">uc_open_with_reconnect</span><span class="p">(</span><span class="n">url</span><span class="p">,</span> <span class="mi">4</span><span class="p">)</span>
2682+
<span class="n">sb</span><span class="o">.</span><span class="n">uc_gui_click_captcha</span><span class="p">()</span>
26812683
</code></pre></div>
26822684
<p>(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.)</p>
2683-
<p>👤 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:</p>
2685+
<p>👤 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.)</p>
26842686
<div class="highlight"><pre><span></span><code><span class="kn">from</span> <span class="nn">seleniumbase</span> <span class="kn">import</span> <span class="n">SB</span>
26852687

26862688
<span class="k">with</span> <span class="n">SB</span><span class="p">(</span><span class="n">uc</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span> <span class="n">test</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> <span class="k">as</span> <span class="n">sb</span><span class="p">:</span>
@@ -2707,7 +2709,7 @@ <h2 id="uc-mode"><a href="https://github.com/seleniumbase/SeleniumBase/"><img sr
27072709
</code></pre></div>
27082710
<p><img src="https://seleniumbase.github.io/other/turnstile_click.jpg" title="SeleniumBase" width="440"></p>
27092711
<p>If running on a Linux server, <code>uc_gui_handle_captcha()</code> might not be good enough. Switch to <code>uc_gui_click_captcha()</code> to be more stealthy. Note that these methods auto-detect between CF Turnstile and Google reCAPTCHA.</p>
2710-
<p>Sometimes you need to add <code>incognito=True</code> with <code>uc=True</code> to maximize your anti-detection abilities. (Some websites can detect you if you don't do that.)</p>
2712+
<p>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.)</p>
27112713
<p>👤 Here's an example <b>where the CAPTCHA appears after submitting a form</b>:</p>
27122714
<div class="highlight"><pre><span></span><code><span class="kn">from</span> <span class="nn">seleniumbase</span> <span class="kn">import</span> <span class="n">SB</span>
27132715

@@ -2744,15 +2746,15 @@ <h2 id="uc-mode"><a href="https://github.com/seleniumbase/SeleniumBase/"><img sr
27442746
<span class="n">url</span> <span class="o">=</span> <span class="s2">&quot;https://www.virtualmanager.com/en/login&quot;</span>
27452747
<span class="n">sb</span><span class="o">.</span><span class="n">uc_open_with_reconnect</span><span class="p">(</span><span class="n">url</span><span class="p">,</span> <span class="mi">4</span><span class="p">)</span>
27462748
<span class="nb">print</span><span class="p">(</span><span class="n">sb</span><span class="o">.</span><span class="n">get_page_title</span><span class="p">())</span>
2747-
<span class="n">sb</span><span class="o">.</span><span class="n">uc_gui_click_captcha</span><span class="p">()</span> <span class="c1"># Only if needed</span>
2749+
<span class="n">sb</span><span class="o">.</span><span class="n">uc_gui_click_captcha</span><span class="p">()</span> <span class="c1"># Only used if needed</span>
27482750
<span class="nb">print</span><span class="p">(</span><span class="n">sb</span><span class="o">.</span><span class="n">get_page_title</span><span class="p">())</span>
27492751
<span class="n">sb</span><span class="o">.</span><span class="n">assert_element</span><span class="p">(</span><span class="s1">&#39;input[name*=&quot;email&quot;]&#39;</span><span class="p">)</span>
27502752
<span class="n">sb</span><span class="o">.</span><span class="n">assert_element</span><span class="p">(</span><span class="s1">&#39;input[name*=&quot;login&quot;]&#39;</span><span class="p">)</span>
27512753
<span class="n">sb</span><span class="o">.</span><span class="n">set_messenger_theme</span><span class="p">(</span><span class="n">location</span><span class="o">=</span><span class="s2">&quot;bottom_center&quot;</span><span class="p">)</span>
27522754
<span class="n">sb</span><span class="o">.</span><span class="n">post_message</span><span class="p">(</span><span class="s2">&quot;SeleniumBase wasn&#39;t detected!&quot;</span><span class="p">)</span>
27532755
</code></pre></div>
27542756
<p><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></p>
2755-
<p>The 2nd <code>print()</code> should output "Virtual Manager", which means that the automation successfully passed the Turnstile.</p>
2757+
<p>The 2nd <code translate="no">print()</code> should output <code translate="no">Virtual Manager</code>, which means that the automation successfully passed the Turnstile.</p>
27562758
<hr />
27572759
<p>👤 In <b translate="no">UC Mode</b>, <code translate="no">driver.get(url)</code> has been modified from its original version: If anti-bot services are detected from a <code translate="no">requests.get(url)</code> call that's made before navigating to the website, then <code translate="no">driver.uc_open_with_reconnect(url)</code> will be used instead. To open a URL normally in <b translate="no">UC Mode</b>, use <code translate="no">driver.default_get(url)</code>.</p>
27582760
<hr />
@@ -2788,7 +2790,7 @@ <h3 id="here-are-some-uc-mode-examples-that-bypass-captchas-when-clicking-is-req
27882790
</ul>
27892791
<p><img src="https://seleniumbase.github.io/other/cf_bypass.png" title="SeleniumBase" width="260"></p>
27902792
<hr />
2791-
<h3 id="here-are-the-driver-specific-methods-added-by-seleniumbase-for-uc-mode-uc-uctrue">👤 Here are the <b><code translate="no">driver</code></b>-specific methods added by SeleniumBase for UC Mode: <code>--uc</code> / <b><code translate="no">uc=True</code></b><a class="headerlink" href="#here-are-the-driver-specific-methods-added-by-seleniumbase-for-uc-mode-uc-uctrue" title="Permanent link">&para;</a></h3>
2793+
<h3 id="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>)<a class="headerlink" href="#here-are-the-seleniumbase-uc-mode-methods-uc-uctrue" title="Permanent link">&para;</a></h3>
27922794
<div class="highlight"><pre><span></span><code><span class="n">driver</span><span class="o">.</span><span class="n">uc_open</span><span class="p">(</span><span class="n">url</span><span class="p">)</span>
27932795

27942796
<span class="n">driver</span><span class="o">.</span><span class="n">uc_open_with_tab</span><span class="p">(</span><span class="n">url</span><span class="p">)</span>
@@ -2845,10 +2847,10 @@ <h3 id="here-are-the-driver-specific-methods-added-by-seleniumbase-for-uc-mode-u
28452847
</code></pre></div>
28462848
<p>(Note that while the special <b><code translate="no">UC Mode</code></b> breakpoint is active, you can't use <b><code translate="no">Selenium</code></b> commands in the browser, and the browser can't detect <b><code translate="no">Selenium</code></b>.)</p>
28472849
<hr />
2848-
<p>👤 On Linux, you may need to use <code>uc_gui_click_captcha()</code> 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 <code>uc_gui_click_captcha()</code>. This method uses <code>pyautogui</code>. In order for <code>pyautogui</code> to focus on the correct element, use <code>xvfb=True</code> / <code>--xvfb</code> to activate a special virtual display on Linux.</p>
2849-
<p>👤 <code>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>uc_gui_click_cf()</code> and <code>uc_gui_click_rc()</code> as needed.</p>
2850-
<p>👤 <code>uc_gui_click_cf(frame="iframe", retry=False, blind=False)</code> has three args. (All optional). The first one, <code>frame</code>, 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, <code>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>blind</code>, (if <code>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>
2851-
<p>👤 <code>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>
2850+
<p>👤 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.</p>
2851+
<p>👤 <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.</p>
2852+
<p>👤 <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.</p>
2853+
<p>👤 <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.</p>
28522854
<hr />
28532855
<p>👤 To find out if <b translate="no">UC Mode</b> will work at all on a specific site (before adjusting for timing), load your site with the following script:</p>
28542856
<div class="highlight"><pre><span></span><code><span class="kn">from</span> <span class="nn">seleniumbase</span> <span class="kn">import</span> <span class="n">SB</span>
@@ -2859,7 +2861,7 @@ <h3 id="here-are-the-driver-specific-methods-added-by-seleniumbase-for-uc-mode-u
28592861
<p>(If you remain undetected while loading the page and performing manual actions, then you know you can create a working script once you swap the breakpoint with a time and add special methods like <b><code translate="no">sb.uc_click</code></b> as needed.)</p>
28602862
<hr />
28612863
<p>👤 <b>Multithreaded UC Mode:</b></p>
2862-
<p>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> <a href="../syntax_formats/">syntax formats</a>), then all you have to do is set the number of threads when your script runs. (<code>-n NUM</code>) Eg:</p>
2864+
<p>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> <a href="../syntax_formats/">syntax formats</a>), then all you have to do is set the number of threads when your script runs. (<code translate="no">-n NUM</code>) Eg:</p>
28632865
<div class="highlight"><pre><span></span><code>pytest<span class="w"> </span>--uc<span class="w"> </span>-n<span class="w"> </span><span class="m">4</span>
28642866
</code></pre></div>
28652867
<p>(Then <b><code translate="no">pytest-xdist</code></b> is automatically used to spin up and process the threads.)</p>

search/search_index.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)