在ui自动化中常见的是在step执行完成后,截图并添加到报告中,以便后面查看:
# 截一张图
start_flow = time.strftime("%Y-%m-%d_%H-%M-%S", time.localtime())
master.save_screenshot('./report/xxx/start_flow_%s.png' % start_flow)
time.sleep(3)
# 将截图添加到报告中
allure.attach.file("./report/xxx/start_flow_%s.png" % start_flow, name="start flow",
attachment_type=allure.attachment_type.JPG)
在每个step执行时记录当前时间,以便跟日志对应:
with allure.step('step4: 进入开流页面,查看开流结果。step时间点:%s'
% time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())):