Web自动化测试—PO设计模式(二)
PO设计模式要点一:页面类都继承于BasePage
目录结构
ui_auto_test
--src
--pages
--__init__.py
--base_page.py
--login_page.py
--work_table_page.py
login_page.py
# conding:utf8
from .base_page import BasePage
from .home_page import WorkTablePage
#页面类都继承于BasePage
class LoginBage(BasePage):
def username_filed(self):
return self.by_css('#username')
def password_filed(self):
return self.by_css('#password_input')
def login_button(self):
return self.by_css('#tcloud_login_button')
def password_fail_text(self,text):
return self.by_css('#error-tips',text).text
class LoginAction(LoginBage):
def login_action(self,username,password):
self.username_filed().clear()
self.username_filed().send_keys(username)
self.password_filed().clear()
self.password_filed().send_keys(password)
self.login_button().click()
return WorkTablePage(self.driver)
work_table_page.py
# conding:utf8
from .base_page import BasePage
class WorkTablePage(BasePage):
def undo_word(self):
return self.by_css('.current.ul-inline a')
def get_undo_word_text(self):
return self.undo_word().text