Hey is there a way to capture a screenshot upon a an Exception, any Exception. My 'failed' solution which is placed in the BaseTestCase
, unittest.TestCase
subclass:
def failureException(self):
class MyFailureException(Exception):
def __init__(self_, *args, **kwargs):
screenshot_dir = '../error_log'
self.driver.save_screenshot('{0}/{1}.jpeg'.format(screenshot_dir, self.id()))
return super().__init__(*args, **kwargs)
MyFailureException.__name__ = Exception.__name__
return MyFailureException
Originally it was AssertionError
instead of the Exception
but it would only catch assertion errors and I'm more interested in other kinds of errors
Aucun commentaire:
Enregistrer un commentaire