java - 宁静报告 - 屏幕截图不起作用
问题描述
我想在我的 Serenity 测试报告中添加屏幕截图,但它不适合我。生成报告但没有屏幕截图。我尝试了我发现的一切,但没有运气。有人可以帮我弄这个吗?
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<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>
<packaging>pom</packaging>
<groupId>com.test</groupId>
<artifactId>project</artifactId>
<version>0.7</version>
<modules>
<module>../test-ui</module>
<module>../commons</module>
</modules>
<properties>
<maven.compiler.source>11</maven.compiler.source>
<maven.compiler.target>11</maven.compiler.target>
<maven.test.failure.ignore>true</maven.test.failure.ignore>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<serenity.version>2.4.0</serenity.version>
</properties>
<dependencies>
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-core</artifactId>
<version>${serenity.version}</version>
</dependency>
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-junit</artifactId>
<version>${serenity.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<version>5.3.5</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
</dependencies>
<profiles>
<profile>
<id>dev</id>
<properties>
<environment>dev</environment>
</properties>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
</profile>
</profiles>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>${maven.compiler.source}</source>
<target>${maven.compiler.target}</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>3.0.0-M1</version>
<executions>
<execution>
<phase>install</phase>
<goals>
<goal>install-file</goal>
</goals>
<configuration>
<file>lib/ojdbc7-12.1.0.1.jar</file>
<groupId>com.oracle</groupId>
<artifactId>ojdbc7</artifactId>
<version>12.1.0.1</version>
<packaging>jar</packaging>
</configuration>
</execution>
</executions>
<inherited>false</inherited>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.21.0</version>
<configuration>
<systemPropertyVariables>
<environment>${environment}</environment>
<browser>${browser}</browser>
</systemPropertyVariables>
<testFailureIgnore>true</testFailureIgnore>
</configuration>
<executions>
<execution>
<id>integration-test</id>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.21.0</version>
<configuration>
<includes>
<include>**/*Test.java</include>
</includes>
<systemPropertyVariables>
<environment>${environment}</environment>
<browser>${browser}</browser>
<webdriver.driver>chrome</webdriver.driver>
</systemPropertyVariables>
<testFailureIgnore>true</testFailureIgnore>
</configuration>
<executions>
<execution>
<id>integration-test</id>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>3.0.0-M3</version>
<executions>
<execution>
<phase>test</phase>
<goals>
<goal>failsafe-report-only</goal>
</goals>
</execution>
</executions>
<configuration>
<showSuccess>true</showSuccess>
</configuration>
</plugin>
<plugin>
<groupId>net.serenity-bdd.maven.plugins</groupId>
<artifactId>serenity-maven-plugin</artifactId>
<version>${serenity.version}</version>
<dependencies>
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-core</artifactId>
<version>${serenity.version}</version>
</dependency>
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-single-page-report</artifactId>
<version>${serenity.version}</version>
</dependency>
<dependency>
<groupId>net.serenity-bdd</groupId>
<artifactId>serenity-reports</artifactId>
<version>${serenity.version}</version>
</dependency>
</dependencies>
<configuration>
<tags>${tags}</tags>
<reports>single-page-html</reports>
</configuration>
<executions>
<execution>
<id>serenity-reports</id>
<phase>test</phase>
<goals>
<goal>aggregate</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
serenity.properties
webdriver.driver = provided
webdriver.provided.type = mydriver
webdriver.provided.mydriver = DriverFactory
thucydides.driver.capabilities = mydriver
serenity.take.screenshots=BEFORE_AND_AFTER_EACH_STEP
#serenity.take.screenshots=FOR_EACH_ACTION
#serenity.take.screenshots=AFTER_EACH_STEP
#serenity.take.screenshots=DISABLED
serenity.logging=VERBOSE
driverfactory.java 看起来像这样
public class DriverFactory extends ThucydidesWebDriverSupport {
@Managed
public static WebDriver driver = null;
public static WebDriver getDriver(){ return driver; }
...
测试从这个开始
@Test
@Screenshots(onlyOnFailures = true)
@Title("Test")
我正在通过命令运行测试
mvn clean verify -Denvironment=dev -Dinjected.tags="browser:chrome"
生成报告但没有屏幕截图。
解决方案
推荐阅读
- view - 如何在 twig 主题中调试和查找变量
- python - 作为索引器提供的不可对齐的布尔系列(布尔系列的索引和索引对象的索引不匹配)
- c++ - 如何正确使用带有 GLint 数组的 glVertexPointer() 和 glDrawArrays 来绘制四边形?
- python - 在 Django 中,我无法检索选项字段的值、文件字段中具有此值的文件字段 ={{i.cv} 以及类似的选项字段
- c - scanf("%[^\n]*c", sen); 有什么区别?和 scanf(" %[^\n]*c", sen); 第二个给出正确的结果
- javascript - 单击任意位置以使用 jQuery 关闭窗口
- python - 数据不会在 Django 上从视图发送到模板
- node.js - Nodejs 和 Angular 端口冲突中的 HTTPS 问题
- arrays - Excel VBA - 如何在保留旧数组值的同时向二维变量数组添加一行?
- javascript - javascript 如何显示已在下一行中定义的东西的属性?