This repository is all about creating automated testing scripts using Python/Selenium WebDriver/Pytest and run them in scale using BlazeMeter.
This repo uses the following open source project:
Selenium WebDriver
Selenium WebDriver is an open source tool for automated testing of web apps across many browsers.
It provides capabilities for navigating to web pages, user input, JavaScript execution, and more.
If you wish to create automated tests and monitor the quality of your product, Selenium WebDriver is one of the top tools to achieve exactly that.
Before diving into this repo, make sure you have the necessary knowledge on the following:
- Python fundamentals
- PyCharm (or any other code editor as you feel comfortable with)
- PyTest basics
- Selenium WebDriver Python bindings
- Github basics
- Chapter # 1 – Introduction to Selenium WebDriver
- Chapter # 2 – Installation Steps (IDE, Python, Selenium WebDriver)
- Chapter # 3 – Creating & Running Selenium WebDriver Test under Chrome
- Chapter # 4 – Useful Libraries & must-use Functions
- Chapter # 5 – How to Debug Selenium WebDriver Tests with PyCharm
- Chapter # 6 – Intro to Page Object Model (POM) Testing Architecture
- Chapter # 7 – Selenium Grid & Remote WebDriver
- Chapter # 8 – Integrate Selenium Tests into BlazeMeter
- Chapter # 9 – Parallel Running of Selenium Tests
Follow these steps to install all requirements of this repo on to your environment:
- Create a python virtual environment
python3 -m venv venv
- Activate your virtual env
source venv/bin/activate
[Mac]
c:\path\to\venv\Scripts\activate.bat
[Windows10] - Install selenium + pytest
pip install selenium
pip install pytest
- Download chromeDriver and geckoDriver
*Make sure the binary driver you download matches your current installed chrome/FF version - Store the binary files in the virtual env
MAC :venv/bin
Windows :venv/Scripts
Run your first selenium test
- Checkout branch: chapter#3-create-and-run-first-selenium-test
- Make sure you have activated you virtual environment
- Run the test using the following command:
pytest test_demo.py
*Chrome browser should be initiated and a login flow should be running automatically.
Run tests under page object model pattern
- Checkout branch: *chapter#6-page-object-model-intro
- Make sure you have activated you virtual environment
- Required environment variables:
BASE_URL
,USERNAME
,PASSWORD
To run a specific test:
BASE_URL=<BASE_URL> USERNAME=<USERNAME> PASSWORD=<PASSWORD> pytest test_homepage.py
Run tests integrated with Blazemeter
- Checkout branch: chapter#8-integrate-selenium-tests-into-blazemeter
- Make sure you have activated you virtual environment
- Required environment variables:
BASE_URL
,USERNAME
,PASSWORD
,API_KEY
,API_SECRET
- Generate api keys from
a.blazemeter.com
To run a specific test:
BASE_URL=<BASE_URL> USERNAME=<USERNAME> PASSWORD=<PASSWORD> API_KEY=<API_KEY> API_SECRET=<API_SECRET> pytest test_homepage.py
Run tests integrated with Blazemeter in parallel
- Checkout branch: chapter#9-parallel-running-of-selenium-tests
- Make sure you have activated you virtual environment
- Install
pytest-xdist
by running the following command:
pip install pytest-xdist
- Required environment variables:
BASE_URL
,USERNAME
,PASSWORD
,API_KEY
,API_SECRET
- Required commandline arguments:
-n 2
(2 parallel runs are available for free blazemeter users) - To run a specific test in parallel (2 concurrent browsers):
BASE_URL=<BASE_URL> USERNAME=<USERNAME> PASSWORD=<PASSWORD> API_KEY=<API_KEY> API_SECRET=<API_SECRET> pytest test_homepage.py -n 2
- Website: http://dbankdemo.com/bank/login
- username: [email protected]
- password: Demo123!