I am using python-appium client and generating a HTML report after the tests are finished. I would like to add the embedded images of the failure tests in the HTML report. The reason to embed the image is that I can access it from the remote machine as well. Here is the code which I tried and doesn't work on another system but locally it works:
@pytest.mark.hookwrapper
def pytest_runtest_makereport(item):
pytest_html = item.config.pluginmanager.getplugin('html')
outcome = yield
report = outcome.get_result()
extra = getattr(report, 'extra', [])
if report.when == 'call' or report.when == 'setup':
xfail = hasattr(report, 'wasxfail')
if (report.skipped and xfail) or (report.failed and not xfail):
screenshot = driver.get_screenshot_as_base64()
extra.append(pytest_html.extras.image(screenshot, ''))
report.extra = extra
It seems to me that the encoded image is not generated properly as this is what I can see in the output HTML file:
<td class="extra" colspan="4">
<div class="image"><a href="assets/75870bcbdda50df90d4691fa21d5958b.png"><img src="assets/75870bcbdda50df90d4691fa21d5958b.png"/></a></div>
and I expect "src" to not to end with ".png" and it should be long string of characters. I have no idea how to resolve this.