selnium 判断页面加载完成,如何检查页面是否在RSelenium中完成加载

当使用Selenium在网页上点击元素并希望获取结果时,如何确保新页面已经加载完成?设置隐式等待时间是一种方法,但可能会导致效率低下。通过设置隐式等待时间并查找页面上的特定元素,可以更优雅地解决这个问题。一旦设置,驱动器将在搜索元素时等待指定的时间,或者直到找到元素或超时,然后继续执行后续操作。
摘要由CSDN通过智能技术生成

Imagine that you click on an element using RSelenium on a page and would like to retrieve the results from the resulting page. How does one check to make sure that the resulting page has loaded? I can insert Sys.sleep() in between processing the page and clicking the element but this seems like a very ugly and slow way to do things.

解决方案

Set ImplicitWaitTimeout and then search for an element on the page. From ?remoteDriver

setImplicitWaitTimeout(milliseconds = 10000)

Set the amount of time

the driver should wait when searching for elements. When searching for

a single element, the driver will poll the page until an element is

found or the timeout expires, whichever occurs first. When searching

for multiple elements, the driver should poll the page until at least

one element is found or the timeout expires, at which point it will

return an empty list. If this method is never called, the driver will

default to an implicit wait of 0ms.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值