Update the docs

This commit is contained in:
Michael Mintz 2022-04-22 22:57:53 -04:00
parent be3fc3a021
commit 97e430c78c
18 changed files with 163 additions and 112 deletions

View File

@ -5,9 +5,9 @@
<meta property="og:image" content="https://seleniumbase.io/cdn/img/mac_sb_logo_5.png" />
<link rel="icon" href="https://seleniumbase.io/img/green_logo.png" />
<h3 align="center"><a href="https://github.com/seleniumbase/SeleniumBase/"><img src="https://seleniumbase.io/cdn/img/mac_sb_logo_3.png" alt="SeleniumBase" title="SeleniumBase" width="310" /></a></h3>
<h3 align="center"><a href="https://github.com/seleniumbase/SeleniumBase/"><img src="https://seleniumbase.io/cdn/img/sb_logo_10t.png" alt="SeleniumBase" title="SeleniumBase" width="270" /></a></h3>
<!-- View on GitHub -->
<h4 align="center">Better web testing with <a href="https://www.selenium.dev/documentation/" target="_blank">Selenium</a> and <a href="https://docs.pytest.org/en/stable/" target="_blank">pytest</a>.</h4>
<h4 align="center">Modern Web Testing with <a href="https://www.selenium.dev/documentation/" target="_blank">Selenium</a> and <a href="https://docs.pytest.org/en/stable/" target="_blank">Pytest</a>.</h4>
<p align="center">
<a href="https://github.com/seleniumbase/SeleniumBase/releases">
<img src="https://img.shields.io/github/v/release/seleniumbase/SeleniumBase.svg?color=2277EE" alt="Latest Release on GitHub" /></a> <a href="https://pypi.python.org/pypi/seleniumbase" target="_blank">
@ -20,32 +20,61 @@
<p align="center">
<a href="#python_installation">🚀 Start</a> |
<a href="https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/features_list.md">🏰 Features</a> |
<a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/ReadMe.md">👩‍🏫 Examples</a> |
<a href="https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/customizing_test_runs.md">🖥 Options</a> |
<a href="https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/console_scripts/ReadMe.md">🧙 Scripts</a> |
<a href="https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/mobile_testing.md">📱 Mobile</a> |
<a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/visual_testing/ReadMe.md">🖼️ Visual</a>
<a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/ReadMe.md"> Examples</a> |
<a href="https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/customizing_test_runs.md">🎛 Options</a> |
<a href="https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/console_scripts/ReadMe.md">🔮 Scripts</a> |
<a href="https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/commander.md">🎖️ Cmdr</a> |
<a href="https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/js_package_manager.md">🕹️ JSMgr</a>
<br />
<a href="https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/method_summary.md">📚 API</a> |
<a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/example_logs/ReadMe.md">🔵 Dashboard</a> |
<a href="https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/recorder_mode.md">🔴 Recorder</a> |
<a href="https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/syntax_formats.md">🔠 Syntaxes</a> |
<a href="https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/locale_codes.md">🗾 Locales</a> |
<a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/example_logs/ReadMe.md">🔵 Dashboard</a> |
<a href="https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/syntax_formats.md">🔠 Formats</a> |
<a href="https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/mobile_testing.md">📱 Mobile</a> |
<a href="https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/utilities/selenium_grid/ReadMe.md">🌐 Grid</a> |
<a href="https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/js_package_manager.md">🕹️ JSMgr</a>
<a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/dialog_boxes/ReadMe.md">🛂 Dialog</a>
<br />
<a href="https://github.com/seleniumbase/SeleniumBase/blob/master/integrations/github/workflows/ReadMe.md">🤖 CI</a> |
<a href="https://github.com/seleniumbase/SeleniumBase/tree/master/examples/boilerplates">♻️ Templates</a> |
<a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/presenter/ReadMe.md">🎞️ Presenter</a> |
<a href="https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/translations.md">🌏 Translator</a> |
<a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/presenter/ReadMe.md">🎞️ Presenter</a> |
<a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/chart_maker/ReadMe.md">📊 Charts</a> |
<a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/tour_examples/ReadMe.md">🗺️ Tours</a> |
<a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/dialog_boxes/ReadMe.md">🛂 Dialog</a>
<a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/visual_testing/ReadMe.md">🖼️ Visual</a>
</p>
--------
<p align="left"><b>One of many examples:</b> <a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/test_demo_site.py">test_demo_site.py</a></p>
<p align="left">An example test using the <code>BaseCase</code> class:</p>
```python
from seleniumbase import BaseCase
class Test_MFA_Login(BaseCase):
def test_mfa_login(self):
self.open("https://seleniumbase.io/realworld/login")
self.type("input#username", "demo_user")
self.type("input#password", "secret_pass")
self.enter_mfa_code("#totpcode", "GAXG2MTEOR3DMMDG")
self.click('a:contains("This Page")')
self.assert_text("Welcome!", "h1")
self.save_screenshot_to_logs()
```
<p align="left">An example test using the <code>sb</code> fixture:</p>
```python
def test_mfa_login(sb):
sb.open("https://seleniumbase.io/realworld/login")
sb.type("input#username", "demo_user")
sb.type("input#password", "secret_pass")
sb.enter_mfa_code("#totpcode", "GAXG2MTEOR3DMMDG")
sb.click('a:contains("This Page")')
sb.assert_text("Welcome!", "h1")
sb.save_screenshot_to_logs()
```
<p align="left">An example of running a test: <a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/test_demo_site.py">test_demo_site.py</a></p>
```bash
cd examples/
@ -54,7 +83,6 @@ pytest test_demo_site.py
<p align="left"><a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/test_demo_site.py"><img src="https://seleniumbase.io/cdn/gif/demo_page_4.gif" width="400" alt="SeleniumBase Demo Mode" title="SeleniumBase Test" /></a></p>
<a id="python_installation"></a>
<h2><img src="https://seleniumbase.io/img/green_logo.png" title="SeleniumBase" width="32" /> Python Setup:</h2>

View File

@ -1,5 +1,3 @@
<h3 align="center"><a href="https://github.com/seleniumbase/SeleniumBase/"><img src="https://seleniumbase.io/cdn/img/sb_logo_10t.png" alt="SeleniumBase" title="SeleniumBase" width="240"></a></h3>
<h2><img src="https://seleniumbase.io/img/logo6.png" title="SeleniumBase" width="32" /> Running Example Tests:</h2>
<p align="left"><a align="center" href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/test_demo_site.py"><img align="center" src="https://seleniumbase.io/cdn/img/sb_demo_page.png" alt="SeleniumBase Demo Page" width="420" /></a></p>
@ -15,7 +13,7 @@
<h3><img src="https://seleniumbase.io/img/logo6.png" title="SeleniumBase" width="32" /> Example tests with run commands to help you get started:</h3>
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
<img src="https://seleniumbase.io/cdn/gif/swag_labs_4.gif" /><br />
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
```
<img src="https://seleniumbase.io/cdn/gif/demo_page_4.gif" title="SeleniumBase Demo Page" /><br />
Run an example test in Firefox:
```bash
@ -37,7 +43,7 @@ pytest test_swag_labs.py --demo
<img src="https://seleniumbase.io/cdn/gif/swag_demo_3.gif" /><br />
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
<img src="https://seleniumbase.io/cdn/gif/swag_mobile_2.gif" title="SeleniumBase Mobile Mode" /><br />
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
```
<img src="https://seleniumbase.io/cdn/gif/demo_page_4.gif" title="SeleniumBase Demo Page" /><br />
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

