-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master'
- Loading branch information
Showing
73 changed files
with
2,598 additions
and
3 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule selenium-docker
deleted from
d9df05
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# Created by .ignore support plugin (hsz.mobi) | ||
### Java template | ||
# Compiled class file | ||
**/*.class | ||
|
||
# Log file | ||
**/*.log | ||
|
||
# BlueJ files | ||
**/*.ctxt | ||
|
||
# Mobile Tools for Java (J2ME) | ||
**/.mtj.tmp/ | ||
|
||
# Package Files # | ||
**/*.jar | ||
**/*.war | ||
**/*.nar | ||
**/*.ear | ||
**/*.zip | ||
**/*.tar.gz | ||
**/*.rar | ||
|
||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml | ||
**/hs_err_pid* | ||
|
||
### Maven template | ||
**/target/ | ||
**/pom.xml.tag | ||
**/pom.xml.releaseBackup | ||
**/pom.xml.versionsBackup | ||
**/pom.xml.next | ||
**/release.properties | ||
**/dependency-reduced-pom.xml | ||
**/buildNumber.properties | ||
**/.mvn/timing.properties | ||
**/.mvn/wrapper/maven-wrapper.jar | ||
|
||
**/*.iml | ||
|
||
**/.idea/ | ||
|
||
|
||
**/HELP.md | ||
**/.mvn/ | ||
**/mvnw | ||
**/mvnw.cmd | ||
**/node_modules/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
FROM java47 | ||
|
||
# Install curl jq | ||
RUN apk add curl jq | ||
|
||
# workspace | ||
WORKDIR /home/selenium-docker | ||
|
||
# Add the required files | ||
ADD target/docker-resources ./ | ||
ADD runner.sh runner.sh | ||
|
||
# Start the runner.sh | ||
ENTRYPOINT sh runner.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
pipeline{ | ||
|
||
agent any | ||
|
||
stages{ | ||
|
||
stage('Build Jar'){ | ||
steps{ | ||
sh 'mvn clean package -DskipTests' | ||
} | ||
} | ||
|
||
stage('Build Image'){ | ||
steps{ | ||
sh 'docker build -t=vinsdocker/selenium:latest .' | ||
} | ||
} | ||
|
||
stage('Push Image'){ | ||
environment{ | ||
DOCKER_HUB = credentials('dockerhub-creds') | ||
} | ||
steps{ | ||
sh 'echo ${DOCKER_HUB_PSW} | docker login -u ${DOCKER_HUB_USR} --password-stdin' | ||
sh 'docker push vinsdocker/selenium:latest' | ||
sh "docker tag vinsdocker/selenium:latest vinsdocker/selenium:${env.BUILD_NUMBER}" | ||
sh "docker push vinsdocker/selenium:${env.BUILD_NUMBER}" | ||
} | ||
} | ||
|
||
} | ||
|
||
post { | ||
always { | ||
sh 'docker logout' | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,159 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!--suppress VulnerableLibrariesLocal --> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>com.vinsguru</groupId> | ||
<artifactId>selenium-docker</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
|
||
<properties> | ||
<selenium.java.version>4.11.0</selenium.java.version> | ||
<logback.version>1.4.8</logback.version> | ||
<webdriver.manager.version>5.4.0</webdriver.manager.version> | ||
<testng.version>7.8.0</testng.version> | ||
<jackson.version>2.12.0</jackson.version> | ||
<!-- plugins versions --> | ||
<maven.compiler.version>3.11.0</maven.compiler.version> | ||
<maven.dependency.version>3.6.0</maven.dependency.version> | ||
<maven.jar.version>3.3.0</maven.jar.version> | ||
<maven.surefire.version>3.1.2</maven.surefire.version> | ||
<maven.resources.plugin>3.3.1</maven.resources.plugin> | ||
<!-- output directory --> | ||
<package.directory>${project.build.directory}/docker-resources</package.directory> | ||
</properties> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.seleniumhq.selenium</groupId> | ||
<artifactId>selenium-java</artifactId> | ||
<version>${selenium.java.version}</version> | ||
</dependency> | ||
<!-- logging library --> | ||
<!-- https://www.baeldung.com/logback --> | ||
<dependency> | ||
<groupId>ch.qos.logback</groupId> | ||
<artifactId>logback-classic</artifactId> | ||
<version>${logback.version}</version> | ||
</dependency> | ||
<!-- web-driver manager for local testing --> | ||
<dependency> | ||
<groupId>io.github.bonigarcia</groupId> | ||
<artifactId>webdrivermanager</artifactId> | ||
<version>${webdriver.manager.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<!-- To deserialize json into Java object or vice versa --> | ||
<dependency> | ||
<groupId>com.fasterxml.jackson.core</groupId> | ||
<artifactId>jackson-databind</artifactId> | ||
<version>${jackson.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
<!-- Test framework --> | ||
<dependency> | ||
<groupId>org.testng</groupId> | ||
<artifactId>testng</artifactId> | ||
<version>${testng.version}</version> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
<build> | ||
<finalName>selenium-docker</finalName> | ||
<plugins> | ||
<!-- To compile the source code using specific java version. also to force IDE to change the settings --> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-compiler-plugin</artifactId> | ||
<version>${maven.compiler.version}</version> | ||
<configuration> | ||
<release>17</release> | ||
</configuration> | ||
</plugin> | ||
<!-- To run the tests using specific parameters, change thread count, testng report output directory etc --> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-surefire-plugin</artifactId> | ||
<version>${maven.surefire.version}</version> | ||
<configuration> | ||
<!-- mvn clean test -Dbrowser=chrome -Dselenium.grid.enabled=true --> | ||
<systemPropertyVariables> | ||
<browser>firefox</browser> | ||
<selenium.grid.enabled>true</selenium.grid.enabled> | ||
</systemPropertyVariables> | ||
<suiteXmlFiles> | ||
<file>src/test/resources/test-suites/vendor-portal.xml</file> | ||
<file>src/test/resources/test-suites/flight-reservation.xml</file> | ||
</suiteXmlFiles> | ||
<threadCount>4</threadCount> | ||
<reportsDirectory>target/test-output</reportsDirectory> | ||
</configuration> | ||
</plugin> | ||
<!-- To copy all the dependencies to run our tests as part of "mvn package" --> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-dependency-plugin</artifactId> | ||
<version>${maven.dependency.version}</version> | ||
<executions> | ||
<execution> | ||
<id>copy-dependencies</id> | ||
<phase>prepare-package</phase> | ||
<goals> | ||
<goal>copy-dependencies</goal> | ||
</goals> | ||
<configuration> | ||
<outputDirectory> | ||
${package.directory}/libs | ||
</outputDirectory> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<!-- To package our page objects, test classes into jar --> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-jar-plugin</artifactId> | ||
<version>${maven.jar.version}</version> | ||
<configuration> | ||
<outputDirectory>${package.directory}/libs</outputDirectory> | ||
</configuration> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>test-jar</goal> | ||
</goals> | ||
<configuration> | ||
<includes>**/*.class</includes> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
<!-- To copy resources into the output directory --> | ||
<plugin> | ||
<groupId>org.apache.maven.plugins</groupId> | ||
<artifactId>maven-resources-plugin</artifactId> | ||
<version>${maven.resources.plugin}</version> | ||
<executions> | ||
<execution> | ||
<id>copy-resources</id> | ||
<phase>prepare-package</phase> | ||
<goals> | ||
<goal>copy-resources</goal> | ||
</goals> | ||
<configuration> | ||
<outputDirectory>${package.directory}</outputDirectory> | ||
<resources> | ||
<resource> | ||
<directory>src/test/resources</directory> | ||
</resource> | ||
</resources> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
|
||
|
||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#!/bin/bash | ||
|
||
#------------------------------------------------------------------- | ||
# This script expects the following environment variables | ||
# HUB_HOST | ||
# BROWSER | ||
# THREAD_COUNT | ||
# TEST_SUITE | ||
#------------------------------------------------------------------- | ||
|
||
# Let's print what we have received | ||
echo "-------------------------------------------" | ||
echo "HUB_HOST : ${HUB_HOST:-hub}" | ||
echo "BROWSER : ${BROWSER:-chrome}" | ||
echo "THREAD_COUNT : ${THREAD_COUNT:-1}" | ||
echo "TEST_SUITE : ${TEST_SUITE}" | ||
echo "-------------------------------------------" | ||
|
||
# Do not start the tests immediately. Hub has to be ready with browser nodes | ||
echo "Checking if hub is ready..!" | ||
count=0 | ||
while [ "$( curl -s http://${HUB_HOST:-hub}:4444/status | jq -r .value.ready )" != "true" ] | ||
do | ||
count=$((count+1)) | ||
echo "Attempt: ${count}" | ||
if [ "$count" -ge 30 ] | ||
then | ||
echo "**** HUB IS NOT READY WITHIN 30 SECONDS ****" | ||
exit 1 | ||
fi | ||
sleep 1 | ||
done | ||
|
||
# At this point, selenium grid should be up! | ||
echo "Selenium Grid is up and running. Running the test...." | ||
|
||
# Start the java command | ||
java -cp 'libs/*' \ | ||
-Dselenium.grid.enabled=true \ | ||
-Dselenium.grid.hubHost="${HUB_HOST:-hub}" \ | ||
-Dbrowser="${BROWSER:-chrome}" \ | ||
org.testng.TestNG \ | ||
-threadcount "${THREAD_COUNT:-1}" \ | ||
test-suites/"${TEST_SUITE}" |
22 changes: 22 additions & 0 deletions
22
06-jenkins-ci-cd/selenium-docker/src/main/java/com/vinsguru/pages/AbstractPage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.vinsguru.pages; | ||
|
||
import org.openqa.selenium.WebDriver; | ||
import org.openqa.selenium.support.PageFactory; | ||
import org.openqa.selenium.support.ui.WebDriverWait; | ||
|
||
import java.time.Duration; | ||
|
||
public abstract class AbstractPage { | ||
|
||
protected final WebDriver driver; | ||
protected final WebDriverWait wait; | ||
|
||
public AbstractPage(WebDriver driver){ | ||
this.driver = driver; | ||
this.wait = new WebDriverWait(driver, Duration.ofSeconds(30)); | ||
PageFactory.initElements(driver, this); | ||
} | ||
|
||
public abstract boolean isAt(); | ||
|
||
} |
Oops, something went wrong.