Skip to content

Commit c6d7dab

Browse files
committed
Update the ReadMe
1 parent b75df42 commit c6d7dab

File tree

1 file changed

+75
-41
lines changed

1 file changed

+75
-41
lines changed

README.md

+75-41
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ With raw Selenium, that requires more code:<br />
156156

157157
<p>💡 SeleniumBase gives you the option to generate a dashboard and reports for tests. It also saves screenshots from failing tests to the <code translate="no">./latest_logs/</code> folder. Raw <a href="https://www.selenium.dev/documentation/webdriver/" target="_blank">Selenium</a> does not have these options out-of-the-box.</p>
158158

159-
<p>💡 SeleniumBase includes desktop GUI apps for running tests, such as <b>SeleniumBase Commander</b> for <code translate="no">pytest</code> and <b>SeleniumBase Behave GUI for <a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/behave_bdd/ReadMe.md"><code translate="no">behave</code></a>.</b></p>
159+
<p>💡 SeleniumBase includes desktop GUI apps for running tests, such as <b translate="no">SeleniumBase Commander</b> for <code translate="no">pytest</code> and <b><span translate="no">SeleniumBase Behave GUI</span> for <a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/behave_bdd/ReadMe.md"><code translate="no">behave</code></a>.</b></p>
160160

161161
<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>
162162

@@ -165,79 +165,113 @@ With raw Selenium, that requires more code:<br />
165165

166166
--------
167167

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>
171169

