Compare commits

..

1 Commits

Author SHA1 Message Date
Александров Александр Владимирович
3f5847053e Stop tracking chromedriver.exe 2025-06-24 00:28:13 +03:00
6 changed files with 0 additions and 161 deletions

View File

@ -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);
}
}
```
![img.png](img.png)

BIN
img.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 56 KiB

81
pom.xml
View File

@ -24,88 +24,7 @@
<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>

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -3,8 +3,6 @@ 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 {
@ -12,9 +10,6 @@ public class ApplineBusinessTripTest extends BaseTests {
private DashboardPage dashboardPage;
private BusinessTripPage businessTripPage;
@Rule
public MyAllureListener allureListener = new MyAllureListener();
@Before
public void setUp() {
// Получаем драйвер из DriverManager (инициализирован в BaseTests)
@ -26,7 +21,6 @@ public class ApplineBusinessTripTest extends BaseTests {
@Test
public void applineLoginScenario() {
AllureUtils.attachScreenshot();
dashboardPage = loginPage.login("Irina Filippova", "testing");
Assert.assertTrue("Dashboard not loaded", dashboardPage.isDashboardLoaded());
@ -40,8 +34,6 @@ 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"
@ -52,8 +44,6 @@ public class ApplineBusinessTripTest extends BaseTests {
"10.01.2025"
);
AllureUtils.attachScreenshot();
businessTripPage.saveAndClose();
Assert.assertTrue("Expected validation error not shown",