yashaka / selene

User-oriented Web UI browser tests in Python
https://yashaka.github.io/selene/
MIT License
695 stars 151 forks source link

The files in the /root/.selene/screenshots path are getting larger and larger #503

Open zhupengfarmer opened 10 months ago

zhupengfarmer commented 10 months ago

image

@pytest.hookimpl(tryfirst=True, hookwrapper=True)
def pytest_runtest_makereport(item, call):
    # 什么时候去识别用例的执行结果呢?
    # 后置处理 yield:表示测试用例执行完了
    outcome = yield
    rep = outcome.get_result()  # 获取测试用例执行完成之后的结果
    if rep.failed:  # 判断用例执行情况:被调用并且失败
        # 实现失败截图并添加到allure附件。截图方法需要使用driver对象,想办法把driver传过来
        # 如果操作步骤过程中有异常,那么用例失败,在这里完成截图操作
        try:
            img = browser.driver.get_screenshot_as_png()
            # 将截图展示在allure测试报告上
            allure.attach(img, '失败截图', allure.attachment_type.PNG)
        except Exception as e:
            logs("截图失败", e)
yashaka commented 5 months ago

What would you expect as a feature from Selene to improve the situation on your side?