==================================
This little project contains scripts to test web pages. We have done this before but in the Java language. I have decided to move to Python as it is easier to understand, in my opinon at least.
This project uses Selenium as the main testing framework and uses a Python virtual environment. The following will guide you to setup this project.
If you have Python already installed or you are on a Mac, ignore this part. You can download the latest version of Python here
You can use the virtualenv package to start the project. use pip install virtualenv to install the package on your machine.
In order for Selenium to work on browsers, we need to install the respective drivers for a web browsers. I have some popular drivers listed below along with the download.
- Chrome: chromedriver
- Firefox: geckodriver
- Opera: operariver
- Edge: edgedriver
Make sure to add the folder that contains the drivers into your machine's path. Here is a mini article to add a folder to your path. Make sure that folder contains the webdrivers!
Make sure to clone / download the project into the directory you want by using the command line or terminal. Once you are in the directory you want the project to be in, type git clone https://github.com/Suttungr/webTesting.git . Or you can go to the GitHub page and download the project by clicking the green button, and select "Download ZIP".
Because this project is based in a little bubble of Python, we're gonna have to activate the environment and download the requirements.
Once the project is downloaded, make sure to start the virtual environment.
- Navigate to the webTesting directory
- Type venv\Scripts\activate to activate the virtual environment
You can tell if the environment is active if at the beginning of the prompt has this text: (venv) . In order to deactivate the environment, just type deactivate .
There is a file present called requirements.txt that we will use to download the necessary requirements. Simply type pip install -r requirements.txt to download all the necessary requirements. Make sure the environment is active.
Once the venv (virtual environment) is active, type python main.py to run the script. Make sure to go into the "main.py" file to change the test URL and browser if need be.