Compare commits
1 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
97f6075658 |
33
README.md
Normal file
33
README.md
Normal file
@ -0,0 +1,33 @@
|
||||
Изменён 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,7 +24,88 @@
|
||||
<scope>test</scope>
|
||||
</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>
|
||||
|
||||
<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>
|
||||
|
||||
|
15
src/test/java/ru/ibs/framework/utils/AllureUtils.java
Normal file
15
src/test/java/ru/ibs/framework/utils/AllureUtils.java
Normal file
@ -0,0 +1,15 @@
|
||||
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);
|
||||
}
|
||||
}
|
22
src/test/java/ru/ibs/framework/utils/MyAllureListener.java
Normal file
22
src/test/java/ru/ibs/framework/utils/MyAllureListener.java
Normal file
@ -0,0 +1,22 @@
|
||||
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,6 +3,8 @@ package ru.ibs.tests;
|
||||
import org.junit.*;
|
||||
import org.openqa.selenium.By;
|
||||
import ru.ibs.framework.managers.DriverManager;
|
||||
import ru.ibs.framework.utils.AllureUtils;
|
||||
import ru.ibs.framework.utils.MyAllureListener;
|
||||
|
||||
public class ApplineBusinessTripTest extends BaseTests {
|
||||
|
||||
@ -10,6 +12,9 @@ public class ApplineBusinessTripTest extends BaseTests {
|
||||
private DashboardPage dashboardPage;
|
||||
private BusinessTripPage businessTripPage;
|
||||
|
||||
@Rule
|
||||
public MyAllureListener allureListener = new MyAllureListener();
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
// Получаем драйвер из DriverManager (инициализирован в BaseTests)
|
||||
@ -21,6 +26,7 @@ public class ApplineBusinessTripTest extends BaseTests {
|
||||
|
||||
@Test
|
||||
public void applineLoginScenario() {
|
||||
AllureUtils.attachScreenshot();
|
||||
dashboardPage = loginPage.login("Irina Filippova", "testing");
|
||||
Assert.assertTrue("Dashboard not loaded", dashboardPage.isDashboardLoaded());
|
||||
|
||||
@ -34,6 +40,8 @@ public class ApplineBusinessTripTest extends BaseTests {
|
||||
businessTripPage.setTicketsCheckbox(true);
|
||||
businessTripPage.fillCity("Дмитров");
|
||||
|
||||
AllureUtils.attachScreenshot();
|
||||
|
||||
businessTripPage.fillDate(
|
||||
By.xpath("//input[@placeholder='Укажите дату' and contains(@id, 'departureDatePlan')]"),
|
||||
"01.01.2025"
|
||||
@ -44,6 +52,8 @@ public class ApplineBusinessTripTest extends BaseTests {
|
||||
"10.01.2025"
|
||||
);
|
||||
|
||||
AllureUtils.attachScreenshot();
|
||||
|
||||
businessTripPage.saveAndClose();
|
||||
|
||||
Assert.assertTrue("Expected validation error not shown",
|
||||
|
Loading…
x
Reference in New Issue
Block a user