-
Notifications
You must be signed in to change notification settings - Fork 68
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
how to get trace and failed screenshot after yield in function scope #267
Comments
could you please share the relevant snippets of your code? |
Running with --screenshot="only-on-failure" and --tracing=on
|
If you |
The use case is pretty simple, once any test is completed I need to upload artifacts(trace and screenshot) of a test to a reporting tool. To upload them I somehow need to get their path in system. |
By "use case" I meant "why do you have to use |
To be honest not sure we understand each other. What do you mean to use |
Ok, let's reverse the question - why you're using |
Because I need to get the trace and screenshot after the test execution, once the test itself is completed. As far as I understand fixture + yield is the only one way to do that(or recommended). |
I think I messed up :( For some reason I thought I'm looking at the test function (your code snippet), but in fact it's a fixture. So my advice was for completely different problem... apologies for that. For your issue - yeah, I think it should work the way you described. Some time ago I was trying to rename the video files (because videos recorded by Playwright are named with quite random chars, so if you run more than one test it's hard to tell which video is for which). Suprisingly the videos were not added "on the fly" after each test case, but after WHOLE test run. It might be the case with the screenshots - maybe they are in the temp folder? (unless the screenshots are not recorded even after whole testrun finishes - in such case I have no idea :) ) |
Hello, you might need to look at Pytest Hooks and perform actions after each test finishes/failed. https://pytest.org/en/stable/reference.html#hooks |
I need to upload trace and screenshot made on failure at the end of each test to my personal external system, but in fixture, in function scope trace and screenshots does not exist. It will be created after the fixture itself. So, my question is how to deal with them at the end of each test?
The text was updated successfully, but these errors were encountered: