如何在json/html rep中包含制作的屏幕截图

2024-10-03 11:22:05 发布

您现在位置:Python中文网/ 问答频道 /正文

我使用Bahave,并且在environment.py中有一个after_scenario的下一个条件

def after_scenario(context, scenario):
  if scenario.status == "failed":
    time_now = datetime.now().strftime("%Y-%m-%d_%H-%M-%S")  
    context.browser.save_screenshot("failed_scenarios_screenshots/%s_%s_failed.png" % (scenario.name, time_now))

如何将制作的屏幕截图添加到json或html报表中?在


Tags: pydatetimeifenvironmenttimedefstatuscontext