- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我正在尝试将屏幕截图添加到我的 ExtentReport HTML 文件中,但由于某种原因,图像不存在,即使它确实存在并且控制台显示它正在查看正确的位置(href 是正确的)。
这是最新的试用代码:
Screenshot screenshot = new AShot().shootingStrategy(ShootingStrategies.viewportPasting(1000)).takeScreenshot(driver);
String destination = getScreenshotPath();
ImageIO.write(screenshot.getImage(), "IMG", new File(destination));
test.fail("Details: " + test.addScreenCaptureFromPath(destination));
屏幕截图保存在目的地。当我尝试 Debug模式或查看报告时,它打印为:
详情:com.aventstack.extentreports.ExtentTest@62041567它下面有一张破损的图片:
最佳答案
我用的是绝对路径
注意:从浏览器检查损坏的图像以验证图像的绝对路径
截图:
public static String TakesScreenshot(IWebDriver driver, string FileName)
{
string pathProject = AppDomain.CurrentDomain.BaseDirectory;
string pathScreen = pathProject.Replace("\\bin\\Debug", "");
string path = pathScreen + "project/Test-output/Images/";
StringBuilder TimeAndDate = new StringBuilder(DateTime.Now.ToString());
TimeAndDate.Replace("/", "_");
TimeAndDate.Replace(":", "_");
TimeAndDate.Replace(" ", "_");
string imageName = FileName + TimeAndDate.ToString();
((ITakesScreenshot)driver).GetScreenshot().SaveAsFile(path + "_" + imageName + "." + System.Drawing.Imaging.ImageFormat.Jpeg);
return path + "_" + imageName + "." + "jpeg";
}
使用预览方法的路径将图像附加到报告中:具体步骤中:
ExtentTest.Fail("message", MediaEntityBuilder.CreateScreenCaptureFromPath(TakeScreenShot.TakesScreenshot(driver, "Fatal")).Build());
使用方法"TakesScreenshot"截屏
版本 ExtentReport:3,C#,N单元3
使用 JAVA:
<dependency>
<groupId>com.relevantcodes</groupId>
<artifactId>extentreports</artifactId>
<version>2.41.2</version>
</dependency>
是:
ExtentTestManager.getTest().log(LogStatus.ERROR, ExtentTestManager.getTest().addScreenCapture("//ABOLUTE/PATH/IMAGE.PNG"));
问候。
关于java - ExtentReports - 屏幕截图不在报告中 - 损坏的图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47555567/
我有一个 Selenium/Java 项目,我们正在其中使用 ExtentReports。我们使用 PageFactory 模型,并有一个 BasePageFactory 负责所有测试准备工作。 Be
我正在使用范围报告通过页面对象模型为我的 Selenium 测试生成日志,并且我有单独的页面和测试类。我能够生成范围报告日志,但我的登录页面日志正在重复。我怀疑这是因为所有其他测试都使用了登录名,但我
目前我正在使用 ExtentReport 生成自动化报告。 我使用 ExtentReport 的方式是使用 IReporter 实现在测试结束时生成报告,这很棒。 但是,现在我正在考虑创建一种在执行测
我需要将所有跳过的测试用例添加到我的 ExtentReports 中。我怎样才能实现这个目标? 我在我的BaseTest.java中尝试了以下代码: @AfterMethod public void
当我运行第一类时,结果会添加到报告中,但是当我运行第二类时,报告不会保留第一类的结果 //SimpleReportFactory { package Rapport; import com.relev
我是新来的范围报告。我正在使用 Selenium Webdriver,并希望使用它的范围报告。 但是我的代码无法创建 ExtentReport 对象。 package com.code.draft;
我在调整 ExtentReports 以提供所需的输出时遇到了一些困难。 我有一个带有 TestNG 的简单测试框架,使用 TestBase 类来完成繁重的工作以保持测试简单。我希望以一种简单的方式实
我正在尝试将屏幕截图添加到我的 ExtentReport HTML 文件中,但由于某种原因,图像不存在,即使它确实存在并且控制台显示它正在查看正确的位置(href 是正确的)。 这是最新的试用代码:
有人可以告诉我如何编写结合 Selenium 页面对象模式和 ExtentsReports ( http://extentreports.relevantcodes.com/ ) 的功能性应用程序测试
我正在使用集成在一起的 tesng、extent-report 和 cucumber 构建新的自动化基础设施。使用以下代码。 @CucumberOptions(strict= false,
我正在尝试使用范围报告打印数组列表。但它给了我错误“ExtentTest 类型中的方法 log(LogStatus, Throwable) 不适用于参数 (LogStatus, ArrayList)”
我正在使用 Cucumber 和 TestNG 在移动设备上并行运行测试。下面给出了我的 TestNG 运行器类。 @CucumberOptions( features="src/te
我正在使用放心的库和范围报告进行报告, ValidatableResponse reponseManualLead = given().header("Accept", "application/js
我正在尝试自定义 ExtentReports 4.0.9当我在测试失败后打开报告时,它将屏幕截图显示为非常小的缩略图。如何增加缩略图的大小。 我尝试过extent-config.xml
社区大家好:我在尝试在 Cucumber 中实现范围报告时遇到了一些问题。 执行后我收到此问题: java.lang.IncompatibleClassChangeError: Implementin
我是测试新手,需要使用extentreports报告测试结果, 下面是测试代码: public ExtentReports reports; public ExtentTest logger; pub
我正在一台机器上运行 ThreadLocal 测试。我使用 @BeforeMethod 中的代码来启动网页。我还尝试过将其单独编写为我的 Base Test 类中的方法,并在 @BeforeMetho
我正在尝试使用 TestNG 中的 ExtentReports 准备测试执行报告。下面是我的代码- import org.openqa.selenium.By; import org.openqa.s
我正在寻找一种方法来实现高级范围报告,其中包含基本设置之外的测试步骤和结果数据。 我目前有一个可用的 ExtentReports 报告,并且正在寻找一种使用 ExtentReports (Logger
我有几个字段,我从 HTML 页面解析并添加到我的 report 中: extentTest.log(Status.INFO, String.format( "Add
我是一名优秀的程序员,十分优秀!