当前位置:网站首页>Selenium 显示等待WebDriverWait
Selenium 显示等待WebDriverWait
2022-04-23 20:43:00 【weixin_52539672】
常规用法
from selenium.webdriver.common.by import By
from selenium.webdriver.remote.webdriver import WebDriver
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
class HomePage:
exists_link = (By.XPATH, '/html/body/div[2]/div/div[2]/div[1]/span')
def __init__(self, driver: WebDriver):
self.driver = driver
def get_element_exists(self):
try:
WebDriverWait(self.driver, 10).until(EC.visibility_of_element_located(self.exists_link))
except:
return False
else:
return True
2、等待条件及其含义
等待条件 | 含义 |
---|---|
title_is
|
标题是某内容
|
title_contains
|
标题包含某内容
|
presence_of_element_located
|
节点加载出,传入定位元组,如
(By.ID, 'p')
|
visibility_of_element_located
|
节点可见,传入定位元组
|
visibility_of
|
可见,传入节点对象
|
presence_of_all_elements_located
|
所有节点加载出
|
text_to_be_present_in_element
|
某个节点文本包含某文字
|
text_to_be_present_in_element_value
|
某个节点值包含某文字
|
frame_to_be_available_and_switch_to_it frame
|
加载并切换
|
invisibility_of_element_located
|
节点不可见
|
element_to_be_clickable
|
节点可点击
|
staleness_of
|
判断一个节点是否仍在
DOM,可判断页面是否已经刷新
|
element_to_be_selected
|
节点可选择,传节点对象
|
element_located_to_be_selected
|
节点可选择,传入定位元组
|
element_selection_state_to_be
|
传入节点对象以及状态,相等返回
True,否则返回
False
|
element_located_selection_state_to_be
|
传入定位元组以及状态,相等返回
True,否则返回
False
|
alert_is_present
|
是否出现
Alert
|
版权声明
本文为[weixin_52539672]所创,转载请带上原文链接,感谢
https://blog.csdn.net/weixin_52539672/article/details/124291329
边栏推荐
- LeetCode 116. 填充每个节点的下一个右侧节点指针
- BMP JPEG picture to vector image contourtrace
- 学会打字后的思考
- SQL gets the latest record of the data table
- Automatically fill in body temperature and win10 task plan
- LeetCode 74、搜索二维矩阵
- Install MySQL 5.0 under Linux 64bit 6 - the root password cannot be modified
- 【PTA】L1-002 打印沙漏
- vulnhub DC:1渗透笔记
- Queue template code
猜你喜欢
Some basic configurations in interlij idea
【PTA】整除光棍
Plato Farm元宇宙IEO上线四大,链上交易颇高
Latex formula
MySQL基础合集
Actual measurement of automatic ticket grabbing script of barley network based on selenium (the first part of the new year)
Come in and teach you how to solve the problem of port occupation
Scripy tutorial - (2) write a simple crawler
How to use PM2 management application? Come in and see
UnhandledPromiseRejectionwarning:CastError: Cast to ObjectId failed for value
随机推荐
Installation and use of NVM
SQL: query duplicate data and delete duplicate data
Recognition of high-speed road signs by Matlab using alexnet
How can matlab obtain the truncated image in trainingimagelabeler
上海回应“面粉官网是非法网站”:疏于运维被“黑”,警方已立案
居家第二十三天的午饭
Shanghai a répondu que « le site officiel de la farine est illégal »: l'exploitation et l'entretien négligents ont été « noirs » et la police a déposé une plainte
Three. Based on ply format point cloud voxel model JS upload interface writing
Leetcode 994, rotten orange
一. js的深拷贝和浅拷贝
Latex formula
Shanghai responded that "flour official website is an illegal website": neglect of operation and maintenance has been "hacked", and the police have filed a case
[PTA] l2-011 play with binary tree
Identification of bolt points in aerial photography based on perception
MySQL stored procedures and functions
【PTA】整除光棍
学会打字后的思考
深入探究ASP.NET Core读取Request.Body的正确方式
Solve the Chinese garbled code of URL in JS - decoding
Unity ECS dots notes