├── CBT_OS-logo_Black-V.png ├── images ├── architecture.png └── reportportal.png ├── .mvn └── wrapper │ ├── maven-wrapper.jar │ ├── maven-wrapper.properties │ └── MavenWrapperDownloader.java ├── src ├── test │ ├── resources │ │ ├── settings.properties │ │ ├── reportportal.properties │ │ ├── logback.xml │ │ └── suites │ │ │ ├── SmokeSuite.xml │ │ │ └── RegressionSuite.xml │ └── java │ │ ├── tests │ │ ├── SignInTest.java │ │ └── BaseTest.java │ │ └── listeners │ │ ├── HighlighterEventListener.java │ │ └── TestListener.java └── main │ └── java │ ├── helper │ └── StringConstants.java │ ├── annotations │ ├── Module.java │ ├── Window.java │ └── TestInfo.java │ ├── webdriver │ ├── local │ │ ├── EdgeDriverManager.java │ │ ├── LocalDriverManager.java │ │ ├── FirefoxDriverManager.java │ │ └── ChromeDriverManager.java │ ├── DriverFactory.java │ ├── DriverManager.java │ └── IDriver.java │ ├── pages │ ├── BasePage.java │ ├── HomePage.java │ └── SignInPage.java │ ├── utils │ ├── WebElementUtils.java │ ├── ExecutionUtils.java │ ├── PropertyUtils.java │ ├── ReportUtils.java │ ├── ServicesUtils.java │ ├── LogUtils.java │ └── RestUtils.java │ ├── keywords │ ├── Verification.java │ ├── Action.java │ ├── Element.java │ └── Browser.java │ ├── modules │ ├── WindowInterceptor.java │ ├── TestParameters.java │ └── DriverModule.java │ ├── extentreports │ ├── ExtentTestManager.java │ └── ExtentManager.java │ ├── reportportal │ ├── Launch.java │ ├── LaunchHandler.java │ └── SessionContext.java │ └── ensure │ └── Wait.java ├── .travis.yml ├── healthcheck.sh ├── .gitignore ├── run-tests.sh ├── Jenkinsfile ├── Dockerfile ├── .github └── workflows │ └── maven.yml ├── docker-compose.yaml ├── LICENSE ├── .circleci └── config.yml ├── README.md ├── mvnw.cmd ├── pom.xml └── mvnw /CBT_OS-logo_Black-V.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zarashima/web-test-framework/HEAD/CBT_OS-logo_Black-V.png -------------------------------------------------------------------------------- /images/architecture.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zarashima/web-test-framework/HEAD/images/architecture.png -------------------------------------------------------------------------------- /images/reportportal.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zarashima/web-test-framework/HEAD/images/reportportal.png -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zarashima/web-test-framework/HEAD/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /src/test/resources/settings.properties: -------------------------------------------------------------------------------- 1 | web.timeout=30 2 | aut.homepage=https://another-nodejs-shopping-cart.herokuapp.com/ 3 | kibana.integration=false 4 | -------------------------------------------------------------------------------- /src/test/resources/reportportal.properties: -------------------------------------------------------------------------------- 1 | rp.endpoint = http://localhost:8080 2 | rp.uuid = c892925c-cb9a-43f0-93e4-fff5b1bf1a4e 3 | rp.launch = smoke-test-build-1.0 4 | rp.project = automation-tests 5 | rp.reporting.callback=true 6 | rp.enable = false 7 | -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar 3 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: java 2 | dist: xenial 3 | services: 4 | - xvfb 5 | addons: 6 | chrome: stable 7 | firefox: latest 8 | cache: 9 | directories: 10 | - .autoconf 11 | - $HOME/.m2 12 | env: 13 | - RUNWHERE=pipeline 14 | script: 15 | - mvn test -Dsuite=SmokeSuite 16 | -------------------------------------------------------------------------------- /src/main/java/helper/StringConstants.java: -------------------------------------------------------------------------------- 1 | package helper; 2 | 3 | import reportportal.SessionContext; 4 | 5 | public class StringConstants { 6 | public static final int TIMEOUT = 30; 7 | public static final int SUCCESS_RESPONSE_CODE = 200; 8 | public static final String RP_API_ENDPOINT = SessionContext.getEndPoint() + "/api/v1"; 9 | 10 | } 11 | -------------------------------------------------------------------------------- /healthcheck.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | export RUNWHERE=container 3 | echo "Checking if hub is ready - $HUB_HOST" 4 | 5 | while [[ "$( curl -s http://$HUB_HOST:4444/wd/hub/status | jq -r .value.ready )" != "true" ]] 6 | do 7 | sleep 1 8 | done 9 | 10 | java -cp framework-1.0.jar:framework-1.0-tests.jar:libs/* \ 11 | -DHUB_HOST="$HUB_HOST" \ 12 | org.testng.TestNG "$SUITE" 13 | -------------------------------------------------------------------------------- /src/main/java/annotations/Module.java: -------------------------------------------------------------------------------- 1 | package annotations; 2 | 3 | 4 | import java.lang.annotation.ElementType; 5 | import java.lang.annotation.Retention; 6 | import java.lang.annotation.RetentionPolicy; 7 | import java.lang.annotation.Target; 8 | 9 | @Retention(RetentionPolicy.RUNTIME) 10 | @Target({ElementType.TYPE}) 11 | public @interface Module { 12 | String module() default "none"; 13 | } 14 | -------------------------------------------------------------------------------- /src/main/java/webdriver/local/EdgeDriverManager.java: -------------------------------------------------------------------------------- 1 | package webdriver.local; 2 | 3 | import org.openqa.selenium.WebDriver; 4 | import org.openqa.selenium.edge.EdgeDriver; 5 | import org.openqa.selenium.remote.DesiredCapabilities; 6 | 7 | public class EdgeDriverManager { 8 | 9 | public WebDriver createDriver(DesiredCapabilities desiredCapabilities) { 10 | return new EdgeDriver(); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/main/java/annotations/Window.java: -------------------------------------------------------------------------------- 1 | package annotations; 2 | 3 | import com.google.inject.BindingAnnotation; 4 | 5 | import java.lang.annotation.ElementType; 6 | import java.lang.annotation.Retention; 7 | import java.lang.annotation.RetentionPolicy; 8 | import java.lang.annotation.Target; 9 | 10 | @BindingAnnotation 11 | @Target({ElementType.TYPE}) 12 | @Retention(RetentionPolicy.RUNTIME) 13 | public @interface Window { 14 | int value() default 0; 15 | } 16 | -------------------------------------------------------------------------------- /src/main/java/pages/BasePage.java: -------------------------------------------------------------------------------- 1 | package pages; 2 | 3 | import com.google.inject.Inject; 4 | import keywords.Browser; 5 | import keywords.Element; 6 | import org.openqa.selenium.WebDriver; 7 | 8 | public class BasePage { 9 | 10 | @Inject 11 | protected Browser browserKeywords; 12 | 13 | @Inject 14 | protected Element elementKeywords; 15 | 16 | @Inject 17 | protected WebDriver driver; 18 | 19 | @Inject 20 | public BasePage(WebDriver driver) { 21 | this.driver = driver; 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/utils/WebElementUtils.java: -------------------------------------------------------------------------------- 1 | package utils; 2 | 3 | public class WebElementUtils { 4 | private WebElementUtils() { 5 | } 6 | 7 | public static synchronized String getElementXpathInfo(Object element) { 8 | String[] elementInfo; 9 | if (element.toString().contains("xpath: ")) 10 | elementInfo = element.toString().split("xpath: "); 11 | else 12 | elementInfo = element.toString().split("css selector: "); 13 | return elementInfo[elementInfo.length - 1]; 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled class file 2 | *.class 3 | 4 | # Log file 5 | *.log 6 | 7 | # BlueJ files 8 | *.ctxt 9 | 10 | # Mobile Tools for Java (J2ME) 11 | .mtj.tmp/ 12 | 13 | # Package Files # 14 | *.war 15 | *.nar 16 | *.ear 17 | *.zip 18 | *.tar.gz 19 | *.rar 20 | 21 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml 22 | hs_err_pid* 23 | 24 | # internal project files 25 | /.idea/ 26 | .idea/ 27 | factory.iml 28 | /TestReport/ 29 | /target/ 30 | /failed-screenshots/ 31 | /test-output/ 32 | /target/ 33 | -------------------------------------------------------------------------------- /src/main/java/webdriver/DriverFactory.java: -------------------------------------------------------------------------------- 1 | package webdriver; 2 | 3 | import org.openqa.selenium.remote.DesiredCapabilities; 4 | import webdriver.local.LocalDriverManager; 5 | import org.openqa.selenium.WebDriver; 6 | 7 | public class DriverFactory { 8 | 9 | private DriverFactory() {} 10 | 11 | public static WebDriver createInstance(String browser, DesiredCapabilities desiredCapabilities) { 12 | WebDriver webdriver; 13 | webdriver = new LocalDriverManager().createInstance(browser, desiredCapabilities); 14 | return webdriver; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/main/java/annotations/TestInfo.java: -------------------------------------------------------------------------------- 1 | package annotations; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | @Retention(RetentionPolicy.RUNTIME) 9 | @Target({ElementType.TYPE}) 10 | public @interface TestInfo { 11 | 12 | public enum Priority { 13 | LOW, MEDIUM, HIGH 14 | } 15 | 16 | String module() default ""; 17 | 18 | Priority priority() default Priority.MEDIUM; 19 | 20 | String createdBy() default "vinh.nguyen"; 21 | } 22 | -------------------------------------------------------------------------------- /run-tests.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | echo "Package project" 3 | mvn clean package -DskipTests=true 4 | 5 | echo "Build docker image" 6 | docker build -t=vinh/framework-docker . 7 | 8 | echo "Cleanup previous docker compose" 9 | docker-compose down --rmi local 10 | 11 | echo "Run tests" 12 | SUITE=$1 docker-compose up -d --force-recreate 13 | 14 | echo "Execution logs" 15 | docker-compose logs > output.log 16 | while [[ !($(cat output.log | grep "Total tests run")) ]] 17 | do 18 | docker-compose logs --tail=1000 19 | docker-compose logs --tail=1000 > output.log 20 | sleep 1 21 | done 22 | -------------------------------------------------------------------------------- /src/test/resources/logback.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | %d{HH:mm:ss.SSS} [%thread] %marker %-5level %logger{36} - %msg%n 5 | 6 | 7 | 8 | 9 | %d{HH:mm:ss.SSS} [%t] %-5level - %msg%n 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /Jenkinsfile: -------------------------------------------------------------------------------- 1 | pipeline { 2 | agent none 3 | stages { 4 | stage('Build jar') { 5 | agent { 6 | docker { 7 | image 'maven:3-alpine' 8 | args '-v $HOME/.m2:/root/.m2' 9 | } 10 | } 11 | steps { 12 | sh 'mvn clean package -DskipTests' 13 | } 14 | } 15 | stage('Build image') { 16 | steps { 17 | sh 'docker build -t=vinh/framework-docker .' 18 | } 19 | } 20 | stage('Run tests') { 21 | steps { 22 | sh 'docker-compose up -d' 23 | } 24 | } 25 | stage('Clean up') { 26 | steps { 27 | sh 'docker-compose down' 28 | } 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/keywords/Verification.java: -------------------------------------------------------------------------------- 1 | package keywords; 2 | 3 | import com.google.inject.Inject; 4 | import org.openqa.selenium.WebDriver; 5 | import org.openqa.selenium.WebElement; 6 | import utils.LogUtils; 7 | 8 | import static org.assertj.core.api.Assertions.assertThat; 9 | 10 | public class Verification { 11 | 12 | protected WebElement element; 13 | 14 | @Inject 15 | WebDriver driver; 16 | 17 | @Inject 18 | public Verification(WebDriver driver) { 19 | this.driver = driver; 20 | } 21 | 22 | public void verifyEqual(Object actual, Object expect) { 23 | LogUtils.info("Verify " + actual + " equal to " + expect); 24 | assertThat(actual).isEqualTo(expect); 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM openjdk:8u191-jre-alpine3.8 2 | 3 | RUN apk add curl jq 4 | 5 | WORKDIR /usr/share/framework 6 | 7 | # ADD .jar & libs files under target from host 8 | COPY target/framework-1.0.jar framework-1.0.jar 9 | COPY target/framework-1.0-tests.jar framework-1.0-tests.jar 10 | COPY target/libs libs 11 | 12 | # ADD resources folder 13 | COPY src/test/resources src/test/resources 14 | 15 | # ADD suite files 16 | COPY src/test/resources/suites/SmokeSuite.xml SmokeSuite.xml 17 | COPY src/test/resources/suites/RegressionSuite.xml RegressionSuite.xml 18 | 19 | # ADD bash file for execution 20 | COPY healthcheck.sh healthcheck.sh 21 | 22 | ENTRYPOINT sh healthcheck.sh 23 | -------------------------------------------------------------------------------- /src/test/resources/suites/SmokeSuite.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /src/test/resources/suites/RegressionSuite.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /src/test/java/tests/SignInTest.java: -------------------------------------------------------------------------------- 1 | package tests; 2 | 3 | import annotations.TestInfo; 4 | import org.testng.annotations.Test; 5 | import utils.PropertyUtils; 6 | 7 | @TestInfo(module = "signin", 8 | priority = TestInfo.Priority.MEDIUM, 9 | createdBy = "vinh.nguyen") 10 | public class SignInTest extends BaseTest { 11 | @Test(description = "Verify invalid message is displayed when using invalid email and password") 12 | public void verifySignIn_invalidEmailPassword_shouldPromptInvalidMessage() { 13 | browserKeywords.goTo(PropertyUtils.getInstance().getAutHomepage()); 14 | homePage.goToSignInPage(); 15 | signInPage.signIn("admin", "password"); 16 | verificationKeywords.verifyEqual(signInPage.getErrorMessage(), "Invalid email"); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/main/java/utils/ExecutionUtils.java: -------------------------------------------------------------------------------- 1 | package utils; 2 | 3 | public class ExecutionUtils { 4 | 5 | private ExecutionUtils() { 6 | } 7 | 8 | public static synchronized String getParameter(String name) { 9 | String value = System.getProperty(name); 10 | if (value == null) 11 | throw new RuntimeException(name + " is not a parameter!"); 12 | if (value.isEmpty()) 13 | throw new RuntimeException(name + " is empty!"); 14 | return value; 15 | } 16 | 17 | public static synchronized void setParameter(String key, String name) { 18 | if (key == null) 19 | throw new RuntimeException(name + " is not a parameter!"); 20 | if (key.isEmpty()) 21 | throw new RuntimeException(name + " is empty!"); 22 | System.setProperty(key, name); 23 | } 24 | 25 | public static synchronized Object getEnv(String envName) { 26 | return System.getenv(envName); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/modules/WindowInterceptor.java: -------------------------------------------------------------------------------- 1 | package modules; 2 | 3 | import annotations.Window; 4 | import org.aopalliance.intercept.MethodInterceptor; 5 | import org.aopalliance.intercept.MethodInvocation; 6 | import webdriver.DriverManager; 7 | 8 | public class WindowInterceptor implements MethodInterceptor { 9 | 10 | @Override 11 | public Object invoke(MethodInvocation methodInvocation) throws Throwable { 12 | int index = methodInvocation.getMethod().getDeclaringClass().getAnnotation(Window.class).value(); 13 | this.switchToWindow(index); 14 | Object object = methodInvocation.proceed(); 15 | this.switchToWindow(0); 16 | return object; 17 | } 18 | 19 | private void switchToWindow(int index) { 20 | String handle = DriverManager.getDriver().getWindowHandles().toArray(new String[0])[index]; 21 | DriverManager.getDriver().switchTo().window(handle); 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/main/java/extentreports/ExtentTestManager.java: -------------------------------------------------------------------------------- 1 | package extentreports; 2 | 3 | import com.aventstack.extentreports.ExtentReports; 4 | import com.aventstack.extentreports.ExtentTest; 5 | 6 | import java.util.HashMap; 7 | import java.util.Map; 8 | 9 | public class ExtentTestManager { 10 | 11 | public static ExtentTest test; 12 | static Map extentTestMap = new HashMap(); 13 | static ExtentReports extent = ExtentManager.getInstance(); 14 | 15 | public static synchronized ExtentTest getTest() { 16 | return extentTestMap.get((int) Thread.currentThread().getId()); 17 | } 18 | 19 | public static synchronized void endTest() { 20 | extent.flush(); 21 | } 22 | 23 | public static synchronized ExtentTest startTest(String testName) { 24 | test = extent.createTest(testName); 25 | extentTestMap.put((int) Thread.currentThread().getId(), test); 26 | return test; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/main/java/pages/HomePage.java: -------------------------------------------------------------------------------- 1 | package pages; 2 | 3 | import com.google.inject.Inject; 4 | import org.openqa.selenium.WebDriver; 5 | import org.openqa.selenium.WebElement; 6 | import org.openqa.selenium.support.FindBy; 7 | import org.openqa.selenium.support.PageFactory; 8 | 9 | public class HomePage extends BasePage { 10 | 11 | @FindBy(xpath = "/html/body/div/div[2]/div[1]/div/div/div/a") 12 | public WebElement addToCartButton; 13 | 14 | @FindBy(css = "a[href='/user/signin']") 15 | private WebElement signInButton; 16 | 17 | @FindBy(css = "div[id='bs-example-navbar-collapse-1'] > ul > li a[href='#']") 18 | private WebElement userMenuButton; 19 | 20 | @Inject 21 | public HomePage(WebDriver driver) { 22 | super(driver); 23 | PageFactory.initElements(driver, this); 24 | } 25 | 26 | public HomePage goToSignInPage() { 27 | elementKeywords.click(userMenuButton); 28 | elementKeywords.click(signInButton); 29 | return this; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /.github/workflows/maven.yml: -------------------------------------------------------------------------------- 1 | name: build 2 | 3 | on: [push] 4 | 5 | jobs: 6 | build: 7 | 8 | runs-on: ubuntu-latest 9 | 10 | steps: 11 | 12 | - uses: actions/checkout@v1 13 | - uses: actions/cache@v1 14 | with: 15 | path: ~/.m2/repository 16 | key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }} 17 | restore-keys: | 18 | ${{ runner.os }}-maven- 19 | 20 | - name: Set up JDK 1.8 21 | uses: actions/setup-java@v1 22 | with: 23 | java-version: 1.8 24 | 25 | - name: Setup chromedriver 26 | uses: nanasess/setup-chromedriver@master 27 | - run: | 28 | export DISPLAY=:99 29 | chromedriver --url-base=/wd/hub & 30 | sudo Xvfb -ac :99 -screen 0 1280x1024x24 > /dev/null 2>&1 & # optional 31 | 32 | 33 | - name: maven test 34 | env: 35 | RUNWHERE: pipeline 36 | run: | 37 | mvn clean test -Dsuite=SmokeSuite 38 | -------------------------------------------------------------------------------- /docker-compose.yaml: -------------------------------------------------------------------------------- 1 | version: "2" 2 | services: 3 | selenium-hub: 4 | image: selenium/hub:3.141.59-20200409 5 | container_name: selenium-hub 6 | ports: 7 | - "4444:4444" 8 | 9 | chrome: 10 | image: selenium/node-chrome:3.141.59-20200409 11 | volumes: 12 | - /dev/shm:/dev/shm 13 | depends_on: 14 | - selenium-hub 15 | environment: 16 | - HUB_HOST=selenium-hub 17 | - HUB_PORT=4444 18 | 19 | firefox: 20 | image: selenium/node-firefox:3.141.59-20200409 21 | volumes: 22 | - /dev/shm:/dev/shm 23 | depends_on: 24 | - selenium-hub 25 | environment: 26 | - HUB_HOST=selenium-hub 27 | - HUB_PORT=4444 28 | 29 | smoke: 30 | image: vinh/framework-docker 31 | depends_on: 32 | - chrome 33 | - firefox 34 | environment: 35 | - HUB_HOST=selenium-hub 36 | - SUITE="${SUITE}" 37 | volumes: 38 | - ./TestReport:/usr/share/framework/TestReport 39 | - ./results:/usr/share/framework/test-output 40 | -------------------------------------------------------------------------------- /src/main/java/modules/TestParameters.java: -------------------------------------------------------------------------------- 1 | package modules; 2 | 3 | import annotations.TestInfo; 4 | import annotations.TestInfo.Priority; 5 | 6 | public class TestParameters { 7 | 8 | private static synchronized void checkTestInfoAnnotation(Class T) { 9 | if (!T.isAnnotationPresent(TestInfo.class)) { 10 | throw new RuntimeException("The class " 11 | + T.getSimpleName() 12 | + " is not annotated with TestInfo"); 13 | } 14 | } 15 | 16 | public static synchronized String getModule(Class T) { 17 | checkTestInfoAnnotation(T); 18 | return ((TestInfo) T.getAnnotation(TestInfo.class)).module(); 19 | } 20 | 21 | public static synchronized Priority getPriority(Class T) { 22 | checkTestInfoAnnotation(T); 23 | return ((TestInfo) T.getAnnotation(TestInfo.class)).priority(); 24 | } 25 | 26 | public static synchronized String getCreatedBy(Class T) { 27 | checkTestInfoAnnotation(T); 28 | return ((TestInfo) T.getAnnotation(TestInfo.class)).createdBy(); 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/webdriver/DriverManager.java: -------------------------------------------------------------------------------- 1 | package webdriver; 2 | 3 | import org.openqa.selenium.Capabilities; 4 | import org.openqa.selenium.WebDriver; 5 | import org.openqa.selenium.remote.RemoteWebDriver; 6 | 7 | public class DriverManager { 8 | 9 | private static final ThreadLocal driver = new ThreadLocal<>(); 10 | 11 | private DriverManager() {} 12 | 13 | public static WebDriver getDriver() { 14 | return driver.get(); 15 | } 16 | 17 | public static void setDriver(WebDriver driver) { 18 | DriverManager.driver.set(driver); 19 | } 20 | 21 | public static void quit() { 22 | DriverManager.driver.get().quit(); 23 | driver.remove(); 24 | } 25 | 26 | public static String getBrowserName() { 27 | Capabilities cap = ((RemoteWebDriver) DriverManager.getDriver()).getCapabilities(); 28 | String browserName = cap.getBrowserName(); 29 | String version = cap.getVersion(); 30 | return String.format("%s_%s", browserName, version); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/test/java/listeners/HighlighterEventListener.java: -------------------------------------------------------------------------------- 1 | package listeners; 2 | 3 | import org.openqa.selenium.By; 4 | import org.openqa.selenium.JavascriptExecutor; 5 | import org.openqa.selenium.WebDriver; 6 | import org.openqa.selenium.WebElement; 7 | import org.openqa.selenium.support.events.AbstractWebDriverEventListener; 8 | 9 | class HighlighterEventListener extends AbstractWebDriverEventListener { 10 | 11 | private WebElement lastElement; 12 | 13 | @Override 14 | public void beforeFindBy(By by, WebElement element, WebDriver driver) { 15 | System.out.print("before find by"); 16 | if (lastElement != null) { 17 | ((JavascriptExecutor) driver).executeScript( 18 | "arguments[0].style.border='none'", lastElement); 19 | } 20 | lastElement = null; 21 | } 22 | 23 | @Override 24 | public void afterFindBy(By by, WebElement element, WebDriver driver) { 25 | lastElement = element; 26 | ((JavascriptExecutor) driver).executeScript( 27 | "arguments[0].style.border='pink'", lastElement); 28 | System.out.print("after find by"); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/main/java/modules/DriverModule.java: -------------------------------------------------------------------------------- 1 | package modules; 2 | 3 | import annotations.Window; 4 | import com.google.inject.AbstractModule; 5 | import com.google.inject.Provides; 6 | import com.google.inject.matcher.Matchers; 7 | import ensure.Wait; 8 | import org.aopalliance.intercept.MethodInterceptor; 9 | import org.openqa.selenium.JavascriptExecutor; 10 | import org.openqa.selenium.WebDriver; 11 | import webdriver.DriverManager; 12 | 13 | public class DriverModule extends AbstractModule { 14 | 15 | @Override 16 | protected void configure() { 17 | MethodInterceptor interceptor = new WindowInterceptor(); 18 | requestInjection(interceptor); 19 | bindInterceptor(Matchers.annotatedWith(Window.class), Matchers.any(), interceptor); 20 | } 21 | 22 | @Provides 23 | public WebDriver getDriver() { 24 | return DriverManager.getDriver(); 25 | } 26 | 27 | @Provides 28 | public Wait getWait() { 29 | return new Wait(DriverManager.getDriver()); 30 | } 31 | 32 | @Provides 33 | public JavascriptExecutor getJsExecutor() { 34 | return (JavascriptExecutor) DriverManager.getDriver(); 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/utils/PropertyUtils.java: -------------------------------------------------------------------------------- 1 | package utils; 2 | 3 | import java.io.FileInputStream; 4 | import java.io.IOException; 5 | import java.util.Properties; 6 | 7 | public class PropertyUtils { 8 | 9 | private static PropertyUtils instance; 10 | private final Properties props = new Properties(); 11 | private Integer webTimeout; 12 | private String autHomePage; 13 | 14 | public static PropertyUtils getInstance() { 15 | if (instance == null) { 16 | instance = new PropertyUtils(); 17 | instance.loadData(); 18 | } 19 | return instance; 20 | } 21 | 22 | private void loadData() { 23 | String settingsFilePath = "src/test/resources/settings.properties"; 24 | try { 25 | props.load(new FileInputStream(settingsFilePath)); 26 | } catch (IOException e) { 27 | e.printStackTrace(); 28 | } 29 | webTimeout = Integer.valueOf(props.getProperty("web.timeout")); 30 | autHomePage = props.getProperty("aut.homepage"); 31 | } 32 | 33 | public Integer getWebTimeout() { 34 | return webTimeout; 35 | } 36 | 37 | public String getAutHomepage() { 38 | return autHomePage; 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 Vinh Nguyen 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /src/main/java/keywords/Action.java: -------------------------------------------------------------------------------- 1 | package keywords; 2 | 3 | import com.google.inject.Inject; 4 | import ensure.Wait; 5 | import org.openqa.selenium.WebDriver; 6 | import org.openqa.selenium.WebElement; 7 | import org.openqa.selenium.interactions.Actions; 8 | 9 | public class Action { 10 | 11 | @Inject 12 | WebDriver driver; 13 | 14 | @Inject 15 | Wait wait; 16 | 17 | Actions builder; 18 | 19 | @Inject 20 | public Action(WebDriver driver) { 21 | this.driver = driver; 22 | wait = new Wait(driver); 23 | this.builder = new Actions(driver); 24 | } 25 | 26 | public void dragAndDrop(WebElement sourceElement, WebElement targetElement) { 27 | builder.dragAndDrop(sourceElement, targetElement).build().perform(); 28 | } 29 | 30 | public void doubleClick() { 31 | builder.doubleClick().build().perform(); 32 | } 33 | 34 | public void doubleClick(WebElement element) { 35 | builder.doubleClick(element).build().perform(); 36 | } 37 | 38 | public void moveToElement(WebElement element) { 39 | builder.moveToElement(element).build().perform(); 40 | } 41 | 42 | public void rightClick() { 43 | builder.contextClick().perform(); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/main/java/webdriver/local/LocalDriverManager.java: -------------------------------------------------------------------------------- 1 | package webdriver.local; 2 | 3 | import org.openqa.selenium.remote.DesiredCapabilities; 4 | import webdriver.IDriver; 5 | import io.github.bonigarcia.wdm.WebDriverManager; 6 | import io.github.bonigarcia.wdm.config.DriverManagerType; 7 | import org.openqa.selenium.WebDriver; 8 | 9 | public class LocalDriverManager implements IDriver { 10 | @Override 11 | public WebDriver createInstance(String browser, DesiredCapabilities desiredCapabilities) { 12 | WebDriver driver; 13 | DriverManagerType driverManagerType = DriverManagerType.valueOf(browser.toUpperCase()); 14 | WebDriverManager.getInstance(driverManagerType).setup(); 15 | switch(driverManagerType) { 16 | case CHROME: 17 | driver = new ChromeDriverManager().createDriver(desiredCapabilities); 18 | break; 19 | case FIREFOX: 20 | driver = new FirefoxDriverManager().createDriver(desiredCapabilities); 21 | break; 22 | case EDGE: 23 | driver = new EdgeDriverManager().createDriver(desiredCapabilities); 24 | break; 25 | default: 26 | throw new IllegalArgumentException("Not supported browser"); 27 | } 28 | return driver; 29 | } 30 | 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/pages/SignInPage.java: -------------------------------------------------------------------------------- 1 | package pages; 2 | 3 | import com.google.inject.Inject; 4 | import org.openqa.selenium.WebDriver; 5 | import org.openqa.selenium.WebElement; 6 | import org.openqa.selenium.support.FindBy; 7 | import org.openqa.selenium.support.PageFactory; 8 | 9 | public class SignInPage extends BasePage { 10 | 11 | @FindBy(css = "input[id='email']") 12 | private WebElement emailField; 13 | 14 | @FindBy(css = "input[id='password']") 15 | private WebElement passwordField; 16 | 17 | @FindBy(xpath = "//button[text()='Sign In']") 18 | private WebElement signInButton; 19 | 20 | @FindBy(css = "div[class='alert alert-danger']") 21 | private WebElement errorMessageDiv; 22 | 23 | @Inject 24 | public SignInPage(WebDriver driver) { 25 | super(driver); 26 | PageFactory.initElements(driver, this); 27 | } 28 | 29 | public SignInPage signIn(String email, String password) { 30 | elementKeywords.setText(emailField, email); 31 | elementKeywords.setText(passwordField, password); 32 | elementKeywords.click(signInButton); 33 | return this; 34 | } 35 | 36 | public String getErrorMessage() { 37 | return elementKeywords.getText(errorMessageDiv); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/main/java/reportportal/Launch.java: -------------------------------------------------------------------------------- 1 | package reportportal; 2 | 3 | import java.util.ArrayList; 4 | import java.util.HashMap; 5 | import java.util.List; 6 | import java.util.Map; 7 | 8 | public class Launch { 9 | 10 | private String uuid; 11 | private String id; 12 | private String description; 13 | private final List> attributes = new ArrayList<>(); 14 | 15 | Launch() { } 16 | 17 | public String getUuid() { 18 | return uuid; 19 | } 20 | 21 | public void setUuid(String uuid) { 22 | this.uuid = uuid; 23 | } 24 | 25 | public String getId() { 26 | return id; 27 | } 28 | 29 | public void setId(String id) { 30 | this.id = id; 31 | } 32 | 33 | public String getDescription() { 34 | return description; 35 | } 36 | 37 | public void setDescription(String description) { 38 | this.description = description; 39 | } 40 | 41 | public List> getAttributes() { 42 | return attributes; 43 | } 44 | 45 | public void setAttributes(String key, String value) { 46 | Map attribute = new HashMap<>(); 47 | attribute.put("key", key); 48 | attribute.put("value", value); 49 | this.attributes.add(attribute); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/utils/ReportUtils.java: -------------------------------------------------------------------------------- 1 | package utils; 2 | 3 | import java.io.File; 4 | import java.time.format.DateTimeFormatter; 5 | 6 | import static java.time.LocalDateTime.now; 7 | 8 | public class ReportUtils { 9 | 10 | private static final DateTimeFormatter simpleDate = DateTimeFormatter.ofPattern("dd_MM_yyyy-HH_mm_ss"); 11 | private static final String reportFileName = String.format("Test-Automaton-Report-%s.html", simpleDate.format(now())); 12 | private static final String reportPath = System.getProperty("user.dir") + File.separator + "TestReport"; 13 | private static final String reportFileLoc = reportPath + File.separator + reportFileName; 14 | 15 | public static String getReportFileLocation() { 16 | createReportPath(); 17 | return reportFileLoc; 18 | } 19 | 20 | private static void createReportPath() { 21 | File testDirectory = new File(ReportUtils.reportPath); 22 | if (!testDirectory.exists()) { 23 | if (testDirectory.mkdir()) { 24 | System.out.println("Directory: " + ReportUtils.reportPath + " is created!"); 25 | } else { 26 | System.out.println("Failed to create directory: " + ReportUtils.reportPath); 27 | } 28 | } else { 29 | System.out.println("Directory already exists: " + ReportUtils.reportPath); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/extentreports/ExtentManager.java: -------------------------------------------------------------------------------- 1 | package extentreports; 2 | 3 | import com.aventstack.extentreports.ExtentReports; 4 | import com.aventstack.extentreports.reporter.ExtentHtmlReporter; 5 | import com.aventstack.extentreports.reporter.configuration.Theme; 6 | import utils.ReportUtils; 7 | 8 | public class ExtentManager { 9 | 10 | private ExtentManager() {} 11 | 12 | private static ExtentReports extent; 13 | 14 | public static ExtentReports getInstance() { 15 | if (extent == null) 16 | createInstance(); 17 | return extent; 18 | } 19 | 20 | //Create an extent report instance 21 | public static ExtentReports createInstance() { 22 | ExtentHtmlReporter htmlReporter = new ExtentHtmlReporter(ReportUtils.getReportFileLocation()); 23 | htmlReporter.config().setTheme(Theme.DARK); 24 | htmlReporter.config().enableTimeline(true); 25 | htmlReporter.config().setDocumentTitle("Test Report"); 26 | htmlReporter.config().setEncoding("utf-8"); 27 | htmlReporter.config().setReportName("Test Report"); 28 | htmlReporter.config().setTimeStampFormat("EEEE, MMMM dd, yyyy, hh:mm a '('zzz')'"); 29 | htmlReporter.config().setAutoCreateRelativePathMedia(true); 30 | 31 | extent = new ExtentReports(); 32 | extent.attachReporter(htmlReporter); 33 | 34 | return extent; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/utils/ServicesUtils.java: -------------------------------------------------------------------------------- 1 | package utils; 2 | 3 | import helper.StringConstants; 4 | import io.restassured.http.ContentType; 5 | import io.restassured.response.Response; 6 | import io.restassured.specification.RequestSpecification; 7 | 8 | import java.util.Objects; 9 | 10 | import static io.restassured.RestAssured.given; 11 | 12 | public class ServicesUtils { 13 | 14 | public enum HttpMethod { 15 | GET("get"), POST("post"); 16 | 17 | public final String method; 18 | 19 | HttpMethod(String method) { 20 | this.method = method; 21 | } 22 | } 23 | 24 | private static final RequestSpecification request = given().accept(ContentType.JSON); 25 | 26 | public static Response execute(String endpoint, HttpMethod method) { 27 | return execute(endpoint, method, true); 28 | } 29 | 30 | private static Response execute(String endpoint, HttpMethod method, boolean verifyStatusCode) { 31 | Response response = null; 32 | if (method == HttpMethod.GET) { 33 | response = request.get(endpoint); 34 | } else if (method == HttpMethod.POST) { 35 | response = request.post(endpoint); 36 | } 37 | assert response != null; 38 | Objects.requireNonNull(response).then().log().all(); 39 | if (verifyStatusCode) { 40 | response.then().statusCode(StringConstants.SUCCESS_RESPONSE_CODE); 41 | } 42 | return response; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /.circleci/config.yml: -------------------------------------------------------------------------------- 1 | # Java Maven CircleCI 2.0 configuration file 2 | # 3 | # Check https://circleci.com/docs/2.0/language-java/ for more details 4 | # 5 | version: 2 6 | jobs: 7 | build: 8 | docker: 9 | - image: circleci/openjdk:8-jdk-browsers 10 | 11 | working_directory: ~/repo 12 | 13 | environment: 14 | MAVEN_OPTS: -Xmx3200m 15 | RUNWHERE: pipeline 16 | 17 | steps: 18 | - checkout 19 | 20 | - restore_cache: 21 | keys: 22 | - v1-dependencies-{{ checksum "pom.xml" }} 23 | # fallback to using the latest cache if no exact match is found 24 | - v1-dependencies- 25 | 26 | - run: mvn dependency:go-offline 27 | 28 | - save_cache: 29 | paths: 30 | - ~/.m2 31 | key: v1-dependencies-{{ checksum "pom.xml" }} 32 | 33 | # run tests! 34 | - run: mvn test -Dsuite=SmokeSuite 35 | 36 | - run: 37 | name: Save test results 38 | command: | 39 | mkdir -p ~/test-results/junit/ 40 | find . -type f -regex ".*/target/surefire-reports/.*xml" -exec cp {} ~/test-results/junit/ \; 41 | when: always 42 | - store_test_results: 43 | path: ~/test-results/junit 44 | - store_artifacts: 45 | path: ~/test-results/junit 46 | - store_artifacts: 47 | path: target/my-reports 48 | -------------------------------------------------------------------------------- /src/main/java/webdriver/local/FirefoxDriverManager.java: -------------------------------------------------------------------------------- 1 | package webdriver.local; 2 | 3 | import org.openqa.selenium.WebDriver; 4 | import org.openqa.selenium.firefox.FirefoxDriver; 5 | import org.openqa.selenium.firefox.FirefoxOptions; 6 | import org.openqa.selenium.remote.DesiredCapabilities; 7 | import org.openqa.selenium.remote.RemoteWebDriver; 8 | import utils.ExecutionUtils; 9 | 10 | import java.net.MalformedURLException; 11 | import java.net.URL; 12 | 13 | public class FirefoxDriverManager { 14 | 15 | public WebDriver createDriver(DesiredCapabilities desiredCapabilities) { 16 | FirefoxOptions firefoxOptions = new FirefoxOptions(); 17 | WebDriver driver = null; 18 | Object runWhere = ExecutionUtils.getEnv("RUNWHERE"); 19 | if ("pipeline".equals(runWhere)) { 20 | firefoxOptions.addArguments("--headless"); 21 | firefoxOptions.merge(desiredCapabilities); 22 | driver = new FirefoxDriver(firefoxOptions); 23 | } else if ("container".equals(runWhere)) { 24 | String seleniumHubUrl = ExecutionUtils.getParameter("HUB_HOST"); 25 | firefoxOptions.merge(desiredCapabilities); 26 | try { 27 | driver = new RemoteWebDriver(new URL("http://" + seleniumHubUrl + ":4444/wd/hub"), desiredCapabilities); 28 | } catch (MalformedURLException e) { 29 | e.printStackTrace(); 30 | } 31 | } else { 32 | driver = new FirefoxDriver(desiredCapabilities); 33 | } 34 | return driver; 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/webdriver/local/ChromeDriverManager.java: -------------------------------------------------------------------------------- 1 | package webdriver.local; 2 | 3 | import org.openqa.selenium.WebDriver; 4 | import org.openqa.selenium.chrome.ChromeDriver; 5 | import org.openqa.selenium.chrome.ChromeOptions; 6 | import org.openqa.selenium.remote.DesiredCapabilities; 7 | import org.openqa.selenium.remote.RemoteWebDriver; 8 | import utils.ExecutionUtils; 9 | 10 | import java.net.MalformedURLException; 11 | import java.net.URL; 12 | 13 | public class ChromeDriverManager { 14 | 15 | public WebDriver createDriver(DesiredCapabilities desiredCapabilities) { 16 | ChromeOptions chromeOptions = new ChromeOptions(); 17 | WebDriver driver = null; 18 | Object runWhere = ExecutionUtils.getEnv("RUNWHERE"); 19 | if ("pipeline".equals(runWhere)) { 20 | chromeOptions.addArguments("--no-sandbox", "--headless", "--disable-dev-shm-usage"); 21 | chromeOptions.merge(desiredCapabilities); 22 | driver = new ChromeDriver(chromeOptions); 23 | } else if ("container".equals(runWhere)) { 24 | String seleniumHubUrl = ExecutionUtils.getParameter("HUB_HOST"); 25 | chromeOptions.addArguments("--whitelisted-ips", "--no-sandbox"); 26 | chromeOptions.merge(desiredCapabilities); 27 | try { 28 | driver = new RemoteWebDriver(new URL("http://" + seleniumHubUrl + ":4444/wd/hub"), chromeOptions); 29 | } catch (MalformedURLException e) { 30 | e.printStackTrace(); 31 | } 32 | } else { 33 | driver = new ChromeDriver(desiredCapabilities); 34 | } 35 | return driver; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/main/java/webdriver/IDriver.java: -------------------------------------------------------------------------------- 1 | /* 2 | * MIT License 3 | * 4 | * Copyright (c) 2018 Elias Nogueira 5 | * 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy 7 | * of this software and associated documentation files (the "Software"), to deal 8 | * in the Software without restriction, including without limitation the rights 9 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | * copies of the Software, and to permit persons to whom the Software is 11 | * furnished to do so, subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be included in all 14 | * copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 22 | * SOFTWARE. 23 | */ 24 | 25 | package webdriver; 26 | 27 | import org.openqa.selenium.WebDriver; 28 | import org.openqa.selenium.remote.DesiredCapabilities; 29 | 30 | public interface IDriver { 31 | WebDriver createInstance(String browser, DesiredCapabilities desiredCapabilities); 32 | } 33 | -------------------------------------------------------------------------------- /src/main/java/reportportal/LaunchHandler.java: -------------------------------------------------------------------------------- 1 | package reportportal; 2 | 3 | import helper.StringConstants; 4 | import io.restassured.http.ContentType; 5 | import io.restassured.response.Response; 6 | import org.json.simple.JSONObject; 7 | import utils.RestUtils; 8 | import utils.RestUtils.HttpMethod; 9 | 10 | import java.util.List; 11 | import java.util.Map; 12 | 13 | @SuppressWarnings("unchecked") 14 | public class LaunchHandler { 15 | 16 | private static final JSONObject requestParams = new JSONObject(); 17 | 18 | private LaunchHandler() { } 19 | 20 | static { 21 | RestUtils.setHeader("Authorization", "Bearer " + SessionContext.getUUID()); 22 | RestUtils.setBaseURI(StringConstants.RP_API_ENDPOINT); 23 | RestUtils.setContentType(ContentType.JSON); 24 | } 25 | 26 | public static synchronized Response startLaunch() { 27 | RestUtils.setBasePath(String.format("%s/launch", SessionContext.getProject())); 28 | requestParams.put("name", "rp_launch"); 29 | requestParams.put("startTime", "1574423221000"); 30 | RestUtils.addJsonBody(requestParams); 31 | return RestUtils.send(HttpMethod.POST, requestParams); 32 | } 33 | 34 | public static synchronized String getLaunchId() { 35 | RestUtils.setBasePath(String.format("%s/launch/%s", SessionContext.getProject(), System.getProperty("rp.launch.id"))); 36 | return RestUtils.send(HttpMethod.GET, null).jsonPath().getString("id"); 37 | } 38 | 39 | public static synchronized void updateLaunch(List> attributes, String description) { 40 | requestParams.put("attributes", attributes); 41 | requestParams.put("description", description); 42 | RestUtils.addJsonBody(requestParams); 43 | RestUtils.setBasePath(String.format("%s/launch/%s/update", SessionContext.getProject(), getLaunchId())); 44 | RestUtils.send(HttpMethod.PUT, requestParams); 45 | requestParams.clear(); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/main/java/reportportal/SessionContext.java: -------------------------------------------------------------------------------- 1 | package reportportal; 2 | 3 | import org.slf4j.Logger; 4 | import org.slf4j.LoggerFactory; 5 | 6 | import java.io.File; 7 | import java.io.FileInputStream; 8 | import java.io.IOException; 9 | import java.util.Properties; 10 | 11 | public class SessionContext { 12 | private static final Properties reportPortalProperties; 13 | private static final Logger LOGGER = LoggerFactory.getLogger(SessionContext.class.getSimpleName()); 14 | 15 | static { 16 | LOGGER.info("SessionContext default constructor"); 17 | reportPortalProperties = loadReportPortalProperties(); 18 | } 19 | 20 | private static Properties loadReportPortalProperties() { 21 | Properties properties = new Properties(); 22 | try { 23 | String reportPortalPropertiesFile = "src/test/resources/reportportal.properties"; 24 | File reportPortalFile = new File(reportPortalPropertiesFile); 25 | String absolutePath = reportPortalFile.getAbsolutePath(); 26 | if (reportPortalFile.exists()) { 27 | properties.load(new FileInputStream(absolutePath)); 28 | LOGGER.info("Loaded reportportal.properties file - " + absolutePath); 29 | } else { 30 | LOGGER.info("reportportal.properties file NOT FOUND - " + absolutePath); 31 | } 32 | } 33 | catch (IOException e) { 34 | LOGGER.error("ERROR in loading reportportal.properties file\n" + e.getMessage()); 35 | throw new RuntimeException(e.getMessage()); 36 | } 37 | return properties; 38 | } 39 | 40 | public static String getEndPoint() { 41 | return reportPortalProperties.getProperty("rp.endpoint"); 42 | } 43 | 44 | public static String getUUID() { 45 | return reportPortalProperties.getProperty("rp.uuid"); 46 | } 47 | 48 | public static String getLaunchName() { 49 | return reportPortalProperties.getProperty("rp.launch"); 50 | } 51 | 52 | public static String getProject() { 53 | return reportPortalProperties.getProperty("rp.project"); 54 | } 55 | 56 | public static boolean getRpEnable() { 57 | return Boolean.parseBoolean(reportPortalProperties.getProperty("rp.enable")); 58 | } 59 | 60 | } 61 | -------------------------------------------------------------------------------- /src/main/java/utils/LogUtils.java: -------------------------------------------------------------------------------- 1 | package utils; 2 | 3 | import com.aventstack.extentreports.Status; 4 | import com.aventstack.extentreports.markuputils.ExtentColor; 5 | import com.aventstack.extentreports.markuputils.MarkupHelper; 6 | import extentreports.ExtentTestManager; 7 | import org.slf4j.Logger; 8 | import org.slf4j.LoggerFactory; 9 | import org.slf4j.MarkerFactory; 10 | 11 | public class LogUtils { 12 | 13 | private static final Logger Log = LoggerFactory.getLogger(LogUtils.class); 14 | private LogUtils() {} 15 | 16 | //Info Level Logs 17 | public static void info(String message) { 18 | Log.info(message); 19 | ExtentTestManager.getTest().log(Status.INFO, message); 20 | } 21 | 22 | //Info Level Logs 23 | public static void info(String message, Object o, Object o1) { 24 | Log.info(message, o, o1); 25 | ExtentTestManager.getTest().log(Status.INFO, message); 26 | } 27 | 28 | //Warn Level Logs 29 | public static void warn(String message) { 30 | Log.warn(message); 31 | ExtentTestManager.getTest().log(Status.WARNING, MarkupHelper.createLabel(message, ExtentColor.BLACK)); 32 | } 33 | 34 | //Passed Level Logs 35 | public static void pass(String message) { 36 | Log.info(message); 37 | ExtentTestManager.getTest().log(Status.PASS, MarkupHelper.createLabel(message, ExtentColor.GREEN)); 38 | } 39 | 40 | //Error Level Logs 41 | public static void fail(String message) { 42 | Log.error(MarkerFactory.getMarker("FAIL"), message); 43 | ExtentTestManager.getTest().log(Status.FAIL, MarkupHelper.createLabel(message, ExtentColor.RED)); 44 | } 45 | 46 | //Error Level Logs 47 | public static void error(String message) { 48 | Log.error(message); 49 | ExtentTestManager.getTest().log(Status.ERROR, MarkupHelper.createLabel(message, ExtentColor.RED)); 50 | } 51 | 52 | //Fatal Level Logs 53 | public static void fatal(String message) { 54 | Log.error(MarkerFactory.getMarker("FATAL"), message); 55 | ExtentTestManager.getTest().log(Status.FATAL, MarkupHelper.createLabel(message, ExtentColor.RED)); 56 | } 57 | 58 | //Debug Level Logs 59 | public static void debug(String message) { 60 | Log.debug(message); 61 | ExtentTestManager.getTest().log(Status.DEBUG, MarkupHelper.createLabel(message, ExtentColor.RED)); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/main/java/ensure/Wait.java: -------------------------------------------------------------------------------- 1 | package ensure; 2 | 3 | import com.google.inject.Inject; 4 | import org.openqa.selenium.JavascriptExecutor; 5 | import org.openqa.selenium.WebDriver; 6 | import org.openqa.selenium.WebElement; 7 | import org.openqa.selenium.support.ui.ExpectedCondition; 8 | import org.openqa.selenium.support.ui.ExpectedConditions; 9 | import org.openqa.selenium.support.ui.WebDriverWait; 10 | import utils.LogUtils; 11 | import utils.PropertyUtils; 12 | import utils.WebElementUtils; 13 | 14 | import java.util.List; 15 | 16 | public class Wait { 17 | 18 | final WebDriverWait webDriverWait; 19 | private final String waitPrefix = "Wait for "; 20 | 21 | @Inject 22 | WebDriver driver; 23 | 24 | @Inject 25 | public Wait(WebDriver driver) { 26 | this.webDriverWait = new WebDriverWait(driver, PropertyUtils.getInstance().getWebTimeout()); 27 | this.driver = driver; 28 | } 29 | 30 | public void waitForElementDisplay(WebElement element) { 31 | LogUtils.info(waitPrefix + WebElementUtils.getElementXpathInfo(element) + " to display"); 32 | webDriverWait.until(ExpectedConditions.visibilityOf(element)); 33 | } 34 | 35 | public void waitForElementsDisplay(List elements) { 36 | LogUtils.info(waitPrefix + WebElementUtils.getElementXpathInfo(elements) + " to display"); 37 | webDriverWait.until(ExpectedConditions.visibilityOfAllElements(elements)); 38 | } 39 | 40 | public void waitForElementEnabled(WebElement element) { 41 | LogUtils.info(waitPrefix + WebElementUtils.getElementXpathInfo(element) + " to be enabled"); 42 | webDriverWait.until(ExpectedConditions.visibilityOf(element)).isEnabled(); 43 | } 44 | 45 | public void waitForElementClickable(WebElement element) { 46 | LogUtils.info(waitPrefix + WebElementUtils.getElementXpathInfo(element) + " to be clickable"); 47 | webDriverWait.until(ExpectedConditions.elementToBeClickable(element)); 48 | } 49 | 50 | public void waitForPageLoad() { 51 | LogUtils.info("Wait for page load"); 52 | ExpectedCondition javaScriptLoad = webDriver -> 53 | ((JavascriptExecutor) (webDriver)).executeScript("return document.readyState").equals("complete"); 54 | webDriverWait.until(javaScriptLoad); 55 | } 56 | 57 | public void waitUntilDisplayIsNone(WebElement element) { 58 | LogUtils.info("Wait until display is none"); 59 | webDriverWait.until(ExpectedConditions.attributeContains(element, "style", "display: none;")); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/main/java/utils/RestUtils.java: -------------------------------------------------------------------------------- 1 | package utils; 2 | 3 | import io.restassured.RestAssured; 4 | import io.restassured.builder.RequestSpecBuilder; 5 | import io.restassured.http.ContentType; 6 | import io.restassured.path.json.JsonPath; 7 | import io.restassured.response.Response; 8 | import io.restassured.specification.RequestSpecification; 9 | import org.json.simple.JSONObject; 10 | 11 | public class RestUtils { 12 | 13 | public static String path; 14 | public static Response response; 15 | public static RequestSpecification requestSpecification; 16 | public static RequestSpecBuilder builder = new RequestSpecBuilder(); 17 | 18 | public enum HttpMethod { 19 | GET("get"), POST("post"), PUT("put"); 20 | 21 | private final String method; 22 | 23 | HttpMethod(String method) { 24 | this.method = method; 25 | } 26 | } 27 | 28 | private RestUtils() { } 29 | 30 | public static void setHeader(String key, String value) { 31 | builder.addHeader(key, value); 32 | } 33 | 34 | public static void setBaseURI(String baseURI) { 35 | builder.setBaseUri(baseURI); 36 | } 37 | 38 | public static void setBasePath(String basePathTerm) { 39 | builder.setBasePath(basePathTerm); 40 | } 41 | 42 | public static void createSearchQueryPath(String searchTerm, String jsonPathTerm, String param, String paramValue) { 43 | path = searchTerm + "/" + jsonPathTerm + "?" + param + "=" + paramValue; 44 | } 45 | 46 | public static void addJsonBody(JSONObject body) { 47 | builder.setBody(body); 48 | } 49 | 50 | public static void resetBaseURI () { 51 | builder.setBaseUri(""); 52 | } 53 | 54 | public static void resetBasePath() { 55 | builder.setBasePath(""); 56 | } 57 | 58 | public static void setContentType (ContentType type) { 59 | builder.setContentType(type); 60 | } 61 | 62 | public static Response send(HttpMethod method, JSONObject requestBody) { 63 | response = null; 64 | requestSpecification = builder.build(); 65 | if (method == HttpMethod.POST) 66 | { 67 | builder.setBody(requestBody); 68 | response = RestAssured.given().spec(requestSpecification).post(); 69 | } 70 | else if (method == HttpMethod.GET) 71 | { 72 | response = RestAssured.given().spec(requestSpecification).get(); 73 | } 74 | else if (method == HttpMethod.PUT) { 75 | builder.setBody(requestBody); 76 | response = RestAssured.given().spec(requestSpecification).put(); 77 | } 78 | response.then().log().all(); 79 | return response; 80 | } 81 | 82 | public static JsonPath getJsonPath(Response res) { 83 | String json = res.asString(); 84 | return new JsonPath(json); 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /src/main/java/keywords/Element.java: -------------------------------------------------------------------------------- 1 | package keywords; 2 | 3 | import com.google.inject.Inject; 4 | import ensure.Wait; 5 | import org.openqa.selenium.JavascriptExecutor; 6 | import org.openqa.selenium.WebDriver; 7 | import org.openqa.selenium.WebElement; 8 | import org.openqa.selenium.interactions.Actions; 9 | import utils.LogUtils; 10 | 11 | import static utils.WebElementUtils.*; 12 | 13 | public class Element { 14 | 15 | @Inject 16 | Wait wait; 17 | 18 | @Inject 19 | WebDriver driver; 20 | 21 | @Inject 22 | public Element(WebDriver driver) { 23 | this.driver = driver; 24 | wait = new Wait(driver); 25 | } 26 | 27 | public String getText(WebElement element) { 28 | LogUtils.info("Get text from: " + getElementXpathInfo(element)); 29 | wait.waitForElementDisplay(element); 30 | return element.getText(); 31 | } 32 | 33 | public void setText(WebElement element, String inputText) { 34 | LogUtils.info("Set text to: " + getElementXpathInfo(element)); 35 | wait.waitForElementDisplay(element); 36 | element.clear(); 37 | ((JavascriptExecutor) driver).executeScript("arguments[0].setAttribute('value', '" + inputText + "')", element); 38 | } 39 | 40 | public void click(WebElement element) { 41 | LogUtils.info("Click on: " + getElementXpathInfo(element)); 42 | wait.waitForElementDisplay(element); 43 | wait.waitForElementClickable(element); 44 | scrollIntoView(element); 45 | ((JavascriptExecutor) driver).executeScript("arguments[0].click();", element); 46 | } 47 | 48 | public void doubleClick(WebElement element) { 49 | LogUtils.info("Double click on element: " + getElementXpathInfo(element)); 50 | new Actions(driver).doubleClick(element).perform(); 51 | } 52 | 53 | public void moveToElement(WebElement element) { 54 | LogUtils.info("Move to element: " + getElementXpathInfo(element)); 55 | new Actions(driver).moveToElement(element).perform(); 56 | } 57 | 58 | public void dragAndDrop(WebElement sourceElement, WebElement destElement) { 59 | LogUtils.info("Drag and drop from: " 60 | + getElementXpathInfo(sourceElement) + "to: " + getElementXpathInfo(destElement)); 61 | new Actions(driver).dragAndDrop(sourceElement, destElement).perform(); 62 | } 63 | 64 | public void scrollIntoView(WebElement element) { 65 | LogUtils.info("Scroll into view of element: " + getElementXpathInfo(element)); 66 | ((JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView({behavior: 'smooth', block:'center', inline: 'center'});", element); 67 | ((JavascriptExecutor) driver).executeScript("window.scrollBy(0, -250);"); 68 | } 69 | 70 | public boolean verifyElementDisplayed(WebElement element) { 71 | LogUtils.info("Verify " + getElementXpathInfo(element) + " is displayed"); 72 | return element.isDisplayed(); 73 | } 74 | 75 | } 76 | -------------------------------------------------------------------------------- /src/test/java/listeners/TestListener.java: -------------------------------------------------------------------------------- 1 | package listeners; 2 | 3 | import com.aventstack.extentreports.MediaEntityBuilder; 4 | import com.aventstack.extentreports.Status; 5 | import com.aventstack.extentreports.markuputils.ExtentColor; 6 | import com.aventstack.extentreports.markuputils.MarkupHelper; 7 | import org.apache.commons.io.FileUtils; 8 | import org.openqa.selenium.OutputType; 9 | import org.openqa.selenium.TakesScreenshot; 10 | import org.testng.ITestContext; 11 | import org.testng.ITestListener; 12 | import org.testng.ITestResult; 13 | import extentreports.ExtentManager; 14 | import extentreports.ExtentTestManager; 15 | import utils.LogUtils; 16 | import webdriver.DriverManager; 17 | 18 | import java.io.File; 19 | import java.io.IOException; 20 | import java.util.Base64; 21 | 22 | public class TestListener implements ITestListener { 23 | 24 | @Override 25 | public synchronized void onTestStart(ITestResult result) { 26 | ExtentTestManager.startTest(result.getMethod().getMethodName()); 27 | ExtentTestManager.getTest().info(result.getMethod().getMethodName()+" test executions started"); 28 | } 29 | 30 | @Override 31 | public synchronized void onTestSuccess(ITestResult result) { 32 | ExtentTestManager.getTest().log(Status.PASS, 33 | MarkupHelper.createLabel(result.getName() + " - Test Case Passed", ExtentColor.GREEN)); 34 | } 35 | 36 | @Override 37 | public synchronized void onTestFailure(ITestResult result) { 38 | ExtentTestManager.getTest().log(Status.FAIL, 39 | MarkupHelper.createLabel(result.getName() + " - Test Case Failed", ExtentColor.RED)); 40 | try { 41 | String base64StringOfScreenshots; 42 | TakesScreenshot screenshot = (TakesScreenshot) DriverManager.getDriver(); 43 | File src = screenshot.getScreenshotAs(OutputType.FILE); 44 | byte[] fileContent = FileUtils.readFileToByteArray(src); 45 | base64StringOfScreenshots = "data:image/png;base64," + Base64.getEncoder().encodeToString(fileContent); 46 | ExtentTestManager.getTest().fail("Test Case Failed screenshot: ", 47 | MediaEntityBuilder.createScreenCaptureFromBase64String(base64StringOfScreenshots).build()); 48 | LogUtils.info("RP_MESSAGE#FILE#{}#{}", src.getAbsoluteFile(), "Screenshot on Failure"); 49 | } catch (IOException e) { 50 | e.printStackTrace(); 51 | } 52 | } 53 | 54 | @Override 55 | public synchronized void onTestSkipped(ITestResult result) { 56 | } 57 | 58 | @Override 59 | public synchronized void onTestFailedButWithinSuccessPercentage(ITestResult result) { 60 | } 61 | 62 | @Override 63 | public synchronized void onStart(ITestContext context) { 64 | ExtentManager.getInstance(); 65 | } 66 | 67 | @Override 68 | public synchronized void onFinish(ITestContext context) { 69 | extentreports.ExtentTestManager.endTest(); 70 | ExtentManager.getInstance().flush(); 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![Codacy Badge](https://api.codacy.com/project/badge/Grade/ea4a81e6a3cd4bf8a4a51b6f1f16145a)](https://www.codacy.com/manual/npvinh140589/selenium-test-framework?utm_source=github.com&utm_medium=referral&utm_content=zarashima/selenium-test-framework&utm_campaign=Badge_Grade) 2 | [![Build Status](https://travis-ci.com/zarashima/selenium-test-framework.svg?branch=master)](https://travis-ci.com/zarashima/selenium-test-framework) 3 | ![Build Status](https://github.com/zarashima/selenium-test-framework/workflows/Build%20Status/badge.svg) 4 | [![](https://circleci.com/gh/zarashima/selenium-test-framework.svg?style=shield)](https://app.circleci.com/pipelines/github/zarashima/selenium-test-framework) 5 | 6 | # Framework Architecture 7 | ![Framework Architecture](https://github.com/zarashima/java-test-framework/blob/master/images/architecture.png) 8 | 9 | # Introduction 10 | A web automation testing framework written in Java. Support Chrome, Firefox 11 | 12 | # Features 13 | * Dependencies injection using Guice 14 | * Ensure mechanism 15 | * Thread-safe driver instances 16 | * Support different types of execution against local, pipeline or container 17 | * ReportPortal integration 18 | * Docker-ready files for easy CI/CD integration 19 | 20 | # Technologies 21 | * Maven 22 | * TestNG 23 | * Logback 24 | * WebDriverManager 25 | * ExtentReport 26 | * Docker 27 | * Guice 28 | * ReportPortal 29 | 30 | # Integration 31 | ReportPortal 32 | 33 | # Usage 34 | The framework export RUNWHERE environment variable for use in different cases. Different RUNWHERE used will change desired capabilities accordingly 35 | 36 | | RUNWHERE | Description | 37 | | --- | --- | 38 | | LOCAL | Desired capabilities for execution on local machine | 39 | | PIPELINE | Desired capabilities for execution on a automation pipeline | 40 | | CONTAINER | Desired capabilities for execution on Docker | 41 | 42 | ## Enable ReportPortal integration 43 | By default, [ReportPortal](https://reportportal.io/) (RP) integration is disabled. Setup your RP properly first and then change RP settings in `src/test/resources/reportproperties.properties` file 44 | 45 | ## Execution 46 | As told, RUNWHERE will determine the desired capabilities against the browser under test. Example below expose RUNWHERE environment variable as LOCAL 47 | Execute maven command and pass in the browser's name. If RP is enabled, it will send results to the server. 48 | 49 | ![RP Integration](https://github.com/zarashima/java-test-framework/blob/master/images/reportportal.png) 50 | 51 | ### Local 52 | ```bash 53 | export RUNWHERE=LOCAL 54 | 55 | # Parallel executions on Chrome and Firefox 56 | mvn clean test 57 | ``` 58 | 59 | ## Container 60 | ### Prerequisites 61 | By default docker-compose file will roll up Selenium Grid automatically, and run the tests in `vinh/framework-docker` container 62 | 63 | `vinh/framework-docker` is a custom container which is achived by below command 64 | 65 | ```bash 66 | # Build dockerfile using vinh/ 67 | docker build -t=vinh/framework-docker . 68 | ``` 69 | You cange the tag's name after `-t` to whatever you want but ensure to change it consistently in [docker-compose](https://github.com/zarashima/selenium-test-framework/blob/db2214a7dc7154d2d8ab8cfdde7bd4a64b95fbea/docker-compose.yaml#L30) also 70 | 71 | ### Execution 72 | No need to export RUNWHERE=container. The commands in docker-compose has already done it for you. 73 | 74 | Execute docker-compose command 75 | `docker-compose up -d` 76 | 77 | Moreover, scale up of Chrome/Firefox nodes is possible using docker-compose command. Refer to Docker guide for more details 78 | -------------------------------------------------------------------------------- /src/test/java/tests/BaseTest.java: -------------------------------------------------------------------------------- 1 | package tests; 2 | 3 | import com.epam.reportportal.service.tree.ItemTreeReporter; 4 | import com.epam.reportportal.service.tree.TestItemTree; 5 | import com.epam.reportportal.testng.TestNGService; 6 | import com.epam.reportportal.testng.util.ItemTreeUtils; 7 | import com.epam.ta.reportportal.ws.model.FinishTestItemRQ; 8 | import com.epam.ta.reportportal.ws.model.attribute.ItemAttributesRQ; 9 | import com.google.inject.Guice; 10 | import com.google.inject.Injector; 11 | import extentreports.ExtentTestManager; 12 | import keywords.Browser; 13 | import keywords.Element; 14 | import keywords.Verification; 15 | import modules.DriverModule; 16 | import org.openqa.selenium.WebDriver; 17 | import org.openqa.selenium.remote.DesiredCapabilities; 18 | import org.testng.ITestResult; 19 | import org.testng.annotations.AfterMethod; 20 | import org.testng.annotations.AfterTest; 21 | import org.testng.annotations.BeforeTest; 22 | import org.testng.annotations.Parameters; 23 | import org.testng.collections.Sets; 24 | import pages.HomePage; 25 | import pages.SignInPage; 26 | import reportportal.Launch; 27 | import reportportal.SessionContext; 28 | import rp.com.google.common.base.Optional; 29 | import webdriver.DriverFactory; 30 | import webdriver.DriverManager; 31 | 32 | import java.util.Calendar; 33 | import java.util.Set; 34 | 35 | import static com.epam.reportportal.testng.TestNGService.ITEM_TREE; 36 | 37 | public class BaseTest { 38 | 39 | protected WebDriver driver; 40 | protected Browser browserKeywords; 41 | protected Element elementKeywords; 42 | protected Verification verificationKeywords; 43 | protected HomePage homePage; 44 | protected SignInPage signInPage; 45 | protected Launch launch; 46 | 47 | @BeforeTest 48 | @Parameters({"browserName"}) 49 | public void beforeTest(String browserName) { 50 | Injector injector = Guice.createInjector(new DriverModule()); 51 | driver = DriverFactory.createInstance(browserName, new DesiredCapabilities()); 52 | DriverManager.setDriver(driver); 53 | homePage = injector.getInstance(HomePage.class); 54 | signInPage = injector.getInstance(SignInPage.class); 55 | browserKeywords = injector.getInstance(Browser.class); 56 | elementKeywords = injector.getInstance(Element.class); 57 | verificationKeywords = injector.getInstance(Verification.class); 58 | launch = injector.getInstance(Launch.class); 59 | } 60 | 61 | @AfterMethod() 62 | public void afterMethod(ITestResult testResult) { 63 | if (SessionContext.getRpEnable()) { 64 | ItemTreeUtils.retrieveLeaf(testResult, ITEM_TREE).ifPresent(testResultLeaf -> { 65 | sendFinishRequest(testResultLeaf, testResult); 66 | }); 67 | } 68 | ExtentTestManager.getTest().assignCategory(DriverManager.getBrowserName()); 69 | } 70 | 71 | @AfterTest 72 | public void afterTest() { 73 | DriverManager.quit(); 74 | } 75 | 76 | private void sendFinishRequest(TestItemTree.TestItemLeaf testResultLeaf, ITestResult testResult) { 77 | FinishTestItemRQ finishTestItemRQ = new FinishTestItemRQ(); 78 | Set attributes = Optional.fromNullable(finishTestItemRQ.getAttributes()) 79 | .or(Sets.newHashSet(new ItemAttributesRQ("browser", DriverManager.getBrowserName()))); 80 | finishTestItemRQ.setAttributes(attributes); 81 | finishTestItemRQ.setStatus(testResult.isSuccess() ? "PASSED" : "FAILED"); 82 | finishTestItemRQ.setDescription(testResult.getMethod().getDescription()); 83 | finishTestItemRQ.setEndTime(Calendar.getInstance().getTime()); 84 | ItemTreeReporter.finishItem(TestNGService.getReportPortal().getClient(), finishTestItemRQ, ITEM_TREE.getLaunchId(), testResultLeaf) 85 | .cache() 86 | .blockingGet(); 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /src/main/java/keywords/Browser.java: -------------------------------------------------------------------------------- 1 | package keywords; 2 | 3 | import com.google.inject.Inject; 4 | import ensure.Wait; 5 | import org.openqa.selenium.*; 6 | import org.openqa.selenium.remote.DesiredCapabilities; 7 | import org.openqa.selenium.remote.RemoteWebDriver; 8 | import utils.LogUtils; 9 | 10 | import java.util.Set; 11 | 12 | public class Browser { 13 | 14 | @Inject 15 | WebDriver driver; 16 | 17 | @Inject 18 | Wait wait; 19 | 20 | @Inject 21 | public Browser(WebDriver driver) { 22 | this.driver = driver; 23 | wait = new Wait(driver); 24 | } 25 | 26 | /** 27 | * Navigate to a page and wait for page to be loaded 28 | * @param url Page URL e,g. https://www.google.com 29 | */ 30 | public void goTo(String url) { 31 | LogUtils.info("Navigate to: " + url); 32 | driver.get(url); 33 | wait.waitForPageLoad(); 34 | } 35 | 36 | /** 37 | * Maximize current window 38 | */ 39 | public void maximizeWindow() { 40 | LogUtils.info("Maximize browser"); 41 | driver.manage().window().maximize(); 42 | } 43 | 44 | /** 45 | * Clear all cookies 46 | */ 47 | public void clearCookies() { 48 | LogUtils.info("Clear all browser cookies"); 49 | driver.manage().deleteAllCookies(); 50 | } 51 | 52 | /** 53 | * Get cookies 54 | * @return current browser cookies 55 | */ 56 | public Set getCookies() { 57 | LogUtils.info("Get browser cookies"); 58 | return driver.manage().getCookies(); 59 | } 60 | 61 | /** 62 | * Set window size 63 | * @param width desired window width 64 | * @param height desired window height 65 | */ 66 | public void setWindowsSize(int width, int height) { 67 | LogUtils.info("Set windows size"); 68 | if (width == 0 || height == 0) { 69 | LogUtils.fail("Either width or height is set to 0 which is invalid"); 70 | } 71 | else { 72 | driver.manage().window().setSize(new Dimension(width, height)); 73 | } 74 | } 75 | 76 | /** 77 | * Set browser window to full screen 78 | */ 79 | public void setFullScreen() { 80 | LogUtils.info("Set browser window to full screen"); 81 | driver.manage().window().fullscreen(); 82 | } 83 | 84 | 85 | /** 86 | * Get window position 87 | * @return current window position 88 | */ 89 | public Point getPosition() { 90 | LogUtils.info("Get window position"); 91 | return driver.manage().window().getPosition(); 92 | } 93 | 94 | /** 95 | * Switch to new window 96 | */ 97 | public void switchToNewWindow() { 98 | LogUtils.info("Switch to new window"); 99 | String parentHandle = driver.getWindowHandle(); 100 | Set allHandles = driver.getWindowHandles(); 101 | for (String handle : allHandles) { 102 | if (!handle.equals(parentHandle)) 103 | driver.switchTo().window(handle); 104 | } 105 | } 106 | 107 | /** 108 | * Switch back to default window 109 | */ 110 | public void switchBackToDefaultContent() { 111 | LogUtils.info("Switch back to default content"); 112 | driver.switchTo().defaultContent(); 113 | } 114 | 115 | /** 116 | * Refresh the current page 117 | */ 118 | public void refresh() { 119 | LogUtils.info("Refresh window"); 120 | driver.navigate().refresh(); 121 | } 122 | 123 | /** 124 | * Pressing the browser’s back button: 125 | */ 126 | public void back() { 127 | LogUtils.info("Press back button on browser"); 128 | driver.navigate().back(); 129 | } 130 | 131 | /** 132 | * Pressing the browser’s forward button: 133 | */ 134 | public void forward() { 135 | LogUtils.info("Press back button on browser"); 136 | driver.navigate().forward(); 137 | } 138 | 139 | /** 140 | * Get the current page title of the browser 141 | * @return page title 142 | */ 143 | public String getTitle() { 144 | LogUtils.info("Get window title"); 145 | return driver.getTitle(); 146 | } 147 | 148 | public String getBrowserVersion() { 149 | LogUtils.info("Get browser version"); 150 | return ((RemoteWebDriver) driver).getCapabilities().getVersion(); 151 | } 152 | 153 | public String getBrowserName() { 154 | LogUtils.info("Get browser name"); 155 | return ((RemoteWebDriver) driver).getCapabilities().getBrowserName(); 156 | } 157 | 158 | public String getBrowserInformation() { 159 | LogUtils.info("Get browser information"); 160 | return getBrowserName() + "_" + getBrowserVersion(); 161 | } 162 | 163 | public Platform getBrowserPlatform() { 164 | LogUtils.info("Get browser version"); 165 | return ((DesiredCapabilities) driver).getPlatform(); 166 | } 167 | 168 | } 169 | -------------------------------------------------------------------------------- /.mvn/wrapper/MavenWrapperDownloader.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2007-present the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | import java.net.*; 17 | import java.io.*; 18 | import java.nio.channels.*; 19 | import java.util.Properties; 20 | 21 | public class MavenWrapperDownloader { 22 | 23 | private static final String WRAPPER_VERSION = "0.5.6"; 24 | /** 25 | * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. 26 | */ 27 | private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/" 28 | + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar"; 29 | 30 | /** 31 | * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to 32 | * use instead of the default one. 33 | */ 34 | private static final String MAVEN_WRAPPER_PROPERTIES_PATH = 35 | ".mvn/wrapper/maven-wrapper.properties"; 36 | 37 | /** 38 | * Path where the maven-wrapper.jar will be saved to. 39 | */ 40 | private static final String MAVEN_WRAPPER_JAR_PATH = 41 | ".mvn/wrapper/maven-wrapper.jar"; 42 | 43 | /** 44 | * Name of the property which should be used to override the default download url for the wrapper. 45 | */ 46 | private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; 47 | 48 | public static void main(String args[]) { 49 | System.out.println("- Downloader started"); 50 | File baseDirectory = new File(args[0]); 51 | System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); 52 | 53 | // If the maven-wrapper.properties exists, read it and check if it contains a custom 54 | // wrapperUrl parameter. 55 | File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); 56 | String url = DEFAULT_DOWNLOAD_URL; 57 | if(mavenWrapperPropertyFile.exists()) { 58 | FileInputStream mavenWrapperPropertyFileInputStream = null; 59 | try { 60 | mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); 61 | Properties mavenWrapperProperties = new Properties(); 62 | mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); 63 | url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); 64 | } catch (IOException e) { 65 | System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); 66 | } finally { 67 | try { 68 | if(mavenWrapperPropertyFileInputStream != null) { 69 | mavenWrapperPropertyFileInputStream.close(); 70 | } 71 | } catch (IOException e) { 72 | // Ignore ... 73 | } 74 | } 75 | } 76 | System.out.println("- Downloading from: " + url); 77 | 78 | File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); 79 | if(!outputFile.getParentFile().exists()) { 80 | if(!outputFile.getParentFile().mkdirs()) { 81 | System.out.println( 82 | "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'"); 83 | } 84 | } 85 | System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); 86 | try { 87 | downloadFileFromURL(url, outputFile); 88 | System.out.println("Done"); 89 | System.exit(0); 90 | } catch (Throwable e) { 91 | System.out.println("- Error downloading"); 92 | e.printStackTrace(); 93 | System.exit(1); 94 | } 95 | } 96 | 97 | private static void downloadFileFromURL(String urlString, File destination) throws Exception { 98 | if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) { 99 | String username = System.getenv("MVNW_USERNAME"); 100 | char[] password = System.getenv("MVNW_PASSWORD").toCharArray(); 101 | Authenticator.setDefault(new Authenticator() { 102 | @Override 103 | protected PasswordAuthentication getPasswordAuthentication() { 104 | return new PasswordAuthentication(username, password); 105 | } 106 | }); 107 | } 108 | URL website = new URL(urlString); 109 | ReadableByteChannel rbc; 110 | rbc = Channels.newChannel(website.openStream()); 111 | FileOutputStream fos = new FileOutputStream(destination); 112 | fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); 113 | fos.close(); 114 | rbc.close(); 115 | } 116 | 117 | } 118 | -------------------------------------------------------------------------------- /mvnw.cmd: -------------------------------------------------------------------------------- 1 | @REM ---------------------------------------------------------------------------- 2 | @REM Licensed to the Apache Software Foundation (ASF) under one 3 | @REM or more contributor license agreements. See the NOTICE file 4 | @REM distributed with this work for additional information 5 | @REM regarding copyright ownership. The ASF licenses this file 6 | @REM to you under the Apache License, Version 2.0 (the 7 | @REM "License"); you may not use this file except in compliance 8 | @REM with the License. You may obtain a copy of the License at 9 | @REM 10 | @REM http://www.apache.org/licenses/LICENSE-2.0 11 | @REM 12 | @REM Unless required by applicable law or agreed to in writing, 13 | @REM software distributed under the License is distributed on an 14 | @REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | @REM KIND, either express or implied. See the License for the 16 | @REM specific language governing permissions and limitations 17 | @REM under the License. 18 | @REM ---------------------------------------------------------------------------- 19 | 20 | @REM ---------------------------------------------------------------------------- 21 | @REM Maven Start Up Batch script 22 | @REM 23 | @REM Required ENV vars: 24 | @REM JAVA_HOME - location of a JDK home dir 25 | @REM 26 | @REM Optional ENV vars 27 | @REM M2_HOME - location of maven2's installed home dir 28 | @REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands 29 | @REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending 30 | @REM MAVEN_OPTS - parameters passed to the Java VM when running Maven 31 | @REM e.g. to debug Maven itself, use 32 | @REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 33 | @REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files 34 | @REM ---------------------------------------------------------------------------- 35 | 36 | @REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' 37 | @echo off 38 | @REM set title of command window 39 | title %0 40 | @REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' 41 | @if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% 42 | 43 | @REM set %HOME% to equivalent of $HOME 44 | if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") 45 | 46 | @REM Execute a user defined script before this one 47 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre 48 | @REM check for pre script, once with legacy .bat ending and once with .cmd ending 49 | if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" 50 | if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" 51 | :skipRcPre 52 | 53 | @setlocal 54 | 55 | set ERROR_CODE=0 56 | 57 | @REM To isolate internal variables from possible post scripts, we use another setlocal 58 | @setlocal 59 | 60 | @REM ==== START VALIDATION ==== 61 | if not "%JAVA_HOME%" == "" goto OkJHome 62 | 63 | echo. 64 | echo Error: JAVA_HOME not found in your environment. >&2 65 | echo Please set the JAVA_HOME variable in your environment to match the >&2 66 | echo location of your Java installation. >&2 67 | echo. 68 | goto error 69 | 70 | :OkJHome 71 | if exist "%JAVA_HOME%\bin\java.exe" goto init 72 | 73 | echo. 74 | echo Error: JAVA_HOME is set to an invalid directory. >&2 75 | echo JAVA_HOME = "%JAVA_HOME%" >&2 76 | echo Please set the JAVA_HOME variable in your environment to match the >&2 77 | echo location of your Java installation. >&2 78 | echo. 79 | goto error 80 | 81 | @REM ==== END VALIDATION ==== 82 | 83 | :init 84 | 85 | @REM Find the project base dir, i.e. the directory that contains the folder ".mvn". 86 | @REM Fallback to current working directory if not found. 87 | 88 | set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% 89 | IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir 90 | 91 | set EXEC_DIR=%CD% 92 | set WDIR=%EXEC_DIR% 93 | :findBaseDir 94 | IF EXIST "%WDIR%"\.mvn goto baseDirFound 95 | cd .. 96 | IF "%WDIR%"=="%CD%" goto baseDirNotFound 97 | set WDIR=%CD% 98 | goto findBaseDir 99 | 100 | :baseDirFound 101 | set MAVEN_PROJECTBASEDIR=%WDIR% 102 | cd "%EXEC_DIR%" 103 | goto endDetectBaseDir 104 | 105 | :baseDirNotFound 106 | set MAVEN_PROJECTBASEDIR=%EXEC_DIR% 107 | cd "%EXEC_DIR%" 108 | 109 | :endDetectBaseDir 110 | 111 | IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig 112 | 113 | @setlocal EnableExtensions EnableDelayedExpansion 114 | for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a 115 | @endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% 116 | 117 | :endReadAdditionalConfig 118 | 119 | SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" 120 | set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" 121 | set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 122 | 123 | set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 124 | 125 | FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( 126 | IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B 127 | ) 128 | 129 | @REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 130 | @REM This allows using the maven wrapper in projects that prohibit checking in binary data. 131 | if exist %WRAPPER_JAR% ( 132 | if "%MVNW_VERBOSE%" == "true" ( 133 | echo Found %WRAPPER_JAR% 134 | ) 135 | ) else ( 136 | if not "%MVNW_REPOURL%" == "" ( 137 | SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 138 | ) 139 | if "%MVNW_VERBOSE%" == "true" ( 140 | echo Couldn't find %WRAPPER_JAR%, downloading it ... 141 | echo Downloading from: %DOWNLOAD_URL% 142 | ) 143 | 144 | powershell -Command "&{"^ 145 | "$webclient = new-object System.Net.WebClient;"^ 146 | "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ 147 | "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ 148 | "}"^ 149 | "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ 150 | "}" 151 | if "%MVNW_VERBOSE%" == "true" ( 152 | echo Finished downloading %WRAPPER_JAR% 153 | ) 154 | ) 155 | @REM End of extension 156 | 157 | @REM Provide a "standardized" way to retrieve the CLI args that will 158 | @REM work with both Windows and non-Windows executions. 159 | set MAVEN_CMD_LINE_ARGS=%* 160 | 161 | %MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* 162 | if ERRORLEVEL 1 goto error 163 | goto end 164 | 165 | :error 166 | set ERROR_CODE=1 167 | 168 | :end 169 | @endlocal & set ERROR_CODE=%ERROR_CODE% 170 | 171 | if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost 172 | @REM check for post script, once with legacy .bat ending and once with .cmd ending 173 | if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" 174 | if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" 175 | :skipRcPost 176 | 177 | @REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' 178 | if "%MAVEN_BATCH_PAUSE%" == "on" pause 179 | 180 | if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% 181 | 182 | exit /B %ERROR_CODE% 183 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | git.zarashima.selenium 7 | framework 8 | 1.0 9 | 10 | 11 | 3.141.59 12 | 4.0.0 13 | 4.2.3 14 | 29.0-jre 15 | 5.0.0-RC1 16 | 4.1.2 17 | 4.3.1 18 | 7.1.0 19 | 4.0.1 20 | 1.2.17 21 | 2.10.0 22 | 2.8.0 23 | 1.0.3 24 | 3.11.1 25 | 1.4.9 26 | 27 | 28 | 29 | 30 | false 31 | 32 | bintray-epam-reportportal 33 | bintray 34 | http://dl.bintray.com/epam/reportportal 35 | 36 | 37 | jitpack.io 38 | https://jitpack.io 39 | 40 | 41 | public 42 | public 43 | http://mvn.testinium.com/repository/public/ 44 | 45 | true 46 | 47 | 48 | true 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | org.apache.maven.plugins 57 | maven-compiler-plugin 58 | 3.7.0 59 | 60 | 1.8 61 | 1.8 62 | 1.8 63 | 1.8 64 | 1.8 65 | 66 | 67 | 68 | org.apache.maven.plugins 69 | maven-surefire-plugin 70 | 3.0.0-M3 71 | 72 | 73 | 74 | ${project.basedir}/src/test/resources/suites/${suite}.xml 75 | 76 | 77 | 78 | 79 | org.apache.maven.plugins 80 | maven-dependency-plugin 81 | 82 | 83 | copy-dependencies 84 | prepare-package 85 | 86 | copy-dependencies 87 | 88 | 89 | 90 | ${project.build.directory}/libs 91 | 92 | 93 | 94 | 95 | 96 | 97 | org.apache.maven.plugins 98 | maven-jar-plugin 99 | 3.1.0 100 | 101 | 102 | 103 | test-jar 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | com.epam.reportportal 115 | agent-java-testng 116 | 5.0.6 117 | 118 | 119 | 120 | com.epam.reportportal 121 | logger-java-logback 122 | 5.0.3 123 | 124 | 125 | 126 | org.freemarker 127 | freemarker 128 | 2.3.28 129 | 130 | 131 | 132 | com.github.appium 133 | java-client 134 | 7.3.0 135 | 136 | 137 | 138 | org.seleniumhq.selenium 139 | selenium-java 140 | ${selenium.version} 141 | 142 | 143 | 144 | org.yaml 145 | snakeyaml 146 | 1.26 147 | 148 | 149 | 150 | io.cucumber 151 | cucumber-java 152 | 6.1.1 153 | test 154 | 155 | 156 | 157 | io.cucumber 158 | cucumber-testng 159 | 6.1.1 160 | test 161 | 162 | 163 | 164 | io.github.bonigarcia 165 | webdrivermanager 166 | ${webdrivermanager.version} 167 | 168 | 169 | 170 | com.google.inject 171 | guice 172 | ${guice.version} 173 | 174 | 175 | 176 | com.google.guava 177 | guava 178 | ${guava.version} 179 | 180 | 181 | 182 | io.rest-assured 183 | rest-assured 184 | ${rest-assured.version} 185 | 186 | 187 | 188 | org.testng 189 | testng 190 | ${testng.version} 191 | test 192 | 193 | 194 | 195 | org.awaitility 196 | awaitility 197 | ${awaitility.version} 198 | compile 199 | 200 | 201 | 202 | com.aventstack 203 | extentreports-testng-adapter 204 | ${extentreport-adapter.version} 205 | 206 | 207 | 208 | com.mashape.unirest 209 | unirest-java 210 | ${unirest.version} 211 | 212 | 213 | 214 | org.assertj 215 | assertj-core 216 | 3.11.1 217 | 218 | 219 | 220 | com.googlecode.json-simple 221 | json-simple 222 | 1.1.1 223 | 224 | 225 | 226 | com.aventstack 227 | extentreports-cucumber4-adapter 228 | RELEASE 229 | 230 | 231 | 232 | info.cukes 233 | cucumber-java8 234 | RELEASE 235 | test 236 | 237 | 238 | 239 | junit 240 | junit-dep 241 | RELEASE 242 | test 243 | 244 | 245 | 246 | com.testinium.deviceinformation 247 | device-information 248 | 2.0 249 | 250 | 251 | 252 | info.cukes 253 | cucumber-picocontainer 254 | 1.2.5 255 | test 256 | 257 | 258 | 259 | org.awaitility 260 | awaitility-proxy 261 | 3.0.0 262 | 263 | 264 | 265 | ch.qos.logback 266 | logback-classic 267 | 1.2.3 268 | 269 | 270 | 271 | org.apache.logging.log4j 272 | log4j-core 273 | 2.17.1 274 | 275 | 276 | 277 | com.jayway.restassured 278 | json-schema-validator 279 | 2.8.0 280 | 281 | 282 | 283 | com.jayway.restassured 284 | rest-assured 285 | ${restassured.version} 286 | 287 | 288 | 289 | 290 | 291 | -------------------------------------------------------------------------------- /mvnw: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # ---------------------------------------------------------------------------- 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, 14 | # software distributed under the License is distributed on an 15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | # KIND, either express or implied. See the License for the 17 | # specific language governing permissions and limitations 18 | # under the License. 19 | # ---------------------------------------------------------------------------- 20 | 21 | # ---------------------------------------------------------------------------- 22 | # Maven Start Up Batch script 23 | # 24 | # Required ENV vars: 25 | # ------------------ 26 | # JAVA_HOME - location of a JDK home dir 27 | # 28 | # Optional ENV vars 29 | # ----------------- 30 | # M2_HOME - location of maven2's installed home dir 31 | # MAVEN_OPTS - parameters passed to the Java VM when running Maven 32 | # e.g. to debug Maven itself, use 33 | # set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 34 | # MAVEN_SKIP_RC - flag to disable loading of mavenrc files 35 | # ---------------------------------------------------------------------------- 36 | 37 | if [ -z "$MAVEN_SKIP_RC" ] ; then 38 | 39 | if [ -f /etc/mavenrc ] ; then 40 | . /etc/mavenrc 41 | fi 42 | 43 | if [ -f "$HOME/.mavenrc" ] ; then 44 | . "$HOME/.mavenrc" 45 | fi 46 | 47 | fi 48 | 49 | # OS specific support. $var _must_ be set to either true or false. 50 | cygwin=false; 51 | darwin=false; 52 | mingw=false 53 | case "`uname`" in 54 | CYGWIN*) cygwin=true ;; 55 | MINGW*) mingw=true;; 56 | Darwin*) darwin=true 57 | # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home 58 | # See https://developer.apple.com/library/mac/qa/qa1170/_index.html 59 | if [ -z "$JAVA_HOME" ]; then 60 | if [ -x "/usr/libexec/java_home" ]; then 61 | export JAVA_HOME="`/usr/libexec/java_home`" 62 | else 63 | export JAVA_HOME="/Library/Java/Home" 64 | fi 65 | fi 66 | ;; 67 | esac 68 | 69 | if [ -z "$JAVA_HOME" ] ; then 70 | if [ -r /etc/gentoo-release ] ; then 71 | JAVA_HOME=`java-config --jre-home` 72 | fi 73 | fi 74 | 75 | if [ -z "$M2_HOME" ] ; then 76 | ## resolve links - $0 may be a link to maven's home 77 | PRG="$0" 78 | 79 | # need this for relative symlinks 80 | while [ -h "$PRG" ] ; do 81 | ls=`ls -ld "$PRG"` 82 | link=`expr "$ls" : '.*-> \(.*\)$'` 83 | if expr "$link" : '/.*' > /dev/null; then 84 | PRG="$link" 85 | else 86 | PRG="`dirname "$PRG"`/$link" 87 | fi 88 | done 89 | 90 | saveddir=`pwd` 91 | 92 | M2_HOME=`dirname "$PRG"`/.. 93 | 94 | # make it fully qualified 95 | M2_HOME=`cd "$M2_HOME" && pwd` 96 | 97 | cd "$saveddir" 98 | # echo Using m2 at $M2_HOME 99 | fi 100 | 101 | # For Cygwin, ensure paths are in UNIX format before anything is touched 102 | if $cygwin ; then 103 | [ -n "$M2_HOME" ] && 104 | M2_HOME=`cygpath --unix "$M2_HOME"` 105 | [ -n "$JAVA_HOME" ] && 106 | JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 107 | [ -n "$CLASSPATH" ] && 108 | CLASSPATH=`cygpath --path --unix "$CLASSPATH"` 109 | fi 110 | 111 | # For Mingw, ensure paths are in UNIX format before anything is touched 112 | if $mingw ; then 113 | [ -n "$M2_HOME" ] && 114 | M2_HOME="`(cd "$M2_HOME"; pwd)`" 115 | [ -n "$JAVA_HOME" ] && 116 | JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" 117 | fi 118 | 119 | if [ -z "$JAVA_HOME" ]; then 120 | javaExecutable="`which javac`" 121 | if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then 122 | # readlink(1) is not available as standard on Solaris 10. 123 | readLink=`which readlink` 124 | if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then 125 | if $darwin ; then 126 | javaHome="`dirname \"$javaExecutable\"`" 127 | javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" 128 | else 129 | javaExecutable="`readlink -f \"$javaExecutable\"`" 130 | fi 131 | javaHome="`dirname \"$javaExecutable\"`" 132 | javaHome=`expr "$javaHome" : '\(.*\)/bin'` 133 | JAVA_HOME="$javaHome" 134 | export JAVA_HOME 135 | fi 136 | fi 137 | fi 138 | 139 | if [ -z "$JAVACMD" ] ; then 140 | if [ -n "$JAVA_HOME" ] ; then 141 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 142 | # IBM's JDK on AIX uses strange locations for the executables 143 | JAVACMD="$JAVA_HOME/jre/sh/java" 144 | else 145 | JAVACMD="$JAVA_HOME/bin/java" 146 | fi 147 | else 148 | JAVACMD="`which java`" 149 | fi 150 | fi 151 | 152 | if [ ! -x "$JAVACMD" ] ; then 153 | echo "Error: JAVA_HOME is not defined correctly." >&2 154 | echo " We cannot execute $JAVACMD" >&2 155 | exit 1 156 | fi 157 | 158 | if [ -z "$JAVA_HOME" ] ; then 159 | echo "Warning: JAVA_HOME environment variable is not set." 160 | fi 161 | 162 | CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher 163 | 164 | # traverses directory structure from process work directory to filesystem root 165 | # first directory with .mvn subdirectory is considered project base directory 166 | find_maven_basedir() { 167 | 168 | if [ -z "$1" ] 169 | then 170 | echo "Path not specified to find_maven_basedir" 171 | return 1 172 | fi 173 | 174 | basedir="$1" 175 | wdir="$1" 176 | while [ "$wdir" != '/' ] ; do 177 | if [ -d "$wdir"/.mvn ] ; then 178 | basedir=$wdir 179 | break 180 | fi 181 | # workaround for JBEAP-8937 (on Solaris 10/Sparc) 182 | if [ -d "${wdir}" ]; then 183 | wdir=`cd "$wdir/.."; pwd` 184 | fi 185 | # end of workaround 186 | done 187 | echo "${basedir}" 188 | } 189 | 190 | # concatenates all lines of a file 191 | concat_lines() { 192 | if [ -f "$1" ]; then 193 | echo "$(tr -s '\n' ' ' < "$1")" 194 | fi 195 | } 196 | 197 | BASE_DIR=`find_maven_basedir "$(pwd)"` 198 | if [ -z "$BASE_DIR" ]; then 199 | exit 1; 200 | fi 201 | 202 | ########################################################################################## 203 | # Extension to allow automatically downloading the maven-wrapper.jar from Maven-central 204 | # This allows using the maven wrapper in projects that prohibit checking in binary data. 205 | ########################################################################################## 206 | if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then 207 | if [ "$MVNW_VERBOSE" = true ]; then 208 | echo "Found .mvn/wrapper/maven-wrapper.jar" 209 | fi 210 | else 211 | if [ "$MVNW_VERBOSE" = true ]; then 212 | echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." 213 | fi 214 | if [ -n "$MVNW_REPOURL" ]; then 215 | jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 216 | else 217 | jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" 218 | fi 219 | while IFS="=" read key value; do 220 | case "$key" in (wrapperUrl) jarUrl="$value"; break ;; 221 | esac 222 | done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" 223 | if [ "$MVNW_VERBOSE" = true ]; then 224 | echo "Downloading from: $jarUrl" 225 | fi 226 | wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" 227 | if $cygwin; then 228 | wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"` 229 | fi 230 | 231 | if command -v wget > /dev/null; then 232 | if [ "$MVNW_VERBOSE" = true ]; then 233 | echo "Found wget ... using wget" 234 | fi 235 | if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then 236 | wget "$jarUrl" -O "$wrapperJarPath" 237 | else 238 | wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" 239 | fi 240 | elif command -v curl > /dev/null; then 241 | if [ "$MVNW_VERBOSE" = true ]; then 242 | echo "Found curl ... using curl" 243 | fi 244 | if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then 245 | curl -o "$wrapperJarPath" "$jarUrl" -f 246 | else 247 | curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f 248 | fi 249 | 250 | else 251 | if [ "$MVNW_VERBOSE" = true ]; then 252 | echo "Falling back to using Java to download" 253 | fi 254 | javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" 255 | # For Cygwin, switch paths to Windows format before running javac 256 | if $cygwin; then 257 | javaClass=`cygpath --path --windows "$javaClass"` 258 | fi 259 | if [ -e "$javaClass" ]; then 260 | if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then 261 | if [ "$MVNW_VERBOSE" = true ]; then 262 | echo " - Compiling MavenWrapperDownloader.java ..." 263 | fi 264 | # Compiling the Java class 265 | ("$JAVA_HOME/bin/javac" "$javaClass") 266 | fi 267 | if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then 268 | # Running the downloader 269 | if [ "$MVNW_VERBOSE" = true ]; then 270 | echo " - Running MavenWrapperDownloader.java ..." 271 | fi 272 | ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") 273 | fi 274 | fi 275 | fi 276 | fi 277 | ########################################################################################## 278 | # End of extension 279 | ########################################################################################## 280 | 281 | export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} 282 | if [ "$MVNW_VERBOSE" = true ]; then 283 | echo $MAVEN_PROJECTBASEDIR 284 | fi 285 | MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" 286 | 287 | # For Cygwin, switch paths to Windows format before running java 288 | if $cygwin; then 289 | [ -n "$M2_HOME" ] && 290 | M2_HOME=`cygpath --path --windows "$M2_HOME"` 291 | [ -n "$JAVA_HOME" ] && 292 | JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` 293 | [ -n "$CLASSPATH" ] && 294 | CLASSPATH=`cygpath --path --windows "$CLASSPATH"` 295 | [ -n "$MAVEN_PROJECTBASEDIR" ] && 296 | MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` 297 | fi 298 | 299 | # Provide a "standardized" way to retrieve the CLI args that will 300 | # work with both Windows and non-Windows executions. 301 | MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" 302 | export MAVEN_CMD_LINE_ARGS 303 | 304 | WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain 305 | 306 | exec "$JAVACMD" \ 307 | $MAVEN_OPTS \ 308 | -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ 309 | "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ 310 | ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" 311 | --------------------------------------------------------------------------------