无法使用 webdriver 打开 InternetExplorer

Unable to open InternetExplorer using webdriver

我在 windows 7 64 位 PC 中尝试在 Internet Explorer 11 中浏览 url 时出现此错误。

IWebDriver NewDriver = new InternetExplorerDriver("D:\"); //IEDriverServer(64bit) is saved in D:\
NewDriver.Navigate().GoToUrl("http://www.google.com");
NewDriver.Manage().Window.Maximize();
IWait<IWebDriver> wait1 = new WebDriverWait(NewDriver, TimeSpan.FromSeconds(5.00));

//ERROR AT THIS LINE
wait1.Until(driver1 => ((IJavaScriptExecutor)NewDriver).ExecuteScript("return document.readyState;").Equals("complete"));

ERROR : javaScript error (UnexpectedJavaScriptError)

我已将 IE 安全选项中的所有安全区域设置为 'Enable Protected Mode',还卸载了 windows 更新 'KB3025390'。调试时,我看到正在加载 google 页面。

相同的代码适用于 FirefoxDriver。

比较合理的例子:

//Nuget install:
//PM > Install-Package Selenium.WebDriver
//PM > Install-Package Selenium.Support
//PM > Install-Package Selenium.WebDriver.ChromeDriver

using (var driver = new ChromeDriver())
{
    driver.Navigate().GoToUrl("http://www.google.com");
    //get will deal with page ready wait, unless it is ajax page. If you choose to do 
    //nothing then browser will close after navigation has completed          
}

"login" 在 selenium 中的示例:

driver.FindElement(By.Id("user")).SendKeys("username"); //fill in username
driver.FindElement(By.Id("pass")).SendKeys("password"); //fill in password 
driver.FindElement(By.Id("pass")).Submit();             //submit form where element is