- @pytest.hookimpl(tryfirst=True, hookwrapper=True)
- def pytest_runtest_makereport(item, call):
- outcome = yield
- rep = outcome.get_result()
- if rep.when == 'call' and rep.outcome == "failed":
- driver = getattr(Context, "driver")
- logger = getattr(Context, "logger")
- title = driver.title
- err_png = driver.get_screenshot_as_png()
-
- # allure.attach.file('./data/totally_open_source_kitten.png', attachment_type=allure.attachment_type.PNG)
-
- logger.error(rep.longreprtext)
- allure.attach(err_png, f"{title}页面失败截图", allure.attachment_type.PNG)