diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..eb6a038 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,59 @@ +version: 2 +updates: + - package-ecosystem: maven + directories: + - "/appium-maven" + - "/jdi-light-testng" + - "/playwright" + - "/selenium-maven" + - "/standalone-from-folder-maven" + schedule: + interval: weekly + groups: + maven-minor-patch: + patterns: + - "*" + update-types: + - minor + - patch + maven-major: + patterns: + - "*" + update-types: + - major + maven-security: + applies-to: security-updates + patterns: + - "*" + + - package-ecosystem: gradle + directories: + - "/allure-junit5-gradle-kts" + - "/selenide-gradle" + schedule: + interval: weekly + groups: + gradle-minor-patch: + patterns: + - "*" + update-types: + - minor + - patch + gradle-major: + patterns: + - "*" + update-types: + - major + gradle-security: + applies-to: security-updates + patterns: + - "*" + + - package-ecosystem: github-actions + directory: "/" + schedule: + interval: weekly + groups: + github-actions: + patterns: + - "*" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..64b63b7 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,49 @@ +name: CI + +on: + push: + branches: [master] + pull_request: + +permissions: + contents: read + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + maven: + name: ${{ matrix.example }} + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + example: [appium-maven, jdi-light-testng, playwright, selenium-maven, standalone-from-folder-maven] + steps: + - uses: actions/checkout@v7 + - uses: actions/setup-java@v6 + with: + distribution: temurin + java-version: 17 + cache: maven + cache-dependency-path: ${{ matrix.example }}/pom.xml + - run: mvn -B test-compile + working-directory: ${{ matrix.example }} + + gradle: + name: ${{ matrix.example }} + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + example: [allure-junit5-gradle-kts, selenide-gradle] + steps: + - uses: actions/checkout@v7 + - uses: actions/setup-java@v6 + with: + distribution: temurin + java-version: 17 + - uses: gradle/actions/setup-gradle@v6 + - run: ./gradlew testClasses + working-directory: ${{ matrix.example }} diff --git a/README.md b/README.md index 65a6009..d05edae 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,18 @@ -# List of examples -* [Playwright](https://github.com/Visual-Regression-Tracker/examples-java/blob/master/playwright) -* [Selenium + Maven + JUnit4](https://github.com/Visual-Regression-Tracker/examples-java/blob/master/selenium-maven) -* [Selenide + Gradle + TestNg](https://github.com/Visual-Regression-Tracker/examples-java/blob/master/selenide-gradle) -* [Allure + screen-diff-plugin + Gradle + JUnit5](https://github.com/Visual-Regression-Tracker/examples-java/blob/master/allure-junit5-gradle-kts) -* [Standalone Java read from folder + Maven](https://github.com/Visual-Regression-Tracker/examples-java/blob/master/standalone-from-folder-maven) -* [JDI Light + TestNg](https://github.com/Visual-Regression-Tracker/examples-java/blob/master/jdi-light-testng) -* [Appium + maven](https://github.com/Visual-Regression-Tracker/examples-java/tree/master/appium-maven) \ No newline at end of file +# Visual Regression Tracker examples for Java + +Each folder is a separate project on [sdk-java](https://github.com/Visual-Regression-Tracker/sdk-java) 5.5.0 from JitPack (Java 17): + +- [Playwright + Maven + JUnit 4](playwright) +- [Selenium 4 + Maven + JUnit 4](selenium-maven) +- [Selenide + Gradle + TestNG](selenide-gradle) +- [Allure + Selenide + Gradle (Kotlin DSL) + JUnit 5](allure-junit5-gradle-kts) +- [Standalone Java: compare PNG and PDF files from a folder + Maven](standalone-from-folder-maven) +- [JDI Light + TestNG + Maven](jdi-light-testng) +- [Appium (iOS) + TestNG + Maven](appium-maven) + +The browser examples open https://the-internet.herokuapp.com headless. They connect to +`http://localhost:4200` with the default API key and project of a fresh +[Visual Regression Tracker](https://github.com/Visual-Regression-Tracker/Visual-Regression-Tracker) +install; change that in each example's `VisualRegressionTrackerConfig`. + +Run a Maven example with `mvn test`, a Gradle one with `./gradlew test`. diff --git a/allure-junit5-gradle-kts/.gitignore b/allure-junit5-gradle-kts/.gitignore index a1458a4..be9f372 100644 --- a/allure-junit5-gradle-kts/.gitignore +++ b/allure-junit5-gradle-kts/.gitignore @@ -1,95 +1,3 @@ -/.allure -# Gradle -# ------ -.gradle -/build -/buildSrc/build -/buildSrc/subprojects/*/build -/subprojects/*/build -/subprojects/docs/src/samples/**/build -/subprojects/docs/src/snippets/**/build -/subprojects/internal-android-performance-testing/build-android-libs - -# IDEA -# ---- -!/.idea -/.idea/* -!/.idea/codeStyles -!/.idea/inspectionProfiles -!/.idea/icon.png -!/.idea/icon_dark.png -*/**/.idea -.shelf -/*.iml -/*.ipr -/*.iws -/buildSrc/.idea -/buildSrc/.shelf -/buildSrc/*.iml -/buildSrc/*.ipr -/buildSrc/*.iws -/buildSrc/out -/buildSrc/subprojects/*/*.iml -/buildSrc/subprojects/*/out -/out -/subprojects/*/*.iml -/subprojects/*/out -/.teamcity/*.iml -/.teamcity/target - -# Eclipse -# ------- -*.classpath -*.project -*.settings -/bin -/subprojects/*/bin -atlassian-ide-plugin.xml -.metadata/ - -# NetBeans -# -------- -.nb-gradle -.nb-gradle-properties - -# Vim -# --- -*.sw[nop] - -# Emacs -# ----- -*~ -\#*\# -.\#* - -# Textmate -# -------- -.textmate - -# Sublime Text -# ------------ -*.sublime-* - -# jEnv -# ---- -.java-version - -# macOS -# ---- -.DS_Store - -# HPROF -# ----- -*.hprof - -# Work dirs -# --------- -/incoming-distributions -/intTestHomeDir - -# Logs -# ---- -/*.log - -# oh-my-zsh gradle plugin -.gradletasknamecache +.gradle/ +build/ +.allure/ diff --git a/allure-junit5-gradle-kts/build.gradle.kts b/allure-junit5-gradle-kts/build.gradle.kts index dcf0858..74fc513 100644 --- a/allure-junit5-gradle-kts/build.gradle.kts +++ b/allure-junit5-gradle-kts/build.gradle.kts @@ -1,68 +1,26 @@ -import io.qameta.allure.gradle.AllureExtension - plugins { java - maven - id("io.qameta.allure") version "2.8.1" -} - -group "io.qameta.allure.examples" -version 1.3 - -val seleniumVersion = "3.141.59" -val allureVersion = "2.13.6" -val junit5Version = "5.6.2" - -tasks.withType(JavaCompile::class) { - sourceCompatibility = "${JavaVersion.VERSION_1_8}" - targetCompatibility = "${JavaVersion.VERSION_1_8}" -} - -tasks { - compileJava { - options.encoding = "UTF-8" - } - compileTestJava { - options.encoding = "UTF-8" - } -} - -configure { - autoconfigure = true - aspectjweaver = true - version = allureVersion - - clean = true - - useJUnit5 { - version = allureVersion - } -} - -tasks.withType(Test::class) { - ignoreFailures = true - useJUnitPlatform { - - } - - systemProperty("junit.jupiter.execution.parallel.enabled", "true") - systemProperty("junit.jupiter.execution.parallel.config.strategy", "dynamic") - systemProperty("junit.jupiter.extensions.autodetection.enabled", "true") + id("io.qameta.allure") version "4.3.0" } repositories { mavenCentral() - mavenLocal() maven(url = "https://jitpack.io") } +tasks.withType().configureEach { + options.release = 17 +} + dependencies { - testImplementation("com.github.visual-regression-tracker:sdk-java:4.5.1") - testImplementation("com.codeborne:selenide:5.14.0") - testImplementation("org.seleniumhq.selenium:selenium-java:$seleniumVersion") - testImplementation("io.qameta.allure:allure-java-commons:$allureVersion") + testImplementation("com.github.Visual-Regression-Tracker:sdk-java:5.5.0") + testImplementation("com.codeborne:selenide:7.19.1") + testImplementation(platform("org.junit:junit-bom:6.1.3")) + testImplementation("org.junit.jupiter:junit-jupiter") + testRuntimeOnly("org.junit.platform:junit-platform-launcher") +} - testImplementation("org.junit.jupiter:junit-jupiter-api:$junit5Version") - testImplementation("org.junit.jupiter:junit-jupiter-engine:$junit5Version") - testImplementation("org.junit.jupiter:junit-jupiter-params:$junit5Version") +tasks.test { + useJUnitPlatform() + ignoreFailures = true } diff --git a/allure-junit5-gradle-kts/gradle/wrapper/gradle-wrapper.jar b/allure-junit5-gradle-kts/gradle/wrapper/gradle-wrapper.jar index 62d4c05..9fa7f28 100644 Binary files a/allure-junit5-gradle-kts/gradle/wrapper/gradle-wrapper.jar and b/allure-junit5-gradle-kts/gradle/wrapper/gradle-wrapper.jar differ diff --git a/allure-junit5-gradle-kts/gradle/wrapper/gradle-wrapper.properties b/allure-junit5-gradle-kts/gradle/wrapper/gradle-wrapper.properties index 622ab64..91c4fc6 100644 --- a/allure-junit5-gradle-kts/gradle/wrapper/gradle-wrapper.properties +++ b/allure-junit5-gradle-kts/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,9 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-9.8.2-bin.zip +networkTimeout=10000 +retries=0 +retryBackOffMs=500 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/allure-junit5-gradle-kts/gradlew b/allure-junit5-gradle-kts/gradlew index fbd7c51..249efbb 100755 --- a/allure-junit5-gradle-kts/gradlew +++ b/allure-junit5-gradle-kts/gradlew @@ -1,7 +1,7 @@ -#!/usr/bin/env sh +#!/bin/sh # -# Copyright 2015 the original author or authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,81 +15,114 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## -## -## Gradle start up script for UN*X -## +# +# gradlew start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh gradlew +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# ############################################################################## # Attempt to set APP_HOME + # Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" +MAX_FD=maximum warn () { echo "$*" -} +} >&2 die () { echo echo "$*" echo exit 1 -} +} >&2 # OS specific support (must be 'true' or 'false'). cygwin=false msys=false darwin=false nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar # Determine the Java command to use to start the JVM. if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" + JAVACMD=$JAVA_HOME/jre/sh/java else - JAVACMD="$JAVA_HOME/bin/java" + JAVACMD=$JAVA_HOME/bin/java fi if [ ! -x "$JAVACMD" ] ; then die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME @@ -98,88 +131,118 @@ Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + JAVACMD=java + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." + fi fi # Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac fi -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. # For Cygwin or MSYS, switch paths to Windows format before running java -if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) fi - i=`expr $i + 1` + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg done - case $i in - 0) set -- ;; - 1) set -- "$args0" ;; - 2) set -- "$args0" "$args1" ;; - 3) set -- "$args0" "$args1" "$args2" ;; - 4) set -- "$args0" "$args1" "$args2" "$args3" ;; - 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac fi -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=`save "$@"` -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' exec "$JAVACMD" "$@" diff --git a/allure-junit5-gradle-kts/gradlew.bat b/allure-junit5-gradle-kts/gradlew.bat index 5093609..03754c4 100755 --- a/allure-junit5-gradle-kts/gradlew.bat +++ b/allure-junit5-gradle-kts/gradlew.bat @@ -1,104 +1,112 @@ -@rem -@rem Copyright 2015 the original author or authors. -@rem -@rem Licensed under the Apache License, Version 2.0 (the "License"); -@rem you may not use this file except in compliance with the License. -@rem You may obtain a copy of the License at -@rem -@rem https://www.apache.org/licenses/LICENSE-2.0 -@rem -@rem Unless required by applicable law or agreed to in writing, software -@rem distributed under the License is distributed on an "AS IS" BASIS, -@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@rem See the License for the specific language governing permissions and -@rem limitations under the License. -@rem - -@if "%DEBUG%" == "" @echo off -@rem ########################################################################## -@rem -@rem Gradle startup script for Windows -@rem -@rem ########################################################################## - -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal - -set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. -set APP_BASE_NAME=%~n0 -set APP_HOME=%DIRNAME% - -@rem Resolve any "." and ".." in APP_HOME to make it shorter. -for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi - -@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" - -@rem Find java.exe -if defined JAVA_HOME goto findJavaFromJavaHome - -set JAVA_EXE=java.exe -%JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init - -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:findJavaFromJavaHome -set JAVA_HOME=%JAVA_HOME:"=% -set JAVA_EXE=%JAVA_HOME%/bin/java.exe - -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windows variants - -if not "%OS%" == "Windows_NT" goto win9xME_args - -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* - -:execute -@rem Setup the command line - -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd - -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 - -:mainEnd -if "%OS%"=="Windows_NT" endlocal - -:omega +@rem +@rem Copyright 2015 the original author or authors. +@rem +@rem Licensed under the Apache License, Version 2.0 (the "License"); +@rem you may not use this file except in compliance with the License. +@rem You may obtain a copy of the License at +@rem +@rem https://www.apache.org/licenses/LICENSE-2.0 +@rem +@rem Unless required by applicable law or agreed to in writing, software +@rem distributed under the License is distributed on an "AS IS" BASIS, +@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +@rem See the License for the specific language governing permissions and +@rem limitations under the License. +@rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem + +@if "%DEBUG%"=="" @echo off +@rem ########################################################################## +@rem +@rem gradlew startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions + +@rem Catch executions from older scripts and ensure they exit cleanly. +@rem This can be removed once we can be reasonably confident that few people +@rem will be migrating directly to this new wrapper. +goto afterSafetyNet +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +goto exitWithErrorLevel +:afterSafetyNet + +set DIRNAME=%~dp0 +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if %ERRORLEVEL% equ 0 goto execute + +1>&2 echo. +1>&2 echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +1>&2 echo. +1>&2 echo Please set the JAVA_HOME variable in your environment to match the +1>&2 echo location of your Java installation. + +"%COMSPEC%" /c exit 1 +goto exitWithErrorLevel + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto execute + +1>&2 echo. +1>&2 echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +1>&2 echo. +1>&2 echo Please set the JAVA_HOME variable in your environment to match the +1>&2 echo location of your Java installation. + +"%COMSPEC%" /c exit 1 +goto exitWithErrorLevel + +:execute +@rem Setup the command line + + + +@rem Execute gradlew +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel & goto exitWithErrorLevel + +@rem This label must not be changed. We rely on old scripts being able to jump to this point. +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/allure-junit5-gradle-kts/settings.gradle.kts b/allure-junit5-gradle-kts/settings.gradle.kts new file mode 100644 index 0000000..e63bc8b --- /dev/null +++ b/allure-junit5-gradle-kts/settings.gradle.kts @@ -0,0 +1 @@ +rootProject.name = "allure-junit5-gradle-kts" diff --git a/allure-junit5-gradle-kts/src/test/java/io/qameta/allure/examples/junit5/AllureImageDiffTest.java b/allure-junit5-gradle-kts/src/test/java/io/qameta/allure/examples/junit5/AllureImageDiffTest.java index ea22b64..4dfb1ce 100644 --- a/allure-junit5-gradle-kts/src/test/java/io/qameta/allure/examples/junit5/AllureImageDiffTest.java +++ b/allure-junit5-gradle-kts/src/test/java/io/qameta/allure/examples/junit5/AllureImageDiffTest.java @@ -2,8 +2,6 @@ import com.codeborne.selenide.Configuration; import com.codeborne.selenide.Selenide; -import com.codeborne.selenide.WebDriverRunner; -import io.github.bonigarcia.wdm.WebDriverManager; import io.qameta.allure.Allure; import io.qameta.allure.Attachment; import io.qameta.allure.Step; @@ -16,78 +14,64 @@ import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import org.openqa.selenium.OutputType; -import org.openqa.selenium.TakesScreenshot; -import javax.imageio.ImageIO; -import java.awt.image.BufferedImage; -import java.io.ByteArrayOutputStream; import java.io.IOException; -import java.net.URL; +import java.io.InputStream; +import java.net.URI; -import static org.junit.jupiter.api.Assertions.assertSame; +import static org.junit.jupiter.api.Assertions.assertEquals; public class AllureImageDiffTest { static VisualRegressionTrackerConfig config = VisualRegressionTrackerConfig.builder() .apiUrl("http://localhost:4200") - .apiKey("0TK0P0NQP6MNFQQPTYYBN27JRAA5") + .apiKey("DEFAULTUSERAPIKEYTOBECHANGED") .project("Default project") .branchName("master") .enableSoftAssert(true) - .ciBuildId("some build id") .build(); static VisualRegressionTracker vrt = new VisualRegressionTracker(config); @BeforeAll - static void setUp() throws IOException { - WebDriverManager.chromedriver().setup(); - Configuration.baseUrl = "http://automationpractice.com/index.php"; + static void setUp() throws IOException, InterruptedException { + Configuration.baseUrl = "https://the-internet.herokuapp.com"; Configuration.browser = "chrome"; - Configuration.browserSize = "1240x1024"; + Configuration.browserSize = "1280x1024"; + Configuration.headless = true; vrt.start(); } @AfterAll - static void tearDown() throws IOException { - WebDriverRunner.closeWebDriver(); + static void tearDown() throws IOException, InterruptedException { + Selenide.closeWebDriver(); vrt.stop(); } @Step @Attachment(value = "{filename}", type = "image/png") public static byte[] attachScreenshotToAllureReport(String href, String filename) { - BufferedImage image; - byte[] imageInByte = new byte[0]; - - try { - URL url = new URL(href); - image = ImageIO.read(url); - - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - ImageIO.write(image, "png", baos); - baos.flush(); - imageInByte = baos.toByteArray(); - baos.close(); + if (href == null) { + return new byte[0]; + } + try (InputStream image = URI.create(href).toURL().openStream()) { + return image.readAllBytes(); } catch (IOException e) { - System.out.println(e.getMessage()); + return new byte[0]; } - return imageInByte; } @Test @DisplayName("imageDiffExample displayName") - public void imageDiffExample() throws IOException { + public void imageDiffExample() throws IOException, InterruptedException { Selenide.open("/"); - TestRunResult result = vrt.track( - "Home page", - ((TakesScreenshot) WebDriverRunner.getWebDriver()).getScreenshotAs(OutputType.BASE64)); + TestRunResult result = vrt.track("Home page", Selenide.screenshot(OutputType.BASE64)); Allure.label("testType", "screenshotDiff"); attachScreenshotToAllureReport(result.getImageUrl(), "actual"); attachScreenshotToAllureReport(result.getBaselineUrl(), "expected"); attachScreenshotToAllureReport(result.getDiffUrl(), "diff"); - assertSame(result.getTestRunResponse().getStatus(), TestRunStatus.OK); + assertEquals(TestRunStatus.OK, result.getTestRunResponse().getStatus()); } } diff --git a/appium-maven/pom.xml b/appium-maven/pom.xml index acccdd9..9854cd5 100644 --- a/appium-maven/pom.xml +++ b/appium-maven/pom.xml @@ -9,8 +9,8 @@ 1.0-SNAPSHOT - 11 - 11 + 17 + UTF-8 @@ -25,21 +25,42 @@ com.github.Visual-Regression-Tracker sdk-java - 5.1.0 + 5.5.0 io.appium java-client - 7.5.1 + 11.0.0 + + + + org.seleniumhq.selenium + selenium-support + 4.52.0 org.testng testng - 6.14.3 + 7.12.0 test + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.15.0 + + + org.apache.maven.plugins + maven-surefire-plugin + 3.6.1 + + + diff --git a/appium-maven/src/test/java/IOSBasicInteractionsTest.java b/appium-maven/src/test/java/IOSBasicInteractionsTest.java index 13c7ce3..b1ee65f 100644 --- a/appium-maven/src/test/java/IOSBasicInteractionsTest.java +++ b/appium-maven/src/test/java/IOSBasicInteractionsTest.java @@ -1,11 +1,10 @@ -import io.appium.java_client.MobileBy; +import io.appium.java_client.AppiumBy; import io.appium.java_client.ios.IOSDriver; -import io.appium.java_client.ios.IOSElement; +import io.appium.java_client.ios.options.XCUITestOptions; import io.visual_regression_tracker.sdk_java.*; +import org.openqa.selenium.By; import org.openqa.selenium.OutputType; -import org.openqa.selenium.TakesScreenshot; import org.openqa.selenium.WebElement; -import org.openqa.selenium.remote.DesiredCapabilities; import org.openqa.selenium.support.ui.ExpectedConditions; import org.openqa.selenium.support.ui.WebDriverWait; import org.testng.annotations.AfterTest; @@ -14,31 +13,30 @@ import org.testng.annotations.Test; import java.io.IOException; +import java.time.Duration; import java.util.Objects; public class IOSBasicInteractionsTest extends BaseTest { String platformName = "iOS"; String deviceName = "iPhone 12"; String platformVersion = "14.5"; - private IOSDriver driver; + private IOSDriver driver; private VisualRegressionTracker vrt; @BeforeTest public void setUp() throws IOException, InterruptedException { - DesiredCapabilities capabilities = new DesiredCapabilities(); - capabilities.setCapability("deviceName", deviceName); - capabilities.setCapability("platformName", platformName); - capabilities.setCapability("platformVersion", platformVersion); String appPath = Objects.requireNonNull(getClass().getClassLoader().getResource("App.zip")).getPath(); - capabilities.setCapability("app", appPath); - capabilities.setCapability("automationName", "XCUITest"); + XCUITestOptions options = new XCUITestOptions() + .setDeviceName(deviceName) + .setPlatformVersion(platformVersion) + .setApp(appPath); - driver = new IOSDriver<>(getServiceUrl(), capabilities); + driver = new IOSDriver(getServiceUrl(), options); VisualRegressionTrackerConfig vrtConfig = VisualRegressionTrackerConfig.builder() .apiUrl("http://localhost:4200") - .apiKey("11Q288KSQKMDJGMH3RVY9N7Y0FJ3") - .project("9cb1ff4d-5675-4c85-a41b-8e08dbf6d5f6") + .apiKey("DEFAULTUSERAPIKEYTOBECHANGED") + .project("Default project") .branchName("master") .enableSoftAssert(true) .build(); @@ -58,20 +56,20 @@ public void tearDown() throws IOException, InterruptedException { @DataProvider(name = "menu-buttons") public Object[][] getMenuButtons() { return new Object[][]{ - {"Home page", MobileBy.AccessibilityId("Home")}, - {"Web page", MobileBy.AccessibilityId("Webview")}, - {"Login page", MobileBy.iOSClassChain("**/XCUIElementTypeButton[`label == \"Login\"`]")}, - {"Forms page", MobileBy.AccessibilityId("Forms")}, - {"Swipe page", MobileBy.AccessibilityId("Swipe")}, - {"Drag page", MobileBy.AccessibilityId("Drag")}, + {"Home page", AppiumBy.accessibilityId("Home")}, + {"Web page", AppiumBy.accessibilityId("Webview")}, + {"Login page", AppiumBy.iOSClassChain("**/XCUIElementTypeButton[`label == \"Login\"`]")}, + {"Forms page", AppiumBy.accessibilityId("Forms")}, + {"Swipe page", AppiumBy.accessibilityId("Swipe")}, + {"Drag page", AppiumBy.accessibilityId("Drag")}, }; } @Test(dataProvider = "menu-buttons") - public void shouldMatchScreenshot(String pageName, MobileBy locator) throws Exception { + public void shouldMatchScreenshot(String pageName, By locator) throws Exception { - IOSElement button = (IOSElement) new WebDriverWait(driver, 30) + WebElement button = new WebDriverWait(driver, Duration.ofSeconds(30)) .until(ExpectedConditions.visibilityOfElementLocated(locator)); button.click(); @@ -92,7 +90,7 @@ void vrtTrackWithRetry(String pageName, TestRunOptions testRunOptions, int maxRe try { result = vrt.track(pageName, - ((TakesScreenshot) driver).getScreenshotAs(OutputType.BASE64), + driver.getScreenshotAs(OutputType.BASE64), testRunOptions); } catch (Exception ex) { exception = ex; diff --git a/jdi-light-testng/pom.xml b/jdi-light-testng/pom.xml index 8fd595b..4b7427d 100644 --- a/jdi-light-testng/pom.xml +++ b/jdi-light-testng/pom.xml @@ -20,12 +20,11 @@ chrome UTF-8 - 1.9.5 - https://jdi-testing.github.io/jdi-light/ - 2.13.1 - 2.10.0 - 9.4.12.RC2 + 17 + 1.9.26 https://jdi-testing.github.io/jdi-light/ + 2.35.5 + 2.18.0 @@ -33,14 +32,14 @@ com.github.Visual-Regression-Tracker sdk-java - 5.0.0 + 5.5.0 com.epam.jdi jdi-light-html - 1.3.8 + 1.6.3 @@ -52,7 +51,7 @@ org.testng testng - 6.14.3 + 7.12.0 test @@ -62,22 +61,12 @@ org.apache.maven.plugins maven-compiler-plugin - 3.8.1 - - 1.8 - 1.8 - - - - - org.eclipse.jetty - jetty-maven-plugin - ${jetty.version} + 3.15.0 org.apache.maven.plugins maven-surefire-plugin - 2.22.2 + 3.6.1 ${project.build.directory}/allure-results @@ -102,9 +91,6 @@ io.qameta.allure allure-maven ${allure.maven} - - 2.4.1 - diff --git a/jdi-light-testng/src/main/java/org/mytests/uiobjects/example/entities/Contacts.java b/jdi-light-testng/src/main/java/org/mytests/uiobjects/example/entities/Contacts.java index 259cb2f..d5da1eb 100644 --- a/jdi-light-testng/src/main/java/org/mytests/uiobjects/example/entities/Contacts.java +++ b/jdi-light-testng/src/main/java/org/mytests/uiobjects/example/entities/Contacts.java @@ -1,6 +1,6 @@ package org.mytests.uiobjects.example.entities; -import com.epam.jdi.tools.DataClass; +import com.jdiai.tools.DataClass; public class Contacts extends DataClass { public String firstName, lastName, acceptConditions, position, passportNumber, diff --git a/jdi-light-testng/src/main/java/org/mytests/uiobjects/example/entities/MarvelUserInfo.java b/jdi-light-testng/src/main/java/org/mytests/uiobjects/example/entities/MarvelUserInfo.java index ae93b21..fa5ef43 100644 --- a/jdi-light-testng/src/main/java/org/mytests/uiobjects/example/entities/MarvelUserInfo.java +++ b/jdi-light-testng/src/main/java/org/mytests/uiobjects/example/entities/MarvelUserInfo.java @@ -1,6 +1,6 @@ package org.mytests.uiobjects.example.entities; -import com.epam.jdi.tools.DataClass; +import com.jdiai.tools.DataClass; public class MarvelUserInfo extends DataClass { public String number, type, user, description; diff --git a/jdi-light-testng/src/main/java/org/mytests/uiobjects/example/entities/User.java b/jdi-light-testng/src/main/java/org/mytests/uiobjects/example/entities/User.java index 157ee74..901f991 100644 --- a/jdi-light-testng/src/main/java/org/mytests/uiobjects/example/entities/User.java +++ b/jdi-light-testng/src/main/java/org/mytests/uiobjects/example/entities/User.java @@ -1,7 +1,7 @@ package org.mytests.uiobjects.example.entities; -import com.epam.jdi.tools.DataClass; +import com.jdiai.tools.DataClass; public class User extends DataClass { public String name = "Roman"; diff --git a/jdi-light-testng/src/main/java/org/mytests/uiobjects/example/site/custom/MultiDropdown.java b/jdi-light-testng/src/main/java/org/mytests/uiobjects/example/site/custom/MultiDropdown.java index 3af90ab..fd61e18 100644 --- a/jdi-light-testng/src/main/java/org/mytests/uiobjects/example/site/custom/MultiDropdown.java +++ b/jdi-light-testng/src/main/java/org/mytests/uiobjects/example/site/custom/MultiDropdown.java @@ -16,8 +16,8 @@ import static com.epam.jdi.light.elements.init.UIFactory.$; import static com.epam.jdi.light.elements.init.UIFactory.$$; import static com.epam.jdi.light.logger.LogLevels.DEBUG; -import static com.epam.jdi.tools.EnumUtils.getEnumValues; -import static com.epam.jdi.tools.LinqUtils.*; +import static com.jdiai.tools.EnumUtils.getEnumValues; +import static com.jdiai.tools.LinqUtils.*; import static java.util.Arrays.asList; import static org.apache.commons.lang3.StringUtils.isBlank; diff --git a/jdi-light-testng/src/main/java/org/mytests/uiobjects/example/site/sections/ContactForm.java b/jdi-light-testng/src/main/java/org/mytests/uiobjects/example/site/sections/ContactForm.java index 1ce81f1..0d2851a 100644 --- a/jdi-light-testng/src/main/java/org/mytests/uiobjects/example/site/sections/ContactForm.java +++ b/jdi-light-testng/src/main/java/org/mytests/uiobjects/example/site/sections/ContactForm.java @@ -10,7 +10,7 @@ import java.lang.reflect.Field; -import static com.epam.jdi.tools.ReflectionUtils.isInterface; +import static com.jdiai.tools.ReflectionUtils.isInterface; public class ContactForm extends Form { TextField firstName, lastName, position, passportNumber, passportSeria; diff --git a/jdi-light-testng/src/test/java/org/mytests/tests/example/DataTableInteractTests.java b/jdi-light-testng/src/test/java/org/mytests/tests/example/DataTableInteractTests.java index 5346cbb..cd9cb4e 100644 --- a/jdi-light-testng/src/test/java/org/mytests/tests/example/DataTableInteractTests.java +++ b/jdi-light-testng/src/test/java/org/mytests/tests/example/DataTableInteractTests.java @@ -19,10 +19,10 @@ public class DataTableInteractTests implements TestsInit { static VisualRegressionTracker vrt; static VisualRegressionTrackerConfig config = VisualRegressionTrackerConfig.builder() .apiUrl("http://localhost:4200") - .apiKey("5H90NFWM6BMWWDMWKG8T11DWW22Y") - .project("cb537710-9d84-4318-b450-2953c5d98361") + .apiKey("DEFAULTUSERAPIKEYTOBECHANGED") + .project("Default project") .branchName("master") - .enableSoftAssert(false) + .enableSoftAssert(true) .build(); @BeforeClass diff --git a/jdi-light-testng/src/test/java/org/mytests/tests/testng/RetryListenerClass.java b/jdi-light-testng/src/test/java/org/mytests/tests/testng/RetryListenerClass.java index 6f6e3ef..f209aee 100644 --- a/jdi-light-testng/src/test/java/org/mytests/tests/testng/RetryListenerClass.java +++ b/jdi-light-testng/src/test/java/org/mytests/tests/testng/RetryListenerClass.java @@ -1,7 +1,6 @@ package org.mytests.tests.testng; import org.testng.IAnnotationTransformer; -import org.testng.IRetryAnalyzer; import org.testng.annotations.ITestAnnotation; import java.lang.reflect.Constructor; @@ -10,11 +9,7 @@ public class RetryListenerClass implements IAnnotationTransformer { @Override - public void transform(ITestAnnotation testannotation, Class testClass, Constructor testConstructor, Method testMethod) { - IRetryAnalyzer retry = testannotation.getRetryAnalyzer(); - if (retry == null) { - testannotation.setRetryAnalyzer(RetryFailedTestCases.class); - } - + public void transform(ITestAnnotation testannotation, Class testClass, Constructor testConstructor, Method testMethod) { + testannotation.setRetryAnalyzer(RetryFailedTestCases.class); } } diff --git a/jdi-light-testng/src/test/java/org/mytests/tests/testng/TestNGListener.java b/jdi-light-testng/src/test/java/org/mytests/tests/testng/TestNGListener.java index 21f7580..74e508e 100644 --- a/jdi-light-testng/src/test/java/org/mytests/tests/testng/TestNGListener.java +++ b/jdi-light-testng/src/test/java/org/mytests/tests/testng/TestNGListener.java @@ -5,7 +5,7 @@ * Email: roman.iovlev.jdi@gmail.com; Skype: roman.iovlev */ -import com.epam.jdi.tools.Safe; +import com.jdiai.tools.Safe; import org.testng.IInvokedMethod; import org.testng.IInvokedMethodListener; import org.testng.ITestNGMethod; @@ -18,7 +18,7 @@ import static com.epam.jdi.light.driver.ScreenshotMaker.takeScreen; import static com.epam.jdi.light.settings.WebSettings.TEST_NAME; import static com.epam.jdi.light.settings.WebSettings.logger; -import static com.epam.jdi.tools.LinqUtils.last; +import static com.jdiai.tools.LinqUtils.last; import static java.lang.System.currentTimeMillis; public class TestNGListener implements IInvokedMethodListener { private Safe start = new Safe<>(0L); diff --git a/jdi-light-testng/src/test/resources/test.properties b/jdi-light-testng/src/test/resources/test.properties index 9a35a6b..5fe324f 100644 --- a/jdi-light-testng/src/test/resources/test.properties +++ b/jdi-light-testng/src/test/resources/test.properties @@ -23,7 +23,7 @@ log.info.details=element #demo.delay=2 #remote.type=sauce | browserstack #driver.remote.url=http://localhost:4444/wd/hub -#headless=true | false +headless=true screenshot.strategy=on failure #element.highlight=off | on failure | on assert | on action | flow #screenshot.strategy=off | on failure | on assert | new page | flow diff --git a/playwright/pom.xml b/playwright/pom.xml index 9be8fbc..1d1516e 100644 --- a/playwright/pom.xml +++ b/playwright/pom.xml @@ -7,18 +7,11 @@ org.example playwright 1.0-SNAPSHOT - - - - org.apache.maven.plugins - maven-compiler-plugin - - 8 - 8 - - - - + + + 17 + UTF-8 + @@ -31,23 +24,33 @@ com.github.Visual-Regression-Tracker sdk-java - 4.5.2 + 5.5.0 com.microsoft.playwright playwright - 0.170.0 - - - com.microsoft.playwright - driver-bundle - 0.170.0 + 1.64.0 junit junit - 4.13.1 + 4.13.2 test - \ No newline at end of file + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.15.0 + + + org.apache.maven.plugins + maven-surefire-plugin + 3.6.1 + + + + diff --git a/playwright/src/test/java/PlaywrightExample.java b/playwright/src/test/java/PlaywrightExampleTest.java similarity index 61% rename from playwright/src/test/java/PlaywrightExample.java rename to playwright/src/test/java/PlaywrightExampleTest.java index afe042a..4d7b789 100644 --- a/playwright/src/test/java/PlaywrightExample.java +++ b/playwright/src/test/java/PlaywrightExampleTest.java @@ -1,5 +1,4 @@ import com.microsoft.playwright.Browser; -import com.microsoft.playwright.BrowserType; import com.microsoft.playwright.Page; import com.microsoft.playwright.Playwright; import io.visual_regression_tracker.sdk_java.IgnoreAreas; @@ -12,13 +11,13 @@ import java.io.IOException; import java.util.Base64; -import java.util.Collections; +import java.util.List; -public class PlaywrightExample { +public class PlaywrightExampleTest { static VisualRegressionTracker vrt = new VisualRegressionTracker( VisualRegressionTrackerConfig.builder() .apiUrl("http://localhost:4200") - .apiKey("0TK0P0NQP6MNFQQPTYYBN27JRAA5") + .apiKey("DEFAULTUSERAPIKEYTOBECHANGED") .project("Default project") .branchName("master") .enableSoftAssert(true) @@ -28,49 +27,43 @@ public class PlaywrightExample { static Page page; @BeforeClass - public static void setUp() throws IOException { + public static void setUp() throws IOException, InterruptedException { playwright = Playwright.create(); - browser = playwright.chromium().launch( - new BrowserType.LaunchOptions().withHeadless(false) - ); - page = browser.newContext( - new Browser.NewContextOptions().withViewport(800, 600) - ).newPage(); + browser = playwright.chromium().launch(); + page = browser.newPage(new Browser.NewPageOptions().setViewportSize(800, 600)); vrt.start(); } @AfterClass - public static void tearDown() throws Exception { - browser.close(); + public static void tearDown() throws IOException, InterruptedException { playwright.close(); vrt.stop(); } @Test - public void example() throws IOException { - page.navigate("http://automationpractice.com/index.php"); + public void example() throws IOException, InterruptedException { + page.navigate("https://the-internet.herokuapp.com/"); vrt.track("Home page", Base64.getEncoder().encodeToString(page.screenshot())); - page.click(".product-container a img"); + page.locator("a[href='/checkboxes']").click(); vrt.track( - "Product page", + "Checkboxes page", Base64.getEncoder().encodeToString(page.screenshot()), TestRunOptions.builder() - .device("Macbook Pro") - .os("macOS Catalina") - .browser("Chrome") - .viewport("1240x1024") + .device("PC") + .os(System.getProperty("os.name")) + .browser("Chromium") + .viewport("800x600") .diffTollerancePercent(0.0f) - .ignoreAreas(Collections.singletonList( + .ignoreAreas(List.of( IgnoreAreas.builder() .x(10L) .y(10L) .width(100L) .height(200L) - .build() - )) + .build())) .build()); } } diff --git a/selenide-gradle/.gitignore b/selenide-gradle/.gitignore index eed4ca4..67bcc2f 100644 --- a/selenide-gradle/.gitignore +++ b/selenide-gradle/.gitignore @@ -1,94 +1,2 @@ -# Gradle -# ------ -.gradle -/build -/buildSrc/build -/buildSrc/subprojects/*/build -/subprojects/*/build -/subprojects/docs/src/samples/**/build -/subprojects/docs/src/snippets/**/build -/subprojects/internal-android-performance-testing/build-android-libs - -# IDEA -# ---- -!/.idea -/.idea/* -!/.idea/codeStyles -!/.idea/inspectionProfiles -!/.idea/icon.png -!/.idea/icon_dark.png -*/**/.idea -.shelf -/*.iml -/*.ipr -/*.iws -/buildSrc/.idea -/buildSrc/.shelf -/buildSrc/*.iml -/buildSrc/*.ipr -/buildSrc/*.iws -/buildSrc/out -/buildSrc/subprojects/*/*.iml -/buildSrc/subprojects/*/out -/out -/subprojects/*/*.iml -/subprojects/*/out -/.teamcity/*.iml -/.teamcity/target - -# Eclipse -# ------- -*.classpath -*.project -*.settings -/bin -/subprojects/*/bin -atlassian-ide-plugin.xml -.metadata/ - -# NetBeans -# -------- -.nb-gradle -.nb-gradle-properties - -# Vim -# --- -*.sw[nop] - -# Emacs -# ----- -*~ -\#*\# -.\#* - -# Textmate -# -------- -.textmate - -# Sublime Text -# ------------ -*.sublime-* - -# jEnv -# ---- -.java-version - -# macOS -# ---- -.DS_Store - -# HPROF -# ----- -*.hprof - -# Work dirs -# --------- -/incoming-distributions -/intTestHomeDir - -# Logs -# ---- -/*.log - -# oh-my-zsh gradle plugin -.gradletasknamecache \ No newline at end of file +.gradle/ +build/ diff --git a/selenide-gradle/build.gradle b/selenide-gradle/build.gradle index 836c17a..beb01fa 100644 --- a/selenide-gradle/build.gradle +++ b/selenide-gradle/build.gradle @@ -2,21 +2,21 @@ plugins { id 'java' } -group 'org.example' -version '1.0-SNAPSHOT' - repositories { mavenCentral() - maven { url 'https://jitpack.io' } + maven { url = 'https://jitpack.io' } +} + +tasks.withType(JavaCompile).configureEach { + options.release = 17 } dependencies { - implementation group: 'com.github.visual-regression-tracker', name: 'sdk-java', version: '4.5.2' - implementation group: 'com.codeborne', name: 'selenide', version: '5.14.0' - implementation 'org.testng:testng:7.3.0' - compile group: 'com.google.guava', name: 'guava', version: '29.0-jre' + testImplementation 'com.github.Visual-Regression-Tracker:sdk-java:5.5.0' + testImplementation 'com.codeborne:selenide:7.19.1' + testImplementation 'org.testng:testng:7.12.0' } test { useTestNG() -} \ No newline at end of file +} diff --git a/selenide-gradle/gradle/wrapper/gradle-wrapper.jar b/selenide-gradle/gradle/wrapper/gradle-wrapper.jar index f3d88b1..9fa7f28 100644 Binary files a/selenide-gradle/gradle/wrapper/gradle-wrapper.jar and b/selenide-gradle/gradle/wrapper/gradle-wrapper.jar differ diff --git a/selenide-gradle/gradle/wrapper/gradle-wrapper.properties b/selenide-gradle/gradle/wrapper/gradle-wrapper.properties index df97a2e..91c4fc6 100644 --- a/selenide-gradle/gradle/wrapper/gradle-wrapper.properties +++ b/selenide-gradle/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,9 @@ -#Sun May 10 09:52:26 CEST 2020 -distributionUrl=https\://services.gradle.org/distributions/gradle-6.1-all.zip distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-9.8.2-bin.zip +networkTimeout=10000 +retries=0 +retryBackOffMs=500 +validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists diff --git a/selenide-gradle/gradlew b/selenide-gradle/gradlew index 2fe81a7..249efbb 100755 --- a/selenide-gradle/gradlew +++ b/selenide-gradle/gradlew @@ -1,7 +1,7 @@ -#!/usr/bin/env sh +#!/bin/sh # -# Copyright 2015 the original author or authors. +# Copyright © 2015 the original authors. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -15,80 +15,114 @@ # See the License for the specific language governing permissions and # limitations under the License. # +# SPDX-License-Identifier: Apache-2.0 +# ############################################################################## -## -## Gradle start up script for UN*X -## +# +# gradlew start up script for POSIX generated by Gradle. +# +# Important for running: +# +# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is +# noncompliant, but you have some other compliant shell such as ksh or +# bash, then to run this script, type that shell name before the whole +# command line, like: +# +# ksh gradlew +# +# Busybox and similar reduced shells will NOT work, because this script +# requires all of these POSIX shell features: +# * functions; +# * expansions «$var», «${var}», «${var:-default}», «${var+SET}», +# «${var#prefix}», «${var%suffix}», and «$( cmd )»; +# * compound commands having a testable exit status, especially «case»; +# * various built-in commands including «command», «set», and «ulimit». +# +# Important for patching: +# +# (2) This script targets any POSIX shell, so it avoids extensions provided +# by Bash, Ksh, etc; in particular arrays are avoided. +# +# The "traditional" practice of packing multiple parameters into a +# space-separated string is a well documented source of bugs and security +# problems, so this is (mostly) avoided, by progressively accumulating +# options in "$@", and eventually passing that to Java. +# +# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, +# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; +# see the in-line comments for details. +# +# There are tweaks for specific operating systems such as AIX, CygWin, +# Darwin, MinGW, and NonStop. +# +# (3) This script is generated from the Groovy template +# https://github.com/gradle/gradle/blob/3d91ce3b8caaf77ad09f381f43615b715b53f72c/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt +# within the Gradle project. +# +# You can find Gradle at https://github.com/gradle/gradle/. +# ############################################################################## # Attempt to set APP_HOME + # Resolve links: $0 may be a link -PRG="$0" -# Need this for relative symlinks. -while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG=`dirname "$PRG"`"/$link" - fi +app_path=$0 + +# Need this for daisy-chained symlinks. +while + APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path + [ -h "$app_path" ] +do + ls=$( ls -ld "$app_path" ) + link=${ls#*' -> '} + case $link in #( + /*) app_path=$link ;; #( + *) app_path=$APP_HOME$link ;; + esac done -SAVED="`pwd`" -cd "`dirname \"$PRG\"`/" >/dev/null -APP_HOME="`pwd -P`" -cd "$SAVED" >/dev/null -APP_NAME="Gradle" -APP_BASE_NAME=`basename "$0"` - -# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. -DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' +# This is normally unused +# shellcheck disable=SC2034 +APP_BASE_NAME=${0##*/} +# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. -MAX_FD="maximum" +MAX_FD=maximum warn () { echo "$*" -} +} >&2 die () { echo echo "$*" echo exit 1 -} +} >&2 # OS specific support (must be 'true' or 'false'). cygwin=false msys=false darwin=false nonstop=false -case "`uname`" in - CYGWIN* ) - cygwin=true - ;; - Darwin* ) - darwin=true - ;; - MINGW* ) - msys=true - ;; - NONSTOP* ) - nonstop=true - ;; +case "$( uname )" in #( + CYGWIN* ) cygwin=true ;; #( + Darwin* ) darwin=true ;; #( + MSYS* | MINGW* ) msys=true ;; #( + NONSTOP* ) nonstop=true ;; esac -CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + # Determine the Java command to use to start the JVM. if [ -n "$JAVA_HOME" ] ; then if [ -x "$JAVA_HOME/jre/sh/java" ] ; then # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" + JAVACMD=$JAVA_HOME/jre/sh/java else - JAVACMD="$JAVA_HOME/bin/java" + JAVACMD=$JAVA_HOME/bin/java fi if [ ! -x "$JAVACMD" ] ; then die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME @@ -97,87 +131,118 @@ Please set the JAVA_HOME variable in your environment to match the location of your Java installation." fi else - JAVACMD="java" - which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + JAVACMD=java + if ! command -v java >/dev/null 2>&1 + then + die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. Please set the JAVA_HOME variable in your environment to match the location of your Java installation." + fi fi # Increase the maximum file descriptors if we can. -if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then - MAX_FD_LIMIT=`ulimit -H -n` - if [ $? -eq 0 ] ; then - if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then - MAX_FD="$MAX_FD_LIMIT" - fi - ulimit -n $MAX_FD - if [ $? -ne 0 ] ; then - warn "Could not set maximum file descriptor limit: $MAX_FD" - fi - else - warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" - fi +if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then + case $MAX_FD in #( + max*) + # In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + MAX_FD=$( ulimit -H -n ) || + warn "Could not query maximum file descriptor limit" + esac + case $MAX_FD in #( + '' | soft) :;; #( + *) + # In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked. + # shellcheck disable=SC2039,SC3045 + ulimit -n "$MAX_FD" || + warn "Could not set maximum file descriptor limit to $MAX_FD" + esac fi -# For Darwin, add options to specify how the application appears in the dock -if $darwin; then - GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" -fi +# Collect all arguments for the java command, stacking in reverse order: +# * args from the command line +# * the main class name +# * -classpath +# * -D...appname settings +# * --module-path (only if needed) +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. # For Cygwin or MSYS, switch paths to Windows format before running java -if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then - APP_HOME=`cygpath --path --mixed "$APP_HOME"` - CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` - JAVACMD=`cygpath --unix "$JAVACMD"` - - # We build the pattern for arguments to be converted via cygpath - ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` - SEP="" - for dir in $ROOTDIRSRAW ; do - ROOTDIRS="$ROOTDIRS$SEP$dir" - SEP="|" - done - OURCYGPATTERN="(^($ROOTDIRS))" - # Add a user-defined pattern to the cygpath arguments - if [ "$GRADLE_CYGPATTERN" != "" ] ; then - OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" - fi +if "$cygwin" || "$msys" ; then + APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) + + JAVACMD=$( cygpath --unix "$JAVACMD" ) + # Now convert the arguments - kludge to limit ourselves to /bin/sh - i=0 - for arg in "$@" ; do - CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` - CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option - - if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition - eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` - else - eval `echo args$i`="\"$arg\"" + for arg do + if + case $arg in #( + -*) false ;; # don't mess with options #( + /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath + [ -e "$t" ] ;; #( + *) false ;; + esac + then + arg=$( cygpath --path --ignore --mixed "$arg" ) fi - i=`expr $i + 1` + # Roll the args list around exactly as many times as the number of + # args, so each arg winds up back in the position where it started, but + # possibly modified. + # + # NB: a `for` loop captures its iteration list before it begins, so + # changing the positional parameters here affects neither the number of + # iterations, nor the values presented in `arg`. + shift # remove old arg + set -- "$@" "$arg" # push replacement arg done - case $i in - 0) set -- ;; - 1) set -- "$args0" ;; - 2) set -- "$args0" "$args1" ;; - 3) set -- "$args0" "$args1" "$args2" ;; - 4) set -- "$args0" "$args1" "$args2" "$args3" ;; - 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; - 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; - 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; - 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; - 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; - esac fi -# Escape application args -save () { - for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done - echo " " -} -APP_ARGS=`save "$@"` -# Collect all arguments for the java command, following the shell quoting and substitution rules -eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' + +# Collect all arguments for the java command: +# * DEFAULT_JVM_OPTS, JAVA_OPTS, and optsEnvironmentVar are not allowed to contain shell fragments, +# and any embedded shellness will be escaped. +# * For example: A user cannot expect ${Hostname} to be expanded, as it is an environment variable and will be +# treated as '${Hostname}' itself on the command line. + +set -- \ + "-Dorg.gradle.appname=$APP_BASE_NAME" \ + -jar "$APP_HOME/gradle/wrapper/gradle-wrapper.jar" \ + "$@" + +# Stop when "xargs" is not available. +if ! command -v xargs >/dev/null 2>&1 +then + die "xargs is not available" +fi + +# Use "xargs" to parse quoted args. +# +# With -n1 it outputs one arg per line, with the quotes and backslashes removed. +# +# In Bash we could simply go: +# +# readarray ARGS < <( xargs -n1 <<<"$var" ) && +# set -- "${ARGS[@]}" "$@" +# +# but POSIX shell has neither arrays nor command substitution, so instead we +# post-process each arg (as a line of input to sed) to backslash-escape any +# character that might be a shell metacharacter, then use eval to reverse +# that process (while maintaining the separation between arguments), and wrap +# the whole thing up as a single "set" statement. +# +# This will of course break if any of these variables contains a newline or +# an unmatched quote. +# + +eval "set -- $( + printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | + xargs -n1 | + sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | + tr '\n' ' ' + )" '"$@"' exec "$JAVACMD" "$@" diff --git a/selenide-gradle/gradlew.bat b/selenide-gradle/gradlew.bat index 24467a1..03754c4 100644 --- a/selenide-gradle/gradlew.bat +++ b/selenide-gradle/gradlew.bat @@ -13,22 +13,55 @@ @rem See the License for the specific language governing permissions and @rem limitations under the License. @rem +@rem SPDX-License-Identifier: Apache-2.0 +@rem -@if "%DEBUG%" == "" @echo off +@if "%DEBUG%"=="" @echo off @rem ########################################################################## @rem -@rem Gradle startup script for Windows +@rem gradlew startup script for Windows @rem @rem ########################################################################## -@rem Set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" setlocal +@rem Set local scope for the variables, and ensure extensions are enabled +setlocal EnableExtensions + +@rem Catch executions from older scripts and ensure they exit cleanly. +@rem This can be removed once we can be reasonably confident that few people +@rem will be migrating directly to this new wrapper. +goto afterSafetyNet +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: +goto exitWithErrorLevel +:afterSafetyNet set DIRNAME=%~dp0 -if "%DIRNAME%" == "" set DIRNAME=. +if "%DIRNAME%"=="" set DIRNAME=. +@rem This is normally unused set APP_BASE_NAME=%~n0 set APP_HOME=%DIRNAME% +@rem Resolve any "." and ".." in APP_HOME to make it shorter. +for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi + @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" @@ -37,64 +70,43 @@ if defined JAVA_HOME goto findJavaFromJavaHome set JAVA_EXE=java.exe %JAVA_EXE% -version >NUL 2>&1 -if "%ERRORLEVEL%" == "0" goto init +if %ERRORLEVEL% equ 0 goto execute -echo. -echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. +1>&2 echo. +1>&2 echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +1>&2 echo. +1>&2 echo Please set the JAVA_HOME variable in your environment to match the +1>&2 echo location of your Java installation. -goto fail +"%COMSPEC%" /c exit 1 +goto exitWithErrorLevel :findJavaFromJavaHome set JAVA_HOME=%JAVA_HOME:"=% set JAVA_EXE=%JAVA_HOME%/bin/java.exe -if exist "%JAVA_EXE%" goto init - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% -echo. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation. - -goto fail - -:init -@rem Get command-line arguments, handling Windows variants +if exist "%JAVA_EXE%" goto execute -if not "%OS%" == "Windows_NT" goto win9xME_args +1>&2 echo. +1>&2 echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +1>&2 echo. +1>&2 echo Please set the JAVA_HOME variable in your environment to match the +1>&2 echo location of your Java installation. -:win9xME_args -@rem Slurp the command line arguments. -set CMD_LINE_ARGS= -set _SKIP=2 - -:win9xME_args_slurp -if "x%~1" == "x" goto execute - -set CMD_LINE_ARGS=%* +"%COMSPEC%" /c exit 1 +goto exitWithErrorLevel :execute @rem Setup the command line -set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar - -@rem Execute Gradle -"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% - -:end -@rem End local scope for the variables with windows NT shell -if "%ERRORLEVEL%"=="0" goto mainEnd -:fail -rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of -rem the _cmd.exe /c_ return code! -if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 -exit /b 1 -:mainEnd -if "%OS%"=="Windows_NT" endlocal +@rem Execute gradlew +@rem endlocal doesn't take effect until after the line is parsed and variables are expanded +@rem which allows us to clear the local environment before executing the java command +endlocal & "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -jar "%APP_HOME%\gradle\wrapper\gradle-wrapper.jar" %* & call :exitWithErrorLevel & goto exitWithErrorLevel -:omega +@rem This label must not be changed. We rely on old scripts being able to jump to this point. +:exitWithErrorLevel +@rem Use "%COMSPEC%" /c exit to allow operators to work properly in scripts +"%COMSPEC%" /c exit %ERRORLEVEL% diff --git a/selenide-gradle/src/test/java/SelenideExample.java b/selenide-gradle/src/test/java/SelenideExample.java index a007cab..af19f26 100644 --- a/selenide-gradle/src/test/java/SelenideExample.java +++ b/selenide-gradle/src/test/java/SelenideExample.java @@ -1,27 +1,23 @@ import com.codeborne.selenide.Configuration; import com.codeborne.selenide.Selenide; -import com.codeborne.selenide.WebDriverRunner; -import io.github.bonigarcia.wdm.WebDriverManager; import io.visual_regression_tracker.sdk_java.IgnoreAreas; import io.visual_regression_tracker.sdk_java.TestRunOptions; import io.visual_regression_tracker.sdk_java.VisualRegressionTracker; import io.visual_regression_tracker.sdk_java.VisualRegressionTrackerConfig; -import org.apache.commons.lang3.RandomStringUtils; import org.openqa.selenium.OutputType; -import org.openqa.selenium.TakesScreenshot; import org.testng.annotations.AfterSuite; import org.testng.annotations.BeforeSuite; import org.testng.annotations.Test; import java.io.IOException; -import java.util.Collections; +import java.util.List; import static com.codeborne.selenide.Selenide.$; public class SelenideExample { VisualRegressionTrackerConfig config = VisualRegressionTrackerConfig.builder() .apiUrl("http://localhost:4200") - .apiKey("0TK0P0NQP6MNFQQPTYYBN27JRAA5") + .apiKey("DEFAULTUSERAPIKEYTOBECHANGED") .project("Default project") .branchName("master") .enableSoftAssert(true) @@ -31,48 +27,45 @@ public class SelenideExample { VisualRegressionTracker vrt = new VisualRegressionTracker(config); @BeforeSuite - public void setUp() throws IOException { - WebDriverManager.chromedriver().setup(); - Configuration.baseUrl = "http://automationpractice.com/index.php"; + public void setUp() throws IOException, InterruptedException { + Configuration.baseUrl = "https://the-internet.herokuapp.com"; Configuration.browser = "chrome"; - Configuration.browserSize = "1240x1024"; + Configuration.browserSize = "1280x1024"; + Configuration.headless = true; vrt.start(); } @AfterSuite - public void tearDown() throws IOException { - WebDriverRunner.closeWebDriver(); + public void tearDown() throws IOException, InterruptedException { + Selenide.closeWebDriver(); vrt.stop(); } @Test - public void testExample() throws IOException { + public void testExample() throws IOException, InterruptedException { Selenide.open("/"); - vrt.track( - "Home page", - ((TakesScreenshot) WebDriverRunner.getWebDriver()).getScreenshotAs(OutputType.BASE64)); + vrt.track("Home page", Selenide.screenshot(OutputType.BASE64)); - $(".product-container").click(); + $("a[href='/checkboxes']").click(); vrt.track( - "Product page", - ((TakesScreenshot) WebDriverRunner.getWebDriver()).getScreenshotAs(OutputType.BASE64), + "Checkboxes page", + Selenide.screenshot(OutputType.BASE64), TestRunOptions.builder() - .device("Macbook Pro") - .os("macOS Catalina") + .device("PC") + .os(System.getProperty("os.name")) .browser("Chrome") - .viewport("1240x1024") + .viewport("1280x1024") .diffTollerancePercent(0.0f) - .ignoreAreas(Collections.singletonList( + .ignoreAreas(List.of( IgnoreAreas.builder() .x(10L) .y(10L) .width(100L) .height(200L) - .build() - )) + .build())) .build()); } } diff --git a/selenium-maven/pom.xml b/selenium-maven/pom.xml index f07a494..53d055a 100644 --- a/selenium-maven/pom.xml +++ b/selenium-maven/pom.xml @@ -8,6 +8,11 @@ selenium-maven 1.0-SNAPSHOT + + 17 + UTF-8 + + jitpack.io @@ -19,23 +24,33 @@ com.github.Visual-Regression-Tracker sdk-java - 4.5.1 + 5.5.0 org.seleniumhq.selenium selenium-java - 3.141.59 - - - io.github.bonigarcia - webdrivermanager - 4.1.0 + 4.52.0 junit junit - 4.12 + 4.13.2 test - \ No newline at end of file + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.15.0 + + + org.apache.maven.plugins + maven-surefire-plugin + 3.6.1 + + + + diff --git a/selenium-maven/src/test/java/com/example/test/ExampleSelenium.java b/selenium-maven/src/test/java/com/example/test/SeleniumExampleTest.java similarity index 55% rename from selenium-maven/src/test/java/com/example/test/ExampleSelenium.java rename to selenium-maven/src/test/java/com/example/test/SeleniumExampleTest.java index 79bb32f..72e674e 100644 --- a/selenium-maven/src/test/java/com/example/test/ExampleSelenium.java +++ b/selenium-maven/src/test/java/com/example/test/SeleniumExampleTest.java @@ -1,6 +1,5 @@ package com.example.test; -import io.github.bonigarcia.wdm.WebDriverManager; import io.visual_regression_tracker.sdk_java.IgnoreAreas; import io.visual_regression_tracker.sdk_java.TestRunOptions; import io.visual_regression_tracker.sdk_java.VisualRegressionTracker; @@ -9,67 +8,64 @@ import org.junit.BeforeClass; import org.junit.Test; import org.openqa.selenium.By; +import org.openqa.selenium.Dimension; import org.openqa.selenium.OutputType; -import org.openqa.selenium.TakesScreenshot; import org.openqa.selenium.WebDriver; import org.openqa.selenium.chrome.ChromeDriver; +import org.openqa.selenium.chrome.ChromeOptions; import java.io.IOException; -import java.util.Collections; +import java.util.List; -public class ExampleSelenium { +public class SeleniumExampleTest { static VisualRegressionTracker vrt; - static WebDriver driver; + static ChromeDriver driver; static VisualRegressionTrackerConfig config = VisualRegressionTrackerConfig.builder() .apiUrl("http://localhost:4200") - .apiKey("0TK0P0NQP6MNFQQPTYYBN27JRAA5") + .apiKey("DEFAULTUSERAPIKEYTOBECHANGED") .project("Default project") .branchName("master") .enableSoftAssert(true) - .ciBuildId("some build id") .build(); @BeforeClass - public static void setUp() throws IOException { - WebDriverManager.chromedriver().setup(); - driver = new ChromeDriver(); + public static void setUp() throws IOException, InterruptedException { + driver = new ChromeDriver(new ChromeOptions().addArguments("--headless=new")); + driver.manage().window().setSize(new Dimension(1280, 1024)); vrt = new VisualRegressionTracker(config); vrt.start(); } @AfterClass - public static void tearDown() throws IOException { + public static void tearDown() throws IOException, InterruptedException { driver.quit(); vrt.stop(); } @Test - public void ExampleTest() throws IOException { - driver.navigate().to("http://automationpractice.com/index.php"); + public void exampleTest() throws IOException, InterruptedException { + driver.navigate().to("https://the-internet.herokuapp.com/"); - vrt.track( - "Home page", - ((TakesScreenshot) driver).getScreenshotAs(OutputType.BASE64)); + vrt.track("Home page", driver.getScreenshotAs(OutputType.BASE64)); - driver.findElement(By.cssSelector(".product-container a")).click(); + driver.findElement(By.linkText("Checkboxes")).click(); vrt.track( - "Product page", - ((TakesScreenshot) driver).getScreenshotAs(OutputType.BASE64), + "Checkboxes page", + driver.getScreenshotAs(OutputType.BASE64), TestRunOptions.builder() - .device("Macbook Pro") - .os("macOS Catalina") + .device("PC") + .os(System.getProperty("os.name")) .browser("Chrome") - .viewport("1240x1024") + .viewport("1280x1024") .diffTollerancePercent(0.0f) - .ignoreAreas(Collections.singletonList( + .ignoreAreas(List.of( IgnoreAreas.builder() .x(10L) .y(10L) .width(100L) .height(200L) - .build() - )) + .build())) .build()); } } diff --git a/standalone-from-folder-maven/pom.xml b/standalone-from-folder-maven/pom.xml index 784cde0..09a1820 100644 --- a/standalone-from-folder-maven/pom.xml +++ b/standalone-from-folder-maven/pom.xml @@ -7,19 +7,53 @@ org.example vrt-standalone-client 1.0.1 + + + 17 + UTF-8 + + + + + jitpack.io + https://jitpack.io + + + + + + com.github.Visual-Regression-Tracker + sdk-java + 5.5.0 + + + org.apache.pdfbox + pdfbox + 3.0.8 + + + commons-io + commons-io + 2.22.0 + + + org.apache.maven.plugins maven-compiler-plugin - - 8 - 8 - + 3.15.0 + + + org.apache.maven.plugins + maven-surefire-plugin + 3.6.1 org.apache.maven.plugins maven-assembly-plugin + 3.8.0 @@ -35,34 +69,4 @@ - - - - - jitpack.io - https://jitpack.io - - - - - - - org.apache.pdfbox - pdfbox - 2.0.27 - - - com.github.Visual-Regression-Tracker - sdk-java - 5.1.1 - - - - commons-io - commons-io - 2.6 - - - - diff --git a/standalone-from-folder-maven/src/main/java/CompareFromFile.java b/standalone-from-folder-maven/src/main/java/CompareFromFile.java index 6118c6d..1b51a52 100644 --- a/standalone-from-folder-maven/src/main/java/CompareFromFile.java +++ b/standalone-from-folder-maven/src/main/java/CompareFromFile.java @@ -1,6 +1,7 @@ import io.visual_regression_tracker.sdk_java.*; import io.visual_regression_tracker.sdk_java.response.BuildResponse; import org.apache.commons.io.FilenameUtils; +import org.apache.pdfbox.Loader; import org.apache.pdfbox.pdmodel.PDDocument; import org.apache.pdfbox.rendering.PDFRenderer; @@ -143,9 +144,10 @@ private static void runComparison(VisualRegressionTracker visualRegressionTracke int countOfProcessed = results.get("imageProcessedCount") == null ? 1 : Integer.parseInt(results.get("imageProcessedCount").toString()) + 1; results.put("imageProcessedCount", countOfProcessed); TestRunResult testRunResult = visualRegressionTracker.track(screenshotName, encodedBase64, testRunOptionsBuilder.build()); - String result = String.valueOf(testRunResult.getTestRunResponse().getStatus()); - if (!result.equals("OK") && !result.equals("autoApproved")) + TestRunStatus status = testRunResult.getTestRunResponse().getStatus(); + if (status != TestRunStatus.OK && status != TestRunStatus.AUTO_APPROVED) results.put("allPassed", false); + String result = status.name(); int countOfResult = results.get(result) == null ? 1 : Integer.parseInt(results.get(result).toString()) + 1; results.put(result, countOfResult); Object imageVerifiedCount = results.get("imageVerifiedCount"); @@ -162,7 +164,7 @@ private static void runComparison(VisualRegressionTracker visualRegressionTracke private static List getPDFPagesAsImages(File eachFile) throws Exception { List bufferedImageList = new ArrayList<>(); - try (PDDocument pdDocument = PDDocument.load(eachFile)) { + try (PDDocument pdDocument = Loader.loadPDF(eachFile)) { PDFRenderer pdfRenderer = new PDFRenderer(pdDocument); for (int pageNumber = 0; pageNumber < pdDocument.getNumberOfPages(); ++pageNumber) { BufferedImage bufferedImage = pdfRenderer.renderImageWithDPI(pageNumber, 300);