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
<li><b>SeleniumBase</b> tests are run with <b>pytest</b>.</li>
2624
2624
<li>Chrome is the default browser if not specified.</li>
2625
-
<li>Tests are structured using <ahref="../../help_docs/syntax_formats/">23 unique syntax formats</a>.</li>
2625
+
<li>Tests are structured using <ahref="../../help_docs/syntax_formats/">25 unique syntax formats</a>.</li>
2626
2626
<li>Logs from test failures are saved to <code>./latest_logs/</code>.</li>
2627
2627
<li>Tests can be run with <ahref="../../help_docs/customizing_test_runs/">multiple command-line options</a>.</li>
2628
2628
<li>Examples can be found in: <strong><ahref="https://github.com/seleniumbase/SeleniumBase/tree/master/examples">SeleniumBase/examples/</a></strong>.</li>
<p>🐙 <btranslate="no">SeleniumBase</b><btranslate="no">CDP Mode</b> (Chrome Devtools Protocol Mode) is a special mode inside of <b><ahref="../../../help_docs/uc_mode/" translate="no"><spantranslate="no">SeleniumBase UC Mode</span></a></b> that lets bots appear human while controlling the browser with the <btranslate="no">CDP-Driver</b>. Although regular <spantranslate="no">UC Mode</span> can't perform <spantranslate="no">WebDriver</span> actions while the <code>driver</code> is disconnected from the browser, the <spantranslate="no">CDP-Driver</span> can still perform actions while maintaining its cover.</p>
2724
+
<p>🐙 <btranslate="no">SeleniumBase</b><btranslate="no">CDP Mode</b> (Chrome Devtools Protocol Mode) is a special mode inside of <b><ahref="../../../help_docs/uc_mode/" translate="no"><spantranslate="no">SeleniumBase UC Mode</span></a></b> that lets bots appear human while controlling the browser with the <btranslate="no">CDP-Driver</b>. Although regular <btranslate="no">UC Mode</b> can't perform <spantranslate="no">WebDriver</span> actions while the <code>driver</code> is disconnected from the browser, the <btranslate="no">CDP-Driver</b> can.</p>
<p>(<b><ahref="https://www.youtube.com/watch?v=Mr90iQmNsKM">Watch the CDP Mode tutorial on YouTube! ▶️</a></b>)</p>
2728
2728
2729
2729
<hr/>
2730
2730
<p>👤 <btranslate="no">UC Mode</b> avoids bot-detection by first disconnecting WebDriver from the browser at strategic times, calling special <code>PyAutoGUI</code> methods to bypass CAPTCHAs (as needed), and finally reconnecting the <code>driver</code> afterwards so that WebDriver actions can be performed again. Although this approach works for bypassing simple CAPTCHAs, more flexibility is needed for bypassing bot-detection on websites with advanced protection. (That's where <btranslate="no">CDP Mode</b> comes in.)</p>
2731
-
<p>🐙 <btranslate="no">CDP Mode</b> is based on <ahref="https://github.com/HyperionGray/python-chrome-devtools-protocol" translate="no">python-cdp</a>, <ahref="https://github.com/HyperionGray/trio-chrome-devtools-protocol" translate="no">trio-cdp</a>, and <ahref="https://github.com/ultrafunkamsterdam/nodriver" translate="no">nodriver</a>. <code>trio-cdp</code> is an early implementation of <code>python-cdp</code>, and <code>nodriver</code> is a modern implementation of <code>python-cdp</code>. (Refactored Python-CDP code is imported from <ahref="https://github.com/mdmintz/MyCDP" translate="no">MyCDP</a>.)</p>
2731
+
<p>🐙 <btranslate="no">CDP Mode</b> is based on <ahref="https://github.com/HyperionGray/python-chrome-devtools-protocol" translate="no">python-cdp</a>, <ahref="https://github.com/HyperionGray/trio-chrome-devtools-protocol" translate="no">trio-cdp</a>, and <ahref="https://github.com/ultrafunkamsterdam/nodriver" translate="no">nodriver</a>. <code>trio-cdp</code> is an early implementation of <code>python-cdp</code>, and <code>nodriver</code> is a modern implementation of <code>python-cdp</code>. (Refactored <code>Python-CDP</code> code is imported from <ahref="https://github.com/mdmintz/MyCDP" translate="no">MyCDP</a>.)</p>
2732
2732
<p>🐙 <btranslate="no">CDP Mode</b> includes multiple updates to the above, such as:</p>
2733
2733
<ul>
2734
2734
<li>Sync methods. (Using <code>async</code>/<code>await</code> is not necessary!)</li>
<p>(Call that from a <strong>UC Mode</strong> script)</p>
2749
2749
</blockquote>
2750
2750
<p>That disconnects WebDriver from Chrome (which prevents detection), and gives you access to <code>sb.cdp</code> methods (which don't trigger anti-bot checks).</p>
<p>(If the CAPTCHA wasn't initially bypassed, then the click gets the job done.)</p>
2763
+
<p>Note that <code>PyAutoGUI</code> is an optional dependency. If calling a method that uses it when not already installed, then <code>SeleniumBase</code> will install it at run-time, which pauses the script briefly.</p>
2764
+
<p>For standard Cloudflare pages, use <code>sb.uc_gui_click_captcha()</code> if Turnstiles aren't initially bypassed. Example: (<ahref="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/cdp_mode/raw_gitlab.py">SeleniumBase/examples/cdp_mode/raw_gitlab.py</a>)</p>
<h3id="here-are-a-few-common-sbcdp-methods">🐙 Here are a few common <code>sb.cdp</code> methods<aclass="headerlink" href="#here-are-a-few-common-sbcdp-methods" title="Permanent link">¶</a></h3>
2752
2776
<ul>
2753
-
<li><code>sb.cdp.click(selector)</code></li>
2777
+
<li><code>sb.cdp.click(selector)</code> (Uses the CDP API to click)</li>
<p>When <code>type()</code> is too fast, use the slower <code>press_keys()</code> to avoid detection. You can also use <code>sb.sleep(seconds)</code> to slow things down. Methods that start with <code>sb.cdp.gui</code> use <code>PyAutoGUI</code> for interaction.</p>
2785
+
<p>Methods that start with <code>sb.cdp.gui</code> use <code>PyAutoGUI</code> for interaction.</p>
2762
2786
<p>To use WebDriver methods again, call:</p>
2763
2787
<ul>
2764
2788
<li><strong><code>sb.reconnect()</code></strong> or <strong><code>sb.connect()</code></strong></li>
@@ -2768,13 +2792,14 @@ <h3 id="here-are-a-few-common-sbcdp-methods">🐙 Here are a few common <code>sb
<p>While disconnected, if you accidentally call a WebDriver method, then SeleniumBase will attempt to use the CDP Mode version of that method (if available). For example, if you accidentally call <code>sb.click(selector)</code> instead of <code>sb.cdp.click(selector)</code>, then your WebDriver call will automatically be redirected to the CDP Mode version. Not all WebDriver methods have a matching CDP Mode method. In that scenario, calling a WebDriver method while disconnected could raise an error, or make WebDriver automatically reconnect first.</p>
2795
+
<p>While disconnected, if you accidentally call a WebDriver method, then <btranslate="no">SeleniumBase</b> will attempt to use the <btranslate="no">CDP Mode</b> version of that method (if available). For example, if you accidentally call <code>sb.click(selector)</code> instead of <code>sb.cdp.click(selector)</code>, then your WebDriver call will automatically be redirected to the <btranslate="no">CDP Mode</b> version. Not all WebDriver methods have a matching <btranslate="no">CDP Mode</b> method. In that scenario, calling a WebDriver method while disconnected could raise an error, or make WebDriver automatically reconnect first.</p>
2772
2796
<p>To find out if WebDriver is connected or disconnected, call:</p>
<p><b>Note:</b> When <btranslate="no">CDP Mode</b> is initialized from <btranslate="no">UC Mode</b>, the WebDriver is disconnected from the browser. (The stealthy <btranslate="no">CDP-Driver</b> takes over.)</p>
0 commit comments