def errorScreen(func):
def wrapper(self, *args, **kwargs):
try:
func(self)
except:
self.driver.get_screenshot_as_file('./{}.png'.format(func.__name__))
return wrapper
class TestLogin(unittest.TestCase):
def setUp(self):
self.driver = Browser().driver
self.url = 'https://www.xxx.com/#/login'
self.name = 'admin'
self.password = '123456'
@errorScreen
def testLogin(self):
self.driver.get(self.url)
self.driver.find_element_by_xpath('su').click()