project / repo / mailing list / issues
ℹ️ Note
The canonical project locations are linked above. Other locations are mirrors.
This is a simple template for a selenium web-based test library. It includes some tools which help make selenium-based tests more robust and reliable.
selenium-tools
- project root directorysrc
- source code root directory.venv
- Python virtual environment (created during installation)driver
- module containing basic selenium webdriver codelocators
- selenium locators and related Python codepages
- code related to the Page Object Modeltests
- test code
chromedriver.exe
- chromedriver (created during installation)parameters.yaml
- test configuration filereadme.md
- this readmerequirements.txt
- Python requirements for installation using pip
This guide assumes the following prerequisites have been met:
- Chrome browser installed
Change directory to the project root directory, then execute the following command to create the virtual environment:
python -m venv .venv
Then activate the virtual environment using the command appropriate for your shell. See the documentation for more info.
Download the version of chromedriver matching the version of your Chrome browser
installation. See
the Chrome for Testing site
for download links. Extract the .zip
file and copy the chromeriver file to the root
project directory.
The required Python modules are listed in requirements.txt
. Install them in your
activated virtual environment using:
python -m pip install -r requirements.txt
Test configuration parameters are contained in parameters.yaml
.
In the base project directory with the configured virtual environment activated, execute
the following to run all tests in the tests.py
module:
python -m unittest tests
Run a specific test suite using:
python -m unittest tests.ExampleTestSuite
Run a specific test case using:
python -m unittest tests.ExampleTestSuite.test_example_test
See unittest documentation for more details.