【问题标题】:Generating screenshots in Java&TestNG with Allure reporting使用 Allure 报告在 Java&TestNG 中生成屏幕截图
【发布时间】:2019-06-10 16:10:16
【问题描述】:

我正在使用 Allure 和 TestNG on Java 设置自动化测试的报告。一切正常,只是想知道你们中是否有人尝试在 Allure 报告中生成屏幕截图。我需要在哪里设置负责这个的代码?

【问题讨论】:

    标签: java selenium automation testng allure


    【解决方案1】:

    由于您的问题上有一个 selenium 标签,我认为您可以使用它。 我的解决方案分为:

    1. 使用 selenium 进行屏幕截图。 see here

    2. 将镜头添加为报告的附件。 see TestNg section at allure docs

    在我的 (python) 代码中,它看起来像:

    def AttachScreenshot(picName='Screenshot'):
        """
        add screenshot to current step at allure
        """
        Webdriver = GetDriver()
        allure.attach(Webdriver.get_screenshot_as_png(), name=picName, attachment_type=AttachmentType.PNG)
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-01-02
      • 2021-11-02
      • 2012-02-14
      • 2021-04-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多