Compare commits
1 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
3f5847053e |
33
README.md
33
README.md
@ -1,33 +0,0 @@
|
|||||||
Изменён pom файл для отображения allure отчётов.
|
|
||||||
Успешно собирается в allure-reports/
|
|
||||||
|
|
||||||
Добавлена возможность скриншотов по шагам
|
|
||||||
```
|
|
||||||
AllureUtils.attachScreenshot()
|
|
||||||
```
|
|
||||||
|
|
||||||
а также при ошибках
|
|
||||||
|
|
||||||
```@Rule
|
|
||||||
public MyAllureListener allureListener = new MyAllureListener();
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
```
|
|
||||||
public class MyAllureListener extends TestWatcher {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void failed(Throwable e, Description description) {
|
|
||||||
takeScreenshot();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Attachment(value = "Screenshot on failure", type = "image/png")
|
|
||||||
public byte[] takeScreenshot() {
|
|
||||||
return ((TakesScreenshot) DriverManager.getDriverManager().getDriver())
|
|
||||||
.getScreenshotAs(OutputType.BYTES);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
```
|
|
||||||
|
|
||||||

|
|
||||||
|
|
81
pom.xml
81
pom.xml
@ -24,88 +24,7 @@
|
|||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>io.qameta.allure</groupId>
|
|
||||||
<artifactId>allure-junit4</artifactId>
|
|
||||||
<version>2.13.5</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.aspectj</groupId>
|
|
||||||
<artifactId>aspectjweaver</artifactId>
|
|
||||||
<version>1.9.7</version>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
|
||||||
<plugins>
|
|
||||||
<!-- Компиляция -->
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
|
||||||
<version>3.8.1</version>
|
|
||||||
<configuration>
|
|
||||||
<source>8</source>
|
|
||||||
<target>8</target>
|
|
||||||
<encoding>UTF-8</encoding>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
|
|
||||||
<!-- Тесты + сбор Allure результатов -->
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-surefire-plugin</artifactId>
|
|
||||||
<version>3.0.0-M5</version>
|
|
||||||
<configuration>
|
|
||||||
<testFailureIgnore>true</testFailureIgnore>
|
|
||||||
<argLine>
|
|
||||||
-javaagent:"${settings.localRepository}/org/aspectj/aspectjweaver/1.9.7/aspectjweaver-1.9.7.jar"
|
|
||||||
</argLine>
|
|
||||||
<systemPropertyVariables>
|
|
||||||
<allure.results.directory>${project.build.directory}/allure-results</allure.results.directory>
|
|
||||||
</systemPropertyVariables>
|
|
||||||
<properties>
|
|
||||||
<property>
|
|
||||||
<name>listener</name>
|
|
||||||
<value>io.qameta.allure.junit4.AllureJunit4</value>
|
|
||||||
</property>
|
|
||||||
</properties>
|
|
||||||
</configuration>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.aspectj</groupId>
|
|
||||||
<artifactId>aspectjweaver</artifactId>
|
|
||||||
<version>1.9.7</version>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
|
|
||||||
</plugin>
|
|
||||||
|
|
||||||
<!-- Формирование отчёта -->
|
|
||||||
<plugin>
|
|
||||||
<groupId>io.qameta.allure</groupId>
|
|
||||||
<artifactId>allure-maven</artifactId>
|
|
||||||
<version>2.10.0</version>
|
|
||||||
<configuration>
|
|
||||||
<reportVersion>2.10.0</reportVersion>
|
|
||||||
<resultsDirectory>${project.build.directory}/allure-results</resultsDirectory>
|
|
||||||
<reportDirectory>${project.build.directory}/allure-report</reportDirectory>
|
|
||||||
</configuration>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<id>report</id>
|
|
||||||
<phase>verify</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>report</goal>
|
|
||||||
</goals>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
|
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
||||||
|
@ -1,15 +0,0 @@
|
|||||||
package ru.ibs.framework.utils;
|
|
||||||
|
|
||||||
import io.qameta.allure.Attachment;
|
|
||||||
import org.openqa.selenium.OutputType;
|
|
||||||
import org.openqa.selenium.TakesScreenshot;
|
|
||||||
import ru.ibs.framework.managers.DriverManager;
|
|
||||||
|
|
||||||
public class AllureUtils {
|
|
||||||
|
|
||||||
@Attachment(value = "Screenshot at step", type = "image/png")
|
|
||||||
public static byte[] attachScreenshot() {
|
|
||||||
return ((TakesScreenshot) DriverManager.getDriverManager().getDriver())
|
|
||||||
.getScreenshotAs(OutputType.BYTES);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,22 +0,0 @@
|
|||||||
package ru.ibs.framework.utils;
|
|
||||||
|
|
||||||
import io.qameta.allure.Attachment;
|
|
||||||
import org.junit.rules.TestWatcher;
|
|
||||||
import org.junit.runner.Description;
|
|
||||||
import org.openqa.selenium.OutputType;
|
|
||||||
import org.openqa.selenium.TakesScreenshot;
|
|
||||||
import ru.ibs.framework.managers.DriverManager;
|
|
||||||
|
|
||||||
public class MyAllureListener extends TestWatcher {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void failed(Throwable e, Description description) {
|
|
||||||
takeScreenshot();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Attachment(value = "Screenshot on failure", type = "image/png")
|
|
||||||
public byte[] takeScreenshot() {
|
|
||||||
return ((TakesScreenshot) DriverManager.getDriverManager().getDriver())
|
|
||||||
.getScreenshotAs(OutputType.BYTES);
|
|
||||||
}
|
|
||||||
}
|
|
@ -3,8 +3,6 @@ package ru.ibs.tests;
|
|||||||
import org.junit.*;
|
import org.junit.*;
|
||||||
import org.openqa.selenium.By;
|
import org.openqa.selenium.By;
|
||||||
import ru.ibs.framework.managers.DriverManager;
|
import ru.ibs.framework.managers.DriverManager;
|
||||||
import ru.ibs.framework.utils.AllureUtils;
|
|
||||||
import ru.ibs.framework.utils.MyAllureListener;
|
|
||||||
|
|
||||||
public class ApplineBusinessTripTest extends BaseTests {
|
public class ApplineBusinessTripTest extends BaseTests {
|
||||||
|
|
||||||
@ -12,9 +10,6 @@ public class ApplineBusinessTripTest extends BaseTests {
|
|||||||
private DashboardPage dashboardPage;
|
private DashboardPage dashboardPage;
|
||||||
private BusinessTripPage businessTripPage;
|
private BusinessTripPage businessTripPage;
|
||||||
|
|
||||||
@Rule
|
|
||||||
public MyAllureListener allureListener = new MyAllureListener();
|
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
// Получаем драйвер из DriverManager (инициализирован в BaseTests)
|
// Получаем драйвер из DriverManager (инициализирован в BaseTests)
|
||||||
@ -26,7 +21,6 @@ public class ApplineBusinessTripTest extends BaseTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void applineLoginScenario() {
|
public void applineLoginScenario() {
|
||||||
AllureUtils.attachScreenshot();
|
|
||||||
dashboardPage = loginPage.login("Irina Filippova", "testing");
|
dashboardPage = loginPage.login("Irina Filippova", "testing");
|
||||||
Assert.assertTrue("Dashboard not loaded", dashboardPage.isDashboardLoaded());
|
Assert.assertTrue("Dashboard not loaded", dashboardPage.isDashboardLoaded());
|
||||||
|
|
||||||
@ -40,8 +34,6 @@ public class ApplineBusinessTripTest extends BaseTests {
|
|||||||
businessTripPage.setTicketsCheckbox(true);
|
businessTripPage.setTicketsCheckbox(true);
|
||||||
businessTripPage.fillCity("Дмитров");
|
businessTripPage.fillCity("Дмитров");
|
||||||
|
|
||||||
AllureUtils.attachScreenshot();
|
|
||||||
|
|
||||||
businessTripPage.fillDate(
|
businessTripPage.fillDate(
|
||||||
By.xpath("//input[@placeholder='Укажите дату' and contains(@id, 'departureDatePlan')]"),
|
By.xpath("//input[@placeholder='Укажите дату' and contains(@id, 'departureDatePlan')]"),
|
||||||
"01.01.2025"
|
"01.01.2025"
|
||||||
@ -52,8 +44,6 @@ public class ApplineBusinessTripTest extends BaseTests {
|
|||||||
"10.01.2025"
|
"10.01.2025"
|
||||||
);
|
);
|
||||||
|
|
||||||
AllureUtils.attachScreenshot();
|
|
||||||
|
|
||||||
businessTripPage.saveAndClose();
|
businessTripPage.saveAndClose();
|
||||||
|
|
||||||
Assert.assertTrue("Expected validation error not shown",
|
Assert.assertTrue("Expected validation error not shown",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user