【问题标题】:How does Report Portal take screenshots of failed testcases in the case of TestNG framework?在 TestNG 框架的情况下,Report Portal 如何截取失败的测试用例?
【发布时间】:2026-01-23 15:40:01
【问题描述】:

Report Portal 是否使用 WebDriver 来截取失败的测试用例的屏幕截图? 我在java-testNG监听代理的源码中没有看到WebDriver的用法。 我可以知道这是怎么做到的吗? 还是 RP 不具备为基于 TestNG 的框架截取屏幕截图的能力?

【问题讨论】:

    标签: testng reportportal


    【解决方案1】:

    ReportPortal 不会截取您的屏幕截图,您需要实现 Web 驱动程序中的代码以截取屏幕截图,然后使用您的记录器 (log4j2/log4j/logback) 将其发送到 ReportalPortal。

    例如(来自本地浏览器-chrome)

     Screenshot screenshot = new Screenshot(this);
     
     LOGGER.debug("RP_MESSAGE#FILE#{}#{}", screenshot.takeScreenShot(imageName,true), "snapshot");
    

    【讨论】:

      最近更新 更多