Python,py.测试“HTMLReport”对象没有属性“execute”

2024-05-20 21:37:22 发布

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

我正在尝试从自动测试中向pytest html报告中添加屏幕截图

我增加了插件.py公司名称:

def pytest_runtest_makereport(__multicall__, item):
    report = __multicall__.execute()
    extra = getattr(report, 'extra', [])
    if report.when == 'call':
        xfail = hasattr(report, 'wasxfail')
        if (report.skipped and xfail) or (report.failed and not xfail):
            url = TestSetup.selenium.current_url
            report.extra.append(extras.url(url))
            screenshot = TestSetup.selenium.get_screenshot_as_base64()
            report.extra.append(extras.image(screenshot, 'Screenshot'))
            html = TestSetup.selenium.page_source.encode('utf-8')
            report.extra.append(extra.text(html, 'HTML'))
            report.extra.append(extra.html(html.div('Additional HTML')))
        report.extra = extra
    return report

但是在跑步的时候

^{pr2}$

我明白了

INTERNALERROR>   File "C:\Python27\lib\site-packages\pytest_html\plugin.py", line 288, in pytest_runtest_makereport
INTERNALERROR>     report = __multicall__.execute()
INTERNALERROR> AttributeError: 'HTMLReport' object has no attribute 'execute'

它是从哪里来的?在


Tags: pyreporturlexecutepytesthtmlseleniumextra