@@ -14022,8 +14022,8 @@ def has_exception(self):
14022
14022
14023
14023
def save_teardown_screenshot(self):
14024
14024
"""(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 ").
14027
14027
That way your tearDown() method can navigate away from the last
14028
14028
page where the test failed, and still get the correct screenshot
14029
14029
before performing tearDown() steps on other pages. If this method
@@ -14040,15 +14040,20 @@ def save_teardown_screenshot(self):
14040
14040
if self.recorder_mode:
14041
14041
# In case tearDown() leaves the origin, save actions first.
14042
14042
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
+ ):
14044
14048
test_logpath = os.path.join(self.log_path, self.__get_test_id())
14045
14049
self.__create_log_path_as_needed(test_logpath)
14046
14050
self.__set_last_page_screenshot()
14047
14051
self.__set_last_page_url()
14048
14052
self.__set_last_page_source()
14049
14053
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()
14052
14057
14053
14058
def _log_fail_data(self):
14054
14059
if sys.version_info < (3, 11):
0 commit comments