【发布时间】:2019-06-10 16:10:16
【问题描述】:
我正在使用 Allure 和 TestNG on Java 设置自动化测试的报告。一切正常,只是想知道你们中是否有人尝试在 Allure 报告中生成屏幕截图。我需要在哪里设置负责这个的代码?
【问题讨论】:
标签: java selenium automation testng allure
我正在使用 Allure 和 TestNG on Java 设置自动化测试的报告。一切正常,只是想知道你们中是否有人尝试在 Allure 报告中生成屏幕截图。我需要在哪里设置负责这个的代码?
【问题讨论】:
标签: java selenium automation testng allure
由于您的问题上有一个 selenium 标签,我认为您可以使用它。 我的解决方案分为:
使用 selenium 进行屏幕截图。 see here
将镜头添加为报告的附件。 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)
【讨论】: