This is a Test Automation project using Selenium, Java and TestNG. It is built using Page Object pattern.
-
Test Classes - contains tests written using TestNG. The files are located under tests directory.
-
Pages - contains Page Objects. The files are located under pages directory.
-
Driver Manager - contains classes for managing Web Driver. The file is located in common directory.
-
Configuration - contains Singleton class for managing configuration as stated in config.json. The classes are placed in common directory.
-
Test Logger - Customer test logger in common directory.
-
Utility functions for wrapping Selenium WebDriver functions. BaseFunctions.java in common directory.
Pre-requisite
Install - Maven
Install Docker for desktop - for running tests using docker
- Clone this repo and build the project using maven
mvn compile
All the compiled code will be available in target folder.
- Run the tests using maven
mvn test -DgridUrl=http://<IP Address of Selenium Grid>:4444 -DbrowserName=firefox
If -DgridUrl
is not provided, default gridUrl as provided in config.json
.
If -DgridUrl
is not provided, default browser as provided in config.json
.
Update config.json
if you wish to run the tests without command line args.
{
"baseUrl": "http://automationpractice.com/index.php/",
"gridUrl": "http://127.0.0.1:4444",
"browserSettings":{
"browserType": "chrome",
"headless": true
}
}
- Build docker image for the project
docker build -t pranavkakde/seleniumframeworkjava .
- Run tests with docker container
docker run --name seleniumjava_test_run pranavkakde/seleniumframeworkjava:latest -DgridUrl=http://<IP Address of Selenium Grid>:4444 -DbrowserName=firefox
- Download results from test run.
docker cp seleniumjava_test_run:/app/target/surefire-reports <host directory>
Pre-requisite - Install Docker Desktop
For setting up selenium grid using docker run;
docker compose up -d