v2
This commit is contained in:
parent
272bb61fb9
commit
7f7ec064ef
5
.idea/.gitignore
generated
vendored
5
.idea/.gitignore
generated
vendored
@ -1,5 +0,0 @@
|
|||||||
# Default ignored files
|
|
||||||
/shelf/
|
|
||||||
/workspace.xml
|
|
||||||
# Environment-dependent path to Maven home directory
|
|
||||||
/mavenHomeManager.xml
|
|
20
pom.xml
20
pom.xml
@ -6,5 +6,25 @@
|
|||||||
<version>1.0-SNAPSHOT</version>
|
<version>1.0-SNAPSHOT</version>
|
||||||
<name>Archetype - sel1</name>
|
<name>Archetype - sel1</name>
|
||||||
<url>https://git.goodtester.ru</url>
|
<url>https://git.goodtester.ru</url>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
|
||||||
|
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.seleniumhq.selenium</groupId>
|
||||||
|
<artifactId>selenium-java</artifactId>
|
||||||
|
<version>4.33.0</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<!-- https://mvnrepository.com/artifact/junit/junit -->
|
||||||
|
<dependency>
|
||||||
|
<groupId>junit</groupId>
|
||||||
|
<artifactId>junit</artifactId>
|
||||||
|
<version>4.13.1</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
||||||
|
89
src/test/java/ru/ibs/tests/TestTrainingAppline.java
Normal file
89
src/test/java/ru/ibs/tests/TestTrainingAppline.java
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
package ru.ibs.tests;
|
||||||
|
|
||||||
|
import org.junit.After;
|
||||||
|
import org.junit.Assert;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.openqa.selenium.*;
|
||||||
|
import org.openqa.selenium.chrome.ChromeDriver;
|
||||||
|
import org.openqa.selenium.support.ui.ExpectedConditions;
|
||||||
|
import org.openqa.selenium.support.ui.WebDriverWait;
|
||||||
|
|
||||||
|
import java.time.Duration;
|
||||||
|
|
||||||
|
public class TestTrainingAppline {
|
||||||
|
|
||||||
|
private WebDriver driver;
|
||||||
|
private WebDriverWait wait;
|
||||||
|
Duration default_timeout = Duration.ofSeconds(10);
|
||||||
|
Duration default_sleep = Duration.ofMillis(500);
|
||||||
|
String fieldXPath = "//input[@id='%s']";
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void before() {
|
||||||
|
// win
|
||||||
|
System.setProperty("webdriver.chrome.driver", "src/test/resources/chromedriver.exe");
|
||||||
|
|
||||||
|
driver = new ChromeDriver();
|
||||||
|
driver.manage().window().maximize();
|
||||||
|
driver.manage().timeouts().pageLoadTimeout(Duration.ofSeconds(30));
|
||||||
|
driver.manage().timeouts().scriptTimeout(Duration.ofSeconds(30));
|
||||||
|
|
||||||
|
wait = new WebDriverWait(driver, default_timeout, default_sleep);
|
||||||
|
|
||||||
|
String baseUrl = "http://training.appline.ru/user/login";
|
||||||
|
driver.get(baseUrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void applineLoginScenario() throws InterruptedException {
|
||||||
|
|
||||||
|
WebElement usernameField = driver.findElement(By.xpath(String.format(fieldXPath, "prependedInput")));
|
||||||
|
fillInputField(usernameField, "Irina Filippova");
|
||||||
|
|
||||||
|
WebElement passwordField = driver.findElement(By.xpath(String.format(fieldXPath, "prependedInput2")));
|
||||||
|
fillInputField(passwordField, "testing");
|
||||||
|
|
||||||
|
// Нажать на кнопку Войти
|
||||||
|
String buttonLocator = "//button[@type='submit']";
|
||||||
|
WebElement loginButton = driver.findElement(By.xpath(buttonLocator));
|
||||||
|
scrollToElementJs(loginButton);
|
||||||
|
waitUtilElementToBeClickable(loginButton);
|
||||||
|
loginButton.click();
|
||||||
|
|
||||||
|
Thread.sleep(5000);
|
||||||
|
}
|
||||||
|
|
||||||
|
@After
|
||||||
|
public void after() {
|
||||||
|
driver.quit();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void scrollToElementJs(WebElement element) {
|
||||||
|
JavascriptExecutor javascriptExecutor = (JavascriptExecutor) driver;
|
||||||
|
javascriptExecutor.executeScript("arguments[0].scrollIntoView(true);", element);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void waitUtilElementToBeClickable(WebElement element) {
|
||||||
|
wait.until(ExpectedConditions.elementToBeClickable(element));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void waitUtilElementToBeVisible(By locator) {
|
||||||
|
wait.until(ExpectedConditions.visibilityOfElementLocated(locator));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void waitUtilElementToBeVisible(WebElement element) {
|
||||||
|
wait.until(ExpectedConditions.visibilityOf(element));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void fillInputField(WebElement element, String value) {
|
||||||
|
scrollToElementJs(element);
|
||||||
|
waitUtilElementToBeClickable(element);
|
||||||
|
element.click();
|
||||||
|
element.clear();
|
||||||
|
element.sendKeys(value);
|
||||||
|
boolean checkFlag = wait.until(ExpectedConditions.attributeContains(element, "value", value));
|
||||||
|
Assert.assertTrue("Поле было заполнено некорректно", checkFlag);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user