问题描述
使用 watir-webdriver ,如何在单击后等待页面加载链接?
Using watir-webdriver, how do I wait for a page to load after I click a link?
此刻我正在使用:
sleep n
但这并不理想,因为页面响应变化很大.
But this is not ideal as the page response varies so much.
有没有一种方法可以测试页面是否准备就绪或页面中是否存在某些元素?我了解普通的Watir gem中有Watir::Waiter.wait_until
或类似名称,但在网络驱动程序版本中却看不到.
Is there a way to test whether the page is ready or whether there is a certain element in the page? I understand in the normal Watir gem there is Watir::Waiter.wait_until
or something similar, but I don't see this in the webdriver version.
推荐答案
我不知道它们是否是最好的方法,但这就是我如何处理此问题以等待更新div
清除的方法:
I don't know if they're the best way, but this is how I'm handling this for waiting for an updating div
to clear:
while browser.div(:id=>"updating_div").visible? do sleep 1 end
这是我处理等待显示的方式:
This is how I handle waiting for something to display:
until browser.div(:id=>"some_div").exists? do sleep 1 end
这篇关于如何使用watir-webdriver等待页面加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!