当前位置:网站首页>Selenium 等待元素出现与等待操作可以执行的条件
Selenium 等待元素出现与等待操作可以执行的条件
2022-07-25 09:27:00 【安卓世界库】
1.等待元素能被点击
new WebDriverWait(driver, Duration.ofSeconds(3)).until(ExpectedConditions.elementToBeClickable(By.xpath("//a/h3")));
2.强制等待
time.sleep(delay)
3.隐式等待(无条件等待,在一个时间段内等待)
一次设置,全局生效。不要当作固定等待使用,不要每次需要等待时都写一次隐式等待。
隐式等待设置了一个最长等待时间,在规定时间内网页加载完成(也就是一般情况下你看到浏览器标签栏那个小圈不再转就代表加载完成),则执行下一步,否则一直等到时间结束,然后执行下一步。
如果是只需等待页面中的一个元素加载就用显示等待,等待整个网页加载就用隐式等待。
使用方法:implicitly_wait(delay),delay的单位为秒
4.显式等待(有条件等待)
login_btn=WebDriverWait(wd,10,0.5).until(EC.presence_of_element_located((By.ID, "s-top-loginbtn"))
更多等待条件参考官网ExpectedConditions
边栏推荐
猜你喜欢

安装 oh my zsh

GCD详解
![[RNN] analyze the RNN from rnn- (simple|lstm) to sequence generation, and then to seq2seq framework (encoder decoder, or seq2seq)](/img/6e/da80133e05b18c87d7167c023b6c93.gif)
[RNN] analyze the RNN from rnn- (simple|lstm) to sequence generation, and then to seq2seq framework (encoder decoder, or seq2seq)

Common methods of nodejs version upgrade or switching

Pow(x,n)

@Import, conditional and @importresource annotations

静态路由的配置(以华为eNSP为例)

message from server: “Host ‘xxx.xxx.xxx.xxx‘ is not allowed to connect to this MySQL server“

Debug篇快捷键入门

ROS分布式操作--launch文件启动多个机器上的节点
随机推荐
See how a junior student of double non-2 (0 Internship) can get an offer from Alibaba and Tencent
JDBC操作数据库详解
腾讯云之错误[100007] this env is not enable anonymous login
Summary of most consistency problems
小程序企业发放红包功能
yarn速查手册
Ubuntu20.04系统下安装MySQL数据库5.7.29版本
广度优先遍历(图和二叉树的层序遍历相关问题)
RedisUtil
线程池的设计和原理
[tensorflow2 installation] tensorflow2.3-cpu installation pit avoidance guide!!!
链表相关(设计链表及环链表问题)
Introduction to armv8 architecture
NPM详解
UE4 快速找到打包失败的原因
VoxCeleb1 数据集下载
Arm preliminaries
Introduction to arm GIC
【近万字干货】别让你的简历配不上你的才华——手把手教你制作最适合你的简历
CCF 201512-4 delivery