Create screenshot only on test failure
问题 Currently I have a function that creates a screenshot and I call it here def tearDown(self): self.save_screenshot() self.driver.quit() There is also a folder being created which is used to store the screenshots. I don't want this to happen when the test passes. What do I have to add in order for this not to happen? Thanks for all the help 回答1: Here is one way to capture screenshot only when failure: def setUp(self): # Assume test will fail self.test_failed = True def tearDown(self): if self