【发布时间】:2014-12-17 11:43:57
【问题描述】:
尝试在页面上运行以下 FindElements 方法时:
var match = Driver.Instance.FindElements(By.LinkText("Click here"));
我收到错误消息:
An exception of type 'OpenQA.Selenium.WebDriverException' occurred in WebDriver.dll but was not handled in user code.
OpenQA.Selenium.WebDriverException was unhandled by user code
HResult=-2146233088
Message=The HTTP request to the remote WebDriver server for URL http://localhost:7057/hub/session/a90c4828-3fb3-46d1-923d-8c5cbb65c4fe/elements timed out after 60 seconds.
Source=WebDriver
链接文本“单击此处”实际上并不存在于页面中,因此我不希望 FindElements(By) 实际找到任何内容(我稍后会在 If 语句中使用它)。该方法超时导致上述异常。
根据我的理解,如果 FindElements 超时,并且实际上没有找到任何东西,它应该返回 0 个元素。不只是超时并抛出异常。
有没有其他人遇到过这种情况或有任何想法可能是什么原因造成的?
【问题讨论】:
-
xander,据我所知,findElements 返回符合条件的元素集合。它可以是零个或多个元素。我希望问题是将集合分配给“var match”。你能有一个像 List
eles=your findements 这样的声明并试一试吗 -
什么版本的 Selenium,什么浏览器以及那个浏览器的什么版本?
标签: c# firefox selenium selenium-webdriver