Update the docs

This commit is contained in:
Michael Mintz 2021-11-17 19:20:43 -05:00
parent 65f33d1ba1
commit 3d7d272173
3 changed files with 35 additions and 28 deletions

View File

@ -22,10 +22,10 @@ pytest test_demo_site.py --headless
# Run tests multi-threaded using [n] threads
pytest test_suite.py -n=4
# Reuse the browser session for all tests being run
# Reuse the browser session for all tests ("--rs")
pytest test_suite.py --reuse-session
# Reuse the browser session, but empty cookies between tests
# Reuse the browser session, but erase cookies between tests
pytest test_suite.py --reuse-session --crumbs
# Create a real-time dashboard for test results
@ -182,7 +182,7 @@ sbase options
--------
<h3><img src="https://seleniumbase.io/img/logo6.png" title="SeleniumBase" width="28" /> Example tests using Logging:</h3>
<h3><img src="https://seleniumbase.io/img/green_logo.png" title="SeleniumBase" width="32" /> Example tests using Logging:</h3>
To see logging abilities, you can run a test suite that includes tests that fail on purpose:
@ -192,7 +192,7 @@ pytest test_suite.py
🔵 During test failures, logs and screenshots from the most recent test run will get saved to the ``latest_logs/`` folder. If ``--archive-logs`` is specified (or if ARCHIVE_EXISTING_LOGS is set to True in [settings.py](https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/config/settings.py)), test logs will also get archived to the ``archived_logs/`` folder. Otherwise, the log files will be cleaned out when the next test run begins (by default).
<h3><img src="https://seleniumbase.io/img/logo6.png" title="SeleniumBase" width="28" /> Demo Mode:</h3>
<h3><img src="https://seleniumbase.io/img/green_logo.png" title="SeleniumBase" width="32" /> Demo Mode:</h3>
If any test is moving too fast for your eyes to see what's going on, you can run it in **Demo Mode** by adding ``--demo`` on the command line, which pauses the browser briefly between actions, highlights page elements being acted on, and lets you know what test assertions are happening in real time:
@ -206,15 +206,15 @@ You can override the default wait time by either updating [settings.py](https://
pytest my_first_test.py --demo --demo-sleep=1.2
```
<h3><img src="https://seleniumbase.io/img/logo6.png" title="SeleniumBase" width="28" /> Passing additional data to tests:</h3>
<h3><img src="https://seleniumbase.io/img/green_logo.png" title="SeleniumBase" width="32" /> Passing additional data to tests:</h3>
If you want to pass additional data from the command line to your tests, you can use ``--data=STRING``. Now inside your tests, you can use ``self.data`` to access that.
<h3><img src="https://seleniumbase.io/img/logo6.png" title="SeleniumBase" width="28" /> Running tests multithreaded:</h3>
<h3><img src="https://seleniumbase.io/img/green_logo.png" title="SeleniumBase" width="32" /> Running tests multithreaded:</h3>
To run pytest tests using multiple processes, add ``-n=NUM`` or ``-n NUM`` on the command line, where NUM is the number of CPUs you want to use.
<h3><img src="https://seleniumbase.io/img/logo6.png" title="SeleniumBase" width="28" /> Retrying failing tests automatically:</h3>
<h3><img src="https://seleniumbase.io/img/green_logo.png" title="SeleniumBase" width="32" /> Retrying failing tests automatically:</h3>
You can use ``--reruns=NUM`` to retry failing tests that many times. Use ``--reruns-delay=SECONDS`` to wait that many seconds between retries. Example:
@ -222,7 +222,7 @@ You can use ``--reruns=NUM`` to retry failing tests that many times. Use ``--rer
pytest --reruns=1 --reruns-delay=1
```
<h3><img src="https://seleniumbase.io/img/logo6.png" title="SeleniumBase" width="28" /> Debugging tests:</h3>
<h3><img src="https://seleniumbase.io/img/green_logo.png" title="SeleniumBase" width="32" /> Debugging tests:</h3>
You can use the following calls in your scripts to help you debug issues:
@ -240,7 +240,7 @@ pytest my_first_test.py --pdb -s
The code above will leave your browser window open in case there's a failure. (ipdb commands: 'c', 's', 'n' => continue, step, next).
<h3><img src="https://seleniumbase.io/img/logo6.png" title="SeleniumBase" width="28" /> Combinations of options:</h3>
<h3><img src="https://seleniumbase.io/img/green_logo.png" title="SeleniumBase" width="32" /> Combinations of options:</h3>
There are times when you'll want to combine various command-line options for added effect.
For instance, the multi-process option, ``-n=4``, can be customized by adding:
@ -261,7 +261,7 @@ The above not only runs tests in parallel processes, but it also tells tests in
--------
<h3><img src="https://seleniumbase.io/img/logo6.png" title="SeleniumBase" width="32" /> The SeleniumBase Dashboard:</h3>
<h3><img src="https://seleniumbase.io/img/green_logo.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:
@ -289,7 +289,7 @@ pytest test_suite.py --dashboard --rs --headless
--------
<h3><img src="https://seleniumbase.io/img/logo6.png" title="SeleniumBase" width="32" /> Pytest Reports:</h3>
<h3><img src="https://seleniumbase.io/img/green_logo.png" title="SeleniumBase" width="32" /> Pytest Reports:</h3>
🔵 Using ``--html=report.html`` gives you a fancy report of the name specified after your test suite completes.
@ -319,7 +319,7 @@ pytest test_suite.py --junit-xml=report.xml
--------
<h3><img src="https://seleniumbase.io/img/logo6.png" title="SeleniumBase" width="28" /> Nosetest Reports:</h3>
<h3><img src="https://seleniumbase.io/img/green_logo.png" title="SeleniumBase" width="32" /> Nosetest Reports:</h3>
The ``--report`` option gives you a fancy report after your test suite completes.
@ -333,7 +333,7 @@ nosetests test_suite.py --report
--------
<h3><img src="https://seleniumbase.io/img/logo6.png" title="SeleniumBase" width="28" /> Customizing default settings:</h3>
<h3><img src="https://seleniumbase.io/img/green_logo.png" title="SeleniumBase" width="32" /> Customizing default settings:</h3>
An easy way to override [seleniumbase/config/settings.py](https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/config/settings.py) is by using a custom settings file.
Here's the command-line option to add to tests: (See [examples/custom_settings.py](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/custom_settings.py))
@ -342,9 +342,9 @@ Here's the command-line option to add to tests: (See [examples/custom_settings.p
--------
<h3><img src="https://seleniumbase.io/img/logo6.png" title="SeleniumBase" width="28" /> Running tests on a remote Selenium Grid:</h3>
<h3><img src="https://seleniumbase.io/img/green_logo.png" title="SeleniumBase" width="32" /> Running tests on a remote Selenium Grid:</h3>
SeleniumBase lets you run tests on remote Selenium Grids such as [BrowserStack](https://www.browserstack.com/automate#)'s Selenium Grid, [Sauce Labs](https://saucelabs.com/products/open-source-frameworks/selenium)'s Selenium Grid, [TestingBot](https://testingbot.com/features)'s Selenium Grid, other Grids, and even your own Grid:
SeleniumBase lets you run tests on remote Selenium Grids such as [BrowserStack](https://www.browserstack.com/automate#)'s Selenium Grid, [Sauce Labs](https://saucelabs.com/products/open-source-frameworks/selenium)'s Selenium Grid, other Grids, and even your own Grid:
(For setting browser desired capabilities while running Selenium remotely, see the ReadMe located here: https://github.com/seleniumbase/SeleniumBase/tree/master/examples/capabilities)
@ -360,27 +360,33 @@ Here's how to connect to a Sauce Labs Selenium Grid server for running tests:
pytest test_demo_site.py --server=USERNAME:KEY@ondemand.us-east-1.saucelabs.com --port=443 --protocol=https
```
Here's how to connect to a Perfecto Mobile Selenium Grid server for running tests:
```bash
pytest test_demo_site.py --server=USERNAME:KEY@demo.perfectomobile.com/nexperience/perfectomobile --port=443
```
Here's how to connect to a TestingBot Selenium Grid server for running tests:
```bash
pytest test_demo_site.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 test_demo_site.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 test_demo_site.py --server=USERNAME:KEY@hub.lambdatest.com --port=80
```
Here's how to connect to a CrossBrowserTesting Selenium Grid server for running tests:
```bash
pytest test_demo_site.py --server=USERNAME:KEY@hub.crossbrowsertesting.com --port=80
```
Or you can create your own Selenium Grid for test distribution. ([See this ReadMe for details](https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/utilities/selenium_grid/ReadMe.md))
To use a server on the ``https`` protocol, add ``--protocol=https``:
To use a server on the ``https`` protocol, add ``--protocol=https``: (*Now automatic if the port is 443.*)
```bash
pytest test_demo_site.py --protocol=https --server=IP_ADDRESS --port=PORT
@ -388,7 +394,7 @@ pytest test_demo_site.py --protocol=https --server=IP_ADDRESS --port=PORT
--------
<h3><img src="https://seleniumbase.io/img/logo6.png" title="SeleniumBase" width="28" /> Using a Proxy Server:</h3>
<h3><img src="https://seleniumbase.io/img/green_logo.png" title="SeleniumBase" width="32" /> Using a Proxy Server:</h3>
If you wish to use a proxy server for your browser tests (Chromium or Firefox), you can add ``--proxy=IP_ADDRESS:PORT`` as an argument on the command line.
@ -418,7 +424,7 @@ pytest proxy_test.py --proxy=proxy1
--------
<h3><img src="https://seleniumbase.io/img/logo6.png" title="SeleniumBase" width="28" /> Changing the User-Agent:</h3>
<h3><img src="https://seleniumbase.io/img/green_logo.png" title="SeleniumBase" width="32" /> Changing the User-Agent:</h3>
If you wish to change the User-Agent for your browser tests (Chrome and Firefox only), you can add ``--agent="USER-AGENT-STRING"`` as an argument on the command line.
@ -426,7 +432,7 @@ If you wish to change the User-Agent for your browser tests (Chrome and Firefox
pytest user_agent_test.py --agent="Mozilla/5.0 (Nintendo 3DS; U; ; en) Version/1.7412.EU"
```
<h3><img src="https://seleniumbase.io/img/logo6.png" title="SeleniumBase" width="28" /> Mobile Device Testing:</h3>
<h3><img src="https://seleniumbase.io/img/green_logo.png" title="SeleniumBase" width="32" /> Mobile Device Testing:</h3>
Use ``--mobile`` to quickly run your tests using Chrome's mobile device emulator with default values for device metrics (CSS Width, CSS Height, Pixel-Ratio) and a default value set for the user agent. To configure the mobile device metrics, use ``--metrics="CSS_Width,CSS_Height,Pixel_Ratio"`` to set those values. You'll also be able to set the user agent with ``--agent="USER-AGENT-STRING"`` (a default user agent will be used if not specified). To find real values for device metrics, [see this GitHub Gist](https://gist.github.com/sidferreira/3f5fad525e99b395d8bd882ee0fd9d00). For a list of available user agent strings, [check out this page](https://developers.whatismybrowser.com/useragents/explore/).

View File

@ -4,7 +4,7 @@ docutils==0.18
python-dateutil==2.8.2
livereload==2.6.3;python_version>="3.6"
joblib==1.1.0;python_version>="3.6"
Markdown==3.3.4;python_version>="3.6"
Markdown==3.3.6;python_version>="3.6"
MarkupSafe==2.0.1;python_version>="3.6"
pyparsing==2.4.7;python_version>="3.6"
keyring==23.2.1;python_version>="3.6"

View File

@ -9004,6 +9004,7 @@ class BaseCase(unittest.TestCase):
):
"""Similar to wait_for_text_visible()
Raises an exception if the element or the text is not found.
The text only needs to be a subset within the complete text.
Returns True if successful. Default timeout = SMALL_TIMEOUT."""
self.__check_scope()
if not timeout:
@ -9046,8 +9047,8 @@ class BaseCase(unittest.TestCase):
def assert_exact_text(
self, text, selector="html", by=By.CSS_SELECTOR, timeout=None
):
"""Similar to assert_text(), but the text must be exact, rather than
exist as a subset of the full text.
"""Similar to assert_text(), but the text must be exact,
rather than exist as a subset of the full text.
(Extra whitespace at the beginning or the end doesn't count.)
Raises an exception if the element or the text is not found.
Returns True if successful. Default timeout = SMALL_TIMEOUT."""