我在测试中使用Selenium.WebDriver
和Selenium.Support
3.0.1,但在更新到更高版本后,我的代码会抛出错误。
代码失败:
// Element locating
// [FindsBy(How = How.ClassName, Using = "dot")]
// private IList<IWebElement> gameDots { get; set; }
for (int i = 0; i < levelIndicators.Count; i++)
{
Browser.Action.ClickAndHold(gameDots[0]);
foreach (IWebElement gameDot in gameDots)
{
Browser.Action.MoveToElement(gameDot);
}
Browser.Action.MoveToElement(gameDots[0])
.Build()
.Perform();
}
浏览器类:
public static Actions Action { get; set; }
public static IWebDriver Driver { get; set; }
static Browser()
{
Action = new Actions(Driver);
}
更新到任何较新版本的Selenium后,我会使用StaleElementReferenceException
方法获取Perform()
。降级到3.0.1后再次运行。
OpenQA.Selenium.StaleElementReferenceException:陈旧元素引用:元素未附加到页面文档(会话信息:chrome = 58.0.3029.110)(驱动程序信息:chromedriver = 2.29.461591(62ebf098771772160f391d75e589dc567915b233),platform = Windows NT 10.0。 15063 x86_64)
如果我尝试与gameDot[0]
元素进行交互而不执行任何Actions
,则一切都按预期工作。
答案 0 :(得分:0)
有同样的问题。第一次单击工作正常,第二次单击(没有dom更改!)抛出异常! 用clickElement替换action.clikc(clikckingElement).build.perform。Click()帮助。但这肯定是一个错误!
对于crhome v.59,一切都很好,但是硒3.0.1而不是最新的3.4