├── .DS_Store ├── .gitignore ├── .idea ├── .gitignore ├── compiler.xml ├── gradle.xml ├── jarRepositories.xml ├── misc.xml ├── uiDesigner.xml └── vcs.xml ├── README.md ├── build.gradle ├── build ├── .DS_Store ├── reports │ ├── .DS_Store │ └── tests │ │ └── .DS_Store └── test-results │ └── .DS_Store ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── notifications ├── allure-notifications-4.6.1.jar └── config.json └── src ├── .DS_Store └── test ├── .DS_Store ├── java ├── .DS_Store ├── components │ ├── Calendar.java │ └── CheckResult.java ├── helpers │ ├── Attach.java │ └── CustomAllureListener.java ├── pages │ └── RegistrationFormPage.java ├── properties │ └── SystemPropertiesTests.java └── tests │ ├── SearchTests.java │ ├── TestBase.java │ ├── TestBaseJenkins.java │ ├── lesson_1 │ └── RegistrationFirstTests.java │ ├── lesson_10 │ ├── Person.java │ └── WorkWithFilesTests.java │ ├── lesson_11 │ ├── AllureReportTests.java │ └── WebSteps.java │ ├── lesson_12 │ └── RegistrationWithFakerJenkinsTests.java │ ├── lesson_18 │ ├── ApiTests.java │ ├── models │ │ ├── lombok │ │ │ ├── UserDataLombok.java │ │ │ └── UserLombok.java │ │ └── pojo │ │ │ ├── UserData.java │ │ │ └── UserPojo.java │ └── spec │ │ └── Spec.java │ ├── lesson_5 │ ├── DragDropTests.java │ └── HoverTests.java │ ├── lesson_6 │ └── DataTypesTests.java │ ├── lesson_8 │ └── RegistrationTestWithFakerTests.java │ ├── lesson_9 │ ├── ParameterizedTests.java │ └── SectionNames.java │ └── lesson_collections │ ├── ListCollection.java │ ├── Main.java │ ├── MapCollection.java │ ├── QueueCollection.java │ └── SetCollection.java └── resources ├── allure.properties ├── file.jpeg ├── listUsersResponseScheme.json ├── person.json ├── test-data.csv ├── test_archive.zip └── tpl ├── request.ftl └── response.ftl /.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viktorinka/getting-started-java/27ebec6693d0b0f67373db272b6e9f06cc5114dd/.DS_Store -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | .gradle 3 | build/** 4 | !gradle/wrapper/gradle-wrapper.jar 5 | !gradle/wrapper/gradle-wrapper.properties 6 | !**/src/main/**/build/ 7 | !**/src/test/**/build/ 8 | 9 | ### STS ### 10 | .apt_generated 11 | .classpath 12 | .factorypath 13 | .project 14 | .settings 15 | .springBeans 16 | .sts4-cache 17 | bin/ 18 | !**/src/main/**/bin/ 19 | !**/src/test/**/bin/ 20 | 21 | ### IntelliJ IDEA ### 22 | .idea 23 | *.iws 24 | *.iml 25 | *.ipr 26 | out/ 27 | !**/src/main/**/out/ 28 | !**/src/test/**/out/ 29 | .idea/compiler.xml 30 | 31 | ### NetBeans ### 32 | /nbproject/private/ 33 | /nbbuild/ 34 | /dist/ 35 | /nbdist/ 36 | /.nb-gradle/ 37 | 38 | ### VS Code ### 39 | .vscode/ 40 | 41 | ### gRPC generated files ### 42 | /niffler-grpc-common/src/generated/** 43 | gradle/wrapper 44 | gradlew 45 | gradlew.bat 46 | settings.gradle -------------------------------------------------------------------------------- /.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | # Editor-based HTTP Client requests 5 | /httpRequests/ 6 | # Datasource local storage ignored files 7 | /dataSources/ 8 | /dataSources.local.xml 9 | -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 18 | 19 | -------------------------------------------------------------------------------- /.idea/jarRepositories.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 9 | 10 | 14 | 15 | 19 | 20 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.idea/uiDesigner.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # getting-started-java 2 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'java-library' 3 | id 'io.qameta.allure' version '2.11.2' 4 | id 'io.freefair.lombok' version '8.4' 5 | } 6 | 7 | allure { 8 | report { 9 | version.set("2.19.0") 10 | } 11 | adapter { 12 | aspectjWeaver.set(true) 13 | frameworks { 14 | junit5 { 15 | adapterVersion.set("2.19.0") 16 | } 17 | } 18 | } 19 | } 20 | 21 | repositories { 22 | mavenCentral() 23 | } 24 | 25 | dependencies { 26 | testImplementation( 27 | "com.codeborne:selenide:6.16.0", 28 | "org.junit.jupiter:junit-jupiter:5.9.3", 29 | "com.github.javafaker:javafaker:1.0.2", 30 | "com.codeborne:pdf-test:1.5.0", 31 | "com.codeborne:xls-test:1.4.3", 32 | "com.opencsv:opencsv:5.7.1", 33 | "com.google.code.gson:gson:2.10.1", 34 | "io.qameta.allure:allure-selenide:2.19.0", 35 | "org.slf4j:slf4j-simple:2.0.7", 36 | "org.aspectj:aspectjweaver:1.9.19", 37 | "io.rest-assured:rest-assured:5.4.0", 38 | "io.rest-assured:json-schema-validator:5.4.0", 39 | "io.qameta.allure:allure-rest-assured:2.25.0") 40 | } 41 | 42 | tasks.withType(JavaCompile) { 43 | options.encoding = 'UTF-8' 44 | } 45 | 46 | tasks.withType(Test) { 47 | useJUnitPlatform() 48 | systemProperties(System.getProperties()) 49 | } 50 | 51 | task remote_test(type: Test) { 52 | useJUnitPlatform { 53 | includeTags("remote") 54 | } 55 | } 56 | 57 | task one_property_test(type: Test) { 58 | useJUnitPlatform { 59 | includeTags("one_property") 60 | } 61 | } 62 | 63 | task api_test(type: Test) { 64 | useJUnitPlatform { 65 | includeTags("api") 66 | } 67 | } 68 | 69 | -------------------------------------------------------------------------------- /build/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viktorinka/getting-started-java/27ebec6693d0b0f67373db272b6e9f06cc5114dd/build/.DS_Store -------------------------------------------------------------------------------- /build/reports/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viktorinka/getting-started-java/27ebec6693d0b0f67373db272b6e9f06cc5114dd/build/reports/.DS_Store -------------------------------------------------------------------------------- /build/reports/tests/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viktorinka/getting-started-java/27ebec6693d0b0f67373db272b6e9f06cc5114dd/build/reports/tests/.DS_Store -------------------------------------------------------------------------------- /build/test-results/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viktorinka/getting-started-java/27ebec6693d0b0f67373db272b6e9f06cc5114dd/build/test-results/.DS_Store -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viktorinka/getting-started-java/27ebec6693d0b0f67373db272b6e9f06cc5114dd/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-rc-2-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # 4 | # Copyright © 2015-2021 the original authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | # 21 | # Gradle start up script for POSIX generated by Gradle. 22 | # 23 | # Important for running: 24 | # 25 | # (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is 26 | # noncompliant, but you have some other compliant shell such as ksh or 27 | # bash, then to run this script, type that shell name before the whole 28 | # command line, like: 29 | # 30 | # ksh Gradle 31 | # 32 | # Busybox and similar reduced shells will NOT work, because this script 33 | # requires all of these POSIX shell features: 34 | # * functions; 35 | # * expansions «$var», «${var}», «${var:-default}», «${var+SET}», 36 | # «${var#prefix}», «${var%suffix}», and «$( cmd )»; 37 | # * compound commands having a testable exit status, especially «case»; 38 | # * various built-in commands including «command», «set», and «ulimit». 39 | # 40 | # Important for patching: 41 | # 42 | # (2) This script targets any POSIX shell, so it avoids extensions provided 43 | # by Bash, Ksh, etc; in particular arrays are avoided. 44 | # 45 | # The "traditional" practice of packing multiple parameters into a 46 | # space-separated string is a well documented source of bugs and security 47 | # problems, so this is (mostly) avoided, by progressively accumulating 48 | # options in "$@", and eventually passing that to Java. 49 | # 50 | # Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS, 51 | # and GRADLE_OPTS) rely on word-splitting, this is performed explicitly; 52 | # see the in-line comments for details. 53 | # 54 | # There are tweaks for specific operating systems such as AIX, CygWin, 55 | # Darwin, MinGW, and NonStop. 56 | # 57 | # (3) This script is generated from the Groovy template 58 | # https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt 59 | # within the Gradle project. 60 | # 61 | # You can find Gradle at https://github.com/gradle/gradle/. 62 | # 63 | ############################################################################## 64 | 65 | # Attempt to set APP_HOME 66 | 67 | # Resolve links: $0 may be a link 68 | app_path=$0 69 | 70 | # Need this for daisy-chained symlinks. 71 | while 72 | APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path 73 | [ -h "$app_path" ] 74 | do 75 | ls=$( ls -ld "$app_path" ) 76 | link=${ls#*' -> '} 77 | case $link in #( 78 | /*) app_path=$link ;; #( 79 | *) app_path=$APP_HOME$link ;; 80 | esac 81 | done 82 | 83 | APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit 84 | 85 | APP_NAME="Gradle" 86 | APP_BASE_NAME=${0##*/} 87 | 88 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 89 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 90 | 91 | # Use the maximum available, or set MAX_FD != -1 to use that value. 92 | MAX_FD=maximum 93 | 94 | warn () { 95 | echo "$*" 96 | } >&2 97 | 98 | die () { 99 | echo 100 | echo "$*" 101 | echo 102 | exit 1 103 | } >&2 104 | 105 | # OS specific support (must be 'true' or 'false'). 106 | cygwin=false 107 | msys=false 108 | darwin=false 109 | nonstop=false 110 | case "$( uname )" in #( 111 | CYGWIN* ) cygwin=true ;; #( 112 | Darwin* ) darwin=true ;; #( 113 | MSYS* | MINGW* ) msys=true ;; #( 114 | NONSTOP* ) nonstop=true ;; 115 | esac 116 | 117 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 118 | 119 | 120 | # Determine the Java command to use to start the JVM. 121 | if [ -n "$JAVA_HOME" ] ; then 122 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 123 | # IBM's JDK on AIX uses strange locations for the executables 124 | JAVACMD=$JAVA_HOME/jre/sh/java 125 | else 126 | JAVACMD=$JAVA_HOME/bin/java 127 | fi 128 | if [ ! -x "$JAVACMD" ] ; then 129 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 130 | 131 | Please set the JAVA_HOME variable in your environment to match the 132 | location of your Java installation." 133 | fi 134 | else 135 | JAVACMD=java 136 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 137 | 138 | Please set the JAVA_HOME variable in your environment to match the 139 | location of your Java installation." 140 | fi 141 | 142 | # Increase the maximum file descriptors if we can. 143 | if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then 144 | case $MAX_FD in #( 145 | max*) 146 | MAX_FD=$( ulimit -H -n ) || 147 | warn "Could not query maximum file descriptor limit" 148 | esac 149 | case $MAX_FD in #( 150 | '' | soft) :;; #( 151 | *) 152 | ulimit -n "$MAX_FD" || 153 | warn "Could not set maximum file descriptor limit to $MAX_FD" 154 | esac 155 | fi 156 | 157 | # Collect all arguments for the java command, stacking in reverse order: 158 | # * args from the command line 159 | # * the main class name 160 | # * -classpath 161 | # * -D...appname settings 162 | # * --module-path (only if needed) 163 | # * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables. 164 | 165 | # For Cygwin or MSYS, switch paths to Windows format before running java 166 | if "$cygwin" || "$msys" ; then 167 | APP_HOME=$( cygpath --path --mixed "$APP_HOME" ) 168 | CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" ) 169 | 170 | JAVACMD=$( cygpath --unix "$JAVACMD" ) 171 | 172 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 173 | for arg do 174 | if 175 | case $arg in #( 176 | -*) false ;; # don't mess with options #( 177 | /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath 178 | [ -e "$t" ] ;; #( 179 | *) false ;; 180 | esac 181 | then 182 | arg=$( cygpath --path --ignore --mixed "$arg" ) 183 | fi 184 | # Roll the args list around exactly as many times as the number of 185 | # args, so each arg winds up back in the position where it started, but 186 | # possibly modified. 187 | # 188 | # NB: a `for` loop captures its iteration list before it begins, so 189 | # changing the positional parameters here affects neither the number of 190 | # iterations, nor the values presented in `arg`. 191 | shift # remove old arg 192 | set -- "$@" "$arg" # push replacement arg 193 | done 194 | fi 195 | 196 | # Collect all arguments for the java command; 197 | # * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of 198 | # shell script including quotes and variable substitutions, so put them in 199 | # double quotes to make sure that they get re-expanded; and 200 | # * put everything else in single quotes, so that it's not re-expanded. 201 | 202 | set -- \ 203 | "-Dorg.gradle.appname=$APP_BASE_NAME" \ 204 | -classpath "$CLASSPATH" \ 205 | org.gradle.wrapper.GradleWrapperMain \ 206 | "$@" 207 | 208 | # Use "xargs" to parse quoted args. 209 | # 210 | # With -n1 it outputs one arg per line, with the quotes and backslashes removed. 211 | # 212 | # In Bash we could simply go: 213 | # 214 | # readarray ARGS < <( xargs -n1 <<<"$var" ) && 215 | # set -- "${ARGS[@]}" "$@" 216 | # 217 | # but POSIX shell has neither arrays nor command substitution, so instead we 218 | # post-process each arg (as a line of input to sed) to backslash-escape any 219 | # character that might be a shell metacharacter, then use eval to reverse 220 | # that process (while maintaining the separation between arguments), and wrap 221 | # the whole thing up as a single "set" statement. 222 | # 223 | # This will of course break if any of these variables contains a newline or 224 | # an unmatched quote. 225 | # 226 | 227 | eval "set -- $( 228 | printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" | 229 | xargs -n1 | 230 | sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' | 231 | tr '\n' ' ' 232 | )" '"$@"' 233 | 234 | exec "$JAVACMD" "$@" 235 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%" == "" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%" == "" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 34 | 35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 37 | 38 | @rem Find java.exe 39 | if defined JAVA_HOME goto findJavaFromJavaHome 40 | 41 | set JAVA_EXE=java.exe 42 | %JAVA_EXE% -version >NUL 2>&1 43 | if "%ERRORLEVEL%" == "0" goto execute 44 | 45 | echo. 46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 47 | echo. 48 | echo Please set the JAVA_HOME variable in your environment to match the 49 | echo location of your Java installation. 50 | 51 | goto fail 52 | 53 | :findJavaFromJavaHome 54 | set JAVA_HOME=%JAVA_HOME:"=% 55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 56 | 57 | if exist "%JAVA_EXE%" goto execute 58 | 59 | echo. 60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 61 | echo. 62 | echo Please set the JAVA_HOME variable in your environment to match the 63 | echo location of your Java installation. 64 | 65 | goto fail 66 | 67 | :execute 68 | @rem Setup the command line 69 | 70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 71 | 72 | 73 | @rem Execute Gradle 74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 75 | 76 | :end 77 | @rem End local scope for the variables with windows NT shell 78 | if "%ERRORLEVEL%"=="0" goto mainEnd 79 | 80 | :fail 81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 82 | rem the _cmd.exe /c_ return code! 83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 84 | exit /b 1 85 | 86 | :mainEnd 87 | if "%OS%"=="Windows_NT" endlocal 88 | 89 | :omega 90 | -------------------------------------------------------------------------------- /notifications/allure-notifications-4.6.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viktorinka/getting-started-java/27ebec6693d0b0f67373db272b6e9f06cc5114dd/notifications/allure-notifications-4.6.1.jar -------------------------------------------------------------------------------- /notifications/config.json: -------------------------------------------------------------------------------- 1 | { 2 | "base": { 3 | "logo": "", 4 | "project": "test project", 5 | "environment": "", 6 | "comment": "see @dzherommo", 7 | "reportLink": "https://jenkins.autotests.cloud", 8 | "language": "ru", 9 | "allureFolder": "build/reports/allure-report/allureReport/", 10 | "enableChart": true 11 | }, 12 | "telegram": { 13 | "token": "6797406646:AAHeY78YokZYikG--_ol8wYOv-GMHNIOsz0", 14 | "chat": "-1001433868291", 15 | "replyTo": "" 16 | } 17 | } -------------------------------------------------------------------------------- /src/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viktorinka/getting-started-java/27ebec6693d0b0f67373db272b6e9f06cc5114dd/src/.DS_Store -------------------------------------------------------------------------------- /src/test/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viktorinka/getting-started-java/27ebec6693d0b0f67373db272b6e9f06cc5114dd/src/test/.DS_Store -------------------------------------------------------------------------------- /src/test/java/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viktorinka/getting-started-java/27ebec6693d0b0f67373db272b6e9f06cc5114dd/src/test/java/.DS_Store -------------------------------------------------------------------------------- /src/test/java/components/Calendar.java: -------------------------------------------------------------------------------- 1 | package components; 2 | 3 | import static com.codeborne.selenide.Selenide.$; 4 | 5 | public class Calendar { 6 | 7 | public void setDate(String day, String month, String year){ 8 | $(".react-datepicker__month-select").selectOption(month); 9 | $(".react-datepicker__year-select").selectOption(year); 10 | $(".react-datepicker__day--0" + day + 11 | ":not(.react-datepicker__day--outside-month)").click(); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/test/java/components/CheckResult.java: -------------------------------------------------------------------------------- 1 | package components; 2 | 3 | import static com.codeborne.selenide.Condition.text; 4 | import static com.codeborne.selenide.Selenide.$; 5 | 6 | public class CheckResult { 7 | public void checkResultForm(){ 8 | //Проверка формы 9 | $("#example-modal-sizes-title-lg").shouldHave(text("Thanks for submitting the form")); 10 | $(".table-responsive").shouldHave(text("TestName " + "TestLastName"), text("Test@mail.ru"), 11 | text("1234567890"), text("sddefault.jpeg")); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /src/test/java/helpers/Attach.java: -------------------------------------------------------------------------------- 1 | package helpers; 2 | 3 | import com.codeborne.selenide.Selenide; 4 | import io.qameta.allure.Attachment; 5 | import org.openqa.selenium.OutputType; 6 | import org.openqa.selenium.TakesScreenshot; 7 | 8 | import java.net.MalformedURLException; 9 | import java.net.URL; 10 | import java.nio.charset.StandardCharsets; 11 | 12 | import static com.codeborne.selenide.Selenide.sessionId; 13 | import static com.codeborne.selenide.WebDriverRunner.getWebDriver; 14 | import static org.openqa.selenium.logging.LogType.BROWSER; 15 | 16 | public class Attach { 17 | @Attachment(value = "{attachName}", type = "image/png") 18 | public static byte[] screenshotAs(String attachName) { 19 | return ((TakesScreenshot) getWebDriver()).getScreenshotAs(OutputType.BYTES); 20 | } 21 | 22 | @Attachment(value = "Page source", type = "text/plain") 23 | public static byte[] pageSource() { 24 | return getWebDriver().getPageSource().getBytes(StandardCharsets.UTF_8); 25 | } 26 | 27 | @Attachment(value = "{attachName}", type = "text/plain") 28 | public static String attachAsText(String attachName, String message) { 29 | return message; 30 | } 31 | 32 | public static void browserConsoleLogs() { 33 | attachAsText( 34 | "Browser console logs", 35 | String.join("\n", Selenide.getWebDriverLogs(BROWSER)) 36 | ); 37 | } 38 | 39 | @Attachment(value = "Video", type = "text/html", fileExtension = ".html") 40 | public static String addVideo() { 41 | return ""; 44 | } 45 | 46 | public static URL getVideoUrl() { 47 | String videoUrl = "https://selenoid.autotests.cloud/video/" + sessionId() + ".mp4"; 48 | // System.out.println(sessionId()); 49 | try { 50 | return new URL(videoUrl); 51 | } catch (MalformedURLException e) { 52 | e.printStackTrace(); 53 | } 54 | return null; 55 | } 56 | } -------------------------------------------------------------------------------- /src/test/java/helpers/CustomAllureListener.java: -------------------------------------------------------------------------------- 1 | package helpers; 2 | 3 | import io.qameta.allure.restassured.AllureRestAssured; 4 | 5 | public class CustomAllureListener { 6 | private static final AllureRestAssured FILTER = new AllureRestAssured(); 7 | 8 | public static AllureRestAssured withCustomTemplates() { 9 | FILTER.setRequestTemplate("request.ftl"); 10 | FILTER.setResponseTemplate("response.ftl"); 11 | return FILTER; 12 | } 13 | } -------------------------------------------------------------------------------- /src/test/java/pages/RegistrationFormPage.java: -------------------------------------------------------------------------------- 1 | package pages; 2 | 3 | import com.github.javafaker.Faker; 4 | import components.Calendar; 5 | import components.CheckResult; 6 | import io.qameta.allure.Step; 7 | 8 | import java.io.File; 9 | 10 | import static com.codeborne.selenide.Condition.text; 11 | import static com.codeborne.selenide.Selectors.byText; 12 | import static com.codeborne.selenide.Selenide.*; 13 | 14 | public class RegistrationFormPage { 15 | 16 | Calendar calendar = new Calendar(); 17 | CheckResult checkResult = new CheckResult(); 18 | 19 | public RegistrationFormPage openPage() { 20 | open("/automation-practice-form"); 21 | executeJavaScript("$('footer').remove()"); 22 | executeJavaScript("$('#fixedban').remove()"); 23 | return this; 24 | } 25 | 26 | public RegistrationFormPage setFirstName(String value) { 27 | $("#firstName").setValue(value); 28 | return this; 29 | } 30 | 31 | public RegistrationFormPage setLastName(String value) { 32 | $("#lastName").setValue(value); 33 | 34 | return this; 35 | } 36 | 37 | public RegistrationFormPage setEmail(String value) { 38 | $("#userEmail").setValue(value); 39 | 40 | return this; 41 | } 42 | 43 | public RegistrationFormPage setGender(String value) { 44 | $(byText(value)).click(); 45 | 46 | return this; 47 | } 48 | 49 | public RegistrationFormPage setNumber(String value) { 50 | $("#userNumber").setValue(value); 51 | 52 | return this; 53 | } 54 | 55 | public RegistrationFormPage setDateOfBirth(String day, String month, String year) { 56 | $("#dateOfBirthInput").click(); 57 | 58 | calendar.setDate(day, month, year); 59 | 60 | return this; 61 | } 62 | 63 | public RegistrationFormPage setSubject(String value) { 64 | $("#subjectsInput").setValue(value).pressEnter(); 65 | 66 | return this; 67 | } 68 | 69 | public RegistrationFormPage setHobies(String value) { 70 | $("#hobbiesWrapper").$(byText(value)).click(); 71 | 72 | return this; 73 | } 74 | 75 | public RegistrationFormPage setPicture(String value) { 76 | $("#uploadPicture").uploadFile(new File("src/test/resources/file.jpeg")); 77 | 78 | return this; 79 | } 80 | 81 | public RegistrationFormPage setCurrentAddress(String value) { 82 | $("#currentAddress").setValue(value); 83 | 84 | return this; 85 | } 86 | 87 | public RegistrationFormPage setState(String value) { 88 | $("#state").click(); 89 | $(byText(value)).click(); 90 | 91 | return this; 92 | } 93 | 94 | public RegistrationFormPage setCity(String value) { 95 | $("#city").click(); 96 | $(byText(value)).click(); 97 | 98 | return this; 99 | } 100 | 101 | public RegistrationFormPage pressSubmit() { 102 | $("#submit").click(); 103 | 104 | return this; 105 | } 106 | public RegistrationFormPage checkResult() { 107 | $("#example-modal-sizes-title-lg").shouldHave(text("Thanks for submitting the form")); 108 | return this; 109 | } 110 | 111 | public RegistrationFormPage verifyResultsModalData(String labelText, String valuesText) { 112 | $(".table-responsive").$(byText(labelText)).parent().shouldHave((text(valuesText))); 113 | return this; 114 | } 115 | 116 | } 117 | -------------------------------------------------------------------------------- /src/test/java/properties/SystemPropertiesTests.java: -------------------------------------------------------------------------------- 1 | package properties; 2 | 3 | import org.junit.jupiter.api.Disabled; 4 | import org.junit.jupiter.api.Tag; 5 | import org.junit.jupiter.api.Test; 6 | 7 | import static org.junit.jupiter.api.Assertions.assertTrue; 8 | 9 | @Tag("one_property") 10 | public class SystemPropertiesTests { 11 | @Test 12 | void simplePropertyTest() { 13 | String browserName = System.getProperty("browser"); 14 | System.out.println(browserName); // null 15 | } 16 | 17 | @Test 18 | void simpleProperty1Test() { 19 | System.setProperty("browser", "opera"); 20 | String browserName = System.getProperty("browser"); 21 | System.out.println(browserName); // opera 22 | } 23 | 24 | @Test 25 | void simpleProperty2Test() { 26 | String browserName = System.getProperty("browser", "mozilla"); 27 | System.out.println(browserName); // mozilla 28 | } 29 | 30 | @Test 31 | void simpleProperty3Test() { 32 | System.setProperty("browser", "opera"); 33 | String browserName = System.getProperty("browser", "mozilla"); 34 | System.out.println(browserName); // opera 35 | } 36 | 37 | @Test 38 | void simpleProperty4Test() { 39 | String browserName = System.getProperty("browser", "mozilla"); 40 | System.out.println(browserName); 41 | } 42 | @Test 43 | @Disabled 44 | void skipTest() { 45 | assertTrue(false); 46 | } 47 | 48 | @Test 49 | void negativeTest() { 50 | assertTrue(false); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/test/java/tests/SearchTests.java: -------------------------------------------------------------------------------- 1 | package tests; 2 | 3 | import org.junit.jupiter.api.Test; 4 | 5 | import static com.codeborne.selenide.Condition.text; 6 | import static com.codeborne.selenide.Selenide.$; 7 | import static com.codeborne.selenide.Selenide.open; 8 | 9 | public class SearchTests { 10 | @Test 11 | void successfulSearchTest() { 12 | open("https://www.google.com/"); 13 | $("[name=q]").setValue("selenide").pressEnter(); 14 | $("[id=search]").shouldHave(text("https://selenide.org")); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/test/java/tests/TestBase.java: -------------------------------------------------------------------------------- 1 | package tests; 2 | 3 | import com.codeborne.selenide.Configuration; 4 | import org.junit.jupiter.api.BeforeAll; 5 | 6 | public class TestBase { 7 | @BeforeAll 8 | static void setUp() { 9 | Configuration.baseUrl = "https://demoqa.com"; 10 | Configuration.browserSize = "1920x1080"; 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /src/test/java/tests/TestBaseJenkins.java: -------------------------------------------------------------------------------- 1 | package tests; 2 | 3 | import com.codeborne.selenide.Configuration; 4 | import com.codeborne.selenide.logevents.SelenideLogger; 5 | import helpers.Attach; 6 | import io.qameta.allure.selenide.AllureSelenide; 7 | import org.junit.jupiter.api.AfterEach; 8 | import org.junit.jupiter.api.BeforeAll; 9 | import org.junit.jupiter.api.BeforeEach; 10 | import org.junit.jupiter.api.Test; 11 | import org.openqa.selenium.remote.DesiredCapabilities; 12 | 13 | import java.util.Map; 14 | 15 | import static java.lang.System.getProperties; 16 | 17 | public class TestBaseJenkins { 18 | @BeforeAll 19 | static void beforeAll() { 20 | Configuration.baseUrl = System.getProperty("baseUrl", "https://demoqa.com"); 21 | Configuration.browser = System.getProperty("browser", "chrome"); 22 | Configuration.browserVersion = System.getProperty("browserVersion", "100.0"); 23 | Configuration.browserSize = System.getProperty("browserSize", "1920x1080"); 24 | Configuration.remote = System.getProperty("remoteUrl", "https://user1:1234@selenoid.autotests.cloud/wd/hub"); 25 | 26 | DesiredCapabilities capabilities = new DesiredCapabilities(); 27 | capabilities.setCapability("selenoid:options", Map.of( 28 | "enableVNC", true, 29 | "enableVideo", true 30 | )); 31 | 32 | Configuration.browserCapabilities = capabilities; 33 | } 34 | 35 | @BeforeEach 36 | void addListener() { 37 | SelenideLogger.addListener("AllureSelenide", new AllureSelenide()); 38 | } 39 | 40 | @AfterEach 41 | void addAttachments() { 42 | Attach.screenshotAs("Last screenshot"); 43 | Attach.pageSource(); 44 | Attach.browserConsoleLogs(); 45 | Attach.addVideo(); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /src/test/java/tests/lesson_1/RegistrationFirstTests.java: -------------------------------------------------------------------------------- 1 | package tests.lesson_1; 2 | 3 | import com.codeborne.selenide.Configuration; 4 | import org.junit.jupiter.api.BeforeAll; 5 | import org.junit.jupiter.api.Test; 6 | import pages.RegistrationFormPage; 7 | 8 | public class RegistrationFirstTests { 9 | @BeforeAll 10 | static void setUp() { 11 | Configuration.baseUrl = "https://demoqa.com"; 12 | Configuration.browserSize = "1920x1080"; 13 | } 14 | 15 | RegistrationFormPage registrationFormPages = new RegistrationFormPage(); 16 | 17 | @Test 18 | void Test() { 19 | 20 | String firstName = "TestName"; 21 | String lastName = "TestLastName"; 22 | 23 | registrationFormPages.openPage(); 24 | registrationFormPages.setFirstName(firstName); 25 | registrationFormPages.setLastName(lastName); 26 | registrationFormPages.setEmail("test@mail.ru"); 27 | registrationFormPages.setGender("Other"); 28 | registrationFormPages.setNumber("1234567890"); 29 | registrationFormPages.setDateOfBirth("30", "July", "2008"); 30 | registrationFormPages.setSubject("Math"); 31 | registrationFormPages.setHobies("sport"); 32 | // registrationFormPages.setPicture(); 33 | registrationFormPages.setCurrentAddress("test"); 34 | // registrationFormPages.setState(); 35 | registrationFormPages.pressSubmit(); 36 | registrationFormPages.checkResult(); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /src/test/java/tests/lesson_10/Person.java: -------------------------------------------------------------------------------- 1 | package tests.lesson_10; 2 | 3 | import java.util.List; 4 | 5 | public class Person { 6 | public String name; 7 | public Integer age; 8 | public Boolean isMarried; 9 | public String spouse; 10 | public List contactNumbers; 11 | public List favoriteSports; 12 | public Car car; 13 | public static class Car { 14 | public String color; 15 | public Integer model; 16 | } 17 | 18 | public static class ContactNumbers { 19 | public String type; 20 | public String number; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/test/java/tests/lesson_10/WorkWithFilesTests.java: -------------------------------------------------------------------------------- 1 | package tests.lesson_10; 2 | 3 | import com.codeborne.pdftest.PDF; 4 | import com.codeborne.xlstest.XLS; 5 | import com.google.gson.Gson; 6 | import com.google.gson.JsonObject; 7 | import com.opencsv.CSVReader; 8 | import org.junit.jupiter.api.Assertions; 9 | import org.junit.jupiter.api.Test; 10 | 11 | import java.io.InputStream; 12 | import java.io.InputStreamReader; 13 | import java.util.List; 14 | import java.util.zip.ZipEntry; 15 | import java.util.zip.ZipInputStream; 16 | 17 | public class WorkWithFilesTests { 18 | private ClassLoader cl = WorkWithFilesTests.class.getClassLoader(); 19 | 20 | @Test 21 | void readZipForPdfTest() throws Exception { 22 | try (InputStream is = cl.getResourceAsStream("test_archive.zip"); 23 | ZipInputStream zs = new ZipInputStream(is)) { 24 | ZipEntry entry; 25 | while ((entry = zs.getNextEntry()) != null) { 26 | if (entry.getName().equals("test_pdf.pdf")) { 27 | PDF pdf = new PDF(zs); 28 | Assertions.assertTrue(pdf.text.contains("На горной речке перекаты")); 29 | } 30 | } 31 | } 32 | } 33 | 34 | @Test 35 | void readZipForCsvTest() throws Exception { 36 | try (InputStream is = cl.getResourceAsStream("test_archive.zip"); 37 | ZipInputStream zs = new ZipInputStream(is)) { 38 | ZipEntry entry; 39 | while ((entry = zs.getNextEntry()) != null) { 40 | if (entry.getName().equals("test_csv.csv")) { 41 | CSVReader csvReader = new CSVReader(new InputStreamReader(zs)); 42 | List content = csvReader.readAll(); 43 | Assertions.assertArrayEquals(new String[]{"2;Геворк;бурлят и говорят со мной.;;"}, content.get(2)); 44 | } 45 | } 46 | } 47 | } 48 | 49 | @Test 50 | void readZipForXlsxTest() throws Exception { 51 | try (InputStream is = cl.getResourceAsStream("test_archive.zip"); 52 | ZipInputStream zs = new ZipInputStream(is)) { 53 | ZipEntry entry; 54 | while ((entry = zs.getNextEntry()) != null) { 55 | if (entry.getName().equals("test_xlsx.xlsx")) { 56 | XLS xls = new XLS(zs); 57 | Assertions.assertTrue(xls.excel.getSheetAt(0).getRow(3).getCell(2).getStringCellValue().contains("Там ивы горбятся, лохматы,")); 58 | } 59 | } 60 | } 61 | } 62 | 63 | @Test 64 | void readZipForJsonTest() throws Exception { 65 | Gson gson = new Gson(); 66 | try (InputStream is = cl.getResourceAsStream("person.json"); 67 | InputStreamReader isr = new InputStreamReader(is)) { 68 | JsonObject jsonObject = gson.fromJson(isr, JsonObject.class); 69 | Assertions.assertFalse(jsonObject.get("isMarried").getAsBoolean()); 70 | Assertions.assertEquals(30, jsonObject.get("age").getAsInt()); 71 | } 72 | } 73 | 74 | @Test 75 | void readZipForJsonPrettyTest() throws Exception { 76 | Gson gson = new Gson(); 77 | try (InputStream is = cl.getResourceAsStream("person.json"); 78 | InputStreamReader isr = new InputStreamReader(is)) { 79 | Person person = gson.fromJson(isr, Person.class); 80 | Assertions.assertEquals("123 123-123", person.contactNumbers.get(0).number); 81 | Assertions.assertEquals("Football", person.favoriteSports.get(0)); 82 | Assertions.assertEquals(123, person.car.model); 83 | Assertions.assertFalse(person.isMarried); 84 | } 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /src/test/java/tests/lesson_11/AllureReportTests.java: -------------------------------------------------------------------------------- 1 | package tests.lesson_11; 2 | 3 | import com.codeborne.selenide.Condition; 4 | import com.codeborne.selenide.logevents.SelenideLogger; 5 | import io.qameta.allure.*; 6 | import io.qameta.allure.selenide.AllureSelenide; 7 | import org.junit.jupiter.api.DisplayName; 8 | import org.junit.jupiter.api.Test; 9 | 10 | import static com.codeborne.selenide.Selectors.withText; 11 | import static com.codeborne.selenide.Selenide.$; 12 | import static com.codeborne.selenide.Selenide.open; 13 | import static com.codeborne.selenide.logevents.SelenideLogger.step; 14 | import static org.openqa.selenium.By.linkText; 15 | 16 | public class AllureReportTests { 17 | @Test 18 | void selenideTest(){ 19 | SelenideLogger.addListener("allure", new AllureSelenide()); 20 | open("https://github.com"); 21 | $(".header-search-button").click(); 22 | $("#query-builder-test").sendKeys("eroshenkoam/allure-example"); 23 | $("#query-builder-test").submit(); 24 | 25 | $(linkText("eroshenkoam/allure-example")).click(); 26 | $(("#issues-tab")).click(); 27 | $(withText("#80")).should(Condition.exist); 28 | } 29 | 30 | @Test 31 | @Feature("Issue в репозитории") 32 | @Story("Создание Issue") 33 | @Owner("eroshenkoam") 34 | @Severity(SeverityLevel.BLOCKER) 35 | @Link(value = "Testing", url = "https://testing.github.com") 36 | @DisplayName("Создание Issue для авторизованного пользователя") 37 | public void staticLabelsTest() { 38 | } 39 | 40 | @Test 41 | public void DynamicLabelsTest() { 42 | Allure.getLifecycle().updateTestCase( 43 | t -> t.setName("Создание Issue для авторизованного пользователя") 44 | ); 45 | Allure.feature("Issue в репозитории"); 46 | Allure.story("Создание Issue"); 47 | Allure.label("owner", "eroshenkoam"); 48 | Allure.label("severity", SeverityLevel.CRITICAL.value()); 49 | Allure.link("Testing", "https://testing.github.com"); 50 | } 51 | 52 | private static final String REPOSITORY = "eroshenkoam/allure-example"; 53 | private static final int ISSUE = 80; 54 | 55 | @Test 56 | public void LambdaStepTest() { 57 | SelenideLogger.addListener("allure", new AllureSelenide()); 58 | 59 | step("Открываем главную страницу", () -> { 60 | open("https://github.com"); 61 | }); 62 | step("Ищем репозиторий " + REPOSITORY, () -> { 63 | $(".header-search-button").click(); 64 | $("#query-builder-test").sendKeys(REPOSITORY); 65 | $("#query-builder-test").submit(); 66 | }); 67 | step("Кликаем по ссылке репозитория " + REPOSITORY, () -> { 68 | $(linkText(REPOSITORY)).click(); 69 | }); 70 | step("Открываем таб Issues", () -> { 71 | $("#issues-tab").click(); 72 | }); 73 | step("Проверяем наличие Issue с номером " + ISSUE, () -> { 74 | $(withText("#" + ISSUE)).should(Condition.exist); 75 | }); 76 | } 77 | 78 | @Test 79 | public void AnnotatedStepTest() { 80 | SelenideLogger.addListener("allure", new AllureSelenide()); 81 | WebSteps steps = new WebSteps(); 82 | 83 | steps.openMainPage(); 84 | steps.searchForRepository(REPOSITORY); 85 | steps.clickOnRepositoryLink(REPOSITORY); 86 | steps.openIssuesTab(); 87 | steps.shouldSeeIssueWithNumber(ISSUE); 88 | 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /src/test/java/tests/lesson_11/WebSteps.java: -------------------------------------------------------------------------------- 1 | package tests.lesson_11; 2 | 3 | import com.codeborne.selenide.Condition; 4 | import com.codeborne.selenide.WebDriverRunner; 5 | import io.qameta.allure.Attachment; 6 | import io.qameta.allure.Step; 7 | import org.openqa.selenium.OutputType; 8 | import org.openqa.selenium.TakesScreenshot; 9 | 10 | import static com.codeborne.selenide.Selectors.withText; 11 | import static com.codeborne.selenide.Selenide.$; 12 | import static com.codeborne.selenide.Selenide.open; 13 | import static org.openqa.selenium.By.linkText; 14 | 15 | public class WebSteps { 16 | 17 | @Step("Открываем главную страницу") 18 | public void openMainPage() { 19 | open("https://github.com"); 20 | } 21 | 22 | @Step("Ищем репозиторий {repo}") 23 | public void searchForRepository(String repo) { 24 | $(".header-search-button").click(); 25 | $("#query-builder-test").sendKeys(repo); 26 | $("#query-builder-test").submit(); 27 | } 28 | 29 | @Step("Кликаем по ссылке репозитория {repo}") 30 | public void clickOnRepositoryLink(String repo) { 31 | $(linkText(repo)).click(); 32 | } 33 | 34 | @Step("Открываем таб Issues") 35 | public void openIssuesTab() { 36 | $("#issues-tab").click(); 37 | } 38 | 39 | @Step("Проверяем наличие Issue с номером {issue}") 40 | public void shouldSeeIssueWithNumber(int issue) { 41 | $(withText("#" + issue)).should(Condition.exist); 42 | } 43 | 44 | @Attachment(value = "Screenshot", type = "image/png", fileExtension = "png") 45 | public byte[] takeScreenshot() { 46 | return ((TakesScreenshot)WebDriverRunner.getWebDriver()).getScreenshotAs(OutputType.BYTES); 47 | } 48 | } -------------------------------------------------------------------------------- /src/test/java/tests/lesson_12/RegistrationWithFakerJenkinsTests.java: -------------------------------------------------------------------------------- 1 | package tests.lesson_12; 2 | 3 | import com.github.javafaker.Faker; 4 | import org.junit.jupiter.api.DisplayName; 5 | import org.junit.jupiter.api.Tag; 6 | import org.junit.jupiter.api.Test; 7 | import pages.RegistrationFormPage; 8 | import tests.TestBase; 9 | import tests.TestBaseJenkins; 10 | 11 | import java.text.SimpleDateFormat; 12 | import java.util.Date; 13 | import java.util.Locale; 14 | import java.util.Map; 15 | 16 | import static io.qameta.allure.Allure.step; 17 | 18 | public class RegistrationWithFakerJenkinsTests extends TestBaseJenkins { 19 | 20 | RegistrationFormPage registrationFormPage = new RegistrationFormPage(); 21 | Faker faker = new Faker(); 22 | String firstName = faker.address().firstName(); 23 | String lastName = faker.address().lastName(); 24 | String email = faker.internet().emailAddress(); 25 | String number = String.valueOf(faker.number().randomNumber(10, true)); 26 | String address = faker.address().streetAddress(); 27 | String subject = faker.options().option("Accounting", "Maths", "Arts", "English", "Physics", "Chemistry", 28 | "Computer Science", "Economics", "Social Studies", "History", "Civics", "Commerce", "Hindi", "Biology"); 29 | String hobbies = faker.options().option("Reading", "Sports", "Music"); 30 | String gender = faker.demographic().sex(); 31 | static Map mapStateWithCity = Map.of( 32 | "NCR", new String[]{"Delhi", "Gurgaon", "Noida"}, 33 | "Uttar Pradesh", new String[]{"Agra", "Lucknow", "Merrut"}, 34 | "Haryana", new String[]{"Karnal", "Panipat"}, 35 | "Rajasthan", new String[]{"Jaipur", "Jaiselmer"}); 36 | String state = faker.options().option(mapStateWithCity.keySet().toArray()).toString(); 37 | String city = faker.options().option(mapStateWithCity.get(state)); 38 | Date fakerDateOfBirthday = faker.date().birthday(); 39 | String dayOfBirth = (new SimpleDateFormat("dd", Locale.ENGLISH)).format(fakerDateOfBirthday); 40 | String monthOfBirth = (new SimpleDateFormat("MMMM", Locale.ENGLISH)).format(fakerDateOfBirthday); 41 | String yearOfBirth = (new SimpleDateFormat("y", Locale.ENGLISH)).format(fakerDateOfBirthday); 42 | String pictureName = "file.jpeg"; 43 | 44 | 45 | @Test 46 | @DisplayName("Проверка формы") 47 | @Tag("remote") 48 | void Test() { 49 | step("Fill the registration form", () -> { 50 | registrationFormPage.openPage() 51 | .setFirstName(firstName) 52 | .setLastName(lastName) 53 | .setEmail(email) 54 | .setGender(gender) 55 | .setNumber(number) 56 | .setDateOfBirth(dayOfBirth, monthOfBirth, yearOfBirth) 57 | .setSubject(subject) 58 | .setHobies(hobbies) 59 | .setPicture(pictureName) 60 | .setCurrentAddress(address) 61 | .setState(state) 62 | .setCity(city) 63 | .pressSubmit() 64 | .checkResult(); 65 | }); 66 | step("Verify results", () -> { 67 | registrationFormPage.verifyResultsModalData("Student Name", firstName + " " + lastName) 68 | .verifyResultsModalData("Student Email", email) 69 | .verifyResultsModalData("Gender", gender) 70 | .verifyResultsModalData("Mobile", number) 71 | .verifyResultsModalData("Date of Birth", dayOfBirth + " " + monthOfBirth + "," + yearOfBirth) 72 | .verifyResultsModalData("Subjects", subject) 73 | .verifyResultsModalData("Hobbies", hobbies) 74 | .verifyResultsModalData("Picture", pictureName) 75 | .verifyResultsModalData("Address", address) 76 | .verifyResultsModalData("State and City", state + " " + city); 77 | }); 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /src/test/java/tests/lesson_18/ApiTests.java: -------------------------------------------------------------------------------- 1 | package tests.lesson_18; 2 | 3 | import io.qameta.allure.restassured.AllureRestAssured; 4 | import io.restassured.http.ContentType; 5 | import org.junit.jupiter.api.DisplayName; 6 | import org.junit.jupiter.api.Tag; 7 | import org.junit.jupiter.api.Test; 8 | import tests.lesson_18.models.lombok.UserDataLombok; 9 | import tests.lesson_18.models.pojo.UserData; 10 | import tests.lesson_18.models.pojo.UserPojo; 11 | import tests.lesson_18.spec.Spec; 12 | 13 | import static helpers.CustomAllureListener.withCustomTemplates; 14 | import static io.qameta.allure.Allure.step; 15 | import static io.restassured.RestAssured.given; 16 | import static io.restassured.module.jsv.JsonSchemaValidator.matchesJsonSchemaInClasspath; 17 | import static org.hamcrest.Matchers.*; 18 | import static org.junit.jupiter.api.Assertions.assertEquals; 19 | 20 | @Tag("api") 21 | public class ApiTests { 22 | @Test 23 | void checkListUsersSchemeTest() { 24 | given() 25 | .log().uri() 26 | .when() 27 | .get("https://reqres.in/api/users?page=2") 28 | .then() 29 | .log().status() 30 | .log().body() 31 | .statusCode(200) 32 | .body(matchesJsonSchemaInClasspath("listUsersResponseScheme.json")); 33 | } 34 | 35 | @Test 36 | void checkPostCreateTest() { 37 | String body = "{ \"name\": \"morpheus\", \"job\": \"leader\" }"; 38 | given() 39 | .log().body() 40 | .body(body) 41 | .contentType(ContentType.JSON) 42 | .when() 43 | .post("https://reqres.in/api/users") 44 | .then() 45 | .log().status() 46 | .log().body() 47 | .statusCode(201) 48 | .body("name", is("morpheus")).body("job", is("leader")); 49 | } 50 | 51 | @Test 52 | void checkPutCreateTest() { 53 | String body = "{ \"name\": \"morpheus\", \"job\": \"zion resident\" }"; 54 | given() 55 | .log().body() 56 | .body(body) 57 | .contentType(ContentType.JSON) 58 | .when() 59 | .put("https://reqres.in/api/users/2") 60 | .then() 61 | .log().status() 62 | .log().body() 63 | .statusCode(200) 64 | .body("name", is("morpheus")).body("job", is("zion resident")); 65 | } 66 | 67 | @Test 68 | void checkPatchCreateTest() { 69 | String body = "{ \"name\": \"morpheus\", \"job\": \"zion resident\" }"; 70 | String expectResponse = "zion resident"; 71 | String actualResponse = given() 72 | .log().body() 73 | .body(body) 74 | .contentType(ContentType.JSON) 75 | .when() 76 | .patch("https://reqres.in/api/users/2") 77 | .then() 78 | .log().status() 79 | .log().body() 80 | .statusCode(200) 81 | .extract().path("job"); 82 | assertEquals(actualResponse, expectResponse); 83 | } 84 | 85 | @Test 86 | void checkDeleteTest() { 87 | given() 88 | .log().all() 89 | .when() 90 | .delete("https://reqres.in/api/users/2") 91 | .then() 92 | .log().all() 93 | .statusCode(204); 94 | } 95 | 96 | @Test 97 | void checkNegativeTest() { 98 | String body = "{ \"name\": \"morpheus\", \"job\": \"test }"; 99 | given() 100 | .log().body() 101 | .body(body) 102 | .contentType(ContentType.JSON) 103 | .when() 104 | .patch("https://reqres.in/api/users/2") 105 | .then() 106 | .log().status() 107 | .log().body() 108 | .statusCode(400); 109 | } 110 | 111 | @Test 112 | void checkPostCreateModelTest() { 113 | String body = "{ \"name\": \"morpheus\", \"job\": \"leader\" }"; 114 | UserPojo pojo = Spec.request 115 | .body(body) 116 | .when() 117 | .post("/users") 118 | .then() 119 | .spec(Spec.responseSpec) 120 | .extract().as(UserPojo.class); 121 | assertEquals("leader", pojo.getJob()); 122 | } 123 | 124 | @Test 125 | void checkGetSingleUserModelTest() { 126 | UserData dataPojo = given() 127 | .spec(Spec.request) 128 | .when() 129 | .get("/users/2") 130 | .then() 131 | .log().body() 132 | .statusCode(200) 133 | .extract().as(UserData.class); 134 | assertEquals(2, dataPojo.getData().getId()); 135 | } 136 | 137 | @Test 138 | void checkGetSingleUserModelTest2() { 139 | UserPojo pojo = given() 140 | .spec(Spec.request) 141 | .when() 142 | .get("/users/2") 143 | .then() 144 | .log().body() 145 | .statusCode(200) 146 | .extract().as(UserPojo.class); 147 | assertEquals(2, pojo.getId()); 148 | } 149 | 150 | @Test 151 | void checkGetSingleUserLombokTest() { 152 | UserDataLombok dataLombok = given() 153 | .spec(Spec.request) 154 | .when() 155 | .get("/users/2") 156 | .then() 157 | .log().body() 158 | .statusCode(200) 159 | .extract().as(UserDataLombok.class); 160 | assertEquals(2, dataLombok.getUserLombok().getId()); 161 | } 162 | 163 | @Test 164 | void checkGetSingleUserGroovyTest() { 165 | given() 166 | .spec(Spec.request) 167 | .when() 168 | .get("/users") 169 | .then() 170 | .log().body() 171 | .statusCode(200) 172 | .body("data.findAll{it.first_name =~/[a-zA-Z]+/}.first_name.flatten()", 173 | hasItem("Janet")) 174 | .body("data.last_name[0]", equalTo("Bluth")); 175 | } 176 | 177 | @Test 178 | void checkGetSingleUserWithAllureTest() { 179 | UserDataLombok dataLombok = given() 180 | .filter(new AllureRestAssured()) 181 | .spec(Spec.request) 182 | .when() 183 | .get("/users/2") 184 | .then() 185 | .log().body() 186 | .statusCode(200) 187 | .extract().as(UserDataLombok.class); 188 | assertEquals(2, dataLombok.getUserLombok().getId()); 189 | } 190 | 191 | @Test 192 | void checkGetSingleUserWithCustomAllureTest() { 193 | UserDataLombok dataLombok = given() 194 | .filter(withCustomTemplates()) 195 | .spec(Spec.request) 196 | .when() 197 | .get("/users/2") 198 | .then() 199 | .log().body() 200 | .statusCode(200) 201 | .extract().as(UserDataLombok.class); 202 | assertEquals(2, dataLombok.getUserLombok().getId()); 203 | } 204 | 205 | @Test 206 | @DisplayName("Check data for single user") 207 | void checkGetSingleUserWithStepAllureTest() { 208 | UserDataLombok dataLombok = step("Make request", () -> 209 | given() 210 | .spec(Spec.request) 211 | .when() 212 | .get("/users/2") 213 | .then() 214 | .log().body() 215 | .statusCode(200) 216 | .extract().as(UserDataLombok.class)); 217 | step("Verify response", () -> 218 | assertEquals(2, dataLombok.getUserLombok().getId())); 219 | } 220 | } 221 | -------------------------------------------------------------------------------- /src/test/java/tests/lesson_18/models/lombok/UserDataLombok.java: -------------------------------------------------------------------------------- 1 | package tests.lesson_18.models.lombok; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.Data; 6 | 7 | @Data 8 | @JsonIgnoreProperties(ignoreUnknown = true) 9 | public class UserDataLombok { 10 | @JsonProperty("data") 11 | private UserLombok userLombok; 12 | 13 | } 14 | -------------------------------------------------------------------------------- /src/test/java/tests/lesson_18/models/lombok/UserLombok.java: -------------------------------------------------------------------------------- 1 | package tests.lesson_18.models.lombok; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | import lombok.Data; 6 | 7 | @Data 8 | @JsonIgnoreProperties(ignoreUnknown = true) 9 | public class UserLombok { 10 | private Integer id; 11 | private String email; 12 | @JsonProperty("first_name") 13 | private String firstName; 14 | @JsonProperty("last_name") 15 | private String lastName; 16 | private String avatar; 17 | private String job; 18 | private String name; 19 | } 20 | 21 | 22 | -------------------------------------------------------------------------------- /src/test/java/tests/lesson_18/models/pojo/UserData.java: -------------------------------------------------------------------------------- 1 | package tests.lesson_18.models.pojo; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 4 | 5 | @JsonIgnoreProperties(ignoreUnknown = true) 6 | public class UserData { 7 | private UserPojo data; 8 | 9 | public UserPojo getData() { 10 | return data; 11 | } 12 | 13 | public void setData(UserPojo data) { 14 | this.data = data; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /src/test/java/tests/lesson_18/models/pojo/UserPojo.java: -------------------------------------------------------------------------------- 1 | package tests.lesson_18.models.pojo; 2 | 3 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; 4 | import com.fasterxml.jackson.annotation.JsonProperty; 5 | 6 | @JsonIgnoreProperties(ignoreUnknown = true) 7 | 8 | public class UserPojo { 9 | 10 | private Integer id; 11 | private String email; 12 | @JsonProperty("first_name") 13 | private String firstName; 14 | @JsonProperty("last_name") 15 | private String lastName; 16 | private String avatar; 17 | private String job; 18 | private String name; 19 | 20 | public String getName() { 21 | return name; 22 | } 23 | 24 | public void setName(String name) { 25 | this.name = name; 26 | } 27 | 28 | public String getJob() { 29 | return job; 30 | } 31 | 32 | public void setJob(String job) { 33 | this.job = job; 34 | } 35 | 36 | public Integer getId() { 37 | return id; 38 | } 39 | 40 | public void setId(Integer id) { 41 | this.id = id; 42 | } 43 | 44 | public String getEmail() { 45 | return email; 46 | } 47 | 48 | public void setEmail(String email) { 49 | this.email = email; 50 | } 51 | 52 | public String getFirstName() { 53 | return firstName; 54 | } 55 | 56 | public void setFirstName(String firstName) { 57 | this.firstName = firstName; 58 | } 59 | 60 | public String getLastName() { 61 | return lastName; 62 | } 63 | 64 | public void setLastName(String lastName) { 65 | this.lastName = lastName; 66 | } 67 | 68 | public String getAvatar() { 69 | return avatar; 70 | } 71 | 72 | public void setAvatar(String avatar) { 73 | this.avatar = avatar; 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /src/test/java/tests/lesson_18/spec/Spec.java: -------------------------------------------------------------------------------- 1 | package tests.lesson_18.spec; 2 | 3 | import io.restassured.builder.ResponseSpecBuilder; 4 | import io.restassured.filter.log.LogDetail; 5 | import io.restassured.http.ContentType; 6 | import io.restassured.specification.RequestSpecification; 7 | import io.restassured.specification.ResponseSpecification; 8 | 9 | import static helpers.CustomAllureListener.withCustomTemplates; 10 | import static io.restassured.RestAssured.with; 11 | 12 | public class Spec { 13 | public static RequestSpecification request = with() 14 | .baseUri("https://reqres.in") 15 | .basePath("/api") 16 | .log().all() 17 | .contentType(ContentType.JSON) 18 | .filter(withCustomTemplates()); 19 | 20 | public static ResponseSpecification responseSpec = new ResponseSpecBuilder() 21 | .log(LogDetail.STATUS) 22 | .log(LogDetail.BODY) 23 | .expectStatusCode(201) 24 | .build(); 25 | 26 | } 27 | -------------------------------------------------------------------------------- /src/test/java/tests/lesson_5/DragDropTests.java: -------------------------------------------------------------------------------- 1 | package tests.lesson_5; 2 | 3 | import com.codeborne.selenide.DragAndDropOptions; 4 | import org.junit.jupiter.api.Test; 5 | 6 | import static com.codeborne.selenide.Condition.text; 7 | import static com.codeborne.selenide.Selenide.*; 8 | 9 | public class DragDropTests { 10 | 11 | @Test 12 | void dragAndDropTest(){ 13 | open("https://the-internet.herokuapp.com/drag_and_drop"); 14 | $("#column-a").dragAndDrop(DragAndDropOptions.to($("#column-b"))); 15 | $("#column-a").shouldHave(text("B")); 16 | } 17 | 18 | @Test 19 | void dragAndDropActionsTest(){ 20 | open("https://the-internet.herokuapp.com/drag_and_drop"); 21 | actions().clickAndHold($("#column-a")).moveToElement($("#column-b")).release().build().perform(); 22 | $("#column-a").shouldHave(text("B")); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/test/java/tests/lesson_5/HoverTests.java: -------------------------------------------------------------------------------- 1 | package tests.lesson_5; 2 | 3 | import com.codeborne.selenide.Condition; 4 | import org.junit.jupiter.api.Test; 5 | 6 | import static com.codeborne.selenide.Selectors.byText; 7 | import static com.codeborne.selenide.Selenide.*; 8 | 9 | public class HoverTests { 10 | 11 | @Test 12 | void checkText(){ 13 | open("https://github.com/"); 14 | $$(".HeaderMenu-link").findBy(Condition.text("Solutions")).hover(); 15 | $(byText("Enterprise")).click(); 16 | $(".enterprise-hero-background").shouldHave(Condition.text("The AI-powered developer platform.")); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/test/java/tests/lesson_6/DataTypesTests.java: -------------------------------------------------------------------------------- 1 | package tests.lesson_6; 2 | 3 | public class DataTypesTests { 4 | 5 | public static void main(String[] args) { 6 | 7 | //Целочисленные типы данных 8 | byte a = 12 + 12; // 8 bit 9 | System.out.println("Type of byte from -128 to 127. Example byte " + a); 10 | 11 | short b = -32 + 32768; // 16 bit 12 | System.out.println("Type of short from -32 768 to 32 767. Example short " + b); 13 | 14 | int i = 1234569 + 1234569000; //32 bit 15 | System.out.println("Type of int from -2 147 483 648 to 2 147 483 647. Example int " + i); 16 | 17 | long d = 922337204 + 922337203; //64 bit 18 | System.out.println("Type of long from -9 223 372 036 854 775 808 to 9 223 372 036 854 775 807. Example long " + d); 19 | 20 | // Типы данных с плавающей точкой 21 | double v = i + d; 22 | System.out.println("int plus long = result double. Example double " + v); // приведение к типу данных, который соответствует наибольшей точности вычислений - double 23 | 24 | float e = 12.8F + 28888.0F; 25 | System.out.println("Type of float from -9 223 372 036 854 775 808 to 9 223 372 036 854 775 807. Example float " + e); 26 | 27 | double f = 567.6666 + 46.88888; 28 | System.out.println("Type of double from -9 223 372 036 854 775 808 to 9 223 372 036 854 775 807. Example double " + f); 29 | 30 | boolean yes = 2 < 3; 31 | boolean no = 2 > 3; 32 | System.out.println("Type of boolean, true or false. Example 2 < 3 " + yes); 33 | System.out.println("Type of boolean, true or false. Example 2 > 3 " + no); 34 | 35 | 36 | // Операторы 37 | // 1. Присвоение 38 | char assignment = 'T'; 39 | System.out.println(assignment); 40 | 41 | int c = 10; 42 | System.out.println("c = " + c); 43 | c += 5; // эквивалентно c = c + 5 44 | System.out.println("Эквивалентно c = c + 5: " + c); 45 | c -= 5; // эквивалентно c = c - 5 46 | System.out.println("Эквивалентно c = c - 5: " + c); 47 | c *= 5; // эквивалентно c = c * 5 48 | System.out.println("Эквивалентно c = c * 5: " + c); 49 | c /= 5; // эквивалентно c = c / 5 50 | System.out.println("Эквивалентно c = c / 5: " + c); 51 | c %= 5; // эквивалентно c = c % 5 52 | System.out.println("Эквивалентно c = c % 5: " + c); 53 | 54 | // 2. Математические + - * / % 55 | int math = 6 / 2; 56 | System.out.println("Mathematical operator. Example division " + math); 57 | 58 | int remainder = 6 % 5; // остаток от деления 59 | System.out.println("Остаток от деления: " + remainder); 60 | 61 | // ++ Инкремент - увеличивает значение операнда на 1 62 | // -- Декремент - уменьшает значение операнда на 1 63 | 64 | // 3. Операторы сравнения 65 | // > больше, 66 | // < меньше, 67 | // >= больше или равно, 68 | // <= меньше или равно, 69 | // != не равно, 70 | // == равно 71 | 72 | // 4.Логические операторы 73 | //&& логическое "и" 74 | // || логическое "или" 75 | // ! логическое отрицание 76 | 77 | // 5.Тернарный оператор 78 | int min = (a < b) ? a : b; // если a < b, то min = a, иначе min = b 79 | System.out.println("min = " + min); 80 | 81 | // 6.Оператор instanceof 82 | // – проверяет, является ли объект определенного типа (типа класса или типа интерфейса) и используется 83 | // только для переменных ссылочного объекта. 84 | 85 | String name = "Олег"; 86 | // Следующее вернётся верно, поскольку тип String 87 | boolean result = name instanceof String; 88 | System.out.println(result); 89 | } 90 | } 91 | 92 | -------------------------------------------------------------------------------- /src/test/java/tests/lesson_8/RegistrationTestWithFakerTests.java: -------------------------------------------------------------------------------- 1 | package tests.lesson_8; 2 | 3 | import com.github.javafaker.Faker; 4 | import org.junit.jupiter.api.Test; 5 | import pages.RegistrationFormPage; 6 | import tests.TestBase; 7 | 8 | import java.text.SimpleDateFormat; 9 | import java.util.Date; 10 | import java.util.Locale; 11 | import java.util.Map; 12 | 13 | public class RegistrationTestWithFakerTests extends TestBase { 14 | 15 | RegistrationFormPage registrationFormPage = new RegistrationFormPage(); 16 | Faker faker = new Faker(); 17 | String firstName = faker.address().firstName(); 18 | String lastName = faker.address().lastName(); 19 | String email = faker.internet().emailAddress(); 20 | String number = String.valueOf(faker.number().randomNumber(10, true)); 21 | String address = faker.address().streetAddress(); 22 | String subject = faker.options().option("Accounting", "Maths", "Arts", "English", "Physics", "Chemistry", 23 | "Computer Science", "Economics", "Social Studies", "History", "Civics", "Commerce", "Hindi", "Biology"); 24 | String hobbies = faker.options().option("Reading", "Sports", "Music"); 25 | String gender = faker.demographic().sex(); 26 | static Map mapStateWithCity = Map.of( 27 | "NCR", new String[]{"Delhi", "Gurgaon", "Noida"}, 28 | "Uttar Pradesh", new String[]{"Agra", "Lucknow", "Merrut"}, 29 | "Haryana", new String[]{"Karnal", "Panipat"}, 30 | "Rajasthan", new String[]{"Jaipur", "Jaiselmer"}); 31 | String state = faker.options().option(mapStateWithCity.keySet().toArray()).toString(); 32 | String city = faker.options().option(mapStateWithCity.get(state)); 33 | Date fakerDateOfBirthday = faker.date().birthday(); 34 | String dayOfBirth = (new SimpleDateFormat("dd", Locale.ENGLISH)).format(fakerDateOfBirthday); 35 | String monthOfBirth = (new SimpleDateFormat("MMMM", Locale.ENGLISH)).format(fakerDateOfBirthday); 36 | String yearOfBirth = (new SimpleDateFormat("y", Locale.ENGLISH)).format(fakerDateOfBirthday); 37 | String pictureName = "file.jpeg"; 38 | 39 | 40 | @Test 41 | void Test() { 42 | registrationFormPage.openPage() 43 | .setFirstName(firstName) 44 | .setLastName(lastName) 45 | .setEmail(email) 46 | .setGender(gender) 47 | .setNumber(number) 48 | .setDateOfBirth(dayOfBirth, monthOfBirth, yearOfBirth) 49 | .setSubject(subject) 50 | .setHobies(hobbies) 51 | .setPicture(pictureName) 52 | .setCurrentAddress(address) 53 | .setState(state) 54 | .setCity(city) 55 | .pressSubmit() 56 | .checkResult() 57 | .verifyResultsModalData("Student Name", firstName + " " + lastName) 58 | .verifyResultsModalData("Student Email", email) 59 | .verifyResultsModalData("Gender", gender) 60 | .verifyResultsModalData("Mobile", number) 61 | .verifyResultsModalData("Date of Birth", dayOfBirth + " " + monthOfBirth + "," + yearOfBirth) 62 | .verifyResultsModalData("Subjects", subject) 63 | .verifyResultsModalData("Hobbies", hobbies) 64 | .verifyResultsModalData("Picture", pictureName) 65 | .verifyResultsModalData("Address", address) 66 | .verifyResultsModalData("State and City", state + " " + city); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /src/test/java/tests/lesson_9/ParameterizedTests.java: -------------------------------------------------------------------------------- 1 | package tests.lesson_9; 2 | 3 | import com.codeborne.selenide.Condition; 4 | import org.junit.jupiter.api.BeforeEach; 5 | import org.junit.jupiter.api.DisplayName; 6 | import org.junit.jupiter.params.ParameterizedTest; 7 | import org.junit.jupiter.params.provider.*; 8 | 9 | import java.util.stream.Stream; 10 | 11 | import static com.codeborne.selenide.Selenide.$; 12 | import static com.codeborne.selenide.Selenide.open; 13 | 14 | public class ParameterizedTests { 15 | @BeforeEach 16 | void openSite() { 17 | open("https://github.com/"); 18 | } 19 | 20 | @DisplayName("Поиск названий секций на странице {0} - с помощью ValueSource") 21 | @ParameterizedTest 22 | @ValueSource(strings = {"Product", 23 | "Solutions"}) 24 | void searchSectionValue(String value) { 25 | $(".header-menu-wrapper").shouldHave(Condition.text(value)); 26 | } 27 | 28 | @DisplayName("Поиск названий секций на странице {0} - с помощью EnumSource") 29 | @ParameterizedTest 30 | @EnumSource(SectionNames.class) 31 | void searchSectionEnum(SectionNames value) { 32 | $(".header-menu-wrapper").shouldHave(Condition.text(String.valueOf(value))); 33 | } 34 | 35 | @DisplayName("Поиск названий секций на странице {0} - с помощью MethodSource") 36 | @ParameterizedTest 37 | @MethodSource 38 | void searchSectionMethod(String value, String text) { 39 | $(".header-menu-wrapper").shouldHave(Condition.text(value)); 40 | $(".header-menu-wrapper").shouldHave(Condition.text(text)); // второй аргумент дурацкий потому что ничего не придумала и хотела сделать 2 параметра 41 | } 42 | 43 | static Stream searchSectionMethod() { 44 | return Stream.of( 45 | Arguments.of("Product", "Product"), 46 | Arguments.of("Solutions", "Solutions") 47 | ); 48 | } 49 | 50 | @DisplayName("Поиск названий секций на странице {0} - с помощью CsvSource") 51 | @ParameterizedTest 52 | @CsvSource(value = {"Product, Product", 53 | "Solutions, Solutions"}) 54 | void searchSectionCsv(String value, String text) { 55 | $(".header-menu-wrapper").shouldHave(Condition.text(value)); 56 | $(".header-menu-wrapper").shouldHave(Condition.text(text)); // второй аргумент дурацкий потому что ничего не придумала и хотела сделать 2 параметра 57 | } 58 | 59 | @DisplayName("Поиск названий секций на странице {0} - с помощью CsvFileSource") 60 | @ParameterizedTest 61 | @CsvFileSource(resources = "/test-data.csv", numLinesToSkip = 1) 62 | void searchSectionCsvFile(String value, String text) { 63 | $(".header-menu-wrapper").shouldHave(Condition.text(value)); 64 | $(".header-menu-wrapper").shouldHave(Condition.text(text)); // второй аргумент дурацкий потому что ничего не придумала и хотела сделать 2 параметра 65 | } 66 | } 67 | 68 | 69 | -------------------------------------------------------------------------------- /src/test/java/tests/lesson_9/SectionNames.java: -------------------------------------------------------------------------------- 1 | package tests.lesson_9; 2 | 3 | public enum SectionNames { 4 | PRODUCT, SOLUTIONS 5 | } 6 | -------------------------------------------------------------------------------- /src/test/java/tests/lesson_collections/ListCollection.java: -------------------------------------------------------------------------------- 1 | package tests.lesson_collections; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | public class ListCollection { 7 | ArrayList integerList= new ArrayList<>(List.of(1, 2, 3, 4, 5)); 8 | ArrayList secondList = new ArrayList<>(List.of(11, 22, 33)); 9 | 10 | public void addList(int amount){ 11 | for (int i = integerList.size()+1; i < amount ; i++) { 12 | 13 | System.out.println("Элемент с номером " + i + " добавлен"); 14 | integerList.add(i); 15 | } 16 | System.out.println("Добавлено элементов в List: " + amount); 17 | } 18 | 19 | public void addWithIndex(){ 20 | integerList.add(6, 7); 21 | System.out.println("Добавлен элемент 7 c индексом 6 в List"); 22 | } 23 | 24 | public void secondList(){ 25 | secondList.addAll(integerList); 26 | System.out.println("Первое добавление: " + secondList); 27 | secondList.addAll(1, integerList); 28 | System.out.println("Второе добавление: " + secondList); 29 | } 30 | 31 | public void searchList(int element) { 32 | for (int i = 0; i < secondList.size(); i++) { 33 | int currentElement = secondList.get(i); 34 | if (currentElement == element) { 35 | System.out.println("Элемент найден на позиции рррр" + i); 36 | break; 37 | } 38 | } 39 | } 40 | 41 | public void getSize(){ 42 | System.out.println(integerList.size() + "вывод элементов"); 43 | System.out.println( integerList + "вывод элементов"); 44 | } 45 | 46 | public void removeElement(int element){ 47 | secondList.remove(element); 48 | System.out.println(secondList); 49 | System.out.println("Элемент " + element + " удален"); 50 | } 51 | 52 | 53 | public void jj(int element){ 54 | for (int i = secondList.size() - 1; i >= 0; i--) { 55 | int currentElement = secondList.get(i); 56 | if (currentElement == element) { 57 | System.out.println("Элемент найден на позиции " + i); 58 | break; 59 | } 60 | } 61 | 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /src/test/java/tests/lesson_collections/Main.java: -------------------------------------------------------------------------------- 1 | package tests.lesson_collections; 2 | 3 | public class Main { 4 | public static void main(String[] args){ 5 | ListCollection list = new ListCollection(); 6 | list.addList(7); 7 | list.addWithIndex(); 8 | list.getSize(); 9 | list.secondList(); 10 | list.searchList(11); 11 | list.jj(7); 12 | list.removeElement(5); 13 | 14 | QueueCollection queue = new QueueCollection(); 15 | queue.addQueue("Henry"); 16 | queue.searchQueue("Jerry"); 17 | queue.removeQueueItem(); 18 | 19 | MapCollection map = new MapCollection(); 20 | map.addMap("Moscow"); 21 | map.searchMap(); 22 | map.removeMap(); 23 | 24 | SetCollection set = new SetCollection(); 25 | set.addSet(744); 26 | set.searchSet(744); 27 | set.removeSetItem(111); 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/test/java/tests/lesson_collections/MapCollection.java: -------------------------------------------------------------------------------- 1 | package tests.lesson_collections; 2 | 3 | import java.util.HashMap; 4 | 5 | public class MapCollection { 6 | HashMap map = new HashMap<>(); 7 | 8 | public void addMap(String element){ 9 | int i =0; 10 | do { map.put(i, element); 11 | i++; 12 | }while (i < 10); 13 | System.out.println(map); 14 | } 15 | 16 | public void searchMap(){ 17 | map.replace(3, "Poland"); 18 | map.containsKey(3); 19 | System.out.println(map); 20 | } 21 | 22 | public void removeMap(){ 23 | map.remove(4, "Moscow"); 24 | System.out.println(map.get(4)); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/test/java/tests/lesson_collections/QueueCollection.java: -------------------------------------------------------------------------------- 1 | package tests.lesson_collections; 2 | 3 | import java.util.*; 4 | 5 | public class QueueCollection { 6 | Queue stringQueue = new LinkedList<>(List.of("Amigo", "Tom", "Veronika")); 7 | 8 | public void addQueue(String element){ 9 | stringQueue.add(element); 10 | System.out.println("Добавлен эелемент в очередь " + element); 11 | } 12 | 13 | public void searchQueue(String element){ 14 | while (stringQueue.contains("Tom")){ 15 | stringQueue.offer(element); 16 | System.out.println("Если есть Tom, то " + element); 17 | break; 18 | } 19 | System.out.println(stringQueue); 20 | } 21 | 22 | public void removeQueueItem(){ 23 | stringQueue.remove(); 24 | System.out.println("Удаляет элемент который был добавлен первым то есть Amigo " + stringQueue); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/test/java/tests/lesson_collections/SetCollection.java: -------------------------------------------------------------------------------- 1 | package tests.lesson_collections; 2 | 3 | import java.util.HashSet; 4 | import java.util.Set; 5 | 6 | public class SetCollection { 7 | Set set = new HashSet<>(Set.of(111, 222, 333)); 8 | 9 | public void addSet(int amount){ 10 | set.add(amount); 11 | for (Integer i : set){ 12 | System.out.println(i); 13 | } 14 | } 15 | 16 | public void searchSet(int amount){ 17 | if(set.contains(amount)){ 18 | System.out.println("Набор содержит " + amount); 19 | } 20 | else { 21 | System.out.println("Набор не содержит " + amount); 22 | } 23 | } 24 | 25 | public void removeSetItem(int amount){ 26 | set.remove(amount); 27 | System.out.println("Элемент удален " + amount); 28 | System.out.println(set); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/test/resources/allure.properties: -------------------------------------------------------------------------------- 1 | allure.results.directory = build/allure-results -------------------------------------------------------------------------------- /src/test/resources/file.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viktorinka/getting-started-java/27ebec6693d0b0f67373db272b6e9f06cc5114dd/src/test/resources/file.jpeg -------------------------------------------------------------------------------- /src/test/resources/listUsersResponseScheme.json: -------------------------------------------------------------------------------- 1 | { 2 | "page": 2, 3 | "per_page": 6, 4 | "total": 12, 5 | "total_pages": 2, 6 | "data": [ 7 | { 8 | "id": 7, 9 | "email": "michael.lawson@reqres.in", 10 | "first_name": "Michael", 11 | "last_name": "Lawson", 12 | "avatar": "https://reqres.in/img/faces/7-image.jpg" 13 | }, 14 | { 15 | "id": 8, 16 | "email": "lindsay.ferguson@reqres.in", 17 | "first_name": "Lindsay", 18 | "last_name": "Ferguson", 19 | "avatar": "https://reqres.in/img/faces/8-image.jpg" 20 | }, 21 | { 22 | "id": 9, 23 | "email": "tobias.funke@reqres.in", 24 | "first_name": "Tobias", 25 | "last_name": "Funke", 26 | "avatar": "https://reqres.in/img/faces/9-image.jpg" 27 | }, 28 | { 29 | "id": 10, 30 | "email": "byron.fields@reqres.in", 31 | "first_name": "Byron", 32 | "last_name": "Fields", 33 | "avatar": "https://reqres.in/img/faces/10-image.jpg" 34 | }, 35 | { 36 | "id": 11, 37 | "email": "george.edwards@reqres.in", 38 | "first_name": "George", 39 | "last_name": "Edwards", 40 | "avatar": "https://reqres.in/img/faces/11-image.jpg" 41 | }, 42 | { 43 | "id": 12, 44 | "email": "rachel.howell@reqres.in", 45 | "first_name": "Rachel", 46 | "last_name": "Howell", 47 | "avatar": "https://reqres.in/img/faces/12-image.jpg" 48 | } 49 | ], 50 | "support": { 51 | "url": "https://reqres.in/#support-heading", 52 | "text": "To keep ReqRes free, contributions towards server costs are appreciated!" 53 | } 54 | } -------------------------------------------------------------------------------- /src/test/resources/person.json: -------------------------------------------------------------------------------- 1 | { 2 | "name":"Jack", 3 | "age":30, 4 | "isMarried": false, 5 | "contactNumbers":[ 6 | { 7 | "type":"Home", 8 | "number":"123 123-123" 9 | }, 10 | { 11 | "type":"Office", 12 | "number":"321 321-321" 13 | } 14 | ], 15 | "spouse":null, 16 | "favoriteSports":[ 17 | "Football", 18 | "Cricket" 19 | ], 20 | "car": { 21 | "color": "red", 22 | "model": 123 23 | } 24 | } -------------------------------------------------------------------------------- /src/test/resources/test-data.csv: -------------------------------------------------------------------------------- 1 | value text 2 | Product, Product 3 | Solutions, Solutions -------------------------------------------------------------------------------- /src/test/resources/test_archive.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/viktorinka/getting-started-java/27ebec6693d0b0f67373db272b6e9f06cc5114dd/src/test/resources/test_archive.zip -------------------------------------------------------------------------------- /src/test/resources/tpl/request.ftl: -------------------------------------------------------------------------------- 1 | 2 | <#-- @ftlvariable name="data" type="io.qameta.allure.attachment.http.HttpRequestAttachment" --> 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 22 | 23 | 24 |
25 |
<#if data.method??>${data.method}<#else>GET: <#if data.url??>${data.url}<#else>Unknown
26 |
27 | 28 | <#if data.body??> 29 |

