python+selenium selenium.webdriver.common.by之By
2021-02-18 15:18
标签:bsp 一个 登录 sele element self login driver 元素 By是selenium中内置的一个class,在这个class中有各种方法来定位元素 By所支持的定位器的分类: 用法 python+selenium selenium.webdriver.common.by之By 标签:bsp 一个 登录 sele element self login driver 元素 原文地址:https://www.cnblogs.com/Jasper-changing/p/12689606.htmlCLASS_NAME = ‘class name‘
CSS_SELECTOR = ‘css selector‘
ID = ‘id‘
LINK_TEXT = ‘link text‘
NAME = ‘name‘
PARTIAL_LINK_TEXT = ‘partial link text‘
TAG_NAME = ‘tag name‘
XPATH = ‘xpath‘
from selenium import webdriver
from selenium.webdriver.common.by import By
from time import sleep
class LoginPage(Page):
‘‘‘
126邮箱登录页面模型
‘‘‘
url=‘/‘
username_loc=(By.ID, "idInput")
password_loc=(By.ID, "pwdInput")
submit_loc=(By.ID, "loginBtn")
def type_username(self,username):
self.find_element(*self.username_loc).send_keys(username)
def type_password(self,password):
self.find_element(*self.password_loc).send_keys(password)
def submit(self):
self.find_element(*self.submit_loc).click()
上一篇:学习数据结构和算法的两个利器
文章标题:python+selenium selenium.webdriver.common.by之By
文章链接:http://soscw.com/index.php/essay/57099.html