码迷,mamicode.com
首页 > Web开发 > 详细

web自动化之basepage/loginpage

时间:2020-04-06 00:09:29      阅读:95      评论:0      收藏:0      [点我收藏+]

标签:exp   click   __init__   driver   sub   web   inf   word   self   

# 公共页 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

标签:exp   click   __init__   driver   sub   web   inf   word   self   

原文地址:https://www.cnblogs.com/sophia-985935365/p/12640005.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!