UI自动化装饰器失败截图

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()

 

你可能感兴趣的:(UI自动化测试框架)