def test_login_nopassword(self): Logger().info("测试用例:异常用例-密码为空") Login(self.driver).login( login_account, "") try: WebDriverWait(self.driver, 10, 0.5).until(EC.visibility_of_element_located((By.XPATH, error_nopassword_location))) Logger().info("%s test pass" % sys._getframe().f_code.co_name) except Exception as e: verificationErrors.append(e) self.driver.save_screenshot(Project_path.Image_path+"%s_%s.png"%(sys._getframe().f_code.co_name,self.nowtime)) Logger().error("%s test fail" % sys._getframe().f_code.co_name)
def test_login_wrong_password(self, Web_driver_class): Logger().info("测试用例:异常用例-密码错误") Login(Web_driver_class).login(login_account, "11111111") try: assert Web_driver_class.find_element_by_xpath( error_wrongpassword_location).is_displayed() except Exception as e: Web_driver_class.save_screenshot( Project_path.Image_path + "%s_%s.png" % (sys._getframe().f_code.co_name, self.nowtime)) raise e else: Logger().info("%s test pass" % sys._getframe().f_code.co_name)
def test_login_wrongphone(self): Logger().info("测试用例:异常用例-手机号错误") try: Login(self.driver).login(url, "22222222222", "123456") WebDriverWait(self.driver, 10, 0.5).until( EC.visibility_of_element_located( (By.XPATH, error_wrongphone_location))) self.driver.close() Logger().error("%s test pass" % sys._getframe().f_code.co_name) except Exception as e: verificationErrors.append(e) self.driver.save_screenshot( Project_path.Image_path + "%s_%s.png" % (sys._getframe().f_code.co_name, self.nowtime)) Logger().info("%s test fail" % sys._getframe().f_code.co_name)
def test_login_ok(self): Logger().info("测试用例:正常登录") try: Login(self.driver).login(url, login_account, password) self.assertIn(pickname, Home(self.driver).get_account_name()) self.driver.close() except Exception as e: verificationErrors.append(e) self.driver.save_screenshot( Project_path.Image_path + "%s_%s.png" % (sys._getframe().f_code.co_name, self.nowtime)) Logger().error("%s test fail:%s" % (sys._getframe().f_code.co_name, e)) else: Logger().info("%s test pass" % sys._getframe().f_code.co_name)
def test_login_ok(self): Logger().info("测试用例:正常登录") Login(self.driver).login( login_account, password) try: self.assertIn(pickname,Home(self.driver).get_account_name()) except Exception as e: verificationErrors.append(e) self.driver.save_screenshot(Project_path.Image_path+"%s_%s.png"%(sys._getframe().f_code.co_name,self.nowtime)) Logger().error("%s test fail:%s" % (sys._getframe().f_code.co_name,e)) raise e # self.driver.execute_script('window.stop()') else: Logger().info("%s test pass" % sys._getframe().f_code.co_name) Home(self.driver).quit_login() Logger().info("退出登录成功")
def test_login_ok(self, Web_driver_class): Logger().info("测试用例:正常登录") Login(Web_driver_class).login(login_account, password) try: self.assertIn(pickname, Home(Web_driver_class).get_account_name()) except Exception as e: Web_driver_class.save_screenshot( Project_path.Image_path + "%s_%s.png" % (sys._getframe().f_code.co_name, self.nowtime)) Logger().error("%s test fail:%s" % (sys._getframe().f_code.co_name, e)) Web_driver_class.execute_script('window.stop()') else: Logger().info("%s test pass" % sys._getframe().f_code.co_name) finally: Home(Web_driver_class).quit_login()
def test_login_nopassword(self): Logger().info("测试用例:异常用例-密码为空") Login(self.driver).login(login_account, "") try: WebDriverWait(self.driver, 5, 0.2).until( EC.visibility_of_element_located( (By.XPATH, error_nopassword_location))) self.assertIsNotNone( self.driver.find_element_by_xpath(error_nopassword_location), "没有提示密码为空,fail") except Exception as e: self.driver.save_screenshot( Project_path.Image_path + "%s_%s.png" % (sys._getframe().f_code.co_name, self.nowtime)) raise e else: Logger().info("%s test pass" % sys._getframe().f_code.co_name)
def test_login_wrongphone(self): Logger().info("测试用例:异常用例-手机号错误") Login(self.driver).login("13017659465", "123456") try: WebDriverWait(self.driver, 5, 0.2).until( EC.visibility_of_element_located( (By.XPATH, error_wrongphone_location))) self.assertIsNotNone( self.driver.find_element_by_xpath(error_wrongphone_location), "没有提示手机号错误,fail") except Exception as e: self.driver.save_screenshot( Project_path.Image_path + "%s_%s.png" % (sys._getframe().f_code.co_name, self.nowtime)) raise e else: Logger().info("%s test pass" % sys._getframe().f_code.co_name)