172-
<p align="left">📘📝 An example test with the <b>BaseCase</b> class. Runs with <b><a href="https://docs.pytest.org/en/latest/how-to/usage.html">pytest</a></b> or <b><a href="https://github.com/mdmintz/pynose">pynose</a></b>. (<a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/ReadMe.md">Learn more</a>)</p>
170+
<p align="left">📘📝 An <a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/test_simple_login.py">example test</a> using <code translate="no"><a href="https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/fixtures/base_case.py">BaseCase</a></code> class inheritance. Runs with <b><a href="https://docs.pytest.org/en/latest/how-to/usage.html">pytest</a></b> or <b><a href="https://github.com/mdmintz/pynose">pynose</a></b>. (<a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/ReadMe.md">Learn more</a>). (Use <code translate="no">self.driver</code> to access Selenium's raw <code translate="no">driver</code>.)</p>
173171

174172
```python
175173
from seleniumbase import BaseCase
176174
BaseCase.main(__name__, __file__)
177175

178-
class TestMFALogin(BaseCase):
179-
def test_mfa_login(self):
180-
self.open("https://seleniumbase.io/realworld/login")
176+
class TestSimpleLogin(BaseCase):
177+
def test_simple_login(self):
178+
self.open("seleniumbase.io/simple/login")
181179
self.type("#username", "demo_user")
182180
self.type("#password", "secret_pass")
183-
self.enter_mfa_code("#totpcode", "GAXG2MTEOR3DMMDG") # 6-digit
181+
self.click('a:contains("Sign in")')
184182
self.assert_exact_text("Welcome!", "h1")
185183
self.assert_element("img#image1")
186-
self.click('a:contains("This Page")')
187-
self.save_screenshot_to_logs()
184+
self.highlight("#image1")
185+
self.click_link("Sign out")
186+
self.assert_text("signed out", "#top_message")
188187
```
189188

190-
<p align="left">📗📝 An example test with the <b><code translate="no">sb</code></b> <code translate="no">pytest</code> fixture. Runs with <b><a href="https://docs.pytest.org/en/latest/how-to/usage.html">pytest</a></b>.</p>
189+
<p align="left">📗📝 An <a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/sb_fixture_tests.py">example test</a> using the <b><code translate="no">sb</code></b> <code translate="no">pytest</code> fixture. Runs with <b><a href="https://docs.pytest.org/en/latest/how-to/usage.html">pytest</a></b>. (Use <code translate="no">sb.driver</code> to access Selenium's raw <code translate="no">driver</code>.)</p>
191190

192191
```python
193-
def test_mfa_login(sb):
194-
sb.open("https://seleniumbase.io/realworld/login")
192+
def test_sb_fixture_with_no_class(sb):
193+
sb.open("seleniumbase.io/simple/login")
195194
sb.type("#username", "demo_user")
196195
sb.type("#password", "secret_pass")
197-
sb.enter_mfa_code("#totpcode", "GAXG2MTEOR3DMMDG") # 6-digit
196+
sb.click('a:contains("Sign in")')
198197
sb.assert_exact_text("Welcome!", "h1")
199198
sb.assert_element("img#image1")
200-
sb.click('a:contains("This Page")')
201-
sb.save_screenshot_to_logs()
199+
sb.highlight("#image1")
200+
sb.click_link("Sign out")
201+
sb.assert_text("signed out", "#top_message")
202202
```
203203

204-
<p align="left">📙📝 An example test with the <b><code translate="no">SB</code></b> Context Manager. Runs with pure <b><code translate="no">python</code></b>.</p>
204+
<p align="left">📙📝 An <a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/raw_login_sb.py">example test</a> using the <b><code translate="no">SB</code></b> Context Manager. Runs with pure <b><code translate="no">python</code></b>. (Use <code translate="no">sb.driver</code> to access Selenium's raw <code translate="no">driver</code>.)</p>
205205

206206
```python
207207
from seleniumbase import SB
208208

209-
with SB() as sb: # By default, browser="chrome" if not set.
210-
sb.open("https://seleniumbase.io/realworld/login")
209+
with SB() as sb:
210+
sb.open("seleniumbase.io/simple/login")
211211
sb.type("#username", "demo_user")
212212
sb.type("#password", "secret_pass")
213-
sb.enter_mfa_code("#totpcode", "GAXG2MTEOR3DMMDG") # 6-digit
214-
sb.assert_text("Welcome!", "h1")
215-
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+
<p align="left">📔📝 An <a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/raw_login_context.py">example test</a> using the <b><code translate="no">DriverContext</code></b> Manager. Runs with pure <b><code translate="no">python</code></b>. (The <code translate="no">driver</code> is an improved version of Selenium's raw <code translate="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")
220236
```
221237

222-
<p align="left">📕📝 An example test with <b>behave-BDD</b> <a href="https://behave.readthedocs.io/en/stable/gherkin.html#features" target="_blank">Gherkin</a> structure. Runs with <b><code translate="no">behave</code></b>. (<a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/behave_bdd/ReadMe.md">Learn more</a>)</p>
238+
<p align="left">📔📝 An <a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/raw_login_driver.py">example test</a> using the <b><code translate="no">Driver</code></b> Manager. Runs with pure <b><code translate="no">python</code></b>. (The <code>driver</code> is an improved version of Selenium's raw <code translate="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+
<p align="left">📕📝 An <a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/behave_bdd/features/login_app.feature"> example test</a> using <b translate="no">behave-BDD</b> <a href="https://behave.readthedocs.io/en/stable/gherkin.html#features" target="_blank">Gherkin</a> syntax. Runs with <b><code translate="no">behave</code></b>. (<a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/behave_bdd/ReadMe.md">Learn more</a>)</p>
223259

224260
```gherkin
225-
Feature: SeleniumBase scenarios for the RealWorld App
261+
Feature: SeleniumBase scenarios for the Simple App
226262
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"
230266
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"
233269
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"
236273
```
237274

238-
</div>
239-
</details>
240-
241275
--------
242276

243277
<a id="python_installation"></a>
@@ -332,7 +366,7 @@ COMMANDS:
332366
333367
<div></div>
334368
<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>
336370
337371
```bash
338372
*** chromedriver to download = 116.0.5845.96 (Latest Stable)
@@ -865,7 +899,7 @@ behave behave_bdd/features/ -D dashboard -D headless
865899
866900
<img src="https://seleniumbase.github.io/cdn/img/sb_behave_dashboard.png" title="SeleniumBase" width="500">
867901
868-
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.
869903
870904
```bash
871905
behave behave_bdd/features/ --junit -D rs -D headless

0 commit comments

Comments
 (0)