- Support for browser:
- Chrome (default)
- Edge
- Firefox
- Safari
- Support headless test runs
- Selenium 4.7.0
- Logging info for each action
- HTML Report and HTML dashboard For more features, see SeleniumBase Features.
IDE used: PyCharm
Python Selenium Web Automation Framework requires Python v3+ and SeleniumBase to run. Once you install Python from their official website now it's time to Install SeleniumBase:
pip3 install seleniumbase
Note: If your python is version 3 above you will need to run pip3 otherwise pip will work
Next you need to install browser drive for instance chromeDrive through seleniumBase:
sbase get chromedriver latest
Create a virtual environment on your local machine. See Pipenv & Virtual Environments for details.
Install the dependencies:
python3 -m pip install -r requirements.txt
Folders:
- assets: This folder will contain all the files like images, css files or json files or test data.
- custom_Screenshot: This folder will save any screenshots that you make
- latest_logs: This folder will be generated when a test fails to save any log and screenshots.
- recordings: This folder will be generated when you use the recorder feature to store the test code generated.
- tests: All the test cases python files will be kept here.
- requirements.txt: This file stores information about all the libraries, modules, and packages which are specific to project.
Test report files:
- dashboard.html
- report.html
To run each individual test, right-click on the test name on pyCharm IDE and select "run ". To run a test file, go to the terminal and type:
pytest -k <file name without .py> --dashboard --rs --html=report.html
or
pytest tests/<file name with .py> --dashboard --rs --html=report.html
Some useful options pytest
include --headless
(without opening up a browser) and --demo
(for showcasing the test run).
To see a full list of options, go to the terminal and type:
sbase options
If you need cross browser testing for instance firefox you can provide it as a flag:
pytest -k <test_file_name> --browser=firefox
If you need parallel testing for instance you need 3 browser instance to speed up tests run:
pytest -n=3
Read here.
Read here.
- Page object model pattern (see 5. Page Object Model with BaseCase and Page Object Model with the "sb" fixture)
- Test suite file at project root folder