【发布时间】:2017-11-10 14:53:42
【问题描述】:
我目前正在关注这个关于 Selenium Waits 的教程:click me
我一生都无法弄清楚为什么我的 ImplicitWait 被忽略了。
private void TryFind()
{
_driver.Manage().Timeouts().ImplicitWait = TimeSpan.FromSeconds(5);
//go to a url that contains a dynamically loading page element
_driver.Navigate().GoToUrl(URI);
//click the start button
_driver.FindElement(By.TagName("button")).Click();
//find the element that has the text Hello World
var text = _driver.FindElement(By.XPath(".//*[contains(text(),'Hello World!')]"));
//click on the text
text.Click();
}
我希望这会在单击元素之前等待 5 秒钟,但它只是匆匆忙忙并抛出异常。
有什么想法吗?
谢谢
【问题讨论】:
-
请阅读How to Ask,尤其是关于minimal reproducible example(MCVE)和How much research effort is expected?的部分,这将帮助您调试自己的程序并自己解决问题。如果您这样做并且仍然卡住,您可以返回并发布您的 MCVE、您尝试过的内容以及执行结果(包括任何错误消息),以便我们更好地帮助您。还提供指向页面和/或相关 HTML 的链接。
-
你能分享一下这个例外吗?以及在哪个元素上引发了异常?
-
您使用的是哪个 Selenium 客户端? Java/C#/Ruby?