Skip to content

Test Automation framework using BDD, Python and Selenium

Notifications You must be signed in to change notification settings

pranavkakde/SeleniumPythonBDD

Repository files navigation

Docker build

SeleniumPythonBDD

This is a BDD Test Automation framework written in Python and Selenium. It generates html reports using Allure. This framework uses behave module for BDD tests.

Components

  1. features - contains all BDD feature files.
  2. pages - contains all page objects.
  3. steps - contains step definitions.
  4. environment.py contains web driver manager.

Install dependencies

# Install pip

python -m pip install --upgrade pip
# Install dependencies

pip install -r requirements.txt

Run tests command line

Run tests without Selenium Grid

python -m behave -Dbrowser=chrome -f allure -o ./reports/allure-result

Run tests with Selenium Grid

python -m behave -D browser=chrome -DgridUrl=http://<IP Address of Grid>:4444 -f allure -o ./reports/allure-result

-DgridUrl argument is required only to run the tests on Selenium Grid.

-Dbrowser argument can only contain value from one of the these values (chrome, firefox, edge)

Build project with Docker

docker build -t pranavkakde/seleniumframeworkpython . 

Run tests without Selenium Grid

docker run --name seleniumpy-test-run pranavkakde/seleniumframeworkpython:latest -Dbrowser=firefox -f allure -o /app/reports/allure-result

Run tests with Selenium Grid

docker run --name seleniumpy-test-run pranavkakde/seleniumframeworkpython:latest -Dbrowser=firefox -DgridUrl=http://<IP Address of Grid>:4444 -f allure -o /app/reports/allure-result

Copy results from docker container

docker cp seleniumpy-test-run:/app/reports/allure-result ./reports

View results using Allure

http://<IP address of docker host>:5252/allure-docker-service-ui/projects/default

Start Selenium Grid

Pre-requisite - Install Docker Desktop

For setting up selenium grid using docker run;

docker-compose -f docker-compose-grid.yaml -p selenium-grid-python up -d

Selenium Grid Url

http://<IP Address of docker host>:4444

Start Allure Containers

  1. Start Allure docker containers
docker-compose -f docker-compose-allure.yaml -p allure-report up -d
  1. View Allure reports
http://<IP Address of docker host>:5252/allure-docker-service-ui/projects/default