A spring boot based cucumber + testNg selenium framework
Features:
- Dependency Inversion
- Parallel test execution
- Cucumber + TestNg
- Selenium Grid
- Dockerization
- Continuous integration with github actions
- Spring profiles
- Aspect-Oriented Programming (AOP)
Annotations used in project:
Custom Annotations used in project:
- @LazyAutowired
- @LazyConfiguration
- @LazyService
- @PageFragment
- @ThreadScopeBean
- @TakeScreenShot
- @IterativeBackwardWindowSwitch
- @IterativeForwardWindowSwitch
- @TitleBasedWindowSwitch
Clone the repository and below are few dependencies which are required for the project to run:
- Maven 3.8.5 or greater (preferably Maven 3.8.5)
- Java 8 or 11 or higher (preferably Java 11)
- Docker latest
- Docker compose
Required dependencies:
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
<exclusions>
<exclusion>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-logging</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-log4j2</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.github.javafaker</groupId>
<artifactId>javafaker</artifactId>
<version>${faker.version}</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>${selenium.version}</version>
</dependency>
<dependency>
<groupId>io.github.bonigarcia</groupId>
<artifactId>webdrivermanager</artifactId>
<version>${webdrivermanager.version}</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>${cucumber-java.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java8</artifactId>
<version>${cucumber-java.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-spring</artifactId>
<version>${cucumber-srping.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-testng</artifactId>
<version>${cucumber-testng.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>${testng.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
Jar dependencies version:
<java.version>11</java.version>
<selenium.version>4.1.3</selenium.version>
<webdrivermanager.version>5.1.1</webdrivermanager.version>
<testng.version>7.5</testng.version>
<junit.engine.version>5.8.2</junit.engine.version>
<cucumber-java.version>7.3.2</cucumber-java.version>
<cucumber-srping.version>7.3.2</cucumber-srping.version>
<cucumber-testng.version>7.3.2</cucumber-testng.version>
<lombok.version>1.18.24</lombok.version>
<faker.version>1.0.2</faker.version>
<maven.surefire.version>3.0.0-M6</maven.surefire.version>
<maven.compiler.version>3.10.1</maven.compiler.version>
Maven dependencies can be downloaded through below any one command
mvn dependency:resolve
-OR-
mvn install
-OR-
mvn package
To see the output and the magic, just run below command and make sure that all prerequisites with regards to dependencies are completed
docker compose up -- build
-OR-
docker compose up
-OR- (not recommended)
docker compose up -d
The above command builds image for the dockerfile specified in the root project directory
docker build -t ownerName/repositoryName:version-tag -f Dockerfile .
Example:
docker build -t suneel/spring-boot-selenium:0.0.1 -f Dockerfile .
To run a docker compose use the below command
docker-compose up -d
-OR-
docker-compose up
To map a directory from the local system to docker container
docker run -v any_directory_from_local_system:docker_container_directory_even_auto_created_if_not_present container_name
To see existing docker containers
docker ps -a
If any further action has to be performed in the container and don't want to exit immediately after the above operation
docker run -v -it any_directory_from_local_system:docker_container_directory_even_auto_created_if_not_present container_name