class TestSettings(unittest.TestCase): # 创建测试类 @classmethod # 类方法,只执行一次,但必须要加注解@classmethod,且名字固定为setUpClass def setUpClass(cls): # cls.d = u2.connect('192.168.199.168') # cls.d = u2.connect_usb('127.0.0.1:62025') cls.watcherframe = WatcherFrame(outdevice=TestDeviceID) #实例化 cls.watcherframe.new_create_watcher() cls.watcherframe.new_create_watcher(outwatchername='OK', outconditiontextname='OK', outclicktextname='OK') cls.watcherframe.start_watcher() print('\n') pass @classmethod # 类方法,只执行一次,但必须要加注解@classmethod,且名字固定为tearDownClass def tearDownClass(cls): print('\n') cls.watcherframe.close_all_watchers() pass def setUp(self): # 每条用例执行测试之前都要执行此方法 self.baseframe = BaseFrame(outdevice=TestDeviceID) #实例化 print('\n') #pass def tearDown(self): # 每条用例执行测试之后都要执行此方法 print('\n') pass #登录的测试方法 def defineclickandbackandlogout(self, outtestcasediscription=None, issettings=False, islogout=False, outclickelementtext=None): if outtestcasediscription == None: testcasediscription = '测试用例' else: testcasediscription = outtestcasediscription if outclickelementtext == None: clickelementtext = "My QR" else: clickelementtext = outclickelementtext if issettings: self.baseframe.findbytext_and_click("Settings") if islogout: self.baseframe.findbytext_and_click("Log Out") self.baseframe.findbytext_and_click("Log Out") self.baseframe.findbytext(outclickelementtext) else: self.baseframe.findbytext_and_click(clickelementtext) self.baseframe.delaytime(5) self.baseframe.clickback() self.baseframe.findbytext("Settings") print("%s.---测试通过" % testcasediscription) @data(("点击Settings进入Settings页,点击ChangeLoginPassword后返回Settings", True, False, "Change Login Password"), ("点击ChangeTransactionPIN后返回Settings", False, False, "Change Transaction PIN"), ("点击AboutQRindo后返回Settings", False, False, "About QRindo"), ("点击Help后返回Settings", False, False, "Help"), ("点击Logout登出", False, True, "Login")) @unpack def test_clickandbackandlogout(self, outtestcasediscription, issettings, islogout, outclickelementtext): self.defineclickandbackandlogout(outtestcasediscription, issettings, islogout, outclickelementtext)
class TestHome(unittest.TestCase): # 创建测试类 @classmethod # 类方法,只执行一次,但必须要加注解@classmethod,且名字固定为setUpClass def setUpClass(cls): # cls.d = u2.connect('192.168.199.168') # cls.d = u2.connect_usb('127.0.0.1:62025') cls.watcherframe = WatcherFrame(outdevice=TestDeviceID) #实例化 cls.watcherframe.new_create_watcher() cls.watcherframe.new_create_watcher(outwatchername='OK', outconditiontextname='OK', outclicktextname='OK') cls.watcherframe.start_watcher() print('\n') pass @classmethod # 类方法,只执行一次,但必须要加注解@classmethod,且名字固定为tearDownClass def tearDownClass(cls): print('\n') cls.watcherframe.close_all_watchers() pass def setUp(self): # 每条用例执行测试之前都要执行此方法 self.baseframe = BaseFrame(outdevice=TestDeviceID) #实例化 print('\n') #pass def tearDown(self): # 每条用例执行测试之后都要执行此方法 print('\n') pass #登录的测试方法 def defineclickandback(self, outtestcasediscription=None, ishomeorme=None, outclickelementtext=None): if outtestcasediscription == None: testcasediscription = '测试用例' else: testcasediscription = outtestcasediscription if ishomeorme == None: homeorme = "Home" else: homeorme = ishomeorme if outclickelementtext == None: clickelementtext = "My QR" else: clickelementtext = outclickelementtext self.baseframe.findbytext_and_click(homeorme) self.baseframe.findbytext_and_click(clickelementtext) self.baseframe.delaytime(5) self.baseframe.clickback() self.baseframe.findbytext(homeorme) print("%s.---测试通过" % testcasediscription) @data(("点击MYOR然后返回Home页", "Home", "My QR"), ("点击TopUp然后返回Home页", "Home", "Top Up"), ("点击History然后返回Home页", "Home", "History"), ("点击ShowAll然后返回Home页", "Home", "Show all"), ("点击Balance然后返回Me页", "Me", "Balance"), ("点击BankCard然后返回Me页", "Me", "Bank Card"), ("点击BankAccount然后返回Me页", "Me", "Bank Account"), ("点击IdentityVerification然后返回Me页", "Me", "Identity Verification"), ("点击Settings然后返回Me页", "Me", "Settings")) @unpack def test_clickandback(self, outtestcasediscription, ishomeorme, outclickelementtext): self.defineclickandback(outtestcasediscription, ishomeorme, outclickelementtext)