selenium-e2e-sample
Preface
The purpose of this project is to automatically test the UI of a web application. This project uses Docker Compose, Selenium and Python. It provides only the test environment in Docker. So, I recommend using docker-webapp-sample project as the Web Application.
Install
Perform the following steps:
- Install Docker in this command.
yum install docker-ce
- Install Docker Compose.
Starting Container
Perform the following steps:
- Start containers of docker-webapp-sample project by Docker Compose.
docker-compose -f docker-compose_springboot.yml build docker-compose -f docker-compose_springboot.yml up -d
- Build the
docker-compose.yml
of this project.docker-compose build
- Start containers of this project by Docker Compose.
docker-compose up -d
Starting Test
Perform the following steps:
-
Start a bash session on a running container in the following command.
docker exec -it python /bin/bash
-
Run tests in following commands.
cd /script/testcases pytest --alluredir=/tmp/allure-results
Architecture
There are two environments such as this figure: the test environment and the web application environment.
Test Environment
The following is the summary of each container.
- Chrome Container
- Test the web app in Chrome browser.
- Selenium Hub Container
- Operate the browser of the Chrome container with Selenium.
- Python Container
- Run Python test code.
- Allure Container
- Display test results in Allure.
Web Application Environment
The web application of docker-webapp-sample project consists of three containers: web, app and db.
For more information about this application, see:
The web application to be tested must support chrome or firefox.
Project Map
The follwing figure is the map of this sample project.
+ docker ... Dockerfile for the python container.
- script
+ commons ... Define common functions.
+ pages ... Define operations for each input element.
+ testflow ... Define user operations of each page. A page uses a page object.
+ testcase ... Define testcases. A testcase uses a testflow.
- application.yml ... Define test configuration.
- volumes/allure-results ... Volume link directory for test results.
- cache-clean.sh ... Shell Script for clean pycache.
- docker-compose.yml
Links
The following is links to access a website of each container.
Assume the IP address of Docker Engine is localhost
.
- Selenium Hub
- Allure
- Target Web Application
License
The License of this sample is MIT License.