SeleniumBase/examples
Michael Mintz a401b37d7b Update the docs 2021-04-10 13:24:19 -04:00
..
boilerplates Update the example tests 2021-04-02 22:48:39 -04:00
capabilities Update examples 2021-01-25 14:40:13 -05:00
chart_maker Update the docs for ChartMaker 2021-03-14 20:25:01 -04:00
example_logs Update the docs 2021-04-10 13:24:19 -04:00
master_qa Update the docs 2021-03-26 17:52:11 -04:00
migration/protractor Update the Protractor migration ReadMe 2021-04-06 16:45:52 -04:00
offline_examples Update example tests 2021-03-19 00:22:46 -04:00
presenter Update examples 2021-03-10 17:27:52 -05:00
tour_examples Update the docs 2021-03-26 17:52:11 -04:00
translations Allow the use of "conftest.py" for configuring pytest 2021-04-10 12:57:35 -04:00
unit_tests Update the unit tests 2020-12-05 10:39:57 -05:00
visual_testing Update examples 2021-03-10 17:27:52 -05:00
ReadMe.md Update the list of SeleniumBase Syntax Formats 2021-03-19 00:21:21 -04:00
__init__.py Fresh Copy 2015-12-04 16:11:53 -05:00
basic_test.py Update examples 2021-01-25 14:40:13 -05:00
custom_settings.py Refactoring custom settings 2020-08-08 01:05:37 -04:00
decryption_test.py Update the example tests 2021-04-02 22:48:39 -04:00
edge_test.py Update example tests 2021-03-28 23:35:10 -04:00
example_config.cfg Update example config files 2018-03-05 17:33:07 -05:00
github_test.py Update examples 2020-12-18 01:25:31 -05:00
gui_test_runner.py Update examples 2020-05-28 03:37:44 -04:00
handle_alert_test.py Update examples 2021-03-10 17:27:52 -05:00
image_test.py Update examples 2021-03-10 17:27:52 -05:00
locale_code_test.py Update examples 2021-03-10 17:27:52 -05:00
my_first_test.py Update examples 2021-01-25 14:40:13 -05:00
nth_child_test.py Update examples 2020-08-14 02:07:57 -04:00
parameterized_test.py Update examples 2021-03-10 17:27:52 -05:00
proxy_test.py Update examples 2021-03-10 17:27:52 -05:00
pytest.ini Allow the use of "conftest.py" for configuring pytest 2021-04-10 12:57:35 -04:00
rate_limiting_test.py Update examples 2021-03-10 17:27:52 -05:00
raw_parameter_script.py Add custom Chromium args with: --chromium-arg="ARG,ARG" 2021-03-23 15:00:21 -04:00
setup.cfg Python 3 compatibility (remove semicolons from .cfg files) 2017-07-19 18:41:59 -04:00
swag_labs_suite.py Update the example tests 2021-04-02 22:48:39 -04:00
test_agent.py Update examples 2021-03-10 17:27:52 -05:00
test_apple_site.py Update examples 2021-03-10 17:27:52 -05:00
test_checkboxes.py Update examples 2021-03-10 17:27:52 -05:00
test_chinese_pdf.py Update examples 2021-03-10 17:27:52 -05:00
test_chromedriver.py Update an example test 2021-03-26 17:50:17 -04:00
test_contains_selector.py Update examples 2021-03-10 17:27:52 -05:00
test_deferred_asserts.py Update examples 2021-03-10 17:27:52 -05:00
test_demo_site.py Update examples 2021-03-10 17:27:52 -05:00
test_double_click.py Update examples 2021-03-10 17:27:52 -05:00
test_download_files.py Update example tests 2021-03-19 00:22:46 -04:00
test_drag_and_drop.py Update the examples 2020-08-08 01:21:28 -04:00
test_error_page.py Update examples 2021-03-10 17:27:52 -05:00
test_event_firing.py Update examples 2021-03-10 17:27:52 -05:00
test_fail.py Update examples 2021-03-10 17:27:52 -05:00
test_get_locale_code.py Update examples 2021-03-10 17:27:52 -05:00
test_get_pdf_text.py Update examples 2021-03-10 17:27:52 -05:00
test_get_user_agent.py Update examples 2021-03-10 17:27:52 -05:00
test_hack_search.py Update example tests 2021-03-28 23:35:10 -04:00
test_inspect_html.py Update examples 2021-03-10 17:27:52 -05:00
test_login.py Update the example tests 2021-04-02 22:48:39 -04:00
test_markers.py Update pytest marker test suite 2019-05-16 00:25:26 -04:00
test_null.py Update examples 2021-03-10 17:27:52 -05:00
test_parse_soup.py Update examples 2021-03-10 17:27:52 -05:00
test_pdf_asserts.py Update examples 2021-03-10 17:27:52 -05:00
test_pytest_parametrize.py Update examples 2020-06-14 01:17:02 -04:00
test_request_sb_fixture.py Update examples 2020-11-21 14:50:02 -05:00
test_sb_fixture.py Update examples 2020-11-21 14:50:02 -05:00
test_shadow_dom.py Update the Shadow DOM example test 2021-03-23 15:08:24 -04:00
test_skype_site.py Update example tests 2021-03-06 23:42:08 -05:00
test_suite.py Update example tests 2021-03-06 23:42:08 -05:00
test_swag_labs.py Update the example tests 2021-04-02 22:48:39 -04:00
test_tinymce.py Update examples 2021-03-10 17:27:52 -05:00
test_usefixtures.py Update example tests 2020-09-18 16:51:53 -04:00
test_window_switching.py Add an example test that has switching to a new tab/window 2021-03-16 19:40:31 -04:00
test_xfail.py Update examples 2021-03-10 17:27:52 -05:00
time_limit_test.py Update examples 2021-03-10 17:27:52 -05:00
upload_file_test.py Update example tests 2021-03-03 15:53:47 -05:00
user_agent_test.py Update examples 2021-03-10 17:27:52 -05:00
xpath_test.py Update examples 2021-03-10 17:27:52 -05:00

