-
Notifications
You must be signed in to change notification settings - Fork 172
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
Attach base64 images to the report #40
Comments
This project allows you to pass your own template to be rendered. I think you can add logic to your tests where it takes the pictures on fail and then passes your own template to get this rendered. |
Alright, I am "adding" the screenshot as follows:
So, I created my out template, a clone of the dault but I added the following: However, I noticed the Now, I did something stupid that worked but it's so stupid that I am sure it has a better way: I replace Thoughts on how I could make the first scenario do-able? I wouldn't mind contributing some code to your project. |
Hello, I think you can actually do this as-is by using a custom TestResult class and overriding its import unittest
from HtmlTestRunner import HTMLTestRunner
from HtmlTestRunner.result import HtmlTestResult
class CustomTestResult(HtmlTestResult):
images = None
def stopTest(self, test):
self.images = "link to my image"
super().stopTest(test)
class MyTests(unittest.TestCase):
def test_one(self):
self.assertTrue(True)
if __name__ == '__main__':
unittest.main(
testRunner=HTMLTestRunner(
open_in_browser=True,
resultclass=CustomTestResult
)
) You will also need to edit the template accordingly, referencing this new custom field as follows for the non-subtests: I hope this helps. |
HtmlTestRunner is not calling tearDown() in my test cases. is it getting called in your case? |
Have you got solution anyone? Can you please guide me proper solution |
@vishnuvk123 I solved this issue. |
Description
I'd like to have the ability to insert images to a certain test, specifically in base64 format.
We use this library for our selenium test reports and would be nice to attach screenshots when the tests fail.
What I Did
Nothing is specific. I am planning to contribute to this project if that's a feature you'd like to be added.
The text was updated successfully, but these errors were encountered: