我正在尝试创建一个等待页面加载的方法javascript
,但我有一个错误。可能我没有正确使用该方法。
public static void WaitForLoad(this IWebDriver driver, int timeoutSec = 15)
{
WebDriverWait wait = new WebDriverWait(driver, new TimeSpan(0, 0, timeoutSec));
wait.Until(wd => wd.ExecuteJavaScript("return document.readyState") == "complete");
}
错误是:
The type arguments for method 'WebdriverExtensions.ExecuteJavaScript<T>(IWerbDriver,string,params object[]' cannot be inferred from the usage.Try specifying the type arguments explicity)
In the WaitForLoad(...)
您正在检查的函数("return document.readyState") == "complete"
实际上,调用该函数WaitForLoad(...)
纯粹是一种超载,没有任何实际效果。那是因为Selenium DLL/JARS/模块设计的方式是webdriver
仅当以下情况时才执行下一行代码Browser您正在使用的发送document.readyState == "complete"
to the 网络驱动程序.
在你的情况下而不是验证document.readyState == "complete"
如果我们这样做会更有效wait即诱导显式等待为下一个网页元素我们打算与其中任何一个的适当条款进行交互ElementIsVisible(By)
, ElementToBeClickable(By)
, ElementToBeClickable(IWebElement)
, ElementToBeSelected(IWebElement, Boolean)
, etc.
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)