Untitled
unknown
plain_text
a month ago
906 B
1
Indexable
Never
def tearDown(self): """Tear down the WebDriver instance and capture screenshots based on test results.""" if not os.path.exists('screenshots'): os.makedirs('screenshots') result = self._outcome.result if hasattr(self, '_outcome') else None timestamp = time.strftime("%Y%m%d-%H%M%S") if result and (result.failures or result.errors): screenshot_filename = os.path.join('screenshots', f"screenshot_{timestamp}_failure.png") self.driver.save_screenshot(screenshot_filename) print(f"Failed screenshot {screenshot_filename} saved.") else: screenshot_filename = os.path.join('screenshots', f"screenshot_{timestamp}_success.png") self.driver.save_screenshot(screenshot_filename) print(f"Success screenshot {screenshot_filename} saved.") self.driver.quit()
Leave a Comment