web自动化之basepage/loginpage

Posted 测试媛S

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了web自动化之basepage/loginpage相关的知识,希望对你有一定的参考价值。

# 公共页 basepage.py

class BasePage:
def __init__(self, driver):
self.driver = driver


# 登录页面   loginpage.py

from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from locators.login_locator import LoginLocator
from pages.base_page import BasePage


class LoginPage(BasePage):
login_locator = LoginLocator()

def get_phone_element(self):
return WebDriverWait(self.driver, 20).until(EC.visibility_of_element_located(
self.login_locator.phone_element))

def get_password_element(self):
return WebDriverWait(self.driver, 20).until(EC.visibility_of_element_located(
self.login_locator.password_element))

def send_phone_value(self, phone):
return self.get_phone_element().send_keys(phone)

def send_password_value(self, password):
return self.get_password_element().send_keys(password)

def clear_phone_value(self):
return self.get_phone_element().clear()

def clear_password_value(self):
return self.get_password_element().clear()

def get_submit_element(self):
return WebDriverWait(self.driver, 20).until(EC.visibility_of_element_located(
self.login_locator.submit_element))

def click_submit_element(self):
return self.get_submit_element().click()

def get_success_info(self):
return WebDriverWait(self.driver, 20).until(EC.visibility_of_element_located(
self.login_locator.success_info_element))

def get_error_msg_info(self):
return WebDriverWait(self.driver, 20).until(EC.visibility_of_element_located(
self.login_locator.error_msg_info_element))

def get_error_flash_info(self):
return WebDriverWait(self.driver, 20).until(EC.visibility_of_element_located(
self.login_locator.error_flash_info_element))







以上是关于web自动化之basepage/loginpage的主要内容,如果未能解决你的问题,请参考以下文章

web自动化之iframe操作

python自动化之web抓取

python之web自动化测试框架

技术分享 | Web自动化之Selenium安装

web自动化基础之web页面组成

web自动化之 登录 -投标