SeleniumBase/examples
Michael Mintz 23e7dd774a Add option to change the default MySQL port 2020-02-19 03:42:00 -05:00
..
boilerplates Update boilerplate to save a screenshot before the tearDown() 2019-12-27 20:19:47 -05:00
capabilities Update a ReadMe 2019-12-31 17:49:33 -05:00
example_logs Update the sample logs 2020-01-13 02:57:24 -05:00
master_qa Update docs 2019-09-10 13:09:07 -04:00
tour_examples Update the Docs 2020-01-27 00:04:21 -05:00
visual_testing Update comments and ReadMe files 2020-02-18 02:10:36 -05:00
ReadMe.md Update the Docs 2020-01-24 02:26:07 -05:00
__init__.py Fresh Copy 2015-12-04 16:11:53 -05:00
basic_test.py Update the example test 2019-08-13 02:27:03 -04:00
custom_settings.py Add option to change the default MySQL port 2020-02-19 03:42:00 -05:00
decryption_test.py Add a new example test 2019-09-16 05:13:20 -04:00
edge_test.py Update edge_test.py 2020-01-17 00:17:55 -05:00
example_config.cfg Update example config files 2018-03-05 17:33:07 -05:00
github_test.py Update a test 2019-07-14 01:02:45 -04:00
gui_test_runner.py Update the GUI test runner 2019-09-16 05:14:57 -04:00
handle_alert_test.py Add an example test for handling alerts 2019-08-17 02:47:11 -04:00
image_test.py Add image test to save an element screenshot to a file 2019-04-06 01:21:03 -04:00
ip_cow_test.py Add the ip_cow test 2019-03-17 02:09:30 -04:00
my_first_test.py Update test comments 2019-10-29 00:36:07 -04:00
parameterized_test.py Update example tests 2019-09-05 04:41:36 -04:00
proxy_test.py Update example tests 2019-08-06 01:39:32 -04:00
rate_limiting_test.py Make it easier to import SeleniumBase decorators 2018-03-03 19:09:18 -05:00
raw_parameter_script.py Add the --time-limit=s feature to fail long-running tests 2020-01-15 03:16:04 -05: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 2019-11-05 01:56:23 -05:00
test_chinese_pdf.py Add a test for verifying PDF testing with Chinese characters 2019-11-29 00:15:24 -05:00
test_delayed_asserts.py Rename a test 2019-09-16 05:04:40 -04:00
test_double_click.py Update an example test 2020-01-07 00:35:42 -05:00
test_event_firing.py Add an example to demonstrate EventFiringWebDriver 2019-11-29 22:42:08 -05:00
test_fail.py Update test comments 2019-10-25 01:19:11 -04:00
test_get_pdf_text.py Update a test 2019-11-29 00:14:05 -05:00
test_hack_search.py Add test demonstrating set_attribute() and set_attributes() 2019-12-24 18:43:08 -05:00
test_inspect_html.py Update a test comment 2019-11-21 00:19:57 -05:00
test_markers.py Update pytest marker test suite 2019-05-16 00:25:26 -04:00
test_null.py Add the minimum test example 2020-02-18 02:11:20 -05:00
test_pdf_asserts.py Add a test for asserting text in a PDF file 2019-11-22 02:16:24 -05:00
test_pytest_parametrize.py Update test file spelling 2019-11-27 01:52:25 -05:00
test_sb_fixture.py Add tests around the "sb" pytest fixture 2019-08-02 02:21:51 -04:00
test_skype_site.py Add a mobile device test of the Skype website 2020-01-19 02:15:37 -05:00
test_suite.py Update example tests 2018-12-11 02:01:57 -05:00
test_swag_labs.py Update test comments 2020-02-05 22:14:15 -05:00
test_usefixtures.py Add tests around the "sb" pytest fixture 2019-08-02 02:21:51 -04:00
timeout_test.py Add the --time-limit=s feature to fail long-running tests 2020-01-15 03:16:04 -05:00
upload_file_test.py Update an example test 2019-12-11 02:34:27 -05:00
user_agent_test.py Update the user agent test 2019-03-17 02:05:07 -04:00
xpath_test.py Add an example test with XPath selectors 2019-10-25 01:19:58 -04:00

ReadMe.md

Running Example Tests

SeleniumBase tests can be run with either pytest or nosetests, but using pytest is strongly recommended. Chrome is the default browser if not specified.

During test failures, logs and screenshots from the most recent test run will get saved to the latest_logs/ folder. Those logs will get moved to archived_logs/ if you have ARCHIVE_EXISTING_LOGS set to True in settings.py

(NOTE: Many tests in this folder fail on purpose to demonstrate the built-in logging, screenshots, and reporting features.)

Here are some example run commands to help get you 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 an example test in Headless Mode: (invisible browser)

pytest my_first_test.py --headless

Run tests with verbose output: (includes more details)

pytest test_suite.py -v

Run tests multi-threaded using [n] threads:

pytest test_suite.py -v -n=4

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

pytest parameterized_test.py -v

Run a test suite and generate a pytest report: (pytest-only)

pytest test_suite.py -v --html=report.html

Run a failing test: (See the latest_logs/ folder for logs and screenshots)

pytest test_fail.py

Run an example test using Chrome's mobile device emulator: (default settings)

pytest test_swag_labs.py --mobile

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

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

Run an example test suite and generate a nosetest report: (nosetests-only)

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

Run an example test using a nosetest configuration file: (nosetests-only)

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