基于Selenium的web自動化框架(4)

發表于:2016-11-23來源:測試改進工場作者:測試改進工場點擊數: 標簽:框架
) cancelButton = (By.XPATH, //button[@class=\btn btn-warning ng-binding\][@ng-click=\cancel()\] ) okButton = (By.XPATH, //button[@class=\btn btn-primary ng-binding\][@ng-click=\ok()\] ) # Get username
) cancelButton = (By.XPATH,'//button[@class=\"btn btn-warning ng-binding\"][@ng-click=\"cancel()\"]') okButton = (By.XPATH,'//button[@class=\"btn btn-primary ng-binding\"][@ng-click=\"ok()\"]') #Get username textbox and input username def set_username(self,username): name = self.driver.find_element(*LoginPage.usename) name.send_keys(username) #Get password textbox and input password, then hit return def set_password(self, password): pwd = self.driver.find_element(*LoginPage.password) pwd.send_keys(password + Keys.RETURN) #Get pop up dialog title def get_DiaglogTitle(self): digTitle = self.driver.find_element(*LoginPage.dialogTitle) return digTitle.text #Get "cancel" button and then click def click_cancel(self): cancelbtn = self.driver.find_element(*LoginPage.cancelButton) cancelbtn.click() #click Sign in def click_SignIn(self): okbtn = self.driver.find_element(*LoginPage.okButton) okbtn.click()
復制代碼

 

 

采用頁面模式來管理頁面和測試用例有很多好處,主要體現在:

  • 簡單并且清晰

每個頁面都有單獨的類來封裝頁面元素和操作,讓頁面操作更加具體化,而不是相對獨立的。

比如未使用頁面模式,測試用例的輸入用戶名和密碼的代碼:

原文轉自:http://www.cnblogs.com/AlwinXu/p/5836709.html

...

熱門標簽

国产97人人超碰caoprom_尤物国产在线一区手机播放_精品国产一区二区三_色天使久久综合给合久久97