C# 未能在45000内启动套接字

C# 未能在45000内启动套接字,c#,firefox,selenium-webdriver,webdriver,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.Inter

我使用的是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的最新版本中添加了Firefox19“支持”。因此,由于您使用的是.NET,因此在撰写本文时,最新版本的直接下载版本是2.31.2:


您使用的是哪个版本的Selenium IDE?尝试降级Firefox版本。下面的链接中提到了selenium IDE的发行说明


希望这有帮助。

如果升级Webdriver没有帮助,您可以降级FireFox,这将解决问题。

我对FireFox 43和Selenium 2.48有这个问题。 当您的Selenium驱动程序服务器在32位进程中运行,并且您启动64位版本的Firefox时,就会发生这种情况

原因是webdriver服务器试图连接到端口7055,该端口应由在Firefox可执行文件中运行的webdriver打开。但是您可以在www.sysintranses.com的TcpView中看到Firefox没有打开这个端口。因此,驱动程序等待超时时间(45秒)过去

即使在完全关闭Windows防火墙后也会发生这种情况

我在互联网上找到的所有帖子都没有帮助:升级Selenium,降级Firefox等等

但是在安装了32位版本的Firefox43之后,它就可以工作了。我在TcpView中看到Firefox 32位如何正确打开端口:

在我的代码中,我使用

FirefoxProfile Prof = new FirefoxProfile();
FirefoxBinary  Bin  = new FirefoxBinary(sBrowserExe);
mDriver = new FirefoxDriver(Bin, Prof);
使用
sBrowserExe=“C:\Program Files\Mozilla Firefox 43\Firefox.exe”
64位版本的Firefox43启动了,我得到了超时异常

使用
sBrowserExe=“C:\ProgramFiles(x86)\Mozilla Firefox 43\Firefox.exe”
32位版本的Firefox43已经启动,并且可以正常工作


更新:Firefox的开发者现在完全破坏了对Selenium的支持。48个以上的Firefox新版本需要一个数字签名才能安装所有扩展

我不明白的是,为什么Selenium用户无法获得当前Selenium驱动程序的签名

Firefox 47.0版有一个bug,不允许与Selenium一起使用。此错误已在47.0.1版中修复

48.0及以上版本的Firefox不再安装旧的Selenium驱动程序。它们必须由木偶(=壁虎)驱动器自动控制

问题是,木偶仍然是测试版,并且有很多缺失的功能,因此目前还没有解决方案来自动化新的Firefox版本


正如您在这里看到的,新的驱动程序充满了bug:

在您的Nuget软件包管理器中安装所有更新。重新启动IDE

不建议对firefox版本进行降级测试。但最后一个版本的降级听起来不错


这个解决方案对我很有效。

可能是Firefox浏览器更新了吗?ff 19是最新版本,所以我不确定您使用的是哪个Selenium版本?我知道,直到它的最新版本,它与Firefox有问题。我使用的是2.25.1.0 selenium webdriver版本。@AbuHamzah,在这种情况下肯定会更新。我相信Firefox19“支持”是最近才添加的(我想是v2.31吧?)。所以,如果仍然不起作用,请更新并返回。现在从这里获取最新版本:这并不能解决问题。即使使用Selenium 2.48,我也有相同的超时异常。这不是一个好主意:这是Google搜索上述错误消息的第三个结果。很多人都会来这里阅读这篇文章,目的是在最新的Firefox版本上进行测试。降级Firefox不是一个解决方案!这个想法是在最新的Firefox版本上进行测试。降级Firefox不是一个解决方案!我在Windows7,64位机器上使用Firefox48,32位。我仍然知道你提到的错误。但是,在TCPView中,firefox没有打开端口7055。请建议我如何解决这个问题。