develop an automated test case of the system in a page-oriented development mode;
the existing login login_case, will develop a logout_case.
because the prerequisite for logout_case is that the user has logged in, you must first call login_case in the code of logout_case.
excuse me, how is the code organized more elegantly?
here is the code:
LoginPage
class Login(Page):
"""
"""
url = "/honycloud/login.jsp"
login_username_loc = (By.ID, "idToken1")
login_password_loc = (By.ID, "idToken2")
login_button_loc = (By.ID, "loginButton_0")
def login_username(self, username):
self.find_element(*self.login_username_loc).send_keys(username)
def login_password(self, password):
self.find_element(*self.login_password_loc).send_keys(password)
def login_button(self):
self.find_element(*self.login_button_loc).click()
def user_login(self, username="badusername", password="badpassword"):
self.open()
self.login_username(username)
self.login_password(password)
self.login_button()
sleep(1)
login_case
class LoginTest(myunit.MyUnitTest):
"""
"""
-sharp test login
def user_login_verify(self, username="", password=""):
Login(self.driver).user_login(username, password)
def test_login(self):
self.user_login_verify(username="xxxx", password="ffff!")
page = Login(self.driver)
title = page.on_title()
self.assertEqual(title, u"")