当我尝试清除 Internet Explorer 中的所有 cookie 时,webdriver (IEDriverServer) 崩溃。该错误在其他情况下不会出现。
查看屏幕截图
.Net (c#) 代码:
public override IWebDriver CreateRemoteDriver()
{
var options = GetOptions();
return new RemoteWebDriver(new Uri(GridUri), options.ToCapabilities());
}
public InternetExplorerOptions GetOptions()
{
InternetExplorerOptions options = new InternetExplorerOptions
{
IntroduceInstabilityByIgnoringProtectedModeSettings = true,
InitialBrowserUrl = "about:blank",
EnableNativeEvents = true,
EnsureCleanSession = true,
EnablePersistentHover = false,
};
switch (Version)
{
case "9":
case "10":
options.UsePerProcessProxy = false;
break;
case "11":
options.UsePerProcessProxy = true;
break;
}
var str = GetStrategyValueOrNull();
if (str != null)
options.AddAdditionalCapability(PageLoadStrategyCapabilityName, str);
foreach (var capability in CapabilityProperties)
{
options.AddAdditionalCapability(capability.Name, capability.Value);
}
options.Proxy = GetNewProxy();
return options;
}
public void DeleteAllCookie()
{
Driver.Manage().Cookies.DeleteAllCookies();
}
static void Main(string[] args)
{
var wd = new WebDriverManager();
try
{
wd.Config = new IEWebDriverConfig
{
IsGrid = true,
GridUri = "http://example:4435/wd/hub",
};
var url = "https://example.com/index.html";
wd.Driver.Navigate().GoToUrl(url);
wd.DeleteAllCookie();
Console.ReadKey();
}
catch (Exception ex)
{
Console.WriteLine(ex);
}
finally
{
wd.Quit();
}
}
我使用以下版本:
- Selenium 独立服务器 - 3.11.0
- Internet Explorer 驱动程序服务器 - 3.9.0 (x32)
- Windows 10 IE 11.1480.14393
- .NET 框架 4.6.1
堆栈跟踪:
System.Exception: Delete all cookie ---> OpenQA.Selenium.WebDriverException: The HTTP request to the remote WebDriver server for URL http://secret:4435/wd/hub/session/f4e86b53-80dc-49e7-88ef-a102d322b7a8/cookie timed out after 60 seconds. ---> System.Net.WebException: The request was aborted: The operation has timed out.
at System.Net.HttpWebRequest.GetResponse()
at OpenQA.Selenium.Remote.HttpCommandExecutor.MakeHttpRequest(HttpRequestInfo requestInfo)
--- End of inner exception stack trace ---
at OpenQA.Selenium.Remote.HttpCommandExecutor.MakeHttpRequest(HttpRequestInfo requestInfo)
at OpenQA.Selenium.Remote.HttpCommandExecutor.Execute(Command commandToExecute)
at OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute, Dictionary`2 parameters)
at OpenQA.Selenium.Remote.RemoteCookieJar.DeleteAllCookies()
at QA.AutomatedMagic.Managers.WebDriverManager.WebDriverManager.DeleteAllCookie() in C:\mypath\WebDriverManager.cs:line 1055
--- End of inner exception stack trace ---
at QA.AutomatedMagic.Managers.WebDriverManager.WebDriverManager.DeleteAllCookie() in C:\mypath\WebDriverManager.cs:line 1060
at QA.AutomatedMagic.Managers.Test.Program.Main(String[] args) in C:\mypath\Program.cs:line 33