def setUp(self): self.driver = webdriver.Firefox() self.linken = LoginBug(self.driver) self.linken1 = Login(self.driver) self.linken.is_alert() self.driver.delete_all_cookies() self.driver.refresh()
def test003(self): """第三条测试用例,输入正确的用户名密码""" try: po = Login(self.driver) po.login_flow("15179062604", "Z520314") self.assertNotEqual(po.error(), "登陆成功") except: print("登陆成功")
def setUpClass(cls) -> None: cls.case_id = cls.__name__ lg = Login() try: cls.driver = lg.login() except Exception as e: if lg.driver: lg.driver.quit() assert 0, "{} 登录失败! 原因: {}".format(cls.case_id, e.__str__())
def test001(self): """第一条测试用例""" logg.info("第一条用例开始执行") try: po=Login(self.driver) po.login_flow("","")#输入空的用户名和空的密码 self.assertNotEqual(po.error(),"请您输入手机/邮箱/用户名") except Exception as e: print("打印错误信息:%s",e)
def test002(self): """第二条测试用例,输入错误的用户名密码,并且数据来自的是excel表格""" #失败用例 po=Login(self.driver) po.login_flow(testData[2]["username"],testData[2]["password"]) print("用户名:",testData[2]["username"]) print("密码:", testData[2]["password"]) self.assertEqual(po.error(),"帐号或密码错误") #这是断言,因为实际提示信息是“账号或密码错误,或者找回密码” logg.info("这是日志结束哦")
def _initial(self): self.case_id = self.__class__.__name__ lg = Login() try: self.driver = lg.login() except Exception as e: if lg.driver: lg.driver.quit() assert 0, "{} 登录失败! 原因: {}".format(self.case_id, e.__str__())
def setUp(self): warnings.simplefilter("ignore", ResourceWarning) self.driver = webdriver.Chrome() self.baseCom = BaseCommon(self.driver) self.baseCom.maxBroswer() self.data = unit().operaYaml( 'C:/Users/yunwen/PycharmProjects/customerServer/data/pageData/login.yaml' ) self.weadmin_login = Login(self.driver) self.baseCom.openUrl(self.data['url']['webadmin'])
def test_login(self): """ 登录新浪邮箱 """ Login.navigate_email(self) Login.input_username(self,"*****@*****.**") Login.input_passwd(self,"zhouxudong325460") Login.click_btn(self)
def setUpClass(cls): cls.driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', road_transport()) cls.base = Base(cls.driver) cls.h = My(cls.driver) cls.a = Login(cls.driver) b = cls.driver.page_source print(b) warnings.simplefilter("ignore", ResourceWarning) # 忽略警告日志 time.sleep(2)
def setUpClass(cls): cls.driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', road_transport()) cls.base = Base(cls.driver) cls.a = Login(cls.driver) # cls.a.allows() # 允许权限 # cls.a.skip_login() # 跳过滚动页 # a = cls.driver.page_source # print(a) warnings.simplefilter("ignore", ResourceWarning) # 忽略警告日志
def setUp(self): print('* * * Start * * *') self.driver = webdriver.Remote('http://127.0.0.1:4723/wd/hub', road_transport()) self.base = Base(self.driver) self.n = SearchOrder(self.driver) self.a = Login(self.driver) # a = cls.driver.page_source # print(a) warnings.simplefilter("ignore", ResourceWarning) # 忽略警告日志 self.driver.implicitly_wait(20)
def logout(self,x,y): ''' 無法定位“退出登錄”元素 在原生頁面上進行元素點擊操作 :return: ''' # self.driver.switch_to.context(self.driver.contexts[-1]) # print(self.driver.current_url) # self.step("../data/settingpage.yaml", "logout") sleep(2) self.touch_tap(x,y) self.touch_tap(x, y) from page.login import Login return Login(self.driver)
class Main(unittest.TestCase): def setUp(self): warnings.simplefilter("ignore", ResourceWarning) self.driver = webdriver.Chrome() self.baseCom = BaseCommon(self.driver) self.baseCom.maxBroswer() self.data = unit().operaYaml( 'C:/Users/yunwen/PycharmProjects/customerServer/data/pageData/login.yaml' ) self.weadmin_login = Login(self.driver) self.baseCom.openUrl(self.data['url']['webadmin']) #输入正确的用户名及密码 @ddt.data(*readExcel) @ddt.unpack def test_login(self, username, password, result): self.baseCom.untilTime("XPATH", self.data["login"]["username"]) self.weadmin_login.userName().send_keys(username) self.baseCom.untilTime("XPATH", self.data["login"]["password"]) self.weadmin_login.password().send_keys(password) self.baseCom.untilTime("XPATH", self.data["login"]["login-btn"]) self.weadmin_login.login_Btn().click() time.sleep(2) self.assertEqual( self.driver.find_element_by_xpath( self.data["msg-content_username"]).text, result) #只输入用户名,不输入密码 #def test_login_username(self): #self.weadmin_login.webadmin_Login_username() #self.baseCom.untilTime("XPATH",self.data["msg-content_username"]) #self.assertEqual(self.driver.find_element_by_xpath(self.data['msg-content_username']).text,self.assertData['login_username']) #只输入密码,不输入用户名 #def test_login_password(self): #self.weadmin_login.webadmin_Login_password() #self.assertEqual(self.driver.find_element_by_xpath(self.data['msg-content_password']).text,self.assertData['login_password']) #不输入密码及用户名 #def test_login_Null(self): #self.weadmin_login.webadmin_Login_Allnull() #self.baseCom.untilTime("XPATH",self.data["All_Null"]) #time.sleep(3) #self.assertEqual(self.driver.find_element_by_xpath(self.data['All_Null']).text,self.assertData['login_password']) #输入错误的用户名及密码 #def test_login_all_Error(self): #self.weadmin_login.webadmin_Login_All_Errror() #self.assertEqual(self.driver.find_element_by_xpath(self.data['msg-content_AllError']).text,self.assertData['login_AllError']) #客服登录系统 #def test_cus_login(self): #self.weadmin_login.webcustomer_login() #self.assertEqual(self.driver.find_element_by_xpath(self.data['myContent']).text,self.assertData['myContent']) def tearDown(self): self.baseCom.quitBrowser()
class TestE(unittest.TestCase): """登录页面测试案例""" def setUp(self): self.driver = webdriver.Firefox() self.linken = LoginBug(self.driver) self.linken1 = Login(self.driver) self.linken.is_alert() self.driver.delete_all_cookies() self.driver.refresh() def login_case(self,user,pswd,expect): """登录流程""" self.linken.loginpage(user,pswd) result = self.linken1.duanyan() print(result) if expect == "True": expectnew = True else:expectnew = False print(expect) self.assertEqual(result,expectnew) @ddt.data(*datadict) def test_01(self,data): self.login_case(data["user"],data["pswd"],data["expect"]) def tearDown(self): self.driver.quit()
def setUpClass(cls): cls.driver = webdriver.Firefox() cls.driver.maximize_window() cls.linken = Add_product(cls.driver) cls.linken1 = Login(cls.driver)
def into_login(self): # 点击登录按钮 self.find(By.CSS_SELECTOR, ".index_top_operation_loginBtn").click() # 跳转登录页面 return Login(self._driver)
def goto_login(self): self.steps("../page/fmain.yaml") return Login(self._driver)
def goto_login(self): ''' 进入登錄頁 ''' return Login(self.driver)
def goto_login(self): self.find(MobileBy.XPATH,"//*[@text='帐号密码登录']").click() from page.login import Login return Login(self._driver)
def goto_login(self): """ 去登录 :return: Login(self._driver) """ return Login(self._driver)
def goto_login(self): self.find(By.CSS_SELECTOR, ".index_top_operation_loginBtn").click() return Login(self._driver)
def get_log_obj(self): return Login(self.driver)
def setUpClass(cls): cls.driver = webdriver.Chrome() cls.linken = LoginBug(cls.driver) cls.linken1 = Login(cls.driver)
def _logout(driver): return Login(driver).logout()