Compare commits
1 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
b3e391167b |
54
pom.xml
54
pom.xml
@ -1,30 +1,58 @@
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
<project
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
|
||||
http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<groupId>ru.ibs</groupId>
|
||||
<artifactId>sel1</artifactId>
|
||||
<artifactId>appline-test-project</artifactId>
|
||||
<version>1.0-SNAPSHOT</version>
|
||||
<name>Archetype - sel1</name>
|
||||
<url>https://git.goodtester.ru</url>
|
||||
|
||||
<properties>
|
||||
<maven.compiler.source>11</maven.compiler.source>
|
||||
<maven.compiler.target>11</maven.compiler.target>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<!-- JUnit -->
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.13.2</version>
|
||||
</dependency>
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/org.seleniumhq.selenium/selenium-java -->
|
||||
<!-- Selenium -->
|
||||
<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>
|
||||
<groupId>commons-configuration</groupId>
|
||||
<artifactId>commons-configuration</artifactId>
|
||||
<version>1.10</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>3.1.2</version>
|
||||
<configuration>
|
||||
<includes>
|
||||
<include>**/*Test.java</include>
|
||||
</includes>
|
||||
<systemPropertyVariables>
|
||||
<env.properties>src/test/resources/environment.properties</env.properties>
|
||||
</systemPropertyVariables>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
|
||||
|
@ -1,17 +1,16 @@
|
||||
package ru.ibs.tests;
|
||||
|
||||
import org.junit.*;
|
||||
import org.openqa.selenium.*;
|
||||
import org.openqa.selenium.By;
|
||||
import org.openqa.selenium.WebDriver;
|
||||
import org.openqa.selenium.chrome.ChromeDriver;
|
||||
import org.openqa.selenium.interactions.Actions;
|
||||
import org.openqa.selenium.support.ui.*;
|
||||
|
||||
import java.time.Duration;
|
||||
|
||||
public class ApplineBusinessTripTest {
|
||||
|
||||
private WebDriver driver;
|
||||
private WebDriverWait wait;
|
||||
private LoginPage loginPage;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
@ -20,126 +19,47 @@ public class ApplineBusinessTripTest {
|
||||
driver = new ChromeDriver();
|
||||
driver.manage().window().maximize();
|
||||
driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(10));
|
||||
wait = new WebDriverWait(driver, Duration.ofSeconds(10));
|
||||
|
||||
driver.get("http://training.appline.ru/user/login");
|
||||
|
||||
loginPage = new LoginPage(driver);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void applineLoginScenario() {
|
||||
// Логин
|
||||
fillInputField(By.id("prependedInput"), "Irina Filippova");
|
||||
fillInputField(By.id("prependedInput2"), "testing");
|
||||
DashboardPage dashboardPage = loginPage.login("Irina Filippova", "testing");
|
||||
Assert.assertTrue("Dashboard not loaded", dashboardPage.isDashboardLoaded());
|
||||
|
||||
WebElement loginButton = driver.findElement(By.xpath("//button[@type='submit']"));
|
||||
waitUntilClickable(loginButton).click();
|
||||
BusinessTripPage businessTripPage = dashboardPage.goToBusinessTrip();
|
||||
Assert.assertTrue("Trips page not loaded", businessTripPage.isTripsPageLoaded());
|
||||
|
||||
// Проверка заголовка
|
||||
WebElement dashboardTitle = wait.until(ExpectedConditions.visibilityOfElementLocated(
|
||||
By.xpath("//h1[@class='oro-subtitle' and contains(text(), 'Панель быстрого запуска')]")));
|
||||
Assert.assertTrue("Заголовок 'Панель быстрого запуска' не найден", dashboardTitle.isDisplayed());
|
||||
businessTripPage.openCreateTripForm();
|
||||
|
||||
// Наведение на меню "Расходы" и клик по "Командировки"
|
||||
Actions actions = new Actions(driver);
|
||||
WebElement expensesMenu = driver.findElement(By.xpath("//span[text()='Расходы']/ancestor::li"));
|
||||
actions.moveToElement(expensesMenu).perform();
|
||||
businessTripPage.selectDepartment("Отдел внутренней разработки");
|
||||
businessTripPage.selectOrganization("Edge");
|
||||
businessTripPage.setTicketsCheckbox(true);
|
||||
businessTripPage.fillCity("Дмитров");
|
||||
|
||||
WebElement businessTrip = wait.until(ExpectedConditions.elementToBeClickable(
|
||||
By.xpath("//a[@href='/business-trip/']/span[text()='Командировки']")));
|
||||
businessTrip.click();
|
||||
businessTripPage.fillDate(
|
||||
By.xpath("//input[@placeholder='Укажите дату' and contains(@id, 'departureDatePlan')]"),
|
||||
"01.01.2025"
|
||||
);
|
||||
|
||||
wait.until(ExpectedConditions.invisibilityOfElementLocated(By.cssSelector("div.loader-overlay")));
|
||||
businessTripPage.fillDate(
|
||||
By.xpath("//input[@placeholder='Укажите дату' and contains(@id, 'returnDatePlan')]"),
|
||||
"10.01.2025"
|
||||
);
|
||||
|
||||
WebElement tripsHeader = wait.until(ExpectedConditions.visibilityOfElementLocated(
|
||||
By.xpath("//h1[contains(text(), 'Командировки')]")));
|
||||
Assert.assertTrue(tripsHeader.isDisplayed());
|
||||
businessTripPage.saveAndClose();
|
||||
|
||||
// Клик по "Создать командировку"
|
||||
WebElement containerDiv = wait.until(ExpectedConditions.elementToBeClickable(
|
||||
By.cssSelector("div.pull-left.btn-group.icons-holder")
|
||||
));
|
||||
|
||||
containerDiv.click();
|
||||
|
||||
// Проверка заголовка "Создать командировку"
|
||||
WebElement createTripHeader = wait.until(ExpectedConditions.visibilityOfElementLocated(
|
||||
By.xpath("//h1[@class='user-name' and contains(text(), 'Создать командировку')]")));
|
||||
Assert.assertTrue(createTripHeader.isDisplayed());
|
||||
|
||||
// Подразделение
|
||||
WebElement departmentSelect = driver.findElement(By.xpath("//select[contains(@name,'businessUnit')]"));
|
||||
new Select(departmentSelect).selectByVisibleText("Отдел внутренней разработки");
|
||||
|
||||
// Принимающая организация
|
||||
driver.findElement(By.id("company-selector-show")).click();
|
||||
|
||||
WebElement organizationSpan = wait.until(ExpectedConditions.elementToBeClickable(
|
||||
By.cssSelector("span.select2-chosen")
|
||||
));
|
||||
organizationSpan.click();
|
||||
|
||||
WebElement input = wait.until(ExpectedConditions.visibilityOfElementLocated(
|
||||
By.cssSelector("input.select2-input")
|
||||
));
|
||||
|
||||
input.sendKeys("Edge");
|
||||
wait.until(ExpectedConditions.visibilityOfElementLocated(By.xpath("//span[@class='select2-match' and text()='Edge']"))).click();
|
||||
|
||||
// Чекбокс "Заказ билетов"
|
||||
WebElement ticketsCheckbox = driver.findElement(By.xpath("//label[contains(text(),'Заказ билетов')]/preceding-sibling::input"));
|
||||
if (!ticketsCheckbox.isSelected()) {
|
||||
ticketsCheckbox.click();
|
||||
}
|
||||
|
||||
// Заполнить города
|
||||
fillInputField(By.xpath("//input[contains(@id,'arrivalCity')]"), "Дмитров");
|
||||
|
||||
wait.until(ExpectedConditions.invisibilityOfElementLocated(By.cssSelector("div.loader-overlay")));
|
||||
// Даты
|
||||
By departureDateLocator = By.xpath("//input[@placeholder='Укажите дату' and contains(@id, 'departureDatePlan')]");
|
||||
By returnDateLocator = By.xpath("//input[@placeholder='Укажите дату' and contains(@id, 'returnDatePlan')]");
|
||||
|
||||
fillDateField(departureDateLocator, "01.01.2025");
|
||||
fillDateField(returnDateLocator, "10.01.2025");
|
||||
|
||||
// Сохранить и закрыть
|
||||
WebElement saveBtn = driver.findElement(By.xpath("//button[contains(text(),'Сохранить и закрыть')]"));
|
||||
scrollToElement(saveBtn);
|
||||
saveBtn.click();
|
||||
|
||||
WebElement errorMsg = wait.until(ExpectedConditions.visibilityOfElementLocated(
|
||||
By.xpath("//span[@class='validation-failed' and contains(text(), 'Список командируемых сотрудников не может быть пустым')]")));
|
||||
Assert.assertTrue("Ожидаемая ошибка не найдена", errorMsg.isDisplayed());
|
||||
Assert.assertTrue("Expected validation error not shown",
|
||||
businessTripPage.isErrorDisplayed("Список командируемых сотрудников не может быть пустым"));
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() {
|
||||
if (driver != null)
|
||||
if (driver != null) {
|
||||
driver.quit();
|
||||
}
|
||||
|
||||
private WebElement waitUntilClickable(WebElement element) {
|
||||
return wait.until(ExpectedConditions.elementToBeClickable(element));
|
||||
}
|
||||
|
||||
private void fillInputField(By locator, String value) {
|
||||
WebElement element = wait.until(ExpectedConditions.visibilityOfElementLocated(locator));
|
||||
scrollToElement(element);
|
||||
element.clear();
|
||||
element.sendKeys(value);
|
||||
Assert.assertEquals("Поле заполнено некорректно", value, element.getAttribute("value"));
|
||||
}
|
||||
|
||||
private void fillDateField(By locator, String dateValue) {
|
||||
WebElement dateInput = wait.until(ExpectedConditions.elementToBeClickable(locator));
|
||||
scrollToElement(dateInput);
|
||||
dateInput.clear();
|
||||
dateInput.sendKeys(dateValue);
|
||||
dateInput.sendKeys(Keys.TAB);
|
||||
Assert.assertEquals("Поле даты заполнено некорректно", dateValue, dateInput.getAttribute("value"));
|
||||
}
|
||||
|
||||
private void scrollToElement(WebElement element) {
|
||||
((JavascriptExecutor) driver).executeScript("arguments[0].scrollIntoView(true);", element);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user