当前位置:网站首页>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
边栏推荐
- 6-5 字符串 - 2. 字符串复制(赋值) (10 分)C语言标准函数库中包括 strcpy 函数,用于字符串复制(赋值)。作为练习,我们自己编写一个功能与之相同的函数。
- Learn to C language fourth day
- Mathematical modeling column | Part 5: MATLAB optimization model solving method (Part I): Standard Model
- [PTA] l1-006 continuity factor
- Bracket matching -- [implementation of one-dimensional array]
- Leetcode 1351. Negative numbers in statistical ordered matrices
- go slice
- Matlab: psychtoolbox installation
- The ODB model calculates the data and outputs it to excel
- Leetcode 994, rotten orange
猜你喜欢
Monte Carlo py solves the area problem! (save pupils Series)
LeetCode 994、腐烂的橘子
Matlab analytic hierarchy process to quickly calculate the weight
Actual measurement of automatic ticket grabbing script of barley network based on selenium (the first part of the new year)
上海回应“面粉官网是非法网站”:疏于运维被“黑”,警方已立案
Installation and use of NVM
41. 缺失的第一个正数
Leetcode 994, rotten orange
How to configure SSH public key in code cloud
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
随机推荐
Some basic knowledge of devexpress report development
浅谈数据库设计之三大范式
LeetCode 1351、统计有序矩阵中的负数
RT-1052学习笔记 - GPIO架构分析
star
Communication between RING3 and ring0
【PTA】L2-011 玩转二叉树
PHP的Laravel与Composer部署项目时常见问题
Syntax Error: TypeError: this. getOptions is not a function
On IRP from the perspective of source code
JSX syntax rules
2021-09-02 unity project uses rider to build hot change project failure record of ilruntime
An error occurs when the addressable assets system project is packaged. Runtimedata is null
3-5通过XSS获取cookie以及XSS后台管理系统的使用
2022dasctf APR x fat epidemic prevention challenge crypto easy_ real
The iswow64process function determines the number of program bits
bounding box iou
[PTA] l1-006 continuity factor
[PTA] l1-002 printing hourglass
Modeling based on catiav6