def test_05_login_by_null_username_correct_password(self): try: login_by_different_username_password(self.browser, "", "s1234567") sleep(2) tips_ele = self.browser.find_element_by_xpath( '/html/body/div[1]/div/table/tbody/tr[2]/td[2]/div/table/tbody/tr[2]/td/div/table/tbody/tr/td[2]' ) self.assertIsNotNone(tips_ele) except Exception as e: jietu(self.browser, "登录异常") raise e
def test_03_login_by_wrong_username_correct_password(self): try: login_by_different_username_password(self.browser, "supppp", "s1234567") sleep(2) # 使用错误提示信息的内容进行断言 tips_ele = self.browser.find_element_by_xpath( '/html/body/div[1]/div/table/tbody/tr[2]/td[2]/div/table/tbody/tr[2]/td/div/table/tbody/tr/td[2]' ) tips = tips_ele.text self.assertEqual("登录名或密码错误,请重试!", tips) except Exception as e: jietu(self.browser, "登录异常") raise e
def test_01_login_by_correct_username_password(self): try: login_by_different_username_password(self.browser, "sup", "s1234567") sleep(2) # 使用登录后的用户名进行断言 username_ele = self.browser.find_element_by_xpath( '/html/body/div[1]/table/tbody/tr/td[2]/table/tbody/tr[3]/td[1]/label' ) username = username_ele.text self.assertEqual(username, "苏鹏") except Exception as e: jietu(self.browser, "登录异常") raise e
__author__ = 'Administrator' from selenium import webdriver from selenium_day3.user_login import def_user_login from time import sleep browser = webdriver.Firefox() # def_user_login.login_sup(browser) def_user_login.login_by_different_username_password(browser,"sup","s1234567") sleep(2) def_user_login.login_by_different_username_password(browser,"supppppp","s1234567") sleep(2) browser.quit()
def setUp(self): self.browser = webdriver.Firefox() self.browser.maximize_window() login_by_different_username_password(self.browser,"sup","s1234567") sleep(2)
__author__ = 'Administrator' from selenium import webdriver from time import sleep from selenium_day3.user_login.def_user_login import login_by_different_username_password from selenium_day3.change_password.def_change_password import change_password browser = webdriver.Firefox() login_by_different_username_password(browser, "sup", "s1234567") sleep(2) change_password(browser, "s1234567", "s12345678", "s12345678") sleep(2) login_by_different_username_password(browser, "sup", "s12345678") sleep(2) change_password(browser, "s12345678", "s1234567", "s1234567") sleep(2) browser.quit()