From 97e430c78cfb7b8802e31fe9039f95900e7c8bd6 Mon Sep 17 00:00:00 2001
From: Michael Mintz
@@ -20,32 +20,61 @@
đ Start |
đ° Features |
-đŠâđĢ Examples |
-đĨī¸ Options |
-đ§ Scripts |
-đą Mobile |
-đŧī¸ Visual
+â
Examples |
+đī¸ Options |
+đŽ Scripts |
+đī¸ Cmdr |
+đšī¸ JSMgr
One of many examples: test_demo_site.py An example test using the An example test using the An example of running a test: test_demo_site.py
-đ Start |
-đĨī¸ CLI |
-đ° Features
+đ Start
(Watch the tutorial on YouTube)
+
-
Better web testing with Selenium and pytest.
+Modern Web Testing with Selenium and Pytest.
đ API |
-đĩ Dashboard |
đ´ Recorder |
-đ Syntaxes |
-đž Locales |
+đĩ Dashboard |
+đ Formats |
+đą Mobile |
đ Grid |
-đšī¸ JSMgr
+đ Dialog
đ¤ CI |
âģī¸ Templates |
-đī¸ Presenter |
đ Translator |
+đī¸ Presenter |
đ Charts |
đēī¸ Tours |
-đ Dialog
+đŧī¸ Visual
BaseCase
class:sb
fixture: Python Setup:
diff --git a/examples/ReadMe.md b/examples/ReadMe.md
index 2545bf89..d2651f6d 100755
--- a/examples/ReadMe.md
+++ b/examples/ReadMe.md
@@ -1,5 +1,3 @@
-
-
Running Example Tests:
@@ -15,7 +13,7 @@
Example tests with run commands to help you get started:
-Run an example test in Chrome: (Default: ``--browser=chrome``)
+Run an [example test](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/my_first_test.py) in Chrome: (Default: ``--browser=chrome``)
```bash
pytest my_first_test.py
@@ -23,6 +21,14 @@ pytest my_first_test.py
+Run an [example test](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/test_demo_site.py) on the SeleniumBase Demo Site:
+
+```bash
+pytest test_demo_site.py
+```
+
+
+
Run an example test in Firefox:
```bash
@@ -37,7 +43,7 @@ pytest test_swag_labs.py --demo
-Run a Wordle-solver example:
+Run a [Wordle-solver example](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/wordle_test.py):
```bash
pytest wordle_test.py
@@ -51,7 +57,7 @@ Run an example test in Headless Mode: (invisible browser)
pytest my_first_test.py --headless
```
-Run an example test using Chrome's mobile device emulator: (default settings)
+Run an [example test](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/test_swag_labs.py) using Chrome's mobile device emulator: (default settings)
```bash
pytest test_swag_labs.py --mobile
@@ -59,27 +65,19 @@ pytest test_swag_labs.py --mobile
-Run tests with verbose output: (includes more details)
+Run a [test suite](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/test_suite.py) with verbose output: (see 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
-```
-
-
-
-Run tests multi-threaded using [n] threads:
+Run a test suite multi-threaded using [n] threads:
```bash
pytest test_suite.py -n=4
```
-Run a parameterized test: (Generates multiple tests from one)
+Run a [parameterized test](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/parameterized_test.py): (Generates multiple tests from one)
```bash
pytest parameterized_test.py -v
@@ -97,7 +95,7 @@ Run a test suite and generate a pytest report:
pytest test_suite.py --html=report.html
```
-Run a failing test: (See the ``latest_logs/`` folder for logs and screenshots)
+Run a [failing test](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/test_fail.py): (See the ``latest_logs/`` folder for logs and screenshots)
```bash
pytest test_fail.py
@@ -109,25 +107,25 @@ Run a failing test with Debug-mode enabled: (``pdb`` activates on failures)
pytest test_fail.py --pdb -s
```
-Run an example test suite that demonstrates the use of pytest markers:
+Run a 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:
+Run a test suite that reuses the browser session between tests:
```bash
pytest test_suite.py --reuse-session
```
-Run an example test demonstrating the ``rate_limited`` Python decorator:
+Run an [example test](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/rate_limiting_test.py) 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:
+Run an [example test](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/upload_file_test.py) that demonstrates how to upload a file to a website:
```bash
pytest upload_file_test.py
diff --git a/examples/example_logs/ReadMe.md b/examples/example_logs/ReadMe.md
index 0a732938..826c2f01 100755
--- a/examples/example_logs/ReadMe.md
+++ b/examples/example_logs/ReadMe.md
@@ -1,5 +1,3 @@
-
-
Logs, The Dashboard, and Reports:
diff --git a/help_docs/ReadMe.md b/help_docs/ReadMe.md
index b52e4521..3b0d322f 100755
--- a/help_docs/ReadMe.md
+++ b/help_docs/ReadMe.md
@@ -1,13 +1,12 @@
-
-
Help Docs
-đ¨âđĢ Examples |
+đ° Features |
+đī¸ Options
+
+â
Examples |
đą Mobile
đ Syntax Formats |
@@ -17,7 +16,7 @@
đ Reports |
đēī¸ Tours
-đ§â Console Scripts |
+đŽ Console Scripts |
đ Grid
âģī¸ Boilerplates |
@@ -33,7 +32,7 @@
đ NodeRunner
đī¸ Presenter |
-đļ ChartMaker
+đ ChartMaker
+
pytest options for SeleniumBase
-## pytest options for SeleniumBase
+đī¸ SeleniumBase's [pytest plugin](https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/plugins/pytest_plugin.py) lets you customize test runs from the CLI (Command-Line Interface), which adds options for setting/enabling the browser type, Dashboard Mode, Demo Mode, Headless Mode, Mobile Mode, Multi-threading Mode, Recorder Mode, reuse-session mode, proxy config, user agent config, browser extensions, html-report mode, and more.
-SeleniumBase's [pytest plugin](https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/plugins/pytest_plugin.py) lets you customize test runs from the CLI (Command-Line Interface), which adds options for setting/enabling the browser type, Dashboard Mode, Demo Mode, Headless Mode, Mobile Mode, Multi-threading Mode, Recorder Mode, reuse-session mode, proxy config, user agent config, browser extensions, html-report mode, and more.
-
-Here are some examples of configuring tests, which can be run from the [examples/](https://github.com/seleniumbase/SeleniumBase/tree/master/examples) folder:
+đī¸ Here are some examples of configuring tests, which can be run from the [examples/](https://github.com/seleniumbase/SeleniumBase/tree/master/examples) folder:
```bash
# Run a test in Chrome (default browser)
@@ -77,11 +75,11 @@ pytest test_swag_labs.py --mobile --metrics="411,731,3"
pytest my_first_test.py --settings-file=custom_settings.py
```
-You can interchange ``pytest`` with ``nosetests`` for most tests, but using ``pytest`` is recommended. (``chrome`` is the default browser if not specified.)
+đī¸ You can interchange ``pytest`` with ``nosetests`` for most tests, but using ``pytest`` is recommended. (``chrome`` is the default browser if not specified.)
-If you're using ``pytest`` for running tests outside of the SeleniumBase repo, you'll want a copy of [pytest.ini](https://github.com/seleniumbase/SeleniumBase/blob/master/pytest.ini) at the base of the new folder structure. If using ``nosetests``, the same applies for [setup.cfg](https://github.com/seleniumbase/SeleniumBase/blob/master/setup.cfg).
+đī¸ If you're using ``pytest`` for running tests outside of the SeleniumBase repo, you'll want a copy of [pytest.ini](https://github.com/seleniumbase/SeleniumBase/blob/master/pytest.ini) at the base of the new folder structure. If using ``nosetests``, the same applies for [setup.cfg](https://github.com/seleniumbase/SeleniumBase/blob/master/setup.cfg).
-Here are some useful command-line options that come with ``pytest``:
+đī¸ Here are some useful command-line options that come with ``pytest``:
```bash
-v # Verbose mode. Prints the full name of each test run.
@@ -96,7 +94,7 @@ Here are some useful command-line options that come with ``pytest``:
-m=MARKER # Run tests with the specified pytest marker.
```
-SeleniumBase provides additional ``pytest`` command-line options for tests:
+đī¸ SeleniumBase provides additional ``pytest`` command-line options for tests:
```bash
--browser=BROWSER # (The web browser to use. Default: "chrome".)
@@ -171,7 +169,7 @@ SeleniumBase provides additional ``pytest`` command-line options for tests:
(For more details, see the full list of command-line options **[here](https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/plugins/pytest_plugin.py)**.)
-You can also view a list of popular ``pytest`` options for SeleniumBase by typing:
+đī¸ You can also view a list of popular ``pytest`` options for SeleniumBase by typing:
```bash
seleniumbase options
@@ -245,7 +243,7 @@ The code above will leave your browser window open in case there's a failure. (i
Combinations of options:
-There are times when you'll want to combine various command-line options for added effect.
+đī¸ 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:
``--dist=loadscope`` or ``--dist=loadfile`` to it.
Here's more info on that, as taken from [pytest-xdist](https://pypi.org/project/pytest-xdist/):
@@ -254,7 +252,7 @@ Here's more info on that, as taken from [pytest-xdist](https://pypi.org/project/
* ``-n=4 --dist=loadfile``: Tests are grouped by their containing file. Groups are distributed to available workers as whole units. This guarantees that all tests in a file run in the same worker.
-You might also want to combine multiple options at once. For example:
+đī¸ You might also want to combine multiple options at once. For example:
```bash
pytest -n=4 --reuse-session --headless -v --dashboard --html=report.html
@@ -336,20 +334,36 @@ nosetests test_suite.py --report
--------
+ Language Locale Codes
+
+You can specify a Language Locale Code to customize web pages on supported websites. With SeleniumBase, you can change the web browser's Locale on the command line by doing this:
+
+```bash
+pytest --locale=CODE # Example: --locale=ru
+```
+
+Visit đž Locales for a full list of codes.
+
+--------
+
Customizing default settings:
-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.
+đī¸ 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))
-``--settings-file=custom_settings.py``
+
+```bash
+pytest --settings-file=custom_settings.py
+```
+
(Settings include default timeout values, a two-factor auth key, DB credentials, S3 credentials, and other important settings used by tests.)
--------
Running tests on a remote Selenium Grid:
-SeleniumBase lets you run tests on remote Selenium Grids such as [BrowserStack](https://www.browserstack.com/automate#)'s Selenium Grid, [LambdaTest](https://www.lambdatest.com/selenium-automation)'s Selenium Grid, [Sauce Labs](https://saucelabs.com/products/open-source-frameworks/selenium)'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, [LambdaTest](https://www.lambdatest.com/selenium-automation)'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)
+đ 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:
@@ -387,9 +401,9 @@ Here's how to connect to a CrossBrowserTesting Selenium Grid server for running
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))
+đ 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``: (*Now automatic if the port is 443.*)
+đ 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
@@ -399,19 +413,19 @@ pytest test_demo_site.py --protocol=https --server=IP_ADDRESS --port=PORT
Using a Proxy Server:
-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.
+đ 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.
```bash
pytest proxy_test.py --proxy=IP_ADDRESS:PORT
```
-If the proxy server that you wish to use requires authentication, you can do the following (Chromium only):
+đ If the proxy server that you wish to use requires authentication, you can do the following (Chromium only):
```bash
pytest proxy_test.py --proxy=USERNAME:PASSWORD@IP_ADDRESS:PORT
```
-SeleniumBase also supports SOCKS4 and SOCKS5 proxies:
+đ SeleniumBase also supports SOCKS4 and SOCKS5 proxies:
```bash
pytest proxy_test.py --proxy="socks4://IP_ADDRESS:PORT"
@@ -429,7 +443,7 @@ pytest proxy_test.py --proxy=proxy1
Changing the User-Agent:
-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.
+đ¤ 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.
```bash
pytest user_agent_test.py --agent="Mozilla/5.0 (Nintendo 3DS; U; ; en) Version/1.7412.EU"
@@ -437,7 +451,7 @@ pytest user_agent_test.py --agent="Mozilla/5.0 (Nintendo 3DS; U; ; en) Version/1
Mobile Device Testing:
-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/).
+đą 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/).
```bash
# Run tests using Chrome's mobile device emulator (default settings)
diff --git a/help_docs/features_list.md b/help_docs/features_list.md
index 5542134f..bc3e331d 100755
--- a/help_docs/features_list.md
+++ b/help_docs/features_list.md
@@ -1,5 +1,3 @@
-
-
-
JS Package Manager and Code Generators
-đšī¸ SeleniumBase lets you load JavaScript packages from any CDN link into any website.
-
đēī¸ This example is from maps_introjs_tour.py. (The --interval=1
makes the tour go automatically to the next step after 1 second.)
SeleniumBase includes powerful JS code generators for converting Python into JavaScript for using the supported JS packages. A few lines of Python in your tests might generate hundreds of lines of JavaScript. (Here is some tour code in Python from maps_introjs_tour.py that expands into a lot of JavaScript.)
+đšī¸ SeleniumBase includes powerful JS code generators for converting Python into JavaScript for using the supported JS packages. A few lines of Python in your tests might generate hundreds of lines of JavaScript.
+ +đēī¸ Here is some tour code in Python from maps_introjs_tour.py that expands into a lot of JavaScript.
```python self.open("https://www.google.com/maps/@42.3591234,-71.0915634,15z") @@ -30,21 +34,21 @@ self.export_tour(filename="maps_introjs_tour.js") self.play_tour() ``` -đšī¸ If you're wondering how SeleniumBase does this, here's the full Python code from js_utils.py, which uses WebDriver's execute_script()
method for making JS calls after escaping quotes with backslashes as needed:
Now that you've loaded JavaScript into the browser, you may also want to load some CSS to go along with it:
+đšī¸ Now that you've loaded JavaScript into the browser, you may also want to load some CSS to go along with it:
```python self.add_css_link(css_link) ``` -Here's code that loads the IntroJS CSS:
+đšī¸ Here's code that loads the IntroJS CSS:
```python self.add_css_link("https://cdnjs.cloudflare.com/ajax/libs/intro.js/2.9.3/introjs.css") ``` -And here's the Python WebDriver code that makes this possible:
+đšī¸ And here's the Python WebDriver code that makes this possible:
```python def add_css_link(driver, css_link): @@ -95,8 +99,8 @@ def add_css_link(driver, css_link): driver.execute_script(script_to_add_css % css_link) ``` -