我申请硒webdriverwait方法特定IWebElement webdriverwait可用时获取此IWebElement的一些子元素。这是我的代码...使用在特定IWebElement
WebDriverWait wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
IList<IWebElement> elementsA = wait.Until<IList<IWebElement>>((d) =>
{
return driver.FindElements(By.XPath("//table[@class='boxVerde']"));
});
foreach (IWebElement iwe in elementsA)
{
wait = new WebDriverWait(driver, TimeSpan.FromSeconds(10));
IList<IWebElement> elementsB = wait.Until<IList<IWebElement>>((d) =>
{
return iwe.FindElements(By.XPath("tr/td/div/a"));
//trying to fetch the anchor tags from the element
});
}
它不断给我一个错误说“元素不再连接到DOM” ......我认为webdriver的等待是根本无法工作。我做错了什么人吗?非常感谢提前
什么版本的硒?该浏览器的浏览器和版本是什么?尝试使用与您的XPath查询相同的CSS选择器?你甚至需要等待吗? – Arran 2013-04-04 08:29:20
嗨Arran,我使用chromedriver_win_26.0.1383.0和硒版本2 ...还没有尝试CSS选择器。老实说,我不认为我需要等待,因为在我打电话之前我没有改变dom,但是因为它已经通过了,所以staleElementReferenceException的元素不再附加到DOM上了。我假设我不知道要等待什么...... – 2013-04-04 08:45:45
你有什么版本的Chrome?硒版本2点什么?最新版本是v2.31,你在用它吗? – Arran 2013-04-04 08:54:48