You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
``When using pytest-html 3.2.0, the report generated correctly, showing details of failed tests.
When upgraded to pytest-html-4.1.0, the report no longer showed this data.
By upgrading and downgrading I can make the report work correctly and break it again. The only thing effecting the report generating is the version of pytest-html.
Below is my function for the report:
`@pytest.hookimpl(hookwrapper=True)
def pytest_runtest_makereport(item):
"""
Extends the PyTest Plugin to take and embed screenshot in html report, whenever test fails.
:param item:
"""
pytest_html = item.config.pluginmanager.getplugin('html')
outcome = yield
report = outcome.get_result()
extra = getattr(report, 'extra', [])
# Add rerun information if available
rerun = item.config.option.reruns
if rerun:
if hasattr(report, "rerun") and report.rerun > 0:
extra.append(pytest_html.extras.text(f"Rerun Attempt: {report.rerun}", mime_type="text/plain"))
# Embed screenshots for failed or rerun tests
if report.when == 'call' or report.when == "setup":
xfail = hasattr(report, 'wasxfail')
if (report.skipped and xfail) or (report.failed and not xfail):
base64_image = _capture_screenshot()
if base64_image:
html = (
f'<div>'
f'<img src="data:image/png;base64,{base64_image}" alt="screenshot"'
f' style="width:304px;height:228px;" onclick="window.open(this.src)" align="right"/>'
f'</div>'
)
extra.append(pytest_html.extras.html(html))
# Assign updated extras back to the report
report.extra = extra
``When using pytest-html 3.2.0, the report generated correctly, showing details of failed tests.
When upgraded to pytest-html-4.1.0, the report no longer showed this data.
By upgrading and downgrading I can make the report work correctly and break it again. The only thing effecting the report generating is the version of pytest-html.
Below is my function for the report:
`@pytest.hookimpl(hookwrapper=True)
def pytest_runtest_makereport(item):
"""
Extends the PyTest Plugin to take and embed screenshot in html report, whenever test fails.
:param item:
"""
pytest_html = item.config.pluginmanager.getplugin('html')
outcome = yield
report = outcome.get_result()
extra = getattr(report, 'extra', [])
def _capture_screenshot():
return driver.get_screenshot_as_base64()`
The text was updated successfully, but these errors were encountered: