Update the docs
This commit is contained in:
parent
ac06aa8fa3
commit
3bfa7ed196
|
@ -502,7 +502,7 @@ Using ``--html=report.html`` gives you a fancy report of the name specified afte
|
|||
pytest test_suite.py --html=report.html
|
||||
```
|
||||
|
||||
<img src="https://cdn2.hubspot.net/hubfs/100006/images/pytest_report_3c.png" alt="Example Pytest Report" title="Example Pytest Report" width="520" />
|
||||
<img src="https://seleniumbase.io/cdn/img/html_report.png" alt="Example Pytest Report" title="Example Pytest Report" width="520" />
|
||||
|
||||
You can also use ``--junit-xml=report.xml`` to get an xml report instead. Jenkins can use this file to display better reporting for your tests.
|
||||
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
<p align="center"><a align="center" href="https://github.com/seleniumbase/SeleniumBase/blob/master/README.md"><img align="center" src="https://seleniumbase.io/cdn/img/sb_demo_page.png" alt="SeleniumBase" width="288" /></a></p>
|
||||
<img src="https://seleniumbase.io/cdn/img/sb_logo_b.png" title="SeleniumBase" width="300" />
|
||||
|
||||
<h2><img src="https://seleniumbase.io/img/logo3a.png" title="SeleniumBase" width="32" /> Running Example Tests:</h2>
|
||||
|
||||
SeleniumBase tests are run with <b>pytest</b>. Chrome is the default browser if not specifed. During test failures, logs and screenshots from the latest run are saved to the ``latest_logs/`` folder.
|
||||
<p align="left"><a align="center" href="https://github.com/seleniumbase/SeleniumBase/blob/master/README.md"><img align="center" src="https://seleniumbase.io/cdn/img/sb_demo_page.png" alt="SeleniumBase" width="300" /></a></p>
|
||||
|
||||
<b>SeleniumBase</b> tests are run with <b>pytest</b>. Chrome is the default browser if not specifed. During test failures, logs and screenshots from the latest run are saved to the ``latest_logs/`` folder.
|
||||
|
||||
* Example tests are located in <b>[SeleniumBase/examples](https://github.com/seleniumbase/SeleniumBase/tree/master/examples)</b>.
|
||||
|
||||
|
@ -11,90 +13,111 @@ SeleniumBase tests are run with <b>pytest</b>. Chrome is the default browser if
|
|||
**Here are some example run commands to help get you started:**
|
||||
|
||||
Run an example test in Chrome: (Default: ``--browser=chrome``)
|
||||
|
||||
```bash
|
||||
pytest my_first_test.py
|
||||
```
|
||||
|
||||
Run an example test in Firefox:
|
||||
|
||||
```bash
|
||||
pytest my_first_test.py --browser=firefox
|
||||
```
|
||||
|
||||
Run an example test in Demo Mode: (highlight assertions)
|
||||
|
||||
```bash
|
||||
pytest my_first_test.py --demo
|
||||
```
|
||||
|
||||
<img src="https://cdn2.hubspot.net/hubfs/100006/images/my_first_test_gif.gif" title="SeleniumBase Demo Mode" /><br />
|
||||
|
||||
Run a different example in Demo Mode:
|
||||
|
||||
```bash
|
||||
pytest test_swag_labs.py --demo
|
||||
```
|
||||
|
||||
<img src="https://cdn2.hubspot.net/hubfs/100006/images/swag_labs_gif.gif" /><br />
|
||||
|
||||
Run an example test in Headless Mode: (invisible browser)
|
||||
|
||||
```bash
|
||||
pytest my_first_test.py --headless
|
||||
```
|
||||
|
||||
Run an example test using Chrome's mobile device emulator: (default settings)
|
||||
|
||||
```bash
|
||||
pytest test_swag_labs.py --mobile
|
||||
```
|
||||
|
||||
<img src="https://cdn2.hubspot.net/hubfs/100006/images/swag_mobile.gif" title="SeleniumBase Mobile Mode" /><br />
|
||||
|
||||
Run tests with verbose output: (includes more details)
|
||||
|
||||
```bash
|
||||
pytest test_suite.py -v
|
||||
```
|
||||
|
||||
Run a test on the Demo Site to try many SeleniumBase methods:
|
||||
|
||||
```bash
|
||||
pytest test_demo_site.py
|
||||
```
|
||||
|
||||
<img src="https://cdn2.hubspot.net/hubfs/100006/images/demo_page.gif" title="SeleniumBase Mobile Mode" /><br />
|
||||
|
||||
Run tests multi-threaded using [n] threads:
|
||||
|
||||
```bash
|
||||
pytest test_suite.py -v -n=4
|
||||
```
|
||||
|
||||
Run a parameterized test: (Generates multiple tests from one)
|
||||
|
||||
```bash
|
||||
pytest parameterized_test.py -v
|
||||
```
|
||||
|
||||
Run a test suite and generate a pytest report: (pytest-only)
|
||||
|
||||
```bash
|
||||
pytest test_suite.py -v --html=report.html
|
||||
```
|
||||
|
||||
Run a failing test: (See the ``latest_logs/`` folder for logs and screenshots)
|
||||
|
||||
```bash
|
||||
pytest test_fail.py
|
||||
```
|
||||
|
||||
Run a failing test with Debug-mode enabled: (``pdb`` activates on failures)
|
||||
|
||||
```bash
|
||||
pytest test_fail.py --pdb -s
|
||||
```
|
||||
|
||||
Run an example test suite that demonstrates the use of pytest markers:
|
||||
|
||||
```bash
|
||||
pytest -m marker_test_suite -v
|
||||
```
|
||||
|
||||
Run an example test suite that reuses the browser session between tests:
|
||||
|
||||
```bash
|
||||
pytest test_suite.py --reuse-session -v
|
||||
```
|
||||
|
||||
Run an example test demonstrating the ``rate_limited`` Python decorator:
|
||||
|
||||
```bash
|
||||
pytest rate_limiting_test.py
|
||||
```
|
||||
|
||||
Run an example test that demonstrates how to upload a file to a website:
|
||||
|
||||
```bash
|
||||
pytest upload_file_test.py
|
||||
```
|
||||
|
@ -104,16 +127,19 @@ pytest upload_file_test.py
|
|||
<b>SeleniumBase tests can also be run with ``nosetests``:</b>
|
||||
|
||||
Run an example test with nosetests:
|
||||
|
||||
```bash
|
||||
nosetests my_first_test.py
|
||||
```
|
||||
|
||||
Run an example test suite and generate a nosetest report: (nosetests-only)
|
||||
|
||||
```bash
|
||||
nosetests test_suite.py --report --show-report
|
||||
```
|
||||
|
||||
Run an example test using a nosetest configuration file: (nosetests-only)
|
||||
|
||||
```bash
|
||||
nosetests my_first_test.py --config=example_config.cfg
|
||||
```
|
||||
|
@ -127,6 +153,7 @@ To make things easier, here's a simple GUI program that allows you to run a few
|
|||
```bash
|
||||
python gui_test_runner.py
|
||||
```
|
||||
|
||||
<img src="https://cdn2.hubspot.net/hubfs/100006/images/gui_test_runner_py.png" title="GUI Test Runner" width="320" />
|
||||
|
||||
--------
|
||||
|
|
|
@ -170,26 +170,31 @@ SeleniumBase lets you run tests on remote Selenium Grids such as [BrowserStack](
|
|||
(For setting browser desired capabilities while running Selenium remotely, see the ReadMe located here: https://github.com/seleniumbase/SeleniumBase/tree/master/examples/capabilities)
|
||||
|
||||
Here's how to connect to a BrowserStack Selenium Grid server for running tests:
|
||||
|
||||
```bash
|
||||
pytest my_first_test.py --server=USERNAME:KEY@hub.browserstack.com --port=80
|
||||
```
|
||||
|
||||
Here's how to connect to a Sauce Labs Selenium Grid server for running tests:
|
||||
|
||||
```bash
|
||||
pytest my_first_test.py --server=USERNAME:KEY@ondemand.saucelabs.com --port=80
|
||||
```
|
||||
|
||||
Here's how to connect to a TestingBot Selenium Grid server for running tests:
|
||||
|
||||
```bash
|
||||
pytest my_first_test.py --server=USERNAME:KEY@hub.testingbot.com --port=80
|
||||
```
|
||||
|
||||
Here's how to connect to a CrossBrowserTesting Selenium Grid server for running tests:
|
||||
|
||||
```bash
|
||||
pytest my_first_test.py --server=USERNAME:KEY@hub.crossbrowsertesting.com --port=80
|
||||
```
|
||||
|
||||
Here's how to connect to a LambdaTest Selenium Grid server for running tests:
|
||||
|
||||
```bash
|
||||
pytest my_first_test.py --server=USERNAME:KEY@hub.lambdatest.com --port=80
|
||||
```
|
||||
|
@ -229,6 +234,7 @@ To run Pytest multithreaded on multiple CPUs at the same time, add ``-n=NUM`` or
|
|||
### <img src="https://seleniumbase.io/img/logo3a.png" title="SeleniumBase" width="28" /> Retrying failing tests automatically:
|
||||
|
||||
You can use ``--reruns=NUM`` to retry failing tests that many times. Use ``--reruns-delay=SECONDS`` to wait that many seconds between retries. Example:
|
||||
|
||||
```
|
||||
pytest --reruns=2 --reruns-delay=1
|
||||
```
|
||||
|
@ -258,7 +264,8 @@ Using ``--html=report.html`` gives you a fancy report of the name specified afte
|
|||
```bash
|
||||
pytest test_suite.py --html=report.html
|
||||
```
|
||||
<img src="https://cdn2.hubspot.net/hubfs/100006/images/pytest_report_3c.png" alt="Example Pytest Report" title="Example Pytest Report" width="520" />
|
||||
|
||||
<img src="https://seleniumbase.io/cdn/img/html_report.png" alt="Example Pytest Report" title="Example Pytest Report" width="520" />
|
||||
|
||||
### <img src="https://seleniumbase.io/img/logo3a.png" title="SeleniumBase" width="28" /> Nosetest Reports:
|
||||
|
||||
|
@ -267,6 +274,7 @@ The ``--report`` option gives you a fancy report after your test suite completes
|
|||
```bash
|
||||
nosetests test_suite.py --report
|
||||
```
|
||||
|
||||
<img src="https://cdn2.hubspot.net/hubfs/100006/images/Test_Report_2.png" alt="Example Nosetest Report" title="Example Nosetest Report" width="320" />
|
||||
|
||||
(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.)
|
||||
|
@ -313,4 +321,5 @@ pytest test_swag_labs.py --mobile --metrics="411,731,3"
|
|||
# Run mobile tests specifying the user agent
|
||||
pytest test_swag_labs.py --mobile --agent="Mozilla/5.0 (Linux; Android 9; Pixel 3 XL)"
|
||||
```
|
||||
|
||||
[<img src="https://seleniumbase.io/cdn/img/fancy_logo_14.png" title="SeleniumBase" width="290">](https://github.com/seleniumbase/SeleniumBase/blob/master/README.md)
|
||||
|
|
Loading…
Reference in New Issue