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
+75-41
Original file line number
Diff line number
Diff line change
@@ -156,7 +156,7 @@ With raw Selenium, that requires more code:<br />
156
156
157
157
<p>💡 SeleniumBase gives you the option to generate a dashboard and reports for tests. It also saves screenshots from failing tests to the <codetranslate="no">./latest_logs/</code> folder. Raw <ahref="https://www.selenium.dev/documentation/webdriver/"target="_blank">Selenium</a> does not have these options out-of-the-box.</p>
158
158
159
-
<p>💡 SeleniumBase includes desktop GUI apps for running tests, such as <b>SeleniumBase Commander</b> for <codetranslate="no">pytest</code> and <b>SeleniumBase Behave GUI for <ahref="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/behave_bdd/ReadMe.md"><codetranslate="no">behave</code></a>.</b></p>
159
+
<p>💡 SeleniumBase includes desktop GUI apps for running tests, such as <btranslate="no">SeleniumBase Commander</b> for <codetranslate="no">pytest</code> and <b><spantranslate="no">SeleniumBase Behave GUI</span> for <ahref="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/behave_bdd/ReadMe.md"><codetranslate="no">behave</code></a>.</b></p>
160
160
161
161
<p>💡 SeleniumBase has its own Recorder / Test Generator that can create tests from manual browser actions. SeleniumBase also includes other useful tools and console scripts for getting things done quickly. (<i>See the documentation for more details!</i>)</p>
162
162
@@ -165,79 +165,113 @@ With raw Selenium, that requires more code:<br />
165
165
166
166
--------
167
167
168
-
<details>
169
-
<summary> ▶️ Learn about different ways of writing tests (<b>click to expand</b>)</summary>
170
-
<div>
168
+
<p>📚 <b>Learn about different ways of writing tests:</b></p>
171
169
172
-
<palign="left">📘📝 An example test with the <b>BaseCase</b> class. Runs with <b><ahref="https://docs.pytest.org/en/latest/how-to/usage.html">pytest</a></b> or <b><ahref="https://github.com/mdmintz/pynose">pynose</a></b>. (<ahref="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/ReadMe.md">Learn more</a>)</p>
170
+
<palign="left">📘📝 An <ahref="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/test_simple_login.py">example test</a> using <codetranslate="no"><ahref="https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/fixtures/base_case.py">BaseCase</a></code> class inheritance. Runs with <b><ahref="https://docs.pytest.org/en/latest/how-to/usage.html">pytest</a></b> or <b><ahref="https://github.com/mdmintz/pynose">pynose</a></b>. (<ahref="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/ReadMe.md">Learn more</a>). (Use <codetranslate="no">self.driver</code> to access Selenium's raw <codetranslate="no">driver</code>.)</p>
<palign="left">📗📝 An example test with the <b><codetranslate="no">sb</code></b> <codetranslate="no">pytest</code> fixture. Runs with <b><ahref="https://docs.pytest.org/en/latest/how-to/usage.html">pytest</a></b>.</p>
189
+
<palign="left">📗📝 An <ahref="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/sb_fixture_tests.py">example test</a> using the <b><codetranslate="no">sb</code></b> <codetranslate="no">pytest</code> fixture. Runs with <b><ahref="https://docs.pytest.org/en/latest/how-to/usage.html">pytest</a></b>. (Use <codetranslate="no">sb.driver</code> to access Selenium's raw <codetranslate="no">driver</code>.)</p>
<palign="left">📙📝 An example test with the <b><codetranslate="no">SB</code></b> Context Manager. Runs with pure <b><codetranslate="no">python</code></b>.</p>
204
+
<palign="left">📙📝 An <ahref="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/raw_login_sb.py">example test</a> using the <b><codetranslate="no">SB</code></b> Context Manager. Runs with pure <b><codetranslate="no">python</code></b>. (Use <codetranslate="no">sb.driver</code> to access Selenium's raw <codetranslate="no">driver</code>.)</p>
205
205
206
206
```python
207
207
from seleniumbase importSB
208
208
209
-
with SB() as sb:# By default, browser="chrome" if not set.
sb.highlight("img#image1") # A fancier assert_element() call
216
-
sb.click('a:contains("This Page")') # Use :contains() on any tag
217
-
sb.click_link("Sign out") # Link must be "a" tag. Not "button".
218
-
sb.assert_element('a:contains("Sign in")')
219
-
sb.assert_exact_text("You have been signed out!", "#top_message")
213
+
sb.click('a:contains("Sign in")')
214
+
sb.assert_exact_text("Welcome!", "h1")
215
+
sb.assert_element("img#image1")
216
+
sb.highlight("#image1")
217
+
sb.click_link("Sign out")
218
+
sb.assert_text("signed out", "#top_message")
219
+
```
220
+
221
+
<palign="left">📔📝 An <ahref="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/raw_login_context.py">example test</a> using the <b><codetranslate="no">DriverContext</code></b> Manager. Runs with pure <b><codetranslate="no">python</code></b>. (The <codetranslate="no">driver</code> is an improved version of Selenium's raw <codetranslate="no">driver</code>, with more methods.)</p>
222
+
223
+
```python
224
+
from seleniumbase import DriverContext
225
+
226
+
with DriverContext() as driver:
227
+
driver.open("seleniumbase.io/simple/login")
228
+
driver.type("#username", "demo_user")
229
+
driver.type("#password", "secret_pass")
230
+
driver.click('a:contains("Sign in")')
231
+
driver.assert_exact_text("Welcome!", "h1")
232
+
driver.assert_element("img#image1")
233
+
driver.highlight("#image1")
234
+
driver.click_link("Sign out")
235
+
driver.assert_text("signed out", "#top_message")
220
236
```
221
237
222
-
<palign="left">📕📝 An example test with <b>behave-BDD</b> <ahref="https://behave.readthedocs.io/en/stable/gherkin.html#features"target="_blank">Gherkin</a> structure. Runs with <b><codetranslate="no">behave</code></b>. (<ahref="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/behave_bdd/ReadMe.md">Learn more</a>)</p>
238
+
<palign="left">📔📝 An <ahref="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/raw_login_driver.py">example test</a> using the <b><codetranslate="no">Driver</code></b> Manager. Runs with pure <b><codetranslate="no">python</code></b>. (The <code>driver</code> is an improved version of Selenium's raw <codetranslate="no">driver</code>, with more methods.)</p>
239
+
240
+
```python
241
+
from seleniumbase import Driver
242
+
243
+
driver = Driver()
244
+
try:
245
+
driver.open("seleniumbase.io/simple/login")
246
+
driver.type("#username", "demo_user")
247
+
driver.type("#password", "secret_pass")
248
+
driver.click('a:contains("Sign in")')
249
+
driver.assert_exact_text("Welcome!", "h1")
250
+
driver.assert_element("img#image1")
251
+
driver.highlight("#image1")
252
+
driver.click_link("Sign out")
253
+
driver.assert_text("signed out", "#top_message")
254
+
finally:
255
+
driver.quit()
256
+
```
257
+
258
+
<palign="left">📕📝 An <ahref="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/behave_bdd/features/login_app.feature"> example test</a> using <btranslate="no">behave-BDD</b> <ahref="https://behave.readthedocs.io/en/stable/gherkin.html#features"target="_blank">Gherkin</a> syntax. Runs with <b><codetranslate="no">behave</code></b>. (<ahref="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/behave_bdd/ReadMe.md">Learn more</a>)</p>
223
259
224
260
```gherkin
225
-
Feature: SeleniumBase scenarios for the RealWorld App
261
+
Feature: SeleniumBase scenarios for the Simple App
226
262
227
-
Scenario: Verify RealWorld App
228
-
Given Open "seleniumbase.io/realworld/login"
229
-
When Type "demo_user" into "#username"
263
+
Scenario: Verify the Simple App (Login / Logout)
264
+
Given Open "seleniumbase.io/simple/login"
265
+
And Type "demo_user" into "#username"
230
266
And Type "secret_pass" into "#password"
231
-
And Do MFA "GAXG2MTEOR3DMMDG" into "#totpcode"
232
-
Then Assert exact text "Welcome!" in "h1"
267
+
And Click 'a:contains("Sign in")'
268
+
And Assert exact text "Welcome!" in "h1"
233
269
And Assert element "img#image1"
234
-
And Click 'a:contains("This Page")'
235
-
And Save screenshot to logs
270
+
And Highlight "#image1"
271
+
And Click link "Sign out"
272
+
And Assert text "signed out" in "#top_message"
236
273
```
237
274
238
-
</div>
239
-
</details>
240
-
241
275
--------
242
276
243
277
<aid="python_installation"></a>
@@ -332,7 +366,7 @@ COMMANDS:
332
366
333
367
<div></div>
334
368
<details>
335
-
<summary> ▶️ Here's output from a chromedriver download. (<b>click to expand</b>)</summary>
369
+
<summary> ▶️ Here's sample output from a chromedriver download. (<b>click to expand</b>)</summary>
336
370
337
371
```bash
338
372
*** chromedriver to download = 116.0.5845.96 (Latest Stable)
You can also use ``--junit`` to get ``.xml`` reports for each Behave feature. Jenkins can use these files to display better reporting for your tests.
902
+
You can also use ``--junit`` to get ``.xml`` reports for each <code translate="no">behave</code> feature. Jenkins can use these files to display better reporting for your tests.
0 commit comments