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
Copy file name to clipboardexpand all lines: README.md
+57-66
Original file line number
Diff line number
Diff line change
@@ -60,21 +60,60 @@
60
60
61
61
📚 Learn from [**over 200 examples** in the **SeleniumBase/examples/** folder](https://github.com/seleniumbase/SeleniumBase/tree/master/examples).
62
62
63
-
👤 Note that <spantranslate="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 <atranslate="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>.
64
64
65
-
🐙 Also note that Seleniumbase <ahref="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/cdp_mode/ReadMe.md"><b>CDP Mode</b> has its own separate ReadMe</a>.
65
+
ℹ️ Most scripts run with raw <codetranslate="no"><b>python</b></code>, although some scripts use <ahref="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).
66
66
67
-
ℹ️ 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
+
--------
68
68
69
-
<palign="left">📗 Here's <ahref="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
+
<palign="left">📗 Here's <ahref="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/raw_google.py">raw_google.py</a>, which performs a Google search:</p>
70
70
71
-
```bash
72
-
pytest my_first_test.py
71
+
```python
72
+
from seleniumbase importSB
73
+
74
+
with SB(test=True, ad_block=True, locale_code="en") as sb:
<palign="left">📗 Here's <ahref="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/test_get_swag.py">test_get_swag.py</a>, which tests a fake shopping site:</p>
> (The default browser is ``--chrome`` if not set.)
78
117
79
118
--------
80
119
@@ -168,7 +207,7 @@ With raw Selenium, that requires more code:<br />
168
207
169
208
<p>📚 <b>Learn about different ways of writing tests:</b></p>
170
209
171
-
<palign="left">📘📝 Here's <ahref="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/test_simple_login.py">test_simple_login.py</a>, which uses <codetranslate="no"><ahref="https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/fixtures/base_case.py">BaseCase</a></code> class inheritance, and runs with <ahref="https://docs.pytest.org/en/latest/how-to/usage.html">pytest</a> or <ahref="https://github.com/mdmintz/pynose">pynose</a>. (Use <codetranslate="no">self.driver</code> to access Selenium's raw <codetranslate="no">driver</code>.)</p>
210
+
<palign="left">📗📝 Here's <ahref="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/test_simple_login.py">test_simple_login.py</a>, which uses <codetranslate="no"><ahref="https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/fixtures/base_case.py">BaseCase</a></code> class inheritance, and runs with <ahref="https://docs.pytest.org/en/latest/how-to/usage.html">pytest</a> or <ahref="https://github.com/mdmintz/pynose">pynose</a>. (Use <codetranslate="no">self.driver</code> to access Selenium's raw <codetranslate="no">driver</code>.)</p>
172
211
173
212
```python
174
213
from seleniumbase import BaseCase
@@ -187,22 +226,7 @@ class TestSimpleLogin(BaseCase):
187
226
self.assert_text("signed out", "#top_message")
188
227
```
189
228
190
-
<palign="left">📗📝 Here's a test from <ahref="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/sb_fixture_tests.py">sb_fixture_tests.py</a>, which uses the <b><codetranslate="no">sb</code></b> <codetranslate="no">pytest</code> fixture. Runs with <ahref="https://docs.pytest.org/en/latest/how-to/usage.html">pytest</a>. (Use <codetranslate="no">sb.driver</code> to access Selenium's raw <codetranslate="no">driver</code>.)</p>
191
-
192
-
```python
193
-
deftest_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
-
<palign="left">📙📝 Here's <ahref="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/raw_login_sb.py">raw_login_sb.py</a>, which uses the <b><codetranslate="no">SB</code></b> Context Manager. Runs with pure <codetranslate="no">python</code>. (Use <codetranslate="no">sb.driver</code> to access Selenium's raw <codetranslate="no">driver</code>.)</p>
229
+
<palign="left">📘📝 Here's <ahref="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/raw_login_sb.py">raw_login_sb.py</a>, which uses the <b><codetranslate="no">SB</code></b> Context Manager. Runs with pure <codetranslate="no">python</code>. (Use <codetranslate="no">sb.driver</code> to access Selenium's raw <codetranslate="no">driver</code>.)</p>
206
230
207
231
```python
208
232
from seleniumbase importSB
@@ -219,24 +243,7 @@ with SB() as sb:
219
243
sb.assert_text("signed out", "#top_message")
220
244
```
221
245
222
-
<palign="left">📔📝 Here's <ahref="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/raw_login_context.py">raw_login_context.py</a>, which uses the <b><codetranslate="no">DriverContext</code></b> Manager. Runs with pure <codetranslate="no">python</code>. (The <codetranslate="no">driver</code> is an improved version of Selenium's raw <codetranslate="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
-
<palign="left">📔📝 Here's <ahref="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/raw_login_driver.py">raw_login_driver.py</a>, which uses the <b><codetranslate="no">Driver</code></b> Manager. Runs with pure <codetranslate="no">python</code>. (The <code>driver</code> is an improved version of Selenium's raw <codetranslate="no">driver</code>, with more methods.)</p>
246
+
<palign="left">📙📝 Here's <ahref="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/raw_login_driver.py">raw_login_driver.py</a>, which uses the <b><codetranslate="no">Driver</code></b> Manager. Runs with pure <codetranslate="no">python</code>. (The <code>driver</code> is an improved version of Selenium's raw <codetranslate="no">driver</code>, with more methods.)</p>
240
247
241
248
```python
242
249
from seleniumbase import Driver
@@ -256,23 +263,6 @@ finally:
256
263
driver.quit()
257
264
```
258
265
259
-
<palign="left">📕📝 Here's <ahref="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/behave_bdd/features/login_app.feature">login_app.feature</a>, which uses <atranslate="no"href="https://behave.readthedocs.io/en/stable/gherkin.html#features"target="_blank">behave-BDD Gherkin</a> syntax. Runs with <codetranslate="no">behave</code>. (<ahref="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
-
276
266
--------
277
267
278
268
<aid="python_installation"></a>
@@ -371,20 +361,21 @@ pip install -e .
371
361
<summary> ▶️ Here's sample output from a chromedriver download. (<b>click to expand</b>)</summary>
372
362
373
363
```bash
374
-
*** chromedriver to download = 121.0.6167.85 (Latest Stable)
364
+
*** chromedriver to download = 131.0.6778.108 (Latest Stable)
<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>
0 commit comments