Skip to content

Commit 3c9e4c0

Browse files
authored
Merge pull request #4295 from seleniumbase/cdp-mode-patch-100
CDP Mode: Patch 100
2 parents fbd60e1 + a708aae commit 3c9e4c0

File tree

15 files changed

+140
-127
lines changed

15 files changed

+140
-127
lines changed

README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@
6262

6363
--------
6464

65-
<p align="left">📓 Here's the stealthy architecture overview:</p>
65+
<h3 align="left">⚙️ Stealthy architecture flowchart:</h3>
6666

67-
<img src="https://seleniumbase.github.io/other/sb_stealth.png" width="596" alt="Stealthy architecture overview" />
67+
<img src="https://seleniumbase.github.io/other/sb_stealth.png" width="596" alt="Stealthy architecture flowchart" />
6868

6969
(For maximum stealth, use <a translate="no" href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/cdp_mode/ReadMe.md">CDP Mode</a>, which includes <a translate="no" href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/cdp_mode/playwright/ReadMe.md">Stealthy Playwright Mode</a>)
7070

@@ -80,6 +80,7 @@ sb = sb_cdp.Chrome(url)
8080
elements = sb.find_elements("span.titleline > a")
8181
for element in elements:
8282
print("* " + element.text)
83+
sb.driver.stop()
8384
```
8485

8586
--------
@@ -491,6 +492,7 @@ class MyTestClass(BaseCase):
491492

492493
```python
493494
self.open(url) # Navigate the browser window to the URL.
495+
self.activate_cdp_mode() # Activate CDP Mode from UC Mode.
494496
self.type(selector, text) # Update the field with the text.
495497
self.click(selector) # Click the element with the selector.
496498
self.click_link(link_text) # Click the link containing text.
@@ -579,7 +581,7 @@ pytest [FILE_NAME.py]::[CLASS_NAME]::[METHOD_NAME]
579581
pynose [FILE_NAME.py]:[CLASS_NAME].[METHOD_NAME]
580582
```
581583

582-
<p>✅ No More Flaky Tests! SeleniumBase methods automatically wait for page elements to finish loading before interacting with them (<i>up to a timeout limit</i>). This means <b>you no longer need random <span><code translate="no">time.sleep()</code></span> statements</b> in your scripts.</p>
584+
<p>✅ No More Flaky Tests! SeleniumBase methods automatically wait for page elements to finish loading before interacting with them (<i>up to a timeout limit</i>).</p>
583585
<img src="https://img.shields.io/badge/Flaky%20Tests%3F-%20NO%21-11BBDD.svg" alt="NO MORE FLAKY TESTS!" />
584586

585587
✅ SeleniumBase supports all major browsers and operating systems:

examples/cdp_mode/ReadMe.md

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,17 @@
66

77
----
88

9-
⚙️ This diagram shows the stealthy architecture with <b>CDP Mode</b>:
9+
<h3 align="left">⚙️ Stealthy architecture flowchart:</h3>
1010

11-
<img src="https://seleniumbase.github.io/other/sb_stealth.png" width="585" alt="High-Level Stealthy Architecture Overview" title="High-Level Stealthy Architecture Overview" />
11+
<img src="https://seleniumbase.github.io/other/sb_stealth.png" width="596" alt="Stealthy architecture flowchart" />
1212

1313
----
1414

15-
### 🎞️ YouTube tutorials that cover CDP Mode:
15+
### 🎞️ YouTube videos about <b translate="no">CDP Mode</b>:
1616

1717
<!-- YouTube View --><a href="https://www.youtube.com/watch?v=Mr90iQmNsKM"><img src="https://github.com/user-attachments/assets/91e7ff7b-d155-4ba9-b17b-b097825fcf42" title="SeleniumBase on YouTube" width="320" /></a>
1818
<p>(<b><a href="https://www.youtube.com/watch?v=Mr90iQmNsKM">Watch "Undetectable Automation 4" on YouTube! ▶️</a></b>)</p>
1919

20-
(See `examples/cdp_mode/` for up-to-date examples.)
21-
2220
----
2321

2422
<!-- YouTube View --><a href="https://www.youtube.com/watch?v=vt2zsdiNh3U"><img src="https://github.com/user-attachments/assets/82ab2715-727e-4d09-9314-b8905795dc43" title="SeleniumBase on YouTube" width="320" /></a>
@@ -27,7 +25,7 @@
2725
----
2826

2927
<!-- YouTube View --><a href="https://www.youtube.com/watch?v=gEZhTfaIxHQ"><img src="https://github.com/user-attachments/assets/656977e1-5d66-4d1c-9eec-0aaa41f6522f" title="SeleniumBase on YouTube" width="320" /></a>
30-
<p>(<b><a href="https://www.youtube.com/watch?v=gEZhTfaIxHQ">Watch "Web-Scraping with GitHub Actions" on YouTube! ▶️</a></b>)</p>
28+
<p>(<b><a href="https://www.youtube.com/watch?v=gEZhTfaIxHQ">"Unlimited Free Web-Scraping with GitHub Actions" ▶️</a></b>)</p>
3129

3230
----
3331

@@ -403,12 +401,12 @@ sb.cdp.select(selector, timeout=None)
403401
sb.cdp.select_all(selector, timeout=None)
404402
sb.cdp.find_elements(selector, timeout=None)
405403
sb.cdp.find_visible_elements(selector, timeout=None)
406-
sb.cdp.click(selector, timeout=None)
407-
sb.cdp.click_if_visible(selector, timeout=0)
408-
sb.cdp.click_visible_elements(selector, limit=0)
409-
sb.cdp.click_nth_element(selector, number)
410-
sb.cdp.click_nth_visible_element(selector, number)
411-
sb.cdp.click_with_offset(selector, x, y, center=False)
404+
sb.cdp.click(selector, timeout=None, scroll=True)
405+
sb.cdp.click_if_visible(selector, timeout=0, scroll=True)
406+
sb.cdp.click_visible_elements(selector, limit=0, scroll=True)
407+
sb.cdp.click_nth_element(selector, number, scroll=True)
408+
sb.cdp.click_nth_visible_element(selector, number, scroll=True)
409+
sb.cdp.click_with_offset(selector, x, y, center=False, scroll=True)
412410
sb.cdp.click_link(link_text)
413411
sb.cdp.go_back()
414412
sb.cdp.go_forward()
@@ -428,7 +426,7 @@ sb.cdp.bring_to_front()
428426
sb.cdp.get_active_element()
429427
sb.cdp.get_active_element_css()
430428
sb.cdp.click_active_element()
431-
sb.cdp.mouse_click(selector, timeout=None)
429+
sb.cdp.mouse_click(selector, timeout=None, scroll=True)
432430
sb.cdp.nested_click(parent_selector, selector)
433431
sb.cdp.get_nested_element(parent_selector, selector)
434432
sb.cdp.select_option_by_text(dropdown_selector, option)

help_docs/ReadMe.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<!-- SeleniumBase Docs -->
22

3-
<p align="center"><a href="https://github.com/seleniumbase/SeleniumBase/"><img src="https://seleniumbase.github.io/cdn/img/sb_word_cloud.png" alt="SeleniumBase" title="SeleniumBase" width="330" /></a></p>
3+
<p align="center"><a href="https://github.com/seleniumbase/SeleniumBase/"><img src="https://seleniumbase.github.io/cdn/img/sb_word_cloud.png" alt="SeleniumBase" title="SeleniumBase" width="340" /></a></p>
44

55
<h2><a href="https://github.com/seleniumbase/SeleniumBase/"><img src="https://seleniumbase.github.io/img/logo6.png" title="SeleniumBase" width="32"></a> Help Docs</h2>
66

@@ -157,6 +157,6 @@
157157
--------
158158

159159
<p align="center"><a href="https://github.com/seleniumbase/SeleniumBase/">
160-
<img src="https://seleniumbase.github.io/img/sb_logo_10.png" alt="SeleniumBase" width="260" />
160+
<img src="https://seleniumbase.github.io/cdn/img/nice_logo_8t.png" alt="SeleniumBase" width="340" />
161161
</a></p>
162162
<!-- View on GitHub -->

help_docs/cdp_mode_methods.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ sb.cdp.select(selector, timeout=None)
2929
sb.cdp.select_all(selector, timeout=None)
3030
sb.cdp.find_elements(selector, timeout=None)
3131
sb.cdp.find_visible_elements(selector, timeout=None)
32-
sb.cdp.click(selector, timeout=None)
33-
sb.cdp.click_if_visible(selector)
34-
sb.cdp.click_visible_elements(selector, limit=0)
35-
sb.cdp.click_nth_element(selector, number)
36-
sb.cdp.click_nth_visible_element(selector, number)
37-
sb.cdp.click_with_offset(selector, x, y, center=False)
32+
sb.cdp.click(selector, timeout=None, scroll=True)
33+
sb.cdp.click_if_visible(selector, timeout=0, scroll=True)
34+
sb.cdp.click_visible_elements(selector, limit=0, scroll=True)
35+
sb.cdp.click_nth_element(selector, number, scroll=True)
36+
sb.cdp.click_nth_visible_element(selector, number, scroll=True)
37+
sb.cdp.click_with_offset(selector, x, y, center=False, scroll=True)
3838
sb.cdp.click_link(link_text)
3939
sb.cdp.go_back()
4040
sb.cdp.go_forward()
@@ -54,7 +54,7 @@ sb.cdp.bring_to_front()
5454
sb.cdp.get_active_element()
5555
sb.cdp.get_active_element_css()
5656
sb.cdp.click_active_element()
57-
sb.cdp.mouse_click(selector, timeout=None)
57+
sb.cdp.mouse_click(selector, timeout=None, scroll=True)
5858
sb.cdp.nested_click(parent_selector, selector)
5959
sb.cdp.get_nested_element(parent_selector, selector)
6060
sb.cdp.select_option_by_text(dropdown_selector, option)

help_docs/features_list.md

Lines changed: 21 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,29 @@
11
<!-- SeleniumBase Docs -->
22

3-
<!-- YouTube View --><a href="https://www.youtube.com/watch?v=EablmOazy-k"><img src="http://img.youtube.com/vi/EablmOazy-k/0.jpg" title="SeleniumBase on YouTube" width="365" /></a>
4-
<!-- GitHub Only --><p>(<b><a href="https://www.youtube.com/watch?v=EablmOazy-k">Watch the SeleniumBase tutorial from Selenium-Conf-2023 on YouTube</a></b>)</p>
5-
63
<a id="feature_list"></a>
74

85
<h2><a href="https://github.com/seleniumbase/SeleniumBase/"><img src="https://seleniumbase.github.io/img/logo6.png" title="SeleniumBase" width="32"></a> SeleniumBase Features: 🏰</h2>
96

107
* A powerful Python framework for browser automation and E2E UI testing.
11-
* Includes [Recorder Mode](https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/recorder_mode.md) for instantly generating browser tests in Python.
12-
* Supports multiple browsers, tabs, iframes, and proxies in the same test.
13-
* Includes [Test Case Management Software](https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/case_plans.md) with Markdown technology.
8+
* Has [CDP Mode](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/cdp_mode/ReadMe.md) for bypassing bot-detection. (`activate_cdp_mode(url)`)
9+
* [Stealthy Playwright Mode](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/cdp_mode/playwright/ReadMe.md) lets you bypass bot-detection with Playwright.
10+
* There's [Recorder Mode](https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/recorder_mode.md) for instantly generating browser tests in Python.
11+
* Supports [pytest](https://docs.pytest.org/en/latest/), [unittest](https://docs.python.org/3/library/unittest.html), [nose](http://nose.readthedocs.io/en/latest/), and [behave](https://behave.readthedocs.io/en/stable/index.html) for finding & running tests.
1412
* Automatic smart-waiting improves reliability and prevents flaky tests.
15-
* Supports [pytest](https://docs.pytest.org/en/latest/), [unittest](https://docs.python.org/3/library/unittest.html), [nose](http://nose.readthedocs.io/en/latest/), and [behave](https://behave.readthedocs.io/en/stable/index.html) for finding/running tests.
1613
* All the code is open source. Look inside to learn about any feature.
1714
* Powerful logging tools for [dashboards, reports, and screenshots](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/example_logs/ReadMe.md).
18-
* Can run tests in Headless Mode to hide the browser. (``--headless``)
19-
* Can run tests multithreaded from parallel browsers. (``-n NUM_THREADS``)
20-
* Can run tests from a shared browser session. (``--reuse-session``/``--rs``)
21-
* Can run tests using [Chromium's mobile device emulator](https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/mobile_testing.md). (``--mobile``)
22-
* Can run tests through a proxy server. (``--proxy=IP_ADDRESS:PORT``)
23-
* Can run tests with proxy settings via PAC URL. (``--proxy-pac-url=URL.pac``)
24-
* Can run tests through an authenticated proxy server. (``--proxy=USER:PASS@HOST:PORT``)
25-
* Can run tests with proxy+auth via PAC URL. (``--proxy-pac-url=USER:PASS@URL.pac``)
26-
* Can run tests with a customized browser user agent. (``--agent=USER_AGENT_STRING``)
27-
* Can set a Chromium User Data Directory/Profile to load. (``--user-data-dir=DIR``)
28-
* Can [avoid detection](https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/uc_mode.md) by sites that try to block Selenium. (``--undetected``/``--uc``)
29-
* Can [use CDP Mode](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/cdp_mode/ReadMe.md) for advanced stealth abilities. (``activate_cdp_mode(url)``)
30-
* Can integrate with [selenium-wire](https://github.com/wkeeling/selenium-wire) for inspecting browser requests. (``--wire``)
31-
* Can load Chrome Extension ZIP files. (``--extension-zip=ZIP``)
32-
* Can load Chrome Extension folders. (``--extension-dir=DIR``)
33-
* Powerful [console scripts](https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/console_scripts/ReadMe.md). (Type **``seleniumbase``** or **``sbase``** to use.)
15+
* Can run tests in Headless Mode to hide the browser. (`--headless`)
16+
* Can run tests multithreaded from parallel browsers. (`-n NUM_THREADS`)
17+
* Can run tests from a shared browser session. (`--reuse-session`/`--rs`)
18+
* Can run tests using [Chromium's mobile device emulator](https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/mobile_testing.md). (`--mobile`)
19+
* Can run tests through a proxy server. (`--proxy=IP_ADDRESS:PORT`)
20+
* Can run tests with proxy settings via PAC URL. (`--proxy-pac-url=URL.pac`)
21+
* Can run tests through an authenticated proxy server. (`--proxy=USER:PASS@HOST:PORT`)
22+
* Can run tests with proxy+auth via PAC URL. (`--proxy-pac-url=USER:PASS@URL.pac`)
23+
* Can run tests with a customized browser user agent. (`--agent=USER_AGENT_STRING`)
24+
* Can set a Chromium User Data Directory to load. (`--user-data-dir=DIR`)
25+
* Can load Chromium Extension folders. (`--extension-dir=DIR`)
26+
* Powerful [console scripts](https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/console_scripts/ReadMe.md). (Type **`seleniumbase`** or **`sbase`** to use.)
3427
* Has the ability to translate tests into [multiple spoken languages](https://github.com/seleniumbase/SeleniumBase/tree/master/examples/translations).
3528
* Has a flexible [command-line interface](https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/customizing_test_runs.md) for customizing test runs.
3629
* Has a [global config file](https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/config/settings.py) for configuring settings as needed.
@@ -43,19 +36,13 @@
4336
* Can handle Google Authenticator logins with [Python's one-time password library](https://pyotp.readthedocs.io/en/latest/).
4437
* Can load and make assertions on PDF files from websites or the local file system.
4538
* Can inspect HTML to find issues and points of interest with the [HTML Inspector](https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/html_inspector.md).
46-
* Is backwards-compatible with Python [WebDriver](https://www.selenium.dev/projects/) methods. (Use: ``self.driver``)
47-
* Can execute JavaScript code from Python calls. (Use: ``self.execute_script()``)
48-
* Can pierce through [Shadow DOM selectors](https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/shadow_dom.md). (Add ``::shadow`` to CSS fragments.)
39+
* Is backwards-compatible with Python [WebDriver](https://www.selenium.dev/projects/) methods. (Use: `self.driver`)
40+
* Can execute JavaScript code from Python calls. (Use: `self.execute_script()`)
41+
* Can pierce through [Shadow DOM selectors](https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/shadow_dom.md). (Add `::shadow` to CSS fragments.)
4942
* Includes a hybrid-automation solution, [MasterQA](https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/masterqa/ReadMe.md), to speed up manual testing.
43+
* Includes [Test Case Management Software](https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/case_plans.md) with Markdown technology.
5044
* Includes useful [Python decorators and password obfuscation methods](https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/common/ReadMe.md).
5145

5246
--------
5347

54-
<!-- YouTube View --><a href="https://www.youtube.com/watch?v=yEQeAU_mrg0"><img src="http://img.youtube.com/vi/yEQeAU_mrg0/0.jpg" title="SeleniumBase on YouTube" width="365" /></a>
55-
<!-- GitHub Only --><p>(<b><a href="https://www.youtube.com/watch?v=yEQeAU_mrg0">Have fun with test automation!</a></b>)</p>
56-
57-
(<b><a href="https://www.youtube.com/watch?v=Sjzq9kU5kOw">Watch the original tutorial on YouTube</a></b>)
58-
59-
<p align="left"><a href="https://github.com/seleniumbase/SeleniumBase/"><img src="https://seleniumbase.github.io/cdn/img/sb_logo_10.png" alt="SeleniumBase" title="SeleniumBase" width="240"></a></p>
60-
61-
<a href="https://github.com/seleniumbase/SeleniumBase/"><img src="https://seleniumbase.github.io/cdn/img/super_logo_sb.png" title="SeleniumBase" width="240"></a>
48+
<a href="https://github.com/seleniumbase/SeleniumBase/"><img src="https://seleniumbase.github.io/cdn/img/nice_logo_8t.png" title="SeleniumBase" width="320"></a>

0 commit comments

Comments
 (0)