Untitled
unknown
plain_text
a month ago
783 B
1
Indexable
Never
def tearDown(self): """Tear down the WebDriver instance and capture screenshots on failure.""" # Access the test outcome result = self._outcome.result if any(error for error in result.failures): timestamp = time.strftime("%Y%m%d-%H%M%S") screenshot_filename = f"screenshot_{timestamp}_failure.png" self.driver.save_screenshot(screenshot_filename) print(f"Failed screenshot {screenshot_filename} saved.") else: timestamp = time.strftime("%Y%m%d-%H%M%S") screenshot_filename = f"screenshot_{timestamp}_success.png" self.driver.save_screenshot(screenshot_filename) print(f"Success screenshot {screenshot_filename} saved.") self.driver.quit()
Leave a Comment