Pytest Automation with Selenium
You can download the latest Python version from Python.org.
also requires pipenv.
To install pipenv, run pip install pipenv
from the command line.
You should also have a Python editor/IDE of your choice. Good choices include Visual Studio Code and PyCharm.
For Web UI testing, you will need to install the latest versions of Microsoft Edge Google Chrome and Mozilla Firefox. You can use other browsers with Selenium WebDriver, but the course will use Microsoft Edge, Chrome and Firefox.
You will also need to install the latest versions of the WebDriver executables for these browsers: EdgeDriver for Microsoft Edge, ChromeDriver for Chrome and geckodriver for Firefox. Each test case will launch the WebDriver executable for its target browser. The WebDriver executable will act as a proxy between the test automation and the browser instance. Please use the latest versions of both the browsers and the WebDriver executables. Older versions might be incompatible with each other.
EdgeDriver, ChromeDriver and geckodriver must be installed on the system path.
To install ChromeDriver and geckodriver on Windows:
- Create a folder named
C:\Selenium
. - Move the executables into this folder.
- Add this folder to the Path environment variable.
To verify correct setup on any operating system, simply try to run them from the terminal:
$ msedgedriver
$ ChromeDriver
$ geckodriver
You may or may not see any output. Just verify that you can run them without errors. Use Ctrl-C to kill them.
- Clone this repository.
- Run
pipenv install
to install the dependencies. - Run
pipenv run python -m pytest
to verify that the framework can run tests.
A few people attempting to set up this project
encountered the following error when executing pipenv run python -m pytest
:
ModuleNotFoundError: No module named 'atomicwrites'
- Upgrade Python to the latest versions. The following worked for me on Windows:
- Python 3.11.4 (
python --version
) - pip 23.1.2 (
pip --version
) - pipenv 2023.7.11 (
pipenv --version
)
- Python 3.11.4 (
- Run
pipenv update
from within the project directory.
If upgrades don't work, try forcing package installation:
- Run
pipenv install pytest
from within the project directory. - Run
pipenv install atomicwrites
from within the project directory.
If these steps don't work in your project, then try to run without pipenv:
- Install Python packages directly using
pip
. - Run tests directly using
python -m pytest
.