Open vladimir-popescu-idnow opened 4 weeks ago
The function build_img_path_and_div_for_html does the extra.append
def build_img_path_and_div_for_html(filename, extra, pytest_html):
rel_path = "screenshots/" + filename
extra.append(pytest_html.extras.html(
f'<div class="image"><img src="{rel_path}"/></div>')
)
I've also tried the following way with the same result
driver = DRIVER_REGISTRY.get(item.nodeid, {}).get("driver_mod")
if driver:
# driver = item.funcargs['driver_mod']
timestamp = datetime.now().strftime('%Y-%m-%d_%H-%M-%S')
screenshot_name = f"{item.name}_{timestamp}.png"
driver.save_screenshot(os.path.join(SCREENSHOTS_PATH, screenshot_name))
# build_img_path_and_div_for_html(screenshot_name, extra, pytest_html)
rel_path = "screenshots/" + screenshot_name
extra.append(pytest_html.extras.image(rel_path))
Hello,
I have an automation framework with selenium/pytest with some fixtures in the test modules which execute repetitive code. In case the execution fails in the fixture this is marked as ERROR in the html report and despite being able to take a screenshot on this occurrence it is not attached to the report. A few more details :
Example test & fixture
Conftest hook