pytest-dev / pytest-dev/pytest-html
image is not displaying on the report page
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 779
- Forks
- 260
- PR merge metrics
- No merged PRs in 30d
Description

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
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the conftest.py reproduction and run pytest --html=report.html with and without --self-contained-html. Trace how pytest_html.extras.image handles screenshots/my_screenshot.png and how the report renders the resulting URL. Done means the PNG displays on the report page instead of resolving to the broken localhost path.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- html, python
- Domain
- testing-qa, web-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100