Skip to content

Commit

Permalink
Update the docs
Browse files Browse the repository at this point in the history
  • Loading branch information
mdmintz committed Sep 4, 2024
1 parent f1db120 commit 617730b
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 5 deletions.
25 changes: 22 additions & 3 deletions docs/help_docs/uc_mode/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2715,12 +2715,12 @@ <h2 id="uc-mode"><a href="https://github.com/seleniumbase/SeleniumBase/"><img sr
<span class="n">url</span> <span class="o">=</span> <span class="s2">&quot;https://ahrefs.com/website-authority-checker&quot;</span>
<span class="n">input_field</span> <span class="o">=</span> <span class="s1">&#39;input[placeholder=&quot;Enter domain&quot;]&#39;</span>
<span class="n">submit_button</span> <span class="o">=</span> <span class="s1">&#39;span:contains(&quot;Check Authority&quot;)&#39;</span>
<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">2</span><span class="p">)</span> <span class="c1"># The bot-check is later</span>
<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="c1"># The bot-check is later</span>
<span class="n">sb</span><span class="o">.</span><span class="n">type</span><span class="p">(</span><span class="n">input_field</span><span class="p">,</span> <span class="s2">&quot;github.com/seleniumbase/SeleniumBase&quot;</span><span class="p">)</span>
<span class="n">sb</span><span class="o">.</span><span class="n">reconnect</span><span class="p">(</span><span class="mf">0.1</span><span class="p">)</span>
<span class="n">sb</span><span class="o">.</span><span class="n">uc_click</span><span class="p">(</span><span class="n">submit_button</span><span class="p">,</span> <span class="n">reconnect_time</span><span class="o">=</span><span class="mi">4</span><span class="p">)</span>
<span class="n">sb</span><span class="o">.</span><span class="n">uc_gui_click_captcha</span><span class="p">()</span>
<span class="n">sb</span><span class="o">.</span><span class="n">wait_for_text_not_visible</span><span class="p">(</span><span class="s2">&quot;Checking&quot;</span><span class="p">,</span> <span class="n">timeout</span><span class="o">=</span><span class="mi">10</span><span class="p">)</span>
<span class="n">sb</span><span class="o">.</span><span class="n">wait_for_text_not_visible</span><span class="p">(</span><span class="s2">&quot;Checking&quot;</span><span class="p">,</span> <span class="n">timeout</span><span class="o">=</span><span class="mi">12</span><span class="p">)</span>
<span class="n">sb</span><span class="o">.</span><span class="n">highlight</span><span class="p">(</span><span class="s1">&#39;p:contains(&quot;github.com/seleniumbase/SeleniumBase&quot;)&#39;</span><span class="p">)</span>
<span class="n">sb</span><span class="o">.</span><span class="n">highlight</span><span class="p">(</span><span class="s1">&#39;a:contains(&quot;Top 100 backlinks&quot;)&#39;</span><span class="p">)</span>
<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>
Expand Down Expand Up @@ -2761,9 +2761,24 @@ <h3 id="here-are-some-examples-that-use-uc-mode">👤 Here are some examples tha
<li><a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/verify_undetected.py">SeleniumBase/examples/verify_undetected.py</a></li>
<li><a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/raw_bing_captcha.py">SeleniumBase/examples/raw_bing_captcha.py</a></li>
<li><a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/raw_uc_mode.py">SeleniumBase/examples/raw_uc_mode.py</a></li>
<li><a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/raw_cf.py">SeleniumBase/examples/raw_cf.py</a></li>
</ul>
<hr />
<p>👤 Here's an example where <strong><code>incognito=True</code> is needed for bypassing detection</strong>:</p>
<ul>
<li><a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/raw_pixelscan.py">SeleniumBase/examples/raw_pixelscan.py</a></li>
</ul>
<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>

<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">incognito</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>
<span class="n">sb</span><span class="o">.</span><span class="n">driver</span><span class="o">.</span><span class="n">uc_open_with_reconnect</span><span class="p">(</span><span class="s2">&quot;https://pixelscan.net/&quot;</span><span class="p">,</span> <span class="mi">10</span><span class="p">)</span>
<span class="n">sb</span><span class="o">.</span><span class="n">remove_elements</span><span class="p">(</span><span class="s2">&quot;jdiv&quot;</span><span class="p">)</span> <span class="c1"># Remove chat widgets</span>
<span class="n">sb</span><span class="o">.</span><span class="n">highlight</span><span class="p">(</span><span class="s2">&quot;span.text-success&quot;</span><span class="p">,</span> <span class="n">loops</span><span class="o">=</span><span class="mi">8</span><span class="p">)</span>
<span class="n">sb</span><span class="o">.</span><span class="n">highlight</span><span class="p">(</span><span class="s2">&quot;.bot-detection-context&quot;</span><span class="p">,</span> <span class="n">loops</span><span class="o">=</span><span class="mi">10</span><span class="p">,</span> <span class="n">scroll</span><span class="o">=</span><span class="kc">False</span><span class="p">)</span>
<span class="n">sb</span><span class="o">.</span><span class="n">sleep</span><span class="p">(</span><span class="mi">2</span><span class="p">)</span>
</code></pre></div>
<p><img src="https://seleniumbase.github.io/other/pixelscan.jpg" title="SeleniumBase" width="540"></p>
<hr />
<h3 id="here-are-some-uc-mode-examples-that-bypass-captchas-when-clicking-is-required">👤 Here are some UC Mode examples that bypass CAPTCHAs when clicking is required<a class="headerlink" href="#here-are-some-uc-mode-examples-that-bypass-captchas-when-clicking-is-required" title="Permanent link">&para;</a></h3>
<ul>
<li><a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/raw_pyautogui.py">SeleniumBase/examples/raw_pyautogui.py</a></li>
Expand All @@ -2772,6 +2787,7 @@ <h3 id="here-are-some-uc-mode-examples-that-bypass-captchas-when-clicking-is-req
<li><a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/uc_cdp_events.py">SeleniumBase/examples/uc_cdp_events.py</a></li>
</ul>
<p><img src="https://seleniumbase.github.io/other/cf_bypass.png" title="SeleniumBase" width="260"></p>
<hr />
<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>
<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>

Expand Down Expand Up @@ -2828,17 +2844,20 @@ <h3 id="here-are-the-driver-specific-methods-added-by-seleniumbase-for-uc-mode-u
<span class="n">driver</span><span class="o">.</span><span class="n">reconnect</span><span class="p">(</span><span class="s2">&quot;breakpoint&quot;</span><span class="p">)</span>
</code></pre></div>
<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>
<hr />
<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>
<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>
<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>
<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>
<hr />
<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>
<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>

<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>
<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="n">reconnect_time</span><span class="o">=</span><span class="s2">&quot;breakpoint&quot;</span><span class="p">)</span>
</code></pre></div>
<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>
<hr />
<p>👤 <b>Multithreaded UC Mode:</b></p>
<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>
<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>
Expand Down Expand Up @@ -2898,7 +2917,7 @@ <h3 id="here-are-the-driver-specific-methods-added-by-seleniumbase-for-uc-mode-u
<hr />
<p>🏆 <b>Choosing the right CAPTCHA service</b> for your business / website:</p>
<p><img src="https://seleniumbase.github.io/other/me_se_conf.jpg" title="SeleniumBase" width="370"></p>
<p>As an ethical hacker / cybersecurity researcher who builds bots that bypass CAPTCHAs for sport, <b>the CAPTCHA service that I personally recommend</b> for keeping bots out is <b translate="no">Google's reCAPTCHA</b>:</p>
<p>As an ethical hacker / cybersecurity researcher who builds bots that bypass CAPTCHAs for sport, <b>the CAPTCHA service that I personally recommend</b> for keeping bots out is <b translate="no">Google reCAPTCHA</b>:</p>
<p><img src="https://seleniumbase.github.io/other/g_recaptcha.png" title="SeleniumBase" width="315"></p>
<p>Since Google makes Chrome, Google's own <b translate="no">reCAPTCHA</b> service has access to more data than other CAPTCHA services (eg. hCaptcha, CloudFlare, DataDome, etc.), and can therefore use that data to make better decisions about whether or not web activity is coming from real humans or automated bots.</p>
<hr />
Expand Down
4 changes: 3 additions & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2563,10 +2563,12 @@ <h1>SeleniumBase</h1>
<br />
</p>

<p>SeleniumBase is the professional toolkit for web automation activities. Built for testing websites, bypassing CAPTCHAs, enhancing productivity, completing tasks, and scaling your business.</p>

<hr />
<p>📚 Learn from <a href="https://github.com/seleniumbase/SeleniumBase/tree/master/examples"><strong>over 200 examples</strong> in the <strong>SeleniumBase/examples/</strong> folder</a>.</p>
<p>👤 Note that <span translate="no">SeleniumBase</span> <a translate="no" href="help_docs/uc_mode/"><b>UC Mode</b> (Stealth Mode) has its own ReadMe</a>.</p>
<p>ℹ️ Scripts can be called via <code translate="no"><b>python</b></code>, although some <a href="help_docs/syntax_formats/">Syntax Formats</a> expect <a href="https://docs.pytest.org/en/latest/how-to/usage.html" translate="no"><b>pytest</b></a> (a Python unit-testing framework included with SeleniumBase that can discover &amp; collect tests automatically).</p>
<p>ℹ️ Scripts can be called via <code translate="no"><b>python</b></code>, although some <a href="help_docs/syntax_formats/">Syntax Formats</a> expect <a href="https://docs.pytest.org/en/latest/how-to/usage.html" translate="no"><b>pytest</b></a> (a Python unit-testing framework included with SeleniumBase that can discover, collect, and run tests automatically).</p>
<p align="left">📗 Here's <a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/my_first_test.py">my_first_test.py</a>, which tests login, shopping, and checkout:</p>

<div class="highlight"><pre><span></span><code>pytest<span class="w"> </span>my_first_test.py
Expand Down
2 changes: 1 addition & 1 deletion docs/search/search_index.json

Large diffs are not rendered by default.

0 comments on commit 617730b

Please sign in to comment.