Skip to content

image is not displaying on the report page #265

Open
@p00j4

Description

@p00j4

image
The image link shown on the page is relative to localhost, which shows 404
http://localhost:63342/screenshots/my_screenshot.png

To Reproduce
keep a png file named my_screenshot.png in the root of project
contents of conftest.py

import os

@pytest.mark.hookwrapper
def pytest_runtest_makereport(item, call):
    outcome = yield
    report = outcome.get_result()
    pytest_html = item.config.pluginmanager.getplugin('html')
    extra = getattr(report, 'extra', [])

    main_script_dir = os.path.dirname(__file__)
    rel_path = "screenshots/my_screenshot.png" #hardcoded image file temporarily #TODO to get from driver
    image = pytest_html.extras.image(os.path.join(main_script_dir, rel_path))
    extra.append(image)
    report.extra = extra

Run with
pytest --html=report.html
Also have tried with --self-contained-html

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugThis issue/PR relates to a bug.next-genCandidate for the next-gen project

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions