C#Selenium库Chrome驱动程序无法精确读取网页
我在C#中使用selenium库和chrome驱动程序来提取数据。 我尝试了许多解决办法,但问题仍然存在C#Selenium库Chrome驱动程序无法精确读取网页,c#,google-chrome,selenium,selenium-chromedriver,page-load-time,C#,Google Chrome,Selenium,Selenium Chromedriver,Page Load Time,我在C#中使用selenium库和chrome驱动程序来提取数据。 我尝试了许多解决办法,但问题仍然存在 Chrome驱动程序不会显式地等待页面完全加载 有时chrome驱动程序读取以前的记录值并写入excel文件 我尝试过的解决方案有: private static void WaitUntilDocumentIsReady(TimeSpan timeout, ChromeDriver WebDriver) { var javaScriptExecuto
private static void WaitUntilDocumentIsReady(TimeSpan timeout, ChromeDriver WebDriver)
{
var javaScriptExecutor = WebDriver as IJavaScriptExecutor;
var wait = new WebDriverWait(WebDriver, timeout);
// Check if document is ready
Func<IWebDriver, bool> readyCondition = webDriver => (bool)javaScriptExecutor.ExecuteScript("return (document.readyState == 'complete' && jQuery.active == 0)");
wait.Until(readyCondition);
}
谢谢您是否尝试降级您的Chrome版本?我听说最新的Chrome版本与Selenium有一些兼容性问题。@StriterAlfa no。我正在使用最新版本的google Chrome。
detailDriver.Manage().Timeouts().SetPageLoadTimeout(TimeSpan.FromSeconds(50));