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
+68-17Lines changed: 68 additions & 17 deletions
Original file line number
Diff line number
Diff line change
@@ -9,7 +9,7 @@
9
9
10
10
<h1>SeleniumBase</h1>
11
11
12
-
<h3align="center">Python-powered web automation and testing — with advanced tools.</h3>
12
+
<h3align="center">Automate & test web apps on any platform, with Python.</h3>
13
13
14
14
<h3align="center"><ahref="https://github.com/seleniumbase/SeleniumBase"><imgsrc="https://seleniumbase.github.io/cdn/gif/coffee_pdbp.gif"alt="SeleniumBase test with the pdbp debugger"title="SeleniumBase test with the pdbp debugger" /></a></h3>
<li><ahref="#creating_visual_reports"><strong>Generating Test Reports</strong></a></li>
75
+
</ul>
76
+
</blockquote>
77
+
78
+
--------
79
+
60
80
<aid="multiple_examples"></a>
81
+
<palign="left">Run <ahref="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/test_demo_site.py"target="_blank">test_demo_site.py</a> from <ahref="https://github.com/seleniumbase/SeleniumBase/tree/master/examples"target="_blank">examples/</a> (<code>--chrome</code> is the default browser):</p>
> Type text, click, select, toggle, drag-and-drop, etc. Even handle iframes.
91
+
92
+
--------
93
+
94
+
Looking for overpriced coffee? Try running this test:
95
+
61
96
<palign="left"><b>Example:</b> <ahref="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/test_coffee_cart.py"target="_blank">test_coffee_cart.py</a> from <ahref="https://github.com/seleniumbase/SeleniumBase/tree/master/examples"target="_blank">./examples/</a></p>
62
97
63
98
```bash
@@ -97,7 +132,7 @@ class CoffeeCartTest(BaseCase):
97
132
<summary> ▶️ How is <b>SeleniumBase</b> different from raw Selenium? (<b>click to expand</b>)</summary>
98
133
<div>
99
134
100
-
<p>💡 SeleniumBase is a Python framework for browser automation and testing. SeleniumBase uses <ahref="https://www.w3.org/TR/webdriver2/#endpoints"target="_blank">Selenium/WebDriver</a> APIs, and incorporates test-runners such as <code>pytest</code>, <code>nosetests</code>, and <code>behave</code> to provide organized structure, test discovery, test execution, test state (<i>eg. passed, failed, or skipped</i>), and command-line options for changing default settings (<i>such as choosing the browser to use</i>). With raw Selenium, you would need to set up your own options-parser for configuring tests from the command-line.</p>
135
+
<p>💡 SeleniumBase is a Python framework for browser automation and testing. SeleniumBase uses <ahref="https://www.w3.org/TR/webdriver2/#endpoints"target="_blank">Selenium/WebDriver</a> APIs, and incorporates test-runners such as <code>pytest</code>, <code>pynose</code>, and <code>behave</code> to provide organized structure, test discovery, test execution, test state (<i>eg. passed, failed, or skipped</i>), and command-line options for changing default settings (<i>such as choosing the browser to use</i>). With raw Selenium, you would need to set up your own options-parser for configuring tests from the command-line.</p>
101
136
102
137
<p>💡 With raw Selenium, commands that use selectors need to specify the type of selector (eg. <code>"css selector", "button#myButton"</code>). With SeleniumBase, there's auto-detection between CSS Selectors and XPath, which means you don't need to specify the type of selector in your commands (<i>but optionally you could</i>).</p>
103
138
@@ -132,7 +167,7 @@ With raw Selenium, that requires more code:<br />
132
167
<summary> ▶️ Learn about different ways of writing tests (<b>click to expand</b>)</summary>
133
168
<div>
134
169
135
-
<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>nosetests</b>. (<ahref="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/ReadMe.md">Learn more</a>)</p>
170
+
<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>pynose</b>. (<ahref="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/ReadMe.md">Learn more</a>)</p>
136
171
137
172
```python
138
173
from seleniumbase import BaseCase
@@ -206,6 +241,8 @@ Feature: SeleniumBase scenarios for the RealWorld App
206
241
<aid="python_installation"></a>
207
242
<h2><imgsrc="https://seleniumbase.github.io/cdn/img/python_logo.png"title="SeleniumBase"width="42" /> Set up Python & Git:</h2>
🔵 Add <b><ahref="https://www.python.org/downloads/">Python</a></b> and <b><ahref="https://git-scm.com/">Git</a></b> to your System PATH.
210
247
211
248
🔵 Using a <ahref="https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/virtualenv_instructions.md">Python virtual env</a> is recommended.
> SeleniumBase easily handles login, shopping, and checkout.
352
+
314
353
<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>
315
354
316
355
```python
@@ -402,12 +441,21 @@ self.assert_no_js_errors() # Verify there are no JS errors.
402
441
self.type("input", "dogs\n")
403
442
```
404
443
405
-
SeleniumBase tests can be run with <code>pytest</code>or <code>nosetests</code>. (There's also a <a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/behave_bdd/ReadMe.md">behave BDD</a> format.)
444
+
Most SeleniumBase scripts can be run with <code>pytest</code>, <code>pynose</code>, or pure <code>python</code>. Not all test runners can run all test formats. For example, tests that use the ``sb`` pytest fixture can only be run with ``pytest``. (See <a href="https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/syntax_formats.md">Syntax Formats</a>) There's also a <a href="https://behave.readthedocs.io/en/stable/gherkin.html" target="_blank">Gherkin</a>test format that runs with <a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/behave_bdd/ReadMe.md">behave</a>.
<p>✅ <code>pytest</code> includes automatic test discovery. If you don't specify a specific file or folder to run, <code>pytest</code> will automatically search through all subdirectories for tests to run based on the following criteria:</p>
@@ -423,12 +471,12 @@ With a SeleniumBase [pytest.ini](https://github.com/seleniumbase/SeleniumBase/bl
423
471
pytest --collect-only -q
424
472
```
425
473
426
-
<p>✅ You can be more specific when calling <code>pytest</code> on a file:</p>
474
+
<p>✅ You can be more specific when calling <code>pytest</code> or <code>pynose</code> on a file:</p>
<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>time.sleep()</code></span> statements</b> in your scripts.</p>
🔵 <b>Demo Mode</b> helps you see what a test is doing. If a test is moving too fast for your eyes, run it in <b>Demo Mode</b>, which pauses the browser briefly between actions, highlights page elements being acted on, and displays assertions:
454
503
@@ -605,10 +654,10 @@ Here's the command-line option to add to tests: (See [examples/custom_settings.p
605
654
🔵 To pass additional data from the command-line to tests, add ``--data="ANY STRING"``.
606
655
Inside your tests, you can use ``self.data`` to access that.
<h3><img src="https://seleniumbase.github.io/img/logo7.png" title="SeleniumBase" width="32" /> Test Directory Configuration:</h3>
610
-
611
-
🔵 When running tests with **pytest**, you'll want a copy of **[pytest.ini](https://github.com/seleniumbase/SeleniumBase/blob/master/pytest.ini)**in your root folders. When running tests with **nosetests**, you'll want a copy of **[setup.cfg](https://github.com/seleniumbase/SeleniumBase/blob/master/setup.cfg)** in your root folders. These files specify default configuration details for tests. Folders should also include a blank ``__init__.py`` file, which allows your tests to import files from that folder.
660
+
🔵 When running tests with **pytest**, you'll want a copy of **[pytest.ini](https://github.com/seleniumbase/SeleniumBase/blob/master/pytest.ini)**in your root folders. When running tests with **pynose**, you'll want a copy of **[setup.cfg](https://github.com/seleniumbase/SeleniumBase/blob/master/setup.cfg)** in your root folders. These files specify default configuration details for tests. Folders should also include a blank ``__init__.py`` file, which allows your tests to import files from that folder.
612
661
613
662
🔵 ``sbase mkdir DIR`` creates a folder with config files and sample tests:
614
663
@@ -658,7 +707,7 @@ ui_tests/
658
707
└── setup.cfg
659
708
```
660
709
661
-
Of those files, the ``pytest.ini`` config file is the most important, followed by a blank ``__init__.py`` file. There's also a ``setup.cfg`` file (only needed fornosetests). Finally, the ``requirements.txt`` file can be used to help you install seleniumbase into your environments (if it's not already installed).
710
+
Of those files, the ``pytest.ini`` config file is the most important, followed by a blank ``__init__.py`` file. There's also a ``setup.cfg`` file (for pynose). Finally, the ``requirements.txt`` file can be used to help you install seleniumbase into your environments (if it's not already installed).
662
711
663
712
--------
664
713
@@ -688,7 +737,8 @@ pytest test_fail.py
688
737
689
738
--------
690
739
691
-
<h3><img src="https://seleniumbase.github.io/img/logo7.png" title="SeleniumBase" width="32" /> The SeleniumBase Dashboard:</h3>
🔵 The ``--dashboard`` option for pytest generates a SeleniumBase Dashboard located at ``dashboard.html``, which updates automatically as tests run and produce results. Example:
694
744
@@ -747,17 +797,17 @@ You can also use ``--junit-xml=report.xml`` to get an xml report instead. Jenkin
747
797
pytest test_suite.py --junit-xml=report.xml
748
798
```
749
799
750
-
<h4><b>Nosetest Reports:</b></h4>
800
+
<h4><b>pynose Reports:</b></h4>
751
801
752
802
The ``--report`` option gives you a fancy report after your test suite completes.
(NOTE: You can add ``--show-report`` to immediately display Nosetest reports after the test suite completes. Only use ``--show-report`` when running tests locally because it pauses the test run.)
810
+
(NOTE: You can add ``--show-report`` to immediately display pynose reports after the test suite completes. Only use ``--show-report`` when running tests locally because it pauses the test run.)
<imgsrc="https://seleniumbase.github.io/cdn/img/nose_report.png"alt="Example pynose Test Report"title="Example pynose Test Report"width="320" />
102
102
103
-
(NOTE: You can add ``--show-report`` to immediately display Nosetest reports after the test suite completes. Only use ``--show-report`` when running tests locally because it pauses the test run.)
103
+
(NOTE: You can add ``--show-report`` to immediately display pynose reports after the test suite completes. Only use ``--show-report`` when running tests locally because it pauses the test run.)
0 commit comments