5f3e42e4b7 | ||
---|---|---|
.. | ||
boilerplates | ||
example_logs | ||
master_qa | ||
ReadMe.md | ||
__init__.py | ||
basic_script.py | ||
delayed_assert_test.py | ||
example_config.cfg | ||
github_test.py | ||
gui_test_runner.py | ||
my_first_test.py | ||
my_test_suite.py | ||
proxy_test.py | ||
rate_limiting_test.py | ||
run_my_first_test_in_chrome.sh | ||
run_my_first_test_in_firefox.sh | ||
run_rate_limiting_test.sh | ||
run_test_fail_with_logging.sh | ||
setup.cfg | ||
test_fail.py |
ReadMe.md
Running SeleniumBase Scripts
(NOTE: If you didn't install SeleniumBase properly, these scripts won't work. Installation steps include "pip install seleniumbase
" and/or "python setup.py develop
" from the top-level directory.)
To makes things easier, here's a simple GUI program that allows you to kick off a few example scripts by pressing a button:
python gui_test_runner.py
(NOTE: With the exception of my_first_test.py, which should pass, many other tests in this folder fail on purpose to demonstrate features such as screenshots on failure, exception logging, and test reports.)
(NOTE: You can interchange nosetests
with pytest
in most of these examples.)
When you run tests, you’ll see two folders appear: “latest_logs” and “archived_logs”. The “latest_logs” folder will contain log files from the most recent test run, but logs will only be created if the test run is failing. Afterwards, logs from the “latest_logs” folder will get pushed to the “archived_logs” folder if you have have the ARCHIVE_EXISTING_LOGS
feature enabled in settings.py.
For running scripts the usual way, here are some of the example run commands:
Run the example test in Chrome:
pytest my_first_test.py --browser=chrome
Run the example test in Firefox:
pytest my_first_test.py --browser=firefox
Run the example test in Demo Mode (runs slower and adds highlights):
pytest my_first_test.py --browser=chrome --demo_mode
Run the example test suite in Chrome and generate an html report: (nosetests-only)
nosetests my_test_suite.py --browser=chrome --report
Run the example test suite in Firefox and generate an html report: (nosetests-only)
nosetests my_test_suite.py --browser=firefox --report
Run a test with configuration specifed by a config file:
nosetests my_first_test.py --config=example_config.cfg
Run a test demonstrating the use of Python decorators available:
nosetests rate_limiting_test.py
Run a failing test with pdb mode enabled: (If a test failure occurs, test enters pdb mode)
nosetests test_fail.py --browser=chrome --pdb --pdb-failures
Run a failing test (and then look into the latest_logs
folder afterwards:
pytest test_fail.py --browser=chrome
(NOTE: If you see any *.pyc
files appear as you run tests, that's perfectly normal. Compiled bytecode is a natural result of running Python code.)