View File

@ -1,5 +1,3 @@
<h3 align="center"><a href="https://github.com/seleniumbase/SeleniumBase/"><img src="https://seleniumbase.io/cdn/img/sb_logo_10t.png" alt="SeleniumBase" title="SeleniumBase" width="240"></a></h3>
<h3><img src="https://seleniumbase.io/img/logo6.png" title="SeleniumBase" width="32" /> Logs, The Dashboard, and Reports:</h3>
<!-- YouTube View --><a href="https://www.youtube.com/watch?v=XpuJCjJhJwQ"><img src="http://img.youtube.com/vi/XpuJCjJhJwQ/0.jpg" title="SeleniumBase on YouTube" width="285" /></a>

View File

@ -1,13 +1,12 @@
<div><a href="https://github.com/seleniumbase/SeleniumBase"><img src="https://seleniumbase.io/cdn/img/mac_sb_logo_5.png" alt="SeleniumBase" width="304" /></a></div>
<h2><img src="https://seleniumbase.io/img/logo6.png" title="SeleniumBase" width="32" /> Help Docs</h2>
<p align="left">
<a href="https://seleniumbase.io/#python_installation">🚀 Start</a> |
<a href="https://seleniumbase.io/help_docs/customizing_test_runs/">🖥️ CLI</a> |
<a href="https://seleniumbase.io/help_docs/features_list/">🏰 Features</a>
<a href="https://seleniumbase.io/#python_installation">🚀 Start</a>
<br />
<a href="https://seleniumbase.io/examples/ReadMe/">👨‍🏫 Examples</a> |
<a href="https://seleniumbase.io/help_docs/features_list/">🏰 Features</a> |
<a href="https://seleniumbase.io/help_docs/customizing_test_runs/">🎛️ Options</a>
<br />
<a href="https://seleniumbase.io/examples/ReadMe/">✅ Examples</a> |
<a href="https://seleniumbase.io/help_docs/mobile_testing/">📱 Mobile</a>
<br />
<a href="https://seleniumbase.io/help_docs/syntax_formats/">🔠 Syntax Formats</a> |
@ -17,7 +16,7 @@
<a href="https://seleniumbase.io/examples/example_logs/ReadMe/">📊 Reports</a> |
<a href="https://seleniumbase.io/examples/tour_examples/ReadMe/">🗺️ Tours</a>
<br />
<a href="https://seleniumbase.io/seleniumbase/console_scripts/ReadMe/">🧙‍ Console Scripts</a> |
<a href="https://seleniumbase.io/seleniumbase/console_scripts/ReadMe/">🔮 Console Scripts</a> |
<a href="https://seleniumbase.io/seleniumbase/utilities/selenium_grid/ReadMe/">🌐 Grid</a>
<br />
<a href="https://github.com/seleniumbase/SeleniumBase/tree/master/examples/boilerplates">♻️ Boilerplates</a> |
@ -33,7 +32,7 @@
<a href="https://github.com/seleniumbase/SeleniumBase/tree/master/integrations/node_js">🏃 NodeRunner</a>
<br />
<a href="https://seleniumbase.io/examples/presenter/ReadMe/">🎞️ Presenter</a> |
<a href="https://seleniumbase.io/examples/chart_maker/ReadMe/">📶 ChartMaker</a>
<a href="https://seleniumbase.io/examples/chart_maker/ReadMe/">📊 ChartMaker</a>
</p>
--------

