当前位置:网站首页>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
边栏推荐
猜你喜欢

JDBC总结

小程序企业发放红包功能

OSPF协议的配置(以华为eNSP为例)
![[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)

Copy the old project into a web project

史上最全面的UE4 文件操作,打开,读、写,增、删、改、查

nodejs版本升级或切换的常用方式

Introduction to armv8 architecture

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

线程池的设计和原理
随机推荐
小程序分享功能
Vant problem record
Configuring ROS development environment with vscode: Causes and solutions to the problem of ineffective code modification
js利用requestAnimationFrame实时检测当前动画的FPS帧率
鼠标监听,画笔
关于slf4j log4j log4j2的jar包配合使用的那些事
基础背包问题
Pnpm Brief
Leetcode 560 前缀和+哈希表
Advanced introduction to digital IC Design SOC
NPM详解
Yarn quick reference manual
字符串切片的用法
多线程——五大状态
CCF 201509-4 Expressway
See how a junior student of double non-2 (0 Internship) can get an offer from Alibaba and Tencent
Filter filter details (listeners and their applications)
Debug篇快捷键入门
@Import, conditional and @importresource annotations
nodejs版本升级或切换的常用方式