diff --git a/README.md b/README.md index a33cc17b..76bb9ee4 100755 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ - +

SeleniumBase

Scale your web app testing with Selenium, Python, and pytest.

@@ -50,7 +50,7 @@ -------- -

An example of running a test with pytest: test_demo_site.py

+

An example of running a test with pytest: test_demo_site.py

```bash cd examples/ @@ -150,7 +150,7 @@ Feature: SeleniumBase scenarios for the RealWorld App 🔵 Using a [Python virtual env](https://seleniumbase.io/help_docs/virtualenv_instructions/) is recommended. -

Install SeleniumBase:

+

Install SeleniumBase:

**You can install ``seleniumbase`` from [GitHub](https://github.com/seleniumbase/SeleniumBase) or [PyPI](https://pypi.org/project/seleniumbase/):** @@ -236,14 +236,14 @@ COMMANDS: ``` -

Downloading web drivers:

+

Downloading web drivers:

✅ SeleniumBase automatically downloads web drivers as needed, such as ``chromedriver`` and ``geckodriver`` (Firefox). ✅ To manually download a webdriver, see [Console Scripts](https://seleniumbase.io/seleniumbase/console_scripts/ReadMe/) OR [Webdriver Installation](https://seleniumbase.io/help_docs/webdriver_installation/). -

Running tests:

+

Running tests:

🔵 If you've cloned SeleniumBase, you can run tests from the [examples/](https://github.com/seleniumbase/SeleniumBase/tree/master/examples) folder. @@ -292,7 +292,7 @@ class MyTestClass(BaseCase): * For more reading, [here's an advanced guide on CSS attribute selectors](https://developer.mozilla.org/en-US/docs/Web/CSS/Attribute_selectors). -

Here are some common SeleniumBase methods that you might find in tests:

+

Here are some common SeleniumBase methods that you might find in tests:

```python self.open(url) # Navigate the browser window to the URL. @@ -331,7 +331,7 @@ self.assert_no_js_errors() # Verify there are no JS errors. 🔵 For the complete list of SeleniumBase methods, see: Method Summary -

Learn More:

+

Learn More:

✅ Supports all major web browsers and operating systems:

Browsers: Chrome, Edge, Firefox, IE, and Safari.

@@ -379,7 +379,7 @@ nosetests [FILE_NAME.py]:[CLASS_NAME].[METHOD_NAME] -

Detailed Instructions:

+

Detailed Instructions:

🔵 You can use **Demo Mode** to help you see what a test is doing: If a test is moving too fast for your eyes, 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 displays assertions: @@ -539,7 +539,7 @@ Here's the command-line option to add to tests: (See [examples/custom_settings.p Inside your tests, you can use ``self.data`` to access that. -

Test Directory Configuration:

+

Test Directory Configuration:

🔵 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. @@ -595,7 +595,7 @@ Of those files, the ``pytest.ini`` config file is the most important, followed b -------- -

Log files from failed tests:

+

Log files from failed tests:

Let's try an example of a test that fails: @@ -620,7 +620,7 @@ pytest test_fail.py -------- -

The SeleniumBase Dashboard:

+

The SeleniumBase Dashboard:

🔵 The ``--dashboard`` option for pytest generates a SeleniumBase Dashboard located at ``dashboard.html``, which updates automatically as tests run and produce results. Example: @@ -649,7 +649,7 @@ pytest test_suite.py --dashboard --rs --headless -------- -

Creating Visual Test Reports:

+

Creating Visual Test Reports:

Pytest Reports:

@@ -724,7 +724,7 @@ pytest test_suite.py --alluredir=allure_results ``` -

Using a Proxy Server:

+

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. @@ -753,7 +753,7 @@ pytest proxy_test.py --proxy=proxy1 ``` -

Changing the User-Agent:

+

Changing the User-Agent:

🔵 If you wish to change the User-Agent for your browser tests (Chromium and Firefox only), you can add ``--agent="USER AGENT STRING"`` as an argument on the command-line. @@ -762,12 +762,12 @@ pytest user_agent_test.py --agent="Mozilla/5.0 (Nintendo 3DS; U; ; en) Version/1 ``` -

Handling Pop-Up / Pop Up Alerts:

+

Handling Pop-Up / Pop Up Alerts:

🔵 self.accept_alert() automatically waits for and accepts alert pop-ups. self.dismiss_alert() automatically waits for and dismisses alert pop-ups. On occasion, some methods like self.click(SELECTOR) might dismiss a pop-up on its own because they call JavaScript to make sure that the readyState of the page is complete before advancing. If you're trying to accept a pop-up that got dismissed this way, use this workaround: Call self.find_element(SELECTOR).click() instead, (which will let the pop-up remain on the screen), and then use self.accept_alert() to accept the pop-up (more on that here). If pop-ups are intermittent, wrap code in a try/except block. -

Building Guided Tours for Websites:

+

Building Guided Tours for Websites:

🔵 Learn about SeleniumBase Interactive Walkthroughs (in the ``examples/tour_examples/`` folder). It's great for prototyping a website onboarding experience. @@ -777,7 +777,7 @@ pytest user_agent_test.py --agent="Mozilla/5.0 (Nintendo 3DS; U; ; en) Version/1 --------
-

Production Environments & Integrations:

+

Production Environments & Integrations:

@@ -803,7 +803,7 @@ pytest [YOUR_TEST_FILE.py] --with-db-reporting --with-s3-logging -

Detailed Method Specifications and Examples:

+

Detailed Method Specifications and Examples:

🔵 Navigating to a web page: (and related commands) @@ -1107,7 +1107,7 @@ pytest --reruns=1 --reruns-delay=1

Additionally, you can use the @retry_on_exception() decorator to specifically retry failing methods. (First import: from seleniumbase import decorators) To learn more about SeleniumBase decorators, [click here](https://github.com/seleniumbase/SeleniumBase/tree/master/seleniumbase/common).

-

Wrap-Up

+

Wrap-Up

Congratulations on getting started with SeleniumBase! @@ -1125,11 +1125,11 @@ pytest --reruns=1 --reruns-delay=1
Join the chat!
Tested with SeleniumBase
SeleniumBase Docs
SeleniumBase PyPI downloads

-SeleniumBase on GitHub -SeleniumBase on Facebook -SeleniumBase on Gitter -SeleniumBase on Instagram -SeleniumBase on Twitter +SeleniumBase on GitHub +SeleniumBase on Facebook +SeleniumBase on Gitter +SeleniumBase on Instagram +SeleniumBase on Twitter

SeleniumBase

diff --git a/examples/ReadMe.md b/examples/ReadMe.md index 2430a9b8..0883378d 100755 --- a/examples/ReadMe.md +++ b/examples/ReadMe.md @@ -1,6 +1,6 @@ -## [](https://github.com/seleniumbase/SeleniumBase/) Example Tests: +## [](https://github.com/seleniumbase/SeleniumBase/) Example Tests: -

SeleniumBase Demo Page

+

SeleniumBase Demo Page

* SeleniumBase tests are run with pytest. * Chrome is the default browser if not specified. @@ -11,7 +11,7 @@ (NOTE: Some example tests fail on purpose to demonstrate [logging features](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/example_logs/ReadMe.md).) -

Example tests with run commands to help you get started:

+

Example tests with run commands to help you get started:

Run an [example test](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/my_first_test.py) in Chrome: (Default: ``--browser=chrome``) @@ -19,7 +19,7 @@ Run an [example test](https://github.com/seleniumbase/SeleniumBase/blob/master/e 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: @@ -27,7 +27,7 @@ Run an [example test](https://github.com/seleniumbase/SeleniumBase/blob/master/e pytest test_demo_site.py ``` -
+
Run an example test in Firefox: @@ -41,7 +41,7 @@ Run an example test in Demo Mode: (highlight assertions) pytest test_swag_labs.py --demo ``` -
+
Run a [Wordle-solver example](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/wordle_test.py): @@ -49,7 +49,7 @@ Run a [Wordle-solver example](https://github.com/seleniumbase/SeleniumBase/blob/ pytest wordle_test.py ``` -
+
Run an example test in Headless Mode: (invisible browser) @@ -63,7 +63,7 @@ Run an [example test](https://github.com/seleniumbase/SeleniumBase/blob/master/e pytest test_swag_labs.py --mobile ``` -
+
Run another [example test](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/test_xkcd.py) in Demo Mode: (highlight assertions) @@ -71,7 +71,7 @@ Run another [example test](https://github.com/seleniumbase/SeleniumBase/blob/mas pytest test_xkcd.py --demo ``` -
+
Run a [test suite](https://github.com/seleniumbase/SeleniumBase/blob/master/examples/test_suite.py) with verbose output: (see more details) @@ -147,7 +147,7 @@ Try the new SeleniumBase Commander! A GUI for pytest: sbase gui ``` -
+
-------- @@ -179,7 +179,7 @@ For more advanced run commands, such as using a proxy server, see [../help_docs/ If you just need to perform some quick website verification on various devices, you can use the SeleniumBase Device Farm. Just plug in a website URL, and it will display how the website looks on four different devices: -
+
-------- @@ -189,11 +189,11 @@ To make things easier, here's a simple GUI program that allows you to run a few python gui_test_runner.py ``` - + -------- - + Tested with SeleniumBase diff --git a/examples/example_logs/ReadMe.md b/examples/example_logs/ReadMe.md index 3bffbc90..0a063b0f 100755 --- a/examples/example_logs/ReadMe.md +++ b/examples/example_logs/ReadMe.md @@ -1,4 +1,4 @@ -## [](https://github.com/seleniumbase/SeleniumBase/) Logs, The Dashboard, and Reports: +## [](https://github.com/seleniumbase/SeleniumBase/) Logs, The Dashboard, and Reports:

(The Dashboard Tutorial on YouTube)

@@ -22,7 +22,7 @@ pytest test_fail.py -------- -

The SeleniumBase Dashboard:

+

The SeleniumBase Dashboard:

🔵 The ``--dashboard`` option for pytest generates a SeleniumBase Dashboard located at ``dashboard.html``, which updates automatically as tests run and produce results. Example: @@ -30,7 +30,7 @@ pytest test_fail.py pytest --dashboard --rs --headless ``` -The SeleniumBase Dashboard +The SeleniumBase Dashboard 🔵 Additionally, you can host your own SeleniumBase Dashboard Server on a port of your choice. Here's an example of that using Python 3's ``http.server``: @@ -46,11 +46,11 @@ python -m http.server 1948 pytest test_suite.py --dashboard --rs --headless ``` -The SeleniumBase Dashboard +The SeleniumBase Dashboard -------- -

Pytest Reports:

+

Pytest Reports:

🔵 Using ``--html=report.html`` gives you a fancy report of the name specified after your test suite completes. @@ -58,7 +58,7 @@ pytest test_suite.py --dashboard --rs --headless pytest test_suite.py --html=report.html ``` -Example Pytest Report +Example Pytest Report 🔵 When combining pytest html reports with SeleniumBase Dashboard usage, the pie chart from the Dashboard will get added to the html report. Additionally, if you set the html report URL to be the same as the Dashboard URL when also using the dashboard, (example: ``--dashboard --html=dashboard.html``), then the Dashboard will become an advanced html report when all the tests complete. @@ -68,7 +68,7 @@ pytest test_suite.py --html=report.html pytest test_suite.py --dashboard --html=report.html ``` -Dashboard Pytest HTML Report +Dashboard Pytest HTML Report -------- @@ -88,7 +88,7 @@ pytest test_suite.py --junit-xml=report.xml -------- -

Nosetest Reports:

+

Nosetest Reports:

The ``nosetests`` ``--report`` option gives you a fancy report after your tests complete. @@ -96,13 +96,13 @@ The ``nosetests`` ``--report`` option gives you a fancy report after your tests nosetests test_suite.py --report ``` -Example Nosetest Report +Example Nosetest Report (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.) -------- -

🐝⚪ Behave Dashboard & Reports:

+

🐝⚪ Behave Dashboard & Reports:

(The [behave_bdd/](https://github.com/seleniumbase/SeleniumBase/tree/master/examples/behave_bdd) folder can be found in the [examples/](https://github.com/seleniumbase/SeleniumBase/tree/master/examples) folder.) @@ -110,7 +110,7 @@ nosetests test_suite.py --report behave behave_bdd/features/ -D dashboard -D headless ``` - + You can also use ``--junit`` to get ``.xml`` reports for each Behave feature. Jenkins can use these files to display better reporting for your tests. @@ -120,4 +120,4 @@ behave behave_bdd/features/ --junit -D rs -D headless -------- -
SeleniumBase
+
SeleniumBase
diff --git a/help_docs/customizing_test_runs.md b/help_docs/customizing_test_runs.md index b679b0a8..84d0c564 100755 --- a/help_docs/customizing_test_runs.md +++ b/help_docs/customizing_test_runs.md @@ -1,4 +1,4 @@ -## [](https://github.com/seleniumbase/SeleniumBase/) pytest options for SeleniumBase +## [](https://github.com/seleniumbase/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. @@ -199,7 +199,7 @@ sbase options -------- -

Example tests using Logging:

+

Example tests using Logging:

To see logging abilities, you can run a test suite that includes tests that fail on purpose: @@ -209,7 +209,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). -

Demo Mode:

+

Demo Mode:

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: @@ -223,15 +223,15 @@ You can override the default wait time by either updating [settings.py](https:// pytest my_first_test.py --demo --demo-sleep=1.2 ``` -

Passing additional data to tests:

+

Passing additional data to tests:

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. -

Running tests multithreaded:

+

Running tests multithreaded:

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. -

Retrying failing tests automatically:

+

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: @@ -239,7 +239,7 @@ You can use ``--reruns=NUM`` to retry failing tests that many times. Use ``--rer pytest --reruns=1 --reruns-delay=1 ``` -

Debugging tests:

+

Debugging tests:

You can use the following calls in your scripts to help you debug issues: @@ -257,7 +257,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). -

Combinations of options:

+

Combinations of options:

🎛️ 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: @@ -278,7 +278,7 @@ The above not only runs tests in parallel processes, but it also tells tests in -------- -

The SeleniumBase Dashboard:

+

The SeleniumBase Dashboard:

🔵 The ``--dashboard`` option for pytest generates a SeleniumBase Dashboard located at ``dashboard.html``, which updates automatically as tests run and produce results. Example: @@ -286,7 +286,7 @@ The above not only runs tests in parallel processes, but it also tells tests in pytest --dashboard --rs --headless ``` -The SeleniumBase Dashboard +The SeleniumBase Dashboard 🔵 Additionally, you can host your own SeleniumBase Dashboard Server on a port of your choice. Here's an example of that using Python 3's ``http.server``: @@ -302,11 +302,11 @@ python -m http.server 1948 pytest test_suite.py --dashboard --rs --headless ``` -The SeleniumBase Dashboard +The SeleniumBase Dashboard -------- -

Pytest Reports:

+

Pytest Reports:

🔵 Using ``--html=report.html`` gives you a fancy report of the name specified after your test suite completes. @@ -314,7 +314,7 @@ pytest test_suite.py --dashboard --rs --headless pytest test_suite.py --html=report.html ``` -Example Pytest Report +Example Pytest Report 🔵 When combining pytest html reports with SeleniumBase Dashboard usage, the pie chart from the Dashboard will get added to the html report. Additionally, if you set the html report URL to be the same as the Dashboard URL when also using the dashboard, (example: ``--dashboard --html=dashboard.html``), then the Dashboard will become an advanced html report when all the tests complete. @@ -324,7 +324,7 @@ pytest test_suite.py --html=report.html pytest test_suite.py --dashboard --html=report.html ``` -Dashboard Pytest HTML Report +Dashboard Pytest HTML Report If viewing pytest html reports in [Jenkins](https://www.jenkins.io/), you may need to [configure Jenkins settings](https://stackoverflow.com/a/46197356) for the html to render correctly. This is due to [Jenkins CSP changes](https://www.jenkins.io/doc/book/system-administration/security/configuring-content-security-policy/). @@ -336,7 +336,7 @@ pytest test_suite.py --junit-xml=report.xml -------- -

Nosetest Reports:

+

Nosetest Reports:

The ``--report`` option gives you a fancy report after your test suite completes. @@ -344,13 +344,13 @@ The ``--report`` option gives you a fancy report after your test suite completes nosetests test_suite.py --report ``` -Example Nosetest Report +Example Nosetest Report (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.) -------- -

Language Locale Codes

+

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: @@ -362,7 +362,7 @@ Visit Customizing default settings: +

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. 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)) @@ -375,7 +375,7 @@ pytest --settings-file=custom_settings.py -------- -

Running tests on a remote Selenium Grid:

+

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: @@ -427,7 +427,7 @@ pytest test_demo_site.py --protocol=https --server=IP_ADDRESS --port=PORT -------- -

Using a Proxy Server:

+

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. @@ -457,7 +457,7 @@ pytest proxy_test.py --proxy=proxy1 -------- -

Changing the User-Agent:

+

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. @@ -465,7 +465,7 @@ pytest proxy_test.py --proxy=proxy1 pytest user_agent_test.py --agent="Mozilla/5.0 (Nintendo 3DS; U; ; en) Version/1.7412.EU" ``` -

Mobile Device Testing:

+

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/). @@ -482,4 +482,4 @@ pytest test_swag_labs.py --mobile --agent="Mozilla/5.0 (Linux; Android 9; Pixel -------- -[](https://github.com/seleniumbase/SeleniumBase) +[](https://github.com/seleniumbase/SeleniumBase) diff --git a/help_docs/recorder_mode.md b/help_docs/recorder_mode.md index 9fecb283..1e6bb894 100755 --- a/help_docs/recorder_mode.md +++ b/help_docs/recorder_mode.md @@ -1,11 +1,11 @@ -## [](https://github.com/seleniumbase/SeleniumBase/) Recorder Mode 🔴 +## [](https://github.com/seleniumbase/SeleniumBase/) Recorder Mode 🔴

(Watch the tutorial on YouTube)

🔴 SeleniumBase Recorder Mode lets you record & export browser actions into test automation scripts.
- + 🔴 To make a new recording with Recorder Mode, use ``sbase mkrec``, ``sbase codegen``, or ``sbase record``): @@ -44,7 +44,7 @@ sbase recorder * Starting the SeleniumBase Recorder Desktop App... ``` - + 🔴 While a recording is in progress, you can press the ``[ESC]`` key to pause the Recorder. To resume the recording, you can hit the ``[~`]`` key, which is located directly below the ``[ESC]`` key on most keyboards.