View File

@ -1,10 +1,8 @@
<h3 align="center"><a href="https://github.com/seleniumbase/SeleniumBase/"><img src="https://seleniumbase.io/cdn/img/sb_logo_10t.png" alt="SeleniumBase" title="SeleniumBase" width="240"></a></h3>
<h2><img src="https://seleniumbase.io/img/logo6.png" title="SeleniumBase" width="32" /> pytest options for SeleniumBase</h2>
## 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
<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.
🎛️ 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
--------
<h3><img src="https://seleniumbase.io/img/green_logo.png" title="SeleniumBase" width="32" /> Language Locale Codes</h3>
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 <a href="https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/locale_codes.md"><b>🗾 Locales</b></a> for a full list of codes.
--------
<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.
🎛️ 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.)
--------
<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, [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
<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.
🌐 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
<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.
🔤 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
<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/).
📱 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)

View File

@ -1,5 +1,3 @@
<h3 align="center"><a href="https://github.com/seleniumbase/SeleniumBase/"><img src="https://seleniumbase.io/cdn/img/sb_logo_10t.png" alt="SeleniumBase" title="SeleniumBase" width="240"></a></h3>
<!-- YouTube View --><a href="https://www.youtube.com/watch?v=Sjzq9kU5kOw"><img src="http://img.youtube.com/vi/Sjzq9kU5kOw/0.jpg" title="SeleniumBase on YouTube" width="285" /></a>
<!-- GitHub Only --><p>(<b><a href="https://www.youtube.com/watch?v=Sjzq9kU5kOw">Watch the tutorial on YouTube</a></b>)</p>
@ -31,6 +29,7 @@
* Includes [Chart Maker](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/chart_maker/ReadMe.md), a tool for creating interactive charts.
* Includes a [dialog box builder](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/dialog_boxes/ReadMe.md) to allow user-input during automation.
* Includes a [website tour builder](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/tour_examples/ReadMe.md) for creating interactive walkthroughs.
* Includes a GUI for running pytest scripts: [SeleniumBase Commander](https://github.com/seleniumbase/SeleniumBase/blob/master/help_docs/commander.md).
* Includes integrations for [GitHub Actions](https://seleniumbase.io/integrations/github/workflows/ReadMe/), [Google Cloud](https://github.com/seleniumbase/SeleniumBase/tree/master/integrations/google_cloud/ReadMe.md), [Azure](https://github.com/seleniumbase/SeleniumBase/blob/master/integrations/azure/jenkins/ReadMe.md), [S3](https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/plugins/s3_logging_plugin.py), and [Docker](https://github.com/seleniumbase/SeleniumBase/blob/master/integrations/docker/ReadMe.md).
* Can handle Google Authenticator logins with [Python's one-time password library](https://pyotp.readthedocs.io/en/latest/).
* Can load and make assertions on PDF files from websites or the local file system.

View File

@ -1,23 +1,27 @@
<h3 align="center"><a href="https://github.com/seleniumbase/SeleniumBase/"><img src="https://seleniumbase.io/cdn/img/sb_logo_10t.png" alt="SeleniumBase" title="SeleniumBase" width="240"></a></h3>
<h2><img src="https://seleniumbase.io/img/logo6.png" title="SeleniumBase" width="32" /> JS Package Manager and Code Generators</h2>
<div>SeleniumBase lets you load JavaScript packages from any CDN link into any website.</div>
<h3>🕹️ SeleniumBase lets you load JavaScript packages from any CDN link into any website.</h3>
<p><div>In addition to loading JS packages, SeleniumBase also lets you generate JS code from Python so that you can use these packages more easily.</div></p>
<b>🎨 The following SeleniumBase solutions utilize this feature:</b>
<p><div>Here's an example of loading a website-tour library into the browser for a Google Maps tour:</div></p>
<a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/tour_examples/ReadMe.md">🗺️ Website Tours</a> - <a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/presenter/ReadMe.md">🎞️ Presenter</a> - <a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/chart_maker/ReadMe.md">📊 Chart Maker</a> - <a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/dialog_boxes/ReadMe.md">🛂 Dialog Boxes</a>
<p><div>🕹️ In addition to loading JS packages, SeleniumBase also lets you generate JS code from Python so that you can use these packages more easily.</div></p>
<p><div>🗺️ Here's an example of loading a website-tour library into the browser for a Google Maps tour:</div></p>
<img src="https://seleniumbase.io/cdn/gif/introjs_tour.gif" title="SeleniumBase Tour of Google" /><br />
This example, ([maps_introjs_tour.py](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/tour_examples/maps_introjs_tour.py) from the SeleniumBase ``examples/tour_examples/`` folder), can be run with ``pytest`` after you've cloned and installed [SeleniumBase from GitHub](https://github.com/seleniumbase/SeleniumBase): (The ``--interval=1`` makes the tour go automatically to the next step after 1 second.)
<p>🗺️ This example is from <a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/tour_examples/maps_introjs_tour.py">maps_introjs_tour.py</a>. (The <code>--interval=1</code> makes the tour go automatically to the next step after 1 second.)</p>
```bash
cd examples/tour_examples
pytest maps_introjs_tour.py --interval=1
```
<p>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 <a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/tour_examples/maps_introjs_tour.py">maps_introjs_tour.py</a> that expands into a lot of JavaScript.)</p>
<p>🕹️ 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.</p>
<p>🗺️ Here is some tour code in Python from <a href="https://github.com/seleniumbase/SeleniumBase/blob/master/examples/tour_examples/maps_introjs_tour.py">maps_introjs_tour.py</a> that expands into a lot of JavaScript.</p>
```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()
```
<p><div>For existing features, SeleniumBase already takes care of loading all the necessary JS and CSS files into the web browser. To load other packages, here are a few useful methods that you should know about:</div></p>
<p><div>🕹️ For existing features, SeleniumBase already takes care of loading all the necessary JS and CSS files into the web browser. To load other packages, here are a few useful methods that you should know about:</div></p>
```python
self.add_js_link(js_link)
```
<div>This example loads the <a href="https://introjs.com/">IntroJS</a> JavaScript library:</div>
<p><div>🕹️ This example loads the <a href="https://introjs.com/">IntroJS</a> JavaScript library:</div></p>
```python
self.add_js_link("https://cdnjs.cloudflare.com/ajax/libs/intro.js/2.9.3/intro.min.js")
```
<div>You can load any JS package this way as long as you know the URL.</div>
<div>🕹️ You can load any JS package this way as long as you know the URL.</div>
If you're wondering how SeleniumBase does this, here's the full Python code from [js_utils.py](https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/fixtures/js_utils.py), which uses WebDriver's ``execute_script()`` method for making JS calls after escaping quotes with backslashes as needed:
<p>🕹️ If you're wondering how SeleniumBase does this, here's the full Python code from <a href="https://github.com/seleniumbase/SeleniumBase/blob/master/seleniumbase/fixtures/js_utils.py">js_utils.py</a>, which uses WebDriver's <code>execute_script()</code> method for making JS calls after escaping quotes with backslashes as needed:</p>
```python
def add_js_link(driver, js_link):
@ -64,19 +68,19 @@ def add_js_link(driver, js_link):
driver.execute_script(script_to_add_js % js_link)
```
<p>Now that you've loaded JavaScript into the browser, you may also want to load some CSS to go along with it:</p>
<p>🕹️ Now that you've loaded JavaScript into the browser, you may also want to load some CSS to go along with it:</p>
```python
self.add_css_link(css_link)
```
<p>Here's code that loads the <a href="https://introjs.com/">IntroJS</a> CSS:</p>
<p>🕹️ Here's code that loads the <a href="https://introjs.com/">IntroJS</a> CSS:</p>
```python
self.add_css_link("https://cdnjs.cloudflare.com/ajax/libs/intro.js/2.9.3/introjs.css")
```
<p>And here's the Python WebDriver code that makes this possible:</p>
<p>🕹️ And here's the Python WebDriver code that makes this possible:</p>
```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)
```
<div>Website tours are just one of the many uses of the JS Package Manager.</div>
<p><div>The following example shows the <a href="https://github.com/craftpip/jquery-confirm">JqueryConfirm</a> package loaded into a website for creating fancy dialog boxes:</div></p>
<div>🕹️ Website tours are just one of the many uses of the JS Package Manager.</div>
<p><div>🛂 The following example shows the <a href="https://github.com/craftpip/jquery-confirm">JqueryConfirm</a> package loaded into a website for creating fancy dialog boxes:</div></p>
<img src="https://seleniumbase.io/cdn/img/emoji_sports_dialog.png" alt="SeleniumBase" width="400" />
@ -113,7 +117,7 @@ pytest test_dialog_boxes.py
<p><div>(Example from the <a href="https://seleniumbase.io/examples/dialog_boxes/ReadMe/">Dialog Boxes ReadMe</a>)</div></p>
<div>Since packages are loaded directly from a CDN link, you won't need other package managers like NPM, Bower, or Yarn to get the packages that you need into the websites that you want.</div>
<div>🕹️ Since packages are loaded directly from a CDN link, you won't need other package managers like NPM, Bower, or Yarn to get the packages that you need into the websites that you want.</div>
--------
@ -127,4 +131,4 @@ pytest test_dialog_boxes.py
<a href="https://github.com/seleniumbase/SeleniumBase">
<img src="https://img.shields.io/badge/✅%20💛%20View%20Code-on%20GitHub%20🌎%20🚀-02A79E.svg" alt="SeleniumBase on GitHub" /></a>
And if you're just interested in creating website tours with SeleniumBase, here's the link to the <a href="https://seleniumbase.io/examples/tour_examples/ReadMe/">Website Tours ReadMe</a>.
🗺️ If you're only interested in creating website tours with SeleniumBase, here's the link to the <a href="https://seleniumbase.io/examples/tour_examples/ReadMe/">Website Tours ReadMe</a>.

View File

@ -1,6 +1,6 @@
<h2><img src="https://seleniumbase.io/img/logo6.png" title="SeleniumBase" width="25" /> Language Locale Codes</h2>
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 adding:
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

View File

@ -1,5 +1,3 @@
<h3 align="center"><a href="https://github.com/seleniumbase/SeleniumBase/"><img src="https://seleniumbase.io/cdn/img/sb_logo_10t.png" alt="SeleniumBase" title="SeleniumBase" width="240"></a></h3>
<h2><img src="https://seleniumbase.io/img/logo6.png" title="SeleniumBase" width="32" /> Methods (API Reference)</h2>
<!-- YouTube View --><a href="https://www.youtube.com/watch?v=_yNJlHnp2JA"><img src="https://seleniumbase.io/cdn/img/sb_api_youtube.png" title="SeleniumBase on YouTube" width="285" /></a>

View File

@ -7,7 +7,7 @@
<img src="https://seleniumbase.io/cdn/img/sb_recorder_notification.png" title="SeleniumBase" width="380">
🔴 To make a new recording with Recorder Mode, you can use ``sbase mkrec``, ``sbase codegen``, or ``sbase record``):
🔴 To make a new recording with Recorder Mode, use ``sbase mkrec``, ``sbase codegen``, or ``sbase record``):
```bash
sbase mkrec TEST_NAME.py --url=URL

View File

@ -1,5 +1,3 @@
<h3 align="center"><a href="https://github.com/seleniumbase/SeleniumBase/"><img src="https://seleniumbase.io/cdn/img/mac_sb_logo_3.png" alt="SeleniumBase" title="SeleniumBase" width="320" /></a></h3>
<a id="syntax_formats"></a>
<h2><img src="https://seleniumbase.io/img/green_logo.png" title="SeleniumBase" width="32" /> The 17 syntax formats</h2>

View File

@ -1,7 +1,7 @@
<h3 align="left"><a href="https://github.com/seleniumbase/SeleniumBase/"><img src="https://seleniumbase.io/cdn/img/mac_sb_logo_3.png" title="SeleniumBase" width="300" /></a></h3>
<h3 align="left"><a href="https://github.com/seleniumbase/SeleniumBase/"><img src="https://seleniumbase.io/cdn/img/mac_sb_logo_3.png" title="SeleniumBase" width="310" /></a></h3>
<a id="language_tests"></a>
<h3><img src="https://seleniumbase.io/img/logo6.png" title="SeleniumBase" width="32" /> Language Tests (Python 3+)</h3>
<h3>🌏 Language Tests & Translation API</h3>
<b>SeleniumBase</b> supports the following 10 languages: <i>English</i>, <i>Chinese</i>, <i>Dutch</i>, <i>French</i>, <i>Italian</i>, <i>Japanese</i>, <i>Korean</i>, <i>Portuguese</i>, <i>Russian</i>, and <i>Spanish</i>.

View File

@ -82,6 +82,7 @@ nav:
- Running Example Tests: examples/ReadMe.md
- Command Line Options: help_docs/customizing_test_runs.md
- Dashboard / Reports: examples/example_logs/ReadMe.md
- SeleniumBase Commander: help_docs/commander.md
- Console Scripts: seleniumbase/console_scripts/ReadMe.md
- Syntax Formats: help_docs/syntax_formats.md
- Recorder Mode: help_docs/recorder_mode.md

View File

@ -1,8 +1,6 @@
<h3 align="center"><a href="https://github.com/seleniumbase/SeleniumBase/"><img src="https://seleniumbase.io/cdn/img/sb_logo_10t.png" alt="SeleniumBase" title="SeleniumBase" width="240"></a></h3>
<h2>🔮 Console Scripts 🔮</h2>
<h2>Console Scripts</h2>
SeleniumBase console scripts help you get things done more easily, such as installing web drivers, creating a test directory with necessary configuration files, converting old WebDriver unittest scripts into SeleniumBase code, translating tests into multiple languages, and using the Selenium Grid.
⭐ SeleniumBase console scripts help you get things done more easily, such as installing web drivers, creating a test directory with useful configuration files, initializing the SeleniumBase Recorder, launching the SeleniumBase Commander, translating tests into multiple languages, and running a Selenium Grid.
* Usage: ``seleniumbase [COMMAND] [PARAMETERS]``
@ -147,14 +145,21 @@ For the full list of command-line options, type: "pytest --help".
<h3>commander / gui</h3>
* Usage:
``sbase commander [OPTIONAL PATH or TEST FILE]``
``sbase gui [OPTIONAL PATH or TEST FILE]``
```bash
sbase commander [OPTIONAL PATH or TEST FILE]
sbase gui [OPTIONAL PATH or TEST FILE]
```
* Examples:
``sbase gui``
``sbase gui -k agent``
``sbase gui examples/``
``sbase gui test_suite.py``
```bash
sbase gui
sbase gui -k agent
sbase gui -m marker2
sbase gui test_suite.py
sbase gui offline_examples/
```
* Output:
Launches SeleniumBase Commander | GUI for pytest.

View File

@ -163,8 +163,9 @@ def show_commander_usage():
print(" Examples:")
print(" sbase gui")
print(" sbase gui -k agent")
print(" sbase gui examples/")
print(" sbase gui -m marker2")
print(" sbase gui test_suite.py")
print(" sbase gui offline_examples/")
print(" Output:")
print(" Launches SeleniumBase Commander | GUI for pytest.")
print("")

View File

@ -8,8 +8,15 @@ Usage:
seleniumbase gui [OPTIONAL PATH or TEST FILE]
sbase gui [OPTIONAL PATH or TEST FILE]
Examples:
sbase gui
sbase gui -k agent
sbase gui -m marker2
sbase gui test_suite.py
sbase gui offline_examples/
Output:
Launches SeleniumBase Commander | GUI for pytest.
Launches SeleniumBase Commander | GUI for pytest.
"""
import colorama

View File

@ -7,7 +7,7 @@ Usage:
sbase recorder
Output:
Launches the SeleniumBase Recorder Desktop App.
Launches the SeleniumBase Recorder Desktop App.
"""
import colorama

View File

@ -95,5 +95,6 @@ pytest test_demo_site.py --protocol=https --server=IP_ADDRESS --port=PORT
(For setting browser desired capabilities while running Selenium remotely, see the <a href="https://seleniumbase.io/help_docs/desired_capabilities/">desired capabilities documentation</a> and the sample files located in <a href="https://github.com/seleniumbase/SeleniumBase/tree/master/examples/capabilities">SeleniumBase/examples/capabilities</a>)
<h4><img src="https://seleniumbase.io/img/sb_icon.png" title="SeleniumBase" width="30" /> More info about the Selenium Grid Hub can be found here:</h4>
* [https://github.com/SeleniumHQ/selenium/wiki/Grid2](https://github.com/SeleniumHQ/selenium/wiki/Grid2)
<h4><img src="https://seleniumbase.io/img/logo6.png" title="SeleniumBase" width="28" /> More info about the Selenium Grid Hub can be found here:</h4>
* [https://www.selenium.dev/documentation/grid/](https://www.selenium.dev/documentation/grid/)