Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 907a984

Browse files
authored
Merge pull request #3342 from seleniumbase/cdp-mode-patch-21
CDP Mode - Patch 21
2 parents c2d144e + b9ebe70 commit 907a984

File tree

22 files changed

+298
-115
lines changed

22 files changed

+298
-115
lines changed

‎README.md

Lines changed: 57 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -60,21 +60,60 @@
6060

6161
📚 Learn from [**over 200 examples** in the **SeleniumBase/examples/** folder](https://github.com/seleniumbase/SeleniumBase/tree/master/examples).
6262

63-
👤 Note that <span translate="no">SeleniumBase</span> <atranslate="no"href="https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/uc_mode.md"><b>UC Mode</b> (Stealth Mode) has its own ReadMe</a>.
63+
🐙 Note that <a translate="no"href="https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/uc_mode.md"><b>UC Mode</b></a> and <ahref="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/cdp_mode/ReadMe.md"><b>CDP Mode</b></a> (Stealth Mode) have separate docs</a>.
6464

65-
🐙 Also note that Seleniumbase <a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/cdp_mode/ReadMe.md"><b>CDP Mode</b> has its own separate ReadMe</a>.
65+
i️ Most scripts run with raw <codetranslate="no"><b>python</b></code>, although some scripts use <a href="https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/syntax_formats.md">Syntax Formats</a> that expect <ahref="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).
6666

67-
i️ Scripts can be called via <codetranslate="no"><b>python</b></code>, although some <ahref="https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/syntax_formats.md">Syntax Formats</a> expect <ahref="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).
67+
--------
6868

69-
<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>
69+
<p align="left">📗 Here's <a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/raw_google.py">raw_google.py</a>, which performs a Google search:</p>
7070

71-
```bash
72-
pytest my_first_test.py
71+
```python
72+
from seleniumbase import SB
73+
74+
with SB(test=True, ad_block=True, locale_code="en") as sb:
75+
sb.open("https://google.com/ncr")
76+
sb.type('[title="Search"]', "SeleniumBase GitHub page\n")
77+
sb.click('[href*="github.com/seleniumbase/SeleniumBase"]')
78+
sb.save_screenshot_to_logs() # (See ./latest_logs folder)
79+
print(sb.get_page_title())
7380
```
7481

75-
<ahref="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/my_first_test.py"><imgsrc="https://seleniumbase.github.io/cdn/gif/fast_swag_2.gif"alt="SeleniumBase Test"title="SeleniumBase Test"width="520" /></a>
82+
> `python raw_google.py`
7683
77-
> ``pytest`` uses ``--chrome`` by default unless set differently.
84+
<a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/raw_google.py"><img src="https://seleniumbase.github.io/cdn/gif/google_search.gif" alt="SeleniumBase Test" title="SeleniumBase Test" width="480" /></a>
85+
86+
--------
87+
88+
<p align="left">📗 Here's <a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/test_get_swag.py">test_get_swag.py</a>, which tests a fake shopping site:</p>
89+
90+
```python
91+
from seleniumbase import BaseCase
92+
BaseCase.main(__name__, __file__) # Call pytest
93+
94+
class MyTestClass(BaseCase):
95+
def test_swag_labs(self):
96+
self.open("https://www.saucedemo.com")
97+
self.type("#user-name", "standard_user")
98+
self.type("#password", "secret_sauce\n")
99+
self.assert_element("div.inventory_list")
100+
self.click('button[name*="backpack"]')
101+
self.click("#shopping_cart_container a")
102+
self.assert_text("Backpack", "div.cart_item")
103+
self.click("button#checkout")
104+
self.type("input#first-name", "SeleniumBase")
105+
self.type("input#last-name", "Automation")
106+
self.type("input#postal-code", "77123")
107+
self.click("input#continue")
108+
self.click("button#finish")
109+
self.assert_text("Thank you for your order!")
110+
```
111+
112+
> `pytest test_get_swag.py`
113+
114+
<a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/test_get_swag.py"><img src="https://seleniumbase.github.io/cdn/gif/fast_swag_2.gif" alt="SeleniumBase Test" title="SeleniumBase Test" width="520" /></a>
115+
116+
> (The default browser is ``--chrome`` if not set.)
78117
79118
--------
80119

@@ -168,7 +207,7 @@ With raw Selenium, that requires more code:<br />
168207

169208
<p>📚 <b>Learn about different ways of writing tests:</b></p>
170209

171-
<p align="left">📘📝 Here's <a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/test_simple_login.py">test_simple_login.py</a>, which uses <code translate="no"><a href="https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/fixtures/base_case.py">BaseCase</a></code> class inheritance, and runs with <a href="https://docs.pytest.org/en/latest/how-to/usage.html">pytest</a> or <a href="https://github.com/mdmintz/pynose">pynose</a>. (Use <code translate="no">self.driver</code> to access Selenium's raw <code translate="no">driver</code>.)</p>
210+
<p align="left">📗📝 Here's <a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/test_simple_login.py">test_simple_login.py</a>, which uses <code translate="no"><a href="https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/fixtures/base_case.py">BaseCase</a></code> class inheritance, and runs with <a href="https://docs.pytest.org/en/latest/how-to/usage.html">pytest</a> or <a href="https://github.com/mdmintz/pynose">pynose</a>. (Use <code translate="no">self.driver</code> to access Selenium's raw <code translate="no">driver</code>.)</p>
172211

173212
```python
174213
from seleniumbase import BaseCase
@@ -187,22 +226,7 @@ class TestSimpleLogin(BaseCase):
187226
self.assert_text("signed out", "#top_message")
188227
```
189228

190-
<p align="left">📗📝 Here's a test from <a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/sb_fixture_tests.py">sb_fixture_tests.py</a>, which uses the <b><code translate="no">sb</code></b> <code translate="no">pytest</code> fixture. Runs with <a href="https://docs.pytest.org/en/latest/how-to/usage.html">pytest</a>. (Use <code translate="no">sb.driver</code> to access Selenium's raw <code translate="no">driver</code>.)</p>
191-
192-
```python
193-
def test_sb_fixture_with_no_class(sb):
194-
sb.open("seleniumbase.io/simple/login")
195-
sb.type("#username", "demo_user")
196-
sb.type("#password", "secret_pass")
197-
sb.click('a:contains("Sign in")')
198-
sb.assert_exact_text("Welcome!", "h1")
199-
sb.assert_element("img#image1")
200-
sb.highlight("#image1")
201-
sb.click_link("Sign out")
202-
sb.assert_text("signed out", "#top_message")
203-
```
204-
205-
<p align="left">📙📝 Here's <a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/raw_login_sb.py">raw_login_sb.py</a>, which uses the <b><code translate="no">SB</code></b> Context Manager. Runs with pure <code translate="no">python</code>. (Use <code translate="no">sb.driver</code> to access Selenium's raw <code translate="no">driver</code>.)</p>
229+
<p align="left">📘📝 Here's <a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/raw_login_sb.py">raw_login_sb.py</a>, which uses the <b><code translate="no">SB</code></b> Context Manager. Runs with pure <code translate="no">python</code>. (Use <code translate="no">sb.driver</code> to access Selenium's raw <code translate="no">driver</code>.)</p>
206230

207231
```python
208232
from seleniumbase import SB
@@ -219,24 +243,7 @@ with SB() as sb:
219243
sb.assert_text("signed out", "#top_message")
220244
```
221245

222-
<p align="left">📔📝 Here's <a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/raw_login_context.py">raw_login_context.py</a>, which uses the <b><code translate="no">DriverContext</code></b> Manager. Runs with pure <code translate="no">python</code>. (The <code translate="no">driver</code> is an improved version of Selenium's raw <code translate="no">driver</code>, with more methods.)</p>
223-
224-
```python
225-
from seleniumbase import DriverContext
226-
227-
with DriverContext() as driver:
228-
driver.open("seleniumbase.io/simple/login")
229-
driver.type("#username", "demo_user")
230-
driver.type("#password", "secret_pass")
231-
driver.click('a:contains("Sign in")')
232-
driver.assert_exact_text("Welcome!", "h1")
233-
driver.assert_element("img#image1")
234-
driver.highlight("#image1")
235-
driver.click_link("Sign out")
236-
driver.assert_text("signed out", "#top_message")
237-
```
238-
239-
<p align="left">📔📝 Here's <a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/raw_login_driver.py">raw_login_driver.py</a>, which uses the <b><code translate="no">Driver</code></b> Manager. Runs with pure <code translate="no">python</code>. (The <code>driver</code> is an improved version of Selenium's raw <code translate="no">driver</code>, with more methods.)</p>
246+
<p align="left">📙📝 Here's <a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/raw_login_driver.py">raw_login_driver.py</a>, which uses the <b><code translate="no">Driver</code></b> Manager. Runs with pure <code translate="no">python</code>. (The <code>driver</code> is an improved version of Selenium's raw <code translate="no">driver</code>, with more methods.)</p>
240247

241248
```python
242249
from seleniumbase import Driver
@@ -256,23 +263,6 @@ finally:
256263
driver.quit()
257264
```
258265

259-
<p align="left">📕📝 Here's <a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/behave_bdd/features/login_app.feature">login_app.feature</a>, which uses <a translate="no" href="https://behave.readthedocs.io/en/stable/gherkin.html#features" target="_blank">behave-BDD Gherkin</a> syntax. Runs with <code translate="no">behave</code>. (<a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/behave_bdd/ReadMe.md">Learn about the <b>SeleniumBase behave-BDD</b> integration</a>)</p>
260-
261-
```gherkin
262-
Feature: SeleniumBase scenarios for the Simple App
263-
264-
Scenario: Verify the Simple App (Login / Logout)
265-
Given Open "seleniumbase.io/simple/login"
266-
And Type "demo_user" into "#username"
267-
And Type "secret_pass" into "#password"
268-
And Click 'a:contains("Sign in")'
269-
And Assert exact text "Welcome!" in "h1"
270-
And Assert element "img#image1"
271-
And Highlight "#image1"
272-
And Click link "Sign out"
273-
And Assert text "signed out" in "#top_message"
274-
```
275-
276266
--------
277267

278268
<a id="python_installation"></a>
@@ -371,20 +361,21 @@ pip install -e .
371361
<summary> ▶️ Here's sample output from a chromedriver download. (<b>click to expand</b>)</summary>
372362
373363
```bash
374-
*** chromedriver to download = 121.0.6167.85 (Latest Stable)
364+
*** chromedriver to download = 131.0.6778.108 (Latest Stable)
375365
376366
Downloading chromedriver-mac-arm64.zip from:
377-
https://storage.googleapis.com/chrome-for-testing-public/121.0.6167.85/mac-arm64/chromedriver-mac-arm64.zip ...
367+
https://storage.googleapis.com/chrome-for-testing-public/131.0.6778.108/mac-arm64/chromedriver-mac-arm64.zip ...
378368
Download Complete!
379369
380370
Extracting ['chromedriver'] from chromedriver-mac-arm64.zip ...
381371
Unzip Complete!
382372
383373
The file [chromedriver] was saved to:
384-
/Users/michael/github/SeleniumBase/seleniumbase/drivers/chromedriver
374+
~/github/SeleniumBase/seleniumbase/drivers/
375+
chromedriver
385376
386-
Making [chromedriver 121.0.6167.85] executable ...
387-
[chromedriver 121.0.6167.85] is now ready for use!
377+
Making [chromedriver 131.0.6778.108] executable ...
378+
[chromedriver 131.0.6778.108] is now ready for use!
388379
```
389380
390381
</details>
@@ -404,7 +395,7 @@ pytest my_first_test.py
404395
405396
<a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/my_first_test.py"><img src="https://seleniumbase.github.io/cdn/gif/fast_swag_2.gif" alt="SeleniumBase Test" title="SeleniumBase Test" width="520" /></a>
406397
407-
<p align="left"><b>Here's the code for <a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/my_first_test.py">my_first_test.py</a>:</b></p>
398+
<p align="left"><b>Here's the full code for <a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/my_first_test.py">my_first_test.py</a>:</b></p>
408399

409400
```python
410401
from seleniumbase import BaseCase

‎examples/ReadMe.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
* <b>SeleniumBase</b> tests are run with <b>pytest</b>.
88
* Chrome is the default browser if not specified.
9-
* Tests are structured using [23 unique syntax formats](https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/syntax_formats.md).
9+
* Tests are structured using [25 unique syntax formats](https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/syntax_formats.md).
1010
* Logs from test failures are saved to ``./latest_logs/``.
1111
* Tests can be run with [multiple command-line options](https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/customizing_test_runs.md).
1212
* Examples can be found in: **[SeleniumBase/examples/](https://github.com/seleniumbase/SeleniumBase/tree/master/examples)**.

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /