如何检查页面是否在RSelenium中完成加载 [英] how to check if page finished loading in RSelenium
问题描述
想象一下,您在页面上使用RSelenium
单击某个元素,并希望从结果页面中检索结果.如何检查以确保生成的页面已加载?我可以在处理页面和单击元素之间插入Sys.sleep()
,但这似乎是一种非常丑陋且缓慢的方法.
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.
推荐答案
设置ImplicitWaitTimeout
,然后在页面上搜索元素.来自?remoteDriver
Set ImplicitWaitTimeout
and then search for an element on the page. From ?remoteDriver
setImplicitWaitTimeout(毫秒= 10000)
setImplicitWaitTimeout(milliseconds = 10000)
设置时间量 驱动程序在搜索元素时应等待.搜索时 单个元素,驱动程序将轮询页面,直到一个元素被 找到或超时到期,以先到者为准.搜索时 对于多个元素,驱动程序应轮询页面,直到至少 找到一个元素或超时到期,届时它将 返回一个空列表.如果从未调用此方法,驱动程序将 默认为0ms的隐式等待.
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.
这篇关于如何检查页面是否在RSelenium中完成加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!