Skip to content

Commit fe46635

Browse files
committed
Fix "save_teardown_screenshot()" for Python 3.11
1 parent 998f952 commit fe46635

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

seleniumbase/fixtures/base_case.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14022,8 +14022,8 @@ def has_exception(self):
1402214022

1402314023
def save_teardown_screenshot(self):
1402414024
"""(Should ONLY be used at the start of custom tearDown() methods.)
14025-
This method takes a screenshot of the current web page for a
14026-
FAILING test (or when using "--screenshot" / "--save-screenshot").
14025+
This method takes a screenshot of the active page for FAILING tests
14026+
(or when using "--screenshot" / "--save-screenshot" / "--ss").
1402714027
That way your tearDown() method can navigate away from the last
1402814028
page where the test failed, and still get the correct screenshot
1402914029
before performing tearDown() steps on other pages. If this method
@@ -14040,15 +14040,20 @@ def save_teardown_screenshot(self):
1404014040
if self.recorder_mode:
1404114041
# In case tearDown() leaves the origin, save actions first.
1404214042
self.save_recorded_actions()
14043-
if self.__has_exception() or self.save_screenshot_after_test:
14043+
if (
14044+
self.__has_exception()
14045+
or self.save_screenshot_after_test
14046+
or sys.version_info >= (3, 11)
14047+
):
1404414048
test_logpath = os.path.join(self.log_path, self.__get_test_id())
1404514049
self.__create_log_path_as_needed(test_logpath)
1404614050
self.__set_last_page_screenshot()
1404714051
self.__set_last_page_url()
1404814052
self.__set_last_page_source()
1404914053
sb_config._has_logs = True
14050-
if self.is_pytest:
14051-
self.__add_pytest_html_extra()
14054+
if self.__has_exception() or self.save_screenshot_after_test:
14055+
if self.is_pytest:
14056+
self.__add_pytest_html_extra()
1405214057

1405314058
def _log_fail_data(self):
1405414059
if sys.version_info < (3, 11):

0 commit comments

Comments
 (0)