c# - 在 45000 内无法启动套接字

标签 c# firefox selenium-webdriver webdriver

我正在使用 FF 版本 19

昨天之前一切正常,今天早上突然出现这个错误,我的代码与之前运行的代码完全相同,没有任何变化

错误信息:

Test 'M:.TestCases.12' failed: Failed to start up socket within 45000
    OpenQA.Selenium.WebDriverException: Failed to start up socket within 45000
    at OpenQA.Selenium.Firefox.Internal.ExtensionConnection.ConnectToBrowser(Int64 timeToWaitInMilliSeconds)
    at OpenQA.Selenium.Firefox.Internal.ExtensionConnection.Start()
    at OpenQA.Selenium.Firefox.FirefoxDriver.StartClient()
    at OpenQA.Selenium.Remote.RemoteWebDriver..ctor(ICommandExecutor commandExecutor, ICapabilities desiredCapabilities)
    at OpenQA.Selenium.Firefox.FirefoxDriver..ctor(FirefoxBinary binary, FirefoxProfile profile, TimeSpan commandTimeout)
    at OpenQA.Selenium.Firefox.FirefoxDriver..ctor(FirefoxBinary binary, FirefoxProfile profile)
    at OpenQA.Selenium.Firefox.FirefoxDriver..ctor(FirefoxProfile profile)

0 passed, 1 failed, 0 skipped, took 145.80 seconds (Ad hoc).

这是我的源代码:

public static IWebDriver GetDriver()
        {
            switch (Common.BrowserSelected)
            {
                case "ff":
                    FirefoxProfile profile = new FirefoxProfile();
                    profile.SetPreference("network.http.phishy-userpass-length", 255);
                    profile.SetPreference("network.automatic-ntlm-auth.trusted-uris", url);
                    drv = new FirefoxDriver(profile);
                    break;
                case "ie":
                    var options = new InternetExplorerOptions();
                    options.IntroduceInstabilityByIgnoringProtectedModeSettings = true;
                    DesiredCapabilities capabilities = new DesiredCapabilities();
                    capabilities.SetCapability(CapabilityType.AcceptSslCertificates, true);
                    drv = new InternetExplorerDriver(options);
                    break;
                case "chrome":
                    //_driver = new ChromeDriver();
                    break;
            }
            return drv;
        }

最佳答案

Selenium 的最新版本添加了对 Firefox 19 的“支持”。因此,由于您使用的是 .NET,因此在撰写本文时直接下载的最新版本是 2.31.2 版:

selenium-release.storage.googleapis.com/index.html

关于c# - 在 45000 内无法启动套接字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15249820/

相关文章:

Firefox 和 SSL : sec_error_unknown_issuer

java - 使用基本页面对象扩展可加载组件

c# - 为什么对象头大小在 64 位架构中翻了一番?

c# - 如何使用 C# 在嵌套网格中获取按钮查找控件值

javascript - Bing map 上的 HTML 框无法在 IE8 或 Firefox 中正确查看

perl - 哪些 http header 可以在浏览器后退按钮上抑制 "This document is no longer available."?

node.js - 元素存在后如何运行 selenium webdriver 代码

java - Selenium Webdriver (Java) - 从 css 选择器中排除特定标签

c# - 在任务中,为什么 IProgress<T> 在 UI 线程中正确执行而不是 Action<T>?

c# - 为什么这个方法每次都返回相同的随机字符串?