To run tests, make sure you've already installed SeleniumBase using pip install seleniumbase OR pip install -r requirements.txt + python setup.py install from the top-level directory.
You can interchange pytest with nosetests, but using pytest is strongly recommended because developers stopped supporting nosetests. 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 (--browser=chrome is the default):
pytest my_first_test.pyRun an example test in Firefox:
pytest my_first_test.py --browser=firefoxRun an example test in Demo Mode (highlights page objects being acted on):
pytest my_first_test.py --demo_modeRun an example test demonstrating parameterization:
pytest parameterized_test.pyRun an example test suite and generate an pytest report: (pytest-only)
pytest test_suite.py --html=report.htmlRun an example test suite and generate a nosetest report: (nosetests-only)
nosetests test_suite.py --report --show_reportRun an example test using a nosetest configuration file: (nosetests-only)
nosetests my_first_test.py --config=example_config.cfgRun a test demonstrating the use of SeleniumBase Python decorators available:
pytest rate_limiting_test.pyRun a failing test: (See the latest_logs/ folder afterwards for logs and screenshots)
pytest test_fail.pyRun a failing test with Debugging-mode enabled: (If a test failure occurs, pdb activates)
pytest test_fail.py --pdb -sRun an example test suite that demonstrates the use of pytest markers:
pytest -v -m marker_test_suiteRun a test that demonstrates how to upload a file to a website:
pytest upload_file_test.pyFor 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
