-
Notifications
You must be signed in to change notification settings - Fork 241
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
image is not displaying on the report page #265
Comments
What's the use-case? Why are you trying to add a screenshot manually? |
FWIW, it works for me. Both with and without What versions are you using of python, pytest and plugins? What OS? |
@BeyondEvil thanks for quick response. Version info my bad missed last time
|
Try inserting extra HTML with your image relative path embed, like this: extra.append(pytest_html.extras.html(
f'<div class="image"><img src="img/{rel_path}"/></div>')
) |
I can’t find any documentation on what “content” you can add. I had to look at the code to figure out it should be Base64 encoded. Also if you use relative path then the report file must be in the current working directory as the href is not adjusted based on the path to the report. |
Good catch @christiansandberg ! Mind opening a separate issue for improving the docs? 🙏 |
Hey, I think this is a bug introduced in 2.1.0 and results from a refactoring change: 588c41b Before, the For more info, see pytest-dev/pytest-selenium#237 |
Is there a workaround or a known fix for this? I am currently experiencing it today. |
If you have the same issue, it was fully resolved for us once my
pytest-selenium bug was fixed.
This one should be closed imo.
…On Fri, Jan 14, 2022 at 09:32 Colin Wisdom ***@***.***> wrote:
Is there a workaround or a known fix for this? I am currently experiencing
it today.
—
Reply to this email directly, view it on GitHub
<#265 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAEAQT5VNEB335VDE3SVFSDUWBM2ZANCNFSM4KSORFEA>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
Closing this for now. |
This is still not fixed. It might be fixed when you use pytest-selenium but if you use the general selenium package this problem is still happening to me. I have tried with multiple combination of versions of pytest and pytest-html and this issue still occurs. |
Yeah, I've since been able to reproduce it myself. It's a bit tricky to fix.
This is definitely going to be solved in next-gen and then back-ported to the current one. |
@BeyondEvil thanks for reopening this. |
As far as I can tell, this has never worked/been supported. For a workaround you have (at least) two options.
For example: If you run with:
and you have
Then the file needs to be copied to I think option 1 is the best, cause you can handle that directly in code:
For self-contained, the same applies. This is however going to be different in next-gen, where any extra images (on disk) will be base64 encoded. Hope that helps! |
I am having the same issue [as the OP] where the image in the test report is broken:
|
I solved the problem temporarily with a recode import base64
` |
For anyone still facing this issue, I figured out how to fix it. Check out this stack overflow post for details https://stackoverflow.com/questions/70761764/pytest-html-not-displaying-image/70763446#70763446 |
Someone should add that to the docs. |
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
Run with
pytest --html=report.html
Also have tried with
--self-contained-html
The text was updated successfully, but these errors were encountered: