SeleniumBase/examples
Michael Mintz 1cdcc5bfee Build only py3 wheels for PyPI 2023-01-25 01:27:21 -05:00
..
behave_bdd Update output in ReadMe examples of behave/BDD tests 2023-01-16 13:06:42 -05:00
boilerplates Update example tests 2023-01-19 00:07:40 -05:00
capabilities Update the documentation 2022-11-26 15:37:54 -05:00
case_plans Add SeleniumBase Case Plans 2022-08-17 02:04:48 -04:00
chart_maker Update the documentation 2022-12-23 22:59:16 -05:00
desktop_apps Update the documentation 2022-12-23 22:59:16 -05:00
dialog_boxes Update the documentation 2022-11-07 13:52:25 -05:00
example_logs Update example logs 2023-01-03 19:57:56 -05:00
master_qa Update the documentation 2022-11-26 15:37:54 -05:00
migration Update example tests 2023-01-20 18:27:05 -05:00
offline_examples Update example tests 2022-11-25 13:12:58 -05:00
presenter Update the documentation 2022-12-23 22:59:16 -05:00
tour_examples Update example tests 2022-12-31 04:24:53 -05:00
translations Update translated example tests 2023-01-23 13:07:22 -05:00
unit_tests Update the docs 2022-11-05 01:27:22 -04:00
visual_testing Update the documentation 2022-12-23 22:59:16 -05:00
ReadMe.md Update the documentation 2022-12-31 01:34:13 -05:00
__init__.py Fresh Copy 2015-12-04 16:11:53 -05:00
basic_test.py Update example tests 2023-01-19 22:50:04 -05:00
case_summary.md Add "case_summary.md" 2022-08-18 15:49:52 -04:00
coffee_cart_tests.py Update an example test 2023-01-04 12:00:21 -05:00
custom_settings.py Update example tests 2022-08-26 22:01:13 -04:00
edge_test.py Update examples 2022-05-13 16:19:05 -04:00
example_config.cfg Update example config files 2018-03-05 17:33:07 -05:00
github_test.py Update example tests 2023-01-14 21:32:43 -05:00
gui_test_runner.py Update example tests 2023-01-19 22:50:04 -05:00
hack_the_planet.py Update an example script 2023-01-23 13:08:15 -05:00
handle_alert_test.py Update examples (to run with "python" or "pytest") 2023-01-13 10:15:32 -05:00
list_assert_test.py Update example tests 2022-02-01 00:59:15 -05:00
locale_code_test.py Refactor the tests 2021-05-05 21:06:24 -04:00
my_first_test.py Update example tests 2023-01-03 19:58:42 -05:00
nth_child_test.py Update examples (to run with "python" or "pytest") 2023-01-13 10:15:32 -05:00
old_wordle_script.py Update example tests 2022-11-11 14:38:21 -05:00
parameterized_test.py Update example tests 2023-01-19 22:50:04 -05:00
performance_test.py Update example tests 2022-10-10 19:57:06 -04:00
proxy_test.py Update example tests 2023-01-14 21:32:43 -05:00
pytest.ini Update example tests 2022-11-25 13:12:58 -05:00
rate_limiting_test.py Update example tests 2022-08-12 14:59:44 -04:00
raw_browser_launcher.py Update example tests 2023-01-14 21:32:43 -05:00
raw_call.py Update example tests 2022-12-31 01:35:02 -05:00
raw_driver_context.py Update example tests 2023-01-14 21:32:43 -05:00
raw_file_call.py Update example tests 2022-12-31 16:43:19 -05:00
raw_main_call.py Update example tests 2022-12-31 01:35:02 -05:00
raw_parameter_script.py Add option to capture CDP events in UC Mode 2023-01-19 00:02:04 -05:00
raw_sb.py Update example tests 2022-12-02 02:02:35 -05:00
raw_test_scripts.py Update example tests 2022-10-20 00:02:55 -04:00
setup.cfg Build only py3 wheels for PyPI 2023-01-25 01:27:21 -05:00
shadow_root_test.py Update a Shadow Root test 2021-11-25 12:40:09 -05:00
swag_labs_user_tests.py Update example tests 2023-01-03 19:58:42 -05:00
test_agent.py Update example tests 2023-01-19 00:07:40 -05:00
test_apple_site.py Update example tests 2022-12-31 04:24:53 -05:00
test_calculator.py Update example tests 2022-12-31 01:35:02 -05:00
test_canvas.py Update example tests 2022-11-05 00:47:58 -04:00
test_checkboxes.py Update example tests 2022-08-26 22:01:13 -04:00
test_chinese_pdf.py Update example tests 2023-01-19 00:07:40 -05:00
test_chromedriver.py Update example tests 2022-05-26 20:14:48 -04:00
test_coffee_cart.py Update example tests 2023-01-03 19:58:42 -05:00
test_console_logging.py Update example tests 2023-01-19 00:07:40 -05:00
test_contains_selector.py Update example tests 2023-01-19 00:07:40 -05:00
test_cycle_elements.py Update example tests 2023-01-19 00:07:40 -05:00
test_decryption.py Update example tests 2023-01-19 00:07:40 -05:00
test_deferred_asserts.py Update example tests 2023-01-19 00:07:40 -05:00
test_demo_site.py Update example tests 2022-12-31 01:35:02 -05:00
test_detect_404s.py Refactor the tests 2021-05-05 21:06:24 -04:00
test_docs_site.py Update example tests 2023-01-14 21:32:43 -05:00
test_double_click.py Update examples (to run with "python" or "pytest") 2023-01-13 10:15:32 -05:00
test_download_files.py Update an example test 2023-01-13 00:49:08 -05:00
test_download_images.py Update an example test 2023-01-03 22:10:50 -05:00
test_drag_and_drop.py Update example tests 2022-10-29 23:29:55 -04:00
test_error_page.py Update examples 2022-06-06 23:50:26 -04:00
test_event_firing.py Update example tests 2023-01-19 22:50:04 -05:00
test_fail.py Refactor the tests 2021-05-05 21:06:24 -04:00
test_get_locale_code.py Update example tests 2023-01-19 22:50:04 -05:00
test_get_pdf_text.py Update example tests 2022-08-12 14:59:44 -04:00
test_get_user_agent.py Refactor the tests 2021-05-05 21:06:24 -04:00
test_hack_search.py Refactoring 2022-06-24 14:14:17 -04:00
test_iframes.py Update examples (to run with "python" or "pytest") 2023-01-13 10:15:32 -05:00
test_image_saving.py Update example tests 2022-09-24 01:42:16 -04:00
test_inspect_html.py Refactor the tests 2021-05-05 21:06:24 -04:00
test_login.py Update example tests 2022-11-09 01:04:43 -05:00
test_markers.py Refactor the tests 2021-05-05 21:06:24 -04:00
test_mfa_login.py Update example tests 2023-01-03 19:58:42 -05:00
test_multiple_drivers.py Add an example test that uses multiple drivers 2022-01-08 20:25:05 -05:00
test_null.py Refactor the tests 2021-05-05 21:06:24 -04:00
test_override_driver.py Update example tests 2023-01-20 18:27:05 -05:00
test_override_sb_fixture.py Update example tests 2023-01-20 18:27:05 -05:00
test_parse_soup.py Update example tests 2022-12-31 16:43:19 -05:00
test_pdf_asserts.py Update example tests 2022-08-12 14:59:44 -04:00
test_pytest_parametrize.py Refactor the tests 2021-05-05 21:06:24 -04:00
test_repeat_tests.py Refactor examples 2022-04-13 13:40:01 -04:00
test_request_sb_fixture.py Refactor the tests 2021-05-05 21:06:24 -04:00
test_save_screenshots.py Refactor the tests 2021-05-05 21:06:24 -04:00
test_sb_fixture.py Update example tests 2022-08-26 22:01:13 -04:00
test_scrape_bing.py Update example tests 2022-08-12 14:59:44 -04:00
test_select_options.py Update example tests 2023-01-14 21:32:43 -05:00
test_shadow_dom.py Update example tests 2022-06-10 22:14:17 -04:00
test_show_file_choosers.py Update example tests 2023-01-19 22:50:04 -05:00
test_skype_site.py Update example tests 2023-01-19 22:50:04 -05:00
test_suite.py Update example tests 2022-12-31 01:35:02 -05:00
test_swag_labs.py Update example tests 2023-01-03 19:58:42 -05:00
test_tinymce.py Update example tests 2023-01-14 21:32:43 -05:00
test_todomvc.py Update example tests 2023-01-14 21:32:43 -05:00
test_url_asserts.py Add an example test 2023-01-04 16:47:13 -05:00
test_usefixtures.py Update example tests 2022-10-14 03:58:18 -04:00
test_verify_chromedriver.py Rename a test 2022-08-15 20:59:30 -04:00
test_window_switching.py Update examples (to run with "python" or "pytest") 2023-01-13 10:15:32 -05:00
test_xfail.py Refactor the tests 2021-05-05 21:06:24 -04:00
test_xkcd.py Update example tests 2022-02-01 00:59:15 -05:00
time_limit_test.py Update example tests 2022-10-10 19:57:06 -04:00
uc_cdp_events.py Update example tests 2023-01-20 18:27:05 -05:00
upgrade_chromedriver.py Update example tests 2022-10-01 20:29:20 -04:00
upload_file_test.py Update example tests 2022-12-21 17:30:25 -05:00
user_agent_test.py Update example tests 2023-01-19 00:07:40 -05:00
verify_undetected.py Update example tests 2023-01-20 18:27:05 -05:00
wordle_test.py Update the Wordle-solver example test 2023-01-13 00:48:51 -05:00
xpath_test.py Update example tests 2022-10-29 23:29:55 -04:00
youtube_search_test.py Update examples 2022-06-15 13:42:17 -04:00

ReadMe.md

Example Tests:

SeleniumBase Demo Page

(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: (Default option: --browser=chrome)

pytest test_demo_site.py



Run an example test in Firefox:

pytest my_first_test.py --browser=firefox

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

pytest test_swag_labs.py --demo



Run test_coffee_cart.py to test the Coffee Cart app:

pytest test_coffee_cart.py --demo
SeleniumBase Example

Run a Wordle-solver example:

pytest wordle_test.py



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 another example test in Demo Mode: (highlight assertions)

pytest test_xkcd.py --demo



Run a test suite with verbose output: (see more details)

pytest test_suite.py -v

Run a test suite 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 a test suite that demonstrates the use of pytest markers:

pytest -m marker_test_suite -v

Run a 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

Try the new SeleniumBase Commander! A GUI for pytest:

sbase gui



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


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:



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

(The newer SeleniumBase Commander improves on that.)


🎖️ To launch the SeleniumBase Commander GUI for pytest:

sbase gui

Tested with SeleniumBase