我在我的项目中使用cucumber版本4。我在我的项目中使用以下依赖项。
<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>ABCXYZ</groupId>
<artifactId>ABCXYZ</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>ABCXYZ</name>
<url>http://maven.apache.org</url>
<build>
<plugins>
<!-- Plugin For Reporting -->
<plugin>
<groupId>net.masterthought</groupId>
<artifactId>maven-cucumber-reporting</artifactId>
<version>5.3.0</version>
<executions>
<execution>
<id>execution</id>
<phase>test</phase>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<projectName>ABCXYZ</projectName>
<!-- optional, per documentation set this to "true" to bypass generation of Cucumber Reports entirely, defaults to false if not specified -->
<skip>false</skip>
<!-- output directory for the generated report -->
<outputDirectory>target/cucumber-report-html</outputDirectory>
<!-- optional, defaults to outputDirectory if not specified -->
<inputDirectory>${project.build.directory}</inputDirectory>
<jsonFiles>
<!-- supports wildcard or name pattern -->
<param>**/*.json</param>
</jsonFiles>
<!-- optional, defaults to outputDirectory if not specified -->
<classificationDirectory>${project.build.directory}</classificationDirectory>
<classificationFiles>
<!-- supports wildcard or name pattern -->
<param>sample.properties</param>
<param>other.properties</param>
</classificationFiles>
<parallelTesting>false</parallelTesting>
<!-- optional, set true to group features by its Ids -->
<mergeFeaturesById>false</mergeFeaturesById>
<!-- optional, set true to get a final report with latest results of the same test from different test runs -->
<mergeFeaturesWithRetest>false</mergeFeaturesWithRetest>
<!-- optional, set true to fail build on test failures -->
<checkBuildResult>false</checkBuildResult>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M4</version>
<configuration>
<testFailureIgnore>true</testFailureIgnore>
</configuration>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit47</artifactId>
<version>3.0.0-M4</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.4</version>
</plugin>
</plugins>
</build>
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>2.2</version>
<reportSets>
<reportSet>
<reports>
<report>index</report>
<report>license</report>
<report>project-team</report>
<report>distribution-management</report>
<report>dependancy-info</report>
<report>scm</report>
<report>issue-tracking</report>
<report>cim</report>
<report>summary</report>
</reports>
<configuration>
<linkonly>false</linkonly>
</configuration>
</reportSet>
</reportSets>
</plugin>
</plugins>
</reporting>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-chrome-driver</artifactId>
<version>3.141.5</version>
</dependency>
<dependency>
<groupId>org.gdal</groupId>
<artifactId>gdal</artifactId>
<version>1.11.1</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-project</artifactId>
<version>2.2.1</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.12</version>
</dependency>
<dependency>
<groupId>org.apache.maven.plugin-tools</groupId>
<artifactId>maven-plugin-annotations</artifactId>
<version>3.6.0</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>3.141.59</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>3.12</version>
</dependency>
<dependency>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-junit</artifactId>
<version>4.2.3</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-jvm-deps</artifactId>
<version>1.0.6</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-java</artifactId>
<version>4.2.3</version>
</dependency>
<dependency>
<groupId>io.cucumber</groupId>
<artifactId>cucumber-picocontainer</artifactId>
<version>4.2.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-server</artifactId>
<version>3.0.1</version>
</dependency>
<dependency>
<groupId>io.appium</groupId>
<artifactId>java-client</artifactId>
<version>7.0.0</version>
</dependency>
<dependency>
<groupId>commons-configuration</groupId>
<artifactId>commons-configuration</artifactId>
<version>1.10</version>
</dependency>
<dependency>
<groupId>io.github.bonigarcia</groupId>
<artifactId>webdrivermanager</artifactId>
<version>4.1.0</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.5</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.6.4</version>
</dependency>
<dependency>
<groupId>org.testng</groupId>
<artifactId>testng</artifactId>
<version>7.1.0</version>
<scope>test</scope>
</dependency>
</dependencies>
使用上述依赖关系,我能够生成“cucumberjvm报告”。
我还用java编写了代码,用于将屏幕截图附加到报告中,我只在场景失败时拍摄屏幕截图。
@After
public void CloseBrowser(Scenario scenario) {
if (scenario.isFailed()) {
System.out.println("Scenario is Failled Taking ScreenShot...!!!");
TakesScreenshot ts = (TakesScreenshot) driver;
byte[] screenshot = ts.getScreenshotAs(OutputType.BYTES);
scenario.embed(screenshot, "image/png");
}
}
我不确定是否遗漏了什么,但屏幕截图没有附加到报告中。cucumber生成的默认html报告正在显示屏幕截图。
谁能帮我一下吗。谢谢
您可以检查屏幕截图是否嵌入在html报告的After Hooks步骤中吗?,这个5.3.0版本在Hooks步骤附加了屏幕截图,因为我们在@After
钩子中有我们的逻辑。我也首先挣扎,后来注意到了这一点。
我无法看到截图被捕获在cucumber的程度报告。 我已经调试并观察到代码已经执行,但屏幕截图并没有保存在extent report或html report文件中。 截图代码 if(scenario.isFailed()){byte[]screenshot=seleniumitls.captureShot();scenario.public void screenshot(scenario sce
我正在尝试使用extent report构建selenium,但无法使用save screenshot函数,因为我无法引用ITestListener类中的WebDriver对象。下面是我的示例代码: 测试转轮。java: TestListener.java公共类TestListener实现ITestListener{ 问题: > 如何将WebDriver对象从TestRunner.java传递给T
Cucumber Extent Reports在没有屏幕截图的情况下工作,但是当我想要在Extent report中使用屏幕截图时,我会得到以下例外。 为了制作cucumber范围报告,我只做了配置更改。。。没有代码更改。为了添加截图,我在下面添加了钩子来添加截图API。 波姆。xml: 跑步者代码: 在钩子中添加截图代码: 添加了最后一行- 我使用extent.properties文件和exte
问题内容: 目前,我正在以这种方式拍摄测试失败的屏幕截图: 我可以将自己的屏幕截图包含在TestNG报告链接或图片中吗?如果是,怎么办? 我在网上发现的只是FEST框架。但是由于我已经在截屏了,所以我不想使用其他框架。 问题答案: 是的,您可以在testng报告中包含指向屏幕截图的链接。 您需要通过使用@Listeners({yourListener.class})注释您的测试类或所有测试类的父级
问题内容: 目前,我正在以这种方式拍摄测试失败的屏幕截图: 我可以将自己的屏幕截图包含在TestNG报告链接或图片中吗?如果是,怎么办? 我在网上发现的只是FEST框架。但是由于我已经在截屏了,所以我不想使用其他框架。 问题答案: 是的,您可以在testng报告中包含指向屏幕截图的链接。 您需要调用方法以通过@Listeners({yourListener.class})注释您的测试类或所有测试类
在软断言截图得到捕获时softAssertions.assertAll()被调用.因此,为捕获屏幕截图为每个软断言失败,创建了简单的CustomAssertion它扩展到SoftAssertions并在其中覆盖一个方法名称onAssertionErrorCollected(). 下面是示例代码。 在步骤定义文件中: 以上代码工作正常。但是,如何将这些截图附加/嵌入到cucumber报告中?注意:对