"com.tencent.tim:id/password").send_keys(i[1]) sleep(2) log.info(f"输入的手机号是:{i[1]}") self.dr.find_element_by_id("com.tencent.tim:id/login").click() log.info("点击登录按钮") sleep(6) """ if else 处理登录成功与失败,也可以使用try except语句做断言 """ try: log.info("登录失败的处理......") b = self.dr.find_element_by_id( "com.qk.butterfly:id/tv_to_login").text print("登录失败") self.assertEqual(b, "登录", msg="登录失败") except: log.info("登录成功的处理......") a = self.dr.find_elements_by_id( "com.qk.butterfly:id/tv_tab")[-1].text self.assertEqual(a, "首页", msg="断言已经登录成功") def tearDown(self): log.info("手机与appium断开连接......") self.dr.quit() if __name__ == '__main__': # unittest.main() config_2.report(test_name=DS("config_4"), report_path=r"E:\PycharmProjects\diesheng\report\a.html")
'com.qk.butterfly:id/tv_to_login').click() log.info('点击登录按钮') #断言 try: sleep(5) log.info('登录失败的处理') b = self.dr.find_element_by_id( 'com.qk.butterfly:id/tv_to_login').text print('登录失败') self.assertEqual(b, '登录', msg='登录失败') except: sleep(2) log.info('登录成功的处理') a = self.dr.find_elements_by_id( 'com.qk.butterfly:id/tv_tab')[-1].text print('登录成功') self.assertEqual(a, '我的', msg='我已登录成功') #每个测试用例执行完毕之后,运行teardown一次,作用:测试用例运行完,清理测试环境 def tearDown(self): log.info('手机与appium断开连接') self.dr.quit() if __name__ == '__main__': # unittest.main() config_2.report( test_name=DS('test_1'), report_path= 'C:/Users/xiaozy/PycharmProjects/untitled/diesheng/report/a.html')
a = self.dr.find_elements_by_id('')[-1].text self.assertEqual(a, '我的', msg="断言已经登陆成功") print("登录成功") #使用账号密码登录碟声 #点击密码,进入手机号,密码登录页面 #self.dr.find_elements_by_id('com.qk.butterfly:id/et_login_pwd').click() #进入登录手机号密码登录之后的页面之后 # self.dr.find_elements_by_id('com.qk.butterfly:id/et_login_phone').send_keys('') # self.dr.find_elements_by_id('com.qk.butterfly:id/et_login_pwd') # self.dr.find_elements_by_id('com.qk.butterfly:id/tv_to_login') #断言 #进入登录之后的页面 # a = self.dr.find_elements_by_id('')[-1].text # self.assertEqual(a,'我的',msg="断言已经登陆成功") #每一个测试用例执行完毕后, 运行teardown一次, 作用:测试用例运行完,清理测试环境 def tearDown(self): log.info('手机与appium断开连接…………') self.dr.quit() if __name__ == '__main__': #unittest.main() config_2.report( test_name=DS('test_1'), report_path=( 'C:\Users\hanwl\PycharmProjects\untitled2\diesheng\report\a.html'))
self.dr.find_element_by_id( "com.qk.butterfly:id/et_login_pwd").send_keys("i[1]") self.dr.find_element_by_id("com.qk.butterfly:id/tv_to_login").click() #断言 sleep(5.0) #进入登录之后的页面 #if else 处理登录成功与失败,也可使用try except 语句做断言 try: b = self.dr.find_element_by_id("com.qk.butterfly:id/tv_tab").text print("登录失败") self.assertequal(b, "登录", msg="登录失败") except: a = self.dr.find_element_by_id( "com.qk.butterfly:id/tv_tab")[-1].text self.assertequal(a, "我的", msg="断言已登录成功") #每个测试用例执行完之后,运行teardowm一次,作用:测试用例运行完,清理测试环境 def teraDown(self): self.dr.quit() if __name__ == '__main__': # unittest.main() config_2.report( test_name=DS("test_1"), report_path= "/Users/dingxiaobai/PycharmProjects/untitled/diesheng/data/d.html")