Selenium webdriver:IE崩溃与“IE驱动程序的命令行服务器已停止工作”

时间:2018-03-14 09:42:07

标签: c# selenium internet-explorer selenium-webdriver iedriverserver

当我尝试清除Internet Explorer中的所有cookie时,webdriver(IEDriverServer)崩溃了。该错误不会出现在其他情况中。

View screenshot

.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 Standalone Server - 3.11.0
  • Internet Explorer驱动程序服务器 - 3.9.0(x32)
  • Windows 10 IE 11.1480.14393
  • .NET Framework 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

0 个答案:

没有答案