Skip to content

Commit 929aa95

Browse files
committed
Add "SCREENSHOT_WITH_BACKGROUND" to settings
1 parent c8eac6e commit 929aa95

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

seleniumbase/config/settings.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,13 @@
3737
# If False, only the downloads from the most recent run will be saved locally.
3838
ARCHIVE_EXISTING_DOWNLOADS = False
3939

40+
# If True, the last page screenshot will include the <body> and background.
41+
# If False, the last page screenshot will only include the <body> section.
42+
# Depending on the screen size, including a background could make the <body>
43+
# appear very small in the screenshot, which may require manually zooming in
44+
# on the <body> to see page details if you decide to include the background.
45+
SCREENSHOT_WITH_BACKGROUND = False
46+
4047
# Default names for files saved during test failures.
4148
# (These files will get saved to the "latest_logs/" folder.)
4249
SCREENSHOT_NAME = "screenshot.png"

seleniumbase/core/settings_parser.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ def set_settings(settings_file):
7575
settings.ARCHIVE_EXISTING_LOGS = override_settings[key]
7676
elif key == "ARCHIVE_EXISTING_DOWNLOADS":
7777
settings.ARCHIVE_EXISTING_DOWNLOADS = override_settings[key]
78+
elif key == "SCREENSHOT_WITH_BACKGROUND":
79+
settings.SCREENSHOT_WITH_BACKGROUND = override_settings[key]
7880
elif key == "SCREENSHOT_NAME":
7981
settings.SCREENSHOT_NAME = override_settings[key]
8082
elif key == "BASIC_INFO_NAME":

seleniumbase/fixtures/base_case.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14030,7 +14030,17 @@ def __set_last_page_screenshot(self):
1403014030
ignore_test_time_limit=True,
1403114031
)
1403214032
try:
14033-
self.__last_page_screenshot = element.screenshot_as_base64
14033+
if (
14034+
hasattr(settings, "SCREENSHOT_WITH_BACKGROUND")
14035+
and settings.SCREENSHOT_WITH_BACKGROUND
14036+
):
14037+
self.__last_page_screenshot = (
14038+
self.driver.get_screenshot_as_base64()
14039+
)
14040+
else:
14041+
self.__last_page_screenshot = (
14042+
element.screenshot_as_base64
14043+
)
1403414044
except Exception:
1403514045
try:
1403614046
self.__last_page_screenshot = (

0 commit comments

Comments
 (0)