Skip to content
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

Full Page Screenshots #148

Merged
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion pytest_playwright/pytest_playwright.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,9 @@ def context(
context.tracing.stop()

screenshot_option = pytestconfig.getoption("--screenshot")
screenshot_fullscreen = (
True if pytestconfig.getoption("--full-page-screenshot") == "on" else False
CGBassPlayer marked this conversation as resolved.
Show resolved Hide resolved
)
capture_screenshot = screenshot_option == "on" or (
failed and screenshot_option == "only-on-failure"
)
Expand All @@ -246,7 +249,9 @@ def context(
pytestconfig, request, f"test-{human_readable_status}-{index+1}.png"
)
try:
page.screenshot(timeout=5000, path=screenshot_path)
page.screenshot(
timeout=5000, path=screenshot_path, full_page=screenshot_fullscreen
)
except Error:
pass

Expand Down Expand Up @@ -371,3 +376,9 @@ def pytest_addoption(parser: Any) -> None:
choices=["on", "off", "only-on-failure"],
help="Whether to automatically capture a screenshot after each test.",
)
group.addoption(
"--full-page-screenshot",
CGBassPlayer marked this conversation as resolved.
Show resolved Hide resolved
default="off",
choices=["on", "off"],
help="Whether to take a full page screenshot",
)