ReadMe.md

Running Example Tests:

SeleniumBase

  • SeleniumBase tests are run with pytest.
  • Chrome is the default browser if not specified.
  • Example tests are located in: SeleniumBase/examples/.
  • During test failures, logs and screenshots from the latest test run are saved to the latest_logs/ folder.
  • Tests can be structured using 17 unique syntax formats.

(NOTE: Some example tests fail on purpose to demonstrate logging features.)

Example tests with run commands to help you get started:

Run an example test in Chrome: (Default: --browser=chrome)

pytest my_first_test.py

Run an example test in Firefox:

pytest my_first_test.py --browser=firefox

Run an example test in Demo Mode: (highlight assertions)

pytest my_first_test.py --demo


Run a different example in Demo Mode:

pytest test_swag_labs.py --demo


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)

pytest test_swag_labs.py --mobile


Run tests with verbose output: (includes more details)

pytest test_suite.py -v

Run a test on the Demo Site to try many SeleniumBase methods:

pytest test_demo_site.py


Run tests multi-threaded using [n] threads:

pytest test_suite.py -n=4

Run a parameterized test: (Generates multiple tests from one)

pytest parameterized_test.py -v

Run a test suite and generate a SeleniumBase Dashboard:

pytest test_suite.py --dashboard

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)

pytest test_fail.py

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:

pytest -m marker_test_suite -v

Run an example test suite that reuses the browser session between tests:

pytest test_suite.py --reuse-session

Run an example test demonstrating the rate_limited Python decorator:

pytest rate_limiting_test.py

Run an example test that demonstrates how to upload a file to a website:

pytest upload_file_test.py

SeleniumBase tests can also be run with nosetests:

Run an example test with nosetests:

nosetests my_first_test.py

Run an example test suite and generate a nosetest report:

nosetests test_suite.py --report --show-report

Run an example test using a nosetest configuration file:

nosetests my_first_test.py --config=example_config.cfg

For more advanced run commands, such as using a proxy server, see ../help_docs/customizing_test_runs.md


To make things easier, here's a simple GUI program that allows you to run a few example tests by pressing a button:

python gui_test_runner.py

Tested with SeleniumBase