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
<spanclass="c1"># (Mainly for CDP Mode) - (For all CDP methods, see the CDP Mode Docs)</span>
3587
+
3588
+
<spanclass="bp">self</span><spanclass="o">.</span><spanclass="n">activate_cdp_mode</span><spanclass="p">(</span><spanclass="n">url</span><spanclass="o">=</span><spanclass="kc">None</span><spanclass="p">)</span><spanclass="c1"># Activate CDP Mode on the given URL</span>
<spanclass="bp">self</span><spanclass="o">.</span><spanclass="n">disconnect</span><spanclass="p">()</span><spanclass="c1"># Stops the webdriver service to prevent detection</span>
3593
+
3594
+
<spanclass="bp">self</span><spanclass="o">.</span><spanclass="n">connect</span><spanclass="p">()</span><spanclass="c1"># Starts the webdriver service to allow actions again</span>
3595
+
3596
+
<spanclass="c1"># (For regular UC Mode)</span>
3597
+
3598
+
<spanclass="bp">self</span><spanclass="o">.</span><spanclass="n">uc_open</span><spanclass="p">(</span><spanclass="n">url</span><spanclass="p">)</span><spanclass="c1"># (Open in same tab with default reconnect_time)</span>
3599
+
3600
+
<spanclass="bp">self</span><spanclass="o">.</span><spanclass="n">uc_open_with_tab</span><spanclass="p">(</span><spanclass="n">url</span><spanclass="p">)</span><spanclass="c1"># (New tab with default reconnect_time)</span>
3601
+
3602
+
<spanclass="bp">self</span><spanclass="o">.</span><spanclass="n">uc_open_with_reconnect</span><spanclass="p">(</span><spanclass="n">url</span><spanclass="p">,</span><spanclass="n">reconnect_time</span><spanclass="o">=</span><spanclass="kc">None</span><spanclass="p">)</span><spanclass="c1"># (New tab)</span>
3603
+
3604
+
<spanclass="bp">self</span><spanclass="o">.</span><spanclass="n">uc_open_with_disconnect</span><spanclass="p">(</span><spanclass="n">url</span><spanclass="p">,</span><spanclass="n">timeout</span><spanclass="o">=</span><spanclass="kc">None</span><spanclass="p">)</span><spanclass="c1"># New tab + sleep()</span>
3605
+
3606
+
<spanclass="bp">self</span><spanclass="o">.</span><spanclass="n">uc_click</span><spanclass="p">(</span><spanclass="n">selector</span><spanclass="p">)</span><spanclass="c1"># A stealthy click for evading bot-detection</span>
3607
+
3608
+
<spanclass="bp">self</span><spanclass="o">.</span><spanclass="n">uc_gui_press_key</span><spanclass="p">(</span><spanclass="n">key</span><spanclass="p">)</span><spanclass="c1"># Use PyAutoGUI to press the keyboard key</span>
3609
+
3610
+
<spanclass="bp">self</span><spanclass="o">.</span><spanclass="n">uc_gui_press_keys</span><spanclass="p">(</span><spanclass="n">keys</span><spanclass="p">)</span><spanclass="c1"># Use PyAutoGUI to press a list of keys</span>
3611
+
3612
+
<spanclass="bp">self</span><spanclass="o">.</span><spanclass="n">uc_gui_write</span><spanclass="p">(</span><spanclass="n">text</span><spanclass="p">)</span><spanclass="c1"># Similar to uc_gui_press_keys(), but faster</span>
<spanclass="c1">############ # "driver"-specific methods added (or modified) by SeleniumBase</span>
3583
3621
<spanclass="n">driver</span><spanclass="o">.</span><spanclass="n">default_get</span><spanclass="p">(</span><spanclass="n">url</span><spanclass="p">)</span><spanclass="c1"># Because driver.get(url) works differently in UC Mode</span>
<spanclass="n">driver</span><spanclass="o">.</span><spanclass="n">uc_open_with_disconnect</span><spanclass="p">(</span><spanclass="n">url</span><spanclass="p">,</span><spanclass="n">timeout</span><spanclass="o">=</span><spanclass="kc">None</span><spanclass="p">)</span><spanclass="c1"># New tab + sleep()</span>
<spanclass="n">driver</span><spanclass="o">.</span><spanclass="n">uc_activate_cdp_mode</span><spanclass="p">(</span><spanclass="n">url</span><spanclass="o">=</span><spanclass="kc">None</span><spanclass="p">)</span><spanclass="c1"># Activate CDP Mode on the given URL</span>
<spanclass="n">driver</span><spanclass="o">.</span><spanclass="n">disconnect</span><spanclass="p">()</span><spanclass="c1"># Stops the webdriver service to prevent detection</span>
<spanclass="n">driver</span><spanclass="o">.</span><spanclass="n">uc_gui_handle_captcha</span><spanclass="p">(</span><spanclass="n">frame</span><spanclass="o">=</span><spanclass="s2">"iframe"</span><spanclass="p">)</span><spanclass="c1"># (Auto-detects the CAPTCHA)</span>
<p>The first command creates a boilerplate test with a breakpoint; the second command runs the test with the Recorder activated; the third command prints the completed test to the console; and the fourth command replaces the initial boilerplate with the completed test. If you're just experimenting with the Recorder, you can run the second command as many times as you want, and it'll override previous recordings saved to <code>./recordings/TEST_NAME_rec.py</code>. (Note that <code>-s</code> is needed to allow breakpoints, unless you already have a <code>pytest.ini</code> file present with <code>addopts = --capture=no</code> in it. The <code>-q</code> is optional, which shortens <code>pytest</code> console output.)</p>
2672
+
<p>The first command creates a boilerplate test with a breakpoint; the second command runs the test with the Recorder activated; the third command prints the completed test to the console; and the fourth command replaces the initial boilerplate with the completed test. If you're just experimenting with the Recorder, you can run the second command as many times as you want, and it'll override previous recordings saved to <code>./recordings/TEST_NAME_rec.py</code>. (Note that <code>-s</code> is needed to allow breakpoints, unless you already have a <code>pytest.ini</code> file present where you set it. The <code>-q</code> is optional, which shortens <code>pytest</code> console output.)</p>
2673
2673
<p>⏺️ You can also use the Recorder to add code to an existing test. To do that, you'll first need to create a breakpoint in your code to insert manual browser actions:</p>
0 commit comments