Body

30 |
31 |
${data.body}
32 |
33 | 34 | 35 | <#if (data.headers)?has_content> 36 |

Headers

37 |
38 | <#list data.headers as name, value> 39 |
40 |
${name}: ${value}
41 |
42 | 43 |
44 | 45 | 46 | 47 | <#if (data.cookies)?has_content> 48 |

Cookies

49 |
50 | <#list data.cookies as name, value> 51 |
52 |
${name}: ${value}
53 |
54 | 55 |
56 | 57 | 58 | <#if data.curl??> 59 |

Curl

60 |
61 |
${data.curl}
62 |
63 | 64 | 65 | -------------------------------------------------------------------------------- /src/test/resources/tpl/response.ftl: -------------------------------------------------------------------------------- 1 | 2 | <#-- @ftlvariable name="data" type="io.qameta.allure.attachment.http.HttpResponseAttachment" --> 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 22 | 23 | 24 |

Status code

<#if data.responseCode??> 25 |
${data.responseCode}
26 | <#else>Unknown
27 | <#if data.url??> 28 | 29 |
30 |
${data.url}
31 |
32 | 33 | <#if (data.headers)?has_content> 34 |

Headers

35 |
36 | <#list data.headers as name, value> 37 |
38 |
${name}: ${value}
39 |
40 | 41 |
42 | 43 | 44 | <#if data.body??> 45 |

Body

46 |
47 |
${data.body}
48 |
49 | 50 | 51 | <#if (data.cookies)?has_content> 52 |

Cookies

53 |
54 | <#list data.cookies as name, value> 55 |
56 |
${name}: ${value}
57 |
58 | 59 |
60 | 61 | 62 | --------------------------------------------------------------------------------