def accreditation_user(self, value, solution=1): LoginPage(self.driver).login(value) self.prepare_docs_for_accreditation(value) LoginPage(self.driver).logout() LoginPage(self.driver).login(Members().ADMIN_ETP) self.accept_register_contragents(value) self.search_new_accreditation_company(value) self.confirm_registration(value, solution) LoginPage(self.driver).logout()
def registration_page(self, value): LoginPage(self.driver).registration() self.choose_resident_status(value) self.fill_user_info(value) self.choose_role_in_system(value["role"]) self.fill_organizator_info(value) LoginPage(self.driver).logout() LoginPage(self.driver).login(Members().ADMIN_ETP) MainPage(self.driver).admin_confirm_email_new_user(value["user_mail"]) self.button('Закрыть').click() LoginPage(self.driver).logout()
def setup(self, browser): self.link = "http://selenium1py.pythonanywhere.com/catalogue/coders-at-work_207/" self.browser = browser email = str(time.time()) + "@fakemail.org" password = str(time.time()) page_login = LoginPage( browser, "http://selenium1py.pythonanywhere.com/accounts/login/") page_login.open() page_login.register_new_user(email, password)
class aTestLogin: """测试登录脚本类""" def setup_class(self): self.login_page = LoginPage(get_driver()) def teardown_class(self): self.login_page.driver.quit() def atest_login_case(self): self.login_page.page_input_username("18210783786") self.login_page.page_input_passwd("123456") self.login_page.page_login_click()
def get_login_page(cls): """登录""" return LoginPage()
def __init__(self, driver, section): self.login_page = LoginPage(driver, section)
class LoginHandle: """ 所有登录页面的操作 """ def __init__(self, driver, section): self.login_page = LoginPage(driver, section) def send_username(self, username): """ 输入用户名 """ self.login_page.get_username_element().clear() self.login_page.get_username_element().send_keys(username) def send_password(self, password): """ 输入密码 """ self.login_page.get_password_element().clear() self.login_page.get_password_element().send_keys(password) def click_login(self): """ 点击登录按钮 """ self.login_page.get_login_button_element().click() def get_fail_toast(self, message): """ 获取toast 根据返回信息判断是否获取到相应数据 @:param message: 预期得到的toast信息 """ toast_element = self.login_page.get_toast_element(message) if toast_element: return True else: return False def is_login_success(self): """ 根据页面是否出现相应的元素 例:title 来判断是否登录成功 :return: Boolean """ if self.login_page.get_content_page_status_element() is not None: return True else: return False def click_account_button(self): """ 点击首页的账号按钮 进入设置页面 :return: """ self.login_page.get_account_element()[0].click() def click_login_out(self): """ 点击退出登录按钮 :return: """ self.login_page.get_loginout_button_element().click() def is_login_out_success(self): """ 退出登录是否成功 根据登录页面的logo标识判断 :return: """ if self.login_page.get_login_logo_element() is not None: return True return False
def test_reg_form(browser): page = LoginPage(browser, loginLink) page.open() page.should_be_register_form()
def test_login_form(browser): page = LoginPage(browser, loginLink) page.open() page.should_be_login_form()
def test_login_link(browser): page = LoginPage(browser, sLink) page.open() page.should_be_login_url()
def test_guest_can_go_to_login_page(browser): page = MainPage(browser, sLink) page.open() page.go_to_login_page() login_page = LoginPage(browser, browser.current_url) login_page.should_be_login_page()
def get_login_page(self): """返回登录页面对象""" return LoginPage(self.driver)
def setup_class(self): self.login_page = LoginPage(get_driver())