【发布时间】:2025-12-05 13:40:01
【问题描述】:
使用 Allure/Python/Behave 的人似乎非常有限。在过去的几周里,我一直在配置我的 BDD(行为)框架以在 Jenkins 上运行,在那段时间里我发现了 Allure。它看起来非常强大。
我想知道如何将屏幕截图附加到失败的步骤并让它们显示在 Jenkins 的 Allure 报告中。
here 周围传递了简单的代码。我想我只是不确定我缺少什么或我需要在哪里放置此代码。
这是我现在在after_step 的 environment.py 文件中的代码:
def after_step(context, step):
time.sleep(2)
if step.status == "failed":
allure.attach(context.browser.driver.get_screenshot_as_file
('screenshots\\{}.png'.format
(step.name)),
name="Screenshot",
attachment_type=AttachmentType.PNG)
当我在 Jenkins 中打开报告时,没有屏幕截图。
【问题讨论】:
-
根本没有截图还是只是一些损坏的图片链接?
-
完全没有截图。
-
另外,更新为
context.browser.driver.get_screenshot_as_png(),但仍然无法使用@Verv
标签: python jenkins screenshot allure python-behave