-
Notifications
You must be signed in to change notification settings - Fork 65
Akita steps #146
Open
Kutueva
wants to merge
4
commits into
alfa-laboratory:master
Choose a base branch
from
Kutueva:test
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Akita steps #146
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
#Sat Jan 12 21:22:14 MSK 2019 | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-bin.zip | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,84 +1,84 @@ | ||
@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 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= | ||
|
||
@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 | ||
@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 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= | ||
@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 |
58 changes: 58 additions & 0 deletions
58
src/main/java/ru/alfabank/alfatest/cucumber/utils/DateUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package ru.alfabank.alfatest.cucumber.utils; | ||
import java.time.LocalDate; | ||
import java.time.format.DateTimeFormatter; | ||
|
||
public class DateUtils { | ||
|
||
public static LocalDate yesterday() { | ||
return LocalDate.now().minusDays(1); | ||
} | ||
public static LocalDate tomorrow() { | ||
return LocalDate.now().plusDays(1); | ||
} | ||
public static LocalDate today() { | ||
return LocalDate.now(); | ||
} | ||
public static LocalDate monthAgo() { | ||
return LocalDate.now().minusMonths(1); | ||
} | ||
public static LocalDate threeMonthAgo() { | ||
return LocalDate.now().minusMonths(3); | ||
} | ||
public static LocalDate yearAgo() { | ||
return LocalDate.now().minusYears(1); | ||
} | ||
public static LocalDate monthAhead() { | ||
return LocalDate.now().plusMonths(1); | ||
} | ||
public static LocalDate threeMonthAhead() { | ||
return LocalDate.now().plusMonths(3); | ||
} | ||
public static LocalDate yearAhead() { | ||
return LocalDate.now().plusYears(1); | ||
} | ||
public static LocalDate convertStringDateToValues(String expectedDate) { | ||
switch (expectedDate) { | ||
case "сегодня": | ||
return today(); | ||
case "вчера": | ||
return yesterday(); | ||
case "завтра": | ||
return tomorrow(); | ||
case "месяц назад": | ||
return monthAgo(); | ||
case "3 месяца назад": | ||
return threeMonthAgo(); | ||
case "год назад": | ||
return yearAgo(); | ||
case "месяц вперед": | ||
return monthAhead(); | ||
case "3 месяца вперед": | ||
return threeMonthAhead(); | ||
case "год вперед": | ||
return yearAhead(); | ||
default: | ||
return LocalDate.parse(expectedDate, DateTimeFormatter.ofPattern("dd.MM.yyyy")); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Форматтер выглядит как штука, которую имеет смысл как минимум вынести из конвертера. |
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,8 +21,13 @@ | |
import org.openqa.selenium.By; | ||
|
||
import java.io.File; | ||
import java.time.LocalDate; | ||
import java.time.format.DateTimeFormatter; | ||
|
||
import static com.codeborne.selenide.Selenide.$; | ||
import static org.hamcrest.CoreMatchers.containsString; | ||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static ru.alfabank.alfatest.cucumber.utils.DateUtils.convertStringDateToValues; | ||
import static ru.alfabank.tests.core.helpers.PropertyLoader.loadValueFromFileOrPropertyOrVariableOrDefault; | ||
|
||
/** | ||
|
@@ -82,4 +87,30 @@ public void clickOnButtonAndUploadFile(String buttonName, String fileName) { | |
File attachmentFile = new File(file); | ||
akitaScenario.getCurrentPage().getElement(buttonName).uploadFile(attachmentFile); | ||
} | ||
|
||
/** | ||
* Выполняется ввод даты в поле | ||
* Дата преобразуется из значения "сегодня", "вчера", "завтра", "месяц назад", "3 месяца назад", "год назад", "месяц вперед", "3 месяца вперед", "год вперед" | ||
*/ | ||
@И("^в поле \"([^\"]*)\" введено и преобразовано в дату значение \"([^\"]*)\"$") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Что случится, если сунуть сюда, скажем, стрингу «три месяца назад»? |
||
public void enterDateInField(String fieldName, String expectedDate) { | ||
SelenideElement valueInput = akitaScenario.getCurrentPage().getElement(fieldName); | ||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd.MM.yyyy"); | ||
LocalDate actualdate = convertStringDateToValues(expectedDate); | ||
clearField(fieldName); | ||
valueInput.setValue(actualdate.format(formatter)); | ||
} | ||
|
||
/** | ||
* Проверяется, что поле содержит дату | ||
* Дата преобразуется из значения "сегодня", "вчера", "завтра", "месяц назад", "3 месяца назад", "год назад", "месяц вперед", "3 месяца вперед", "год вперед" | ||
*/ | ||
@И("^(?:поле|элемент) \"([^\"]*)\" содержит дату \"(.*)\"$") | ||
public void checkDateInField(String elementName, String expectedDate) { | ||
expectedDate = getPropertyOrStringVariableOrValue(expectedDate); | ||
LocalDate actualdate = convertStringDateToValues(expectedDate); | ||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd.MM.yyyy"); | ||
String actualValue = akitaScenario.getCurrentPage().getAnyElementText(elementName); | ||
assertThat(String.format("Поле [%s] не содержит значение [%s]", elementName, actualdate.format(formatter)), actualValue, containsString(String.valueOf(actualdate.format(formatter)))); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -222,4 +222,13 @@ public void checkIfValueFromVariableEqualPropertyVariable(String envVarible, Str | |
public void expressionExpression(String expression) { | ||
akitaScenario.getVars().evaluate("assert(" + expression + ")"); | ||
} | ||
|
||
/** | ||
* Проверка что в переменной содержится ожидаемое количество символов | ||
*/ | ||
@Тогда("^в переменной \"([^\"]*)\" содержится (\\d+) символов$") | ||
public void checkInVariableContainsCharacters(String variableName, int numbersCount) { | ||
assertThat("Количество символов в поле " + akitaScenario.getVar(variableName).toString().length() + "должно быть " + numbersCount, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. String.format? |
||
akitaScenario.getVar(variableName).toString().length(), equalTo(numbersCount)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Выглядит как enum с методом, так почему бы и не сделать enum? А если ещё и вместо свичкейса сделать EnumMap, то и шанс отстрелить себе ногу существенно снизится.