-
Notifications
You must be signed in to change notification settings - Fork 17
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
Add screenshot teardown fixture - approach 1 #421
Changes from all commits
2ba375a
b495130
33551be
c4f12f4
354bbd0
9ae9165
2853f8c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -90,6 +90,18 @@ def _selenium_driver(nb_path): | |||||
return _selenium_driver | ||||||
|
||||||
|
||||||
@pytest.fixture | ||||||
def final_screenshot(request, screenshot_dir, selenium): | ||||||
"""Take screenshot at the end of the test. | ||||||
Screenshot name is generated from the test function name | ||||||
by stripping the 'test_' prefix | ||||||
""" | ||||||
screenshot_name = f"{request.function.__name__[5:]}.png" | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Maybe this is more pointy to the purpose? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think lstrip here does what you think: https://stackoverflow.com/questions/4148974/removing-a-prefix-from-a-string There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see, then just ignore my request. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note that in Python 3.9 one could use the |
||||||
screenshot_path = Path.joinpath(screenshot_dir, screenshot_name) | ||||||
yield | ||||||
selenium.get_screenshot_as_file(screenshot_path) | ||||||
|
||||||
|
||||||
@pytest.fixture | ||||||
def firefox_options(firefox_options): | ||||||
firefox_options.add_argument("--headless") | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, using
request.function
, didn't know that. This is brilliant!