我在 IE9(win7、c#、selenium 2.3)上遇到了 webdriver 的问题。我得到NoSuchWindowException
例外。我发现我需要将所有安全级别的“启用保护模式”更改为相同的值。但我不想一般地手动更改我的设置,只是为了测试时间以编程方式。我以为我只需要设置IntroduceInstabilityByIgnoringProtectedModeSettings
为true
它就会工作,但事实并非如此。我的代码(这些行可以正常工作):
var option = new InternetExplorerOptions();
option.IntroduceInstabilityByIgnoringProtectedModeSettings = true;
IWebDriver Driver = new InternetExplorerDriver(option);
Driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds(5));
Driver.Navigate().GoToUrl(baseUrl);
这导致异常:
Driver.Manage().Window.Maximize();
An exception of type 'OpenQA.Selenium.NoSuchWindowException' occurred in WebDriver.dll but was not handled in user code
Additional information: Error retrieving window with handle current
还有这个:
string pageSource = Driver.PageSource;
An exception of type 'OpenQA.Selenium.NoSuchWindowException' occurred in WebDriver.dll but was not handled in user code
Additional information: Unable to get browse
你知道出了什么问题/我能做些什么来运行我的测试吗?