Unable to fetch the path for theHTML report using the item.config.option.html in pytest-html
Hey, Just try to build a new Html report for the test cases & attach a screenshot for the Failed test to My Html Report. Got this piece of Code but was unable to get the HTML path for the report which is being created. Is there a better to get the path without Hard Coding it, Please share?
OS : Windows 64 pytest==6.2.5 pytest-html==3.1.1
@pytest.hookimpl(hookwrapper=True) def pytest_runtest_makereport(item, call): pytest_html = item.config.pluginmanager.getplugin("html") outcome = yield report = outcome.get_result() extra = getattr(report, "extra", []) if report.when == "call": extra.append(pytest_html.extras.url("https://www.saucedemo.com/")) xfail = hasattr(report, "wasxfail") if (report.skipped and xfail) or (report.failed and not xfail): report_dir = os.path.dirname(item.config.option.html) file = report.nodeid.replace("::","_") + ".png" dest = os.path.join(report_dir,file) driver.save_screenshot(dest) extra.append(pytest_html.extras.html("
Could you share what you are seeing instead? Stacktrace? Error? Mind sharing how you're executing pytest (command line with flags)?