为什么Firefox 48的Selenium GECKO驱动程序不能启动服务器?

本文关键字:不能 启动 服务器 驱动程序 GECKO Firefox Selenium 为什么 | 更新日期: 2023-09-27 18:04:14

我们正在一个。net自动化测试项目中运行Selenium 2.5.3,作为一个NUnit测试项目。

在Firefox 47中一切正常。但在firefox48中,它停止了工作。我从github上拉下Gecko.exe(版本9)。我几乎可以使它运行,但还不能完全运行。

我得到这些错误:附加信息:向远程WebDriver服务器请求URL http://localhost:53628/session的HTTP请求在30秒后超时。

附加信息:向远程WebDriver服务器请求URL http://localhost:55924/session的HTTP请求在30秒后超时。

似乎默认是使用随机端口。所以我手动将其设置为端口7500,在Windows防火墙中打开端口,现在我得到了这个:其他信息:无法在http://localhost:7500/

上启动驱动程序服务

这是我的代码在WebDriverFactory:

case WebDriverType.Firefox:
                Log.Info("Starting Firefox ...");
                //string driverPath =
                //    $"{Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase)}''wires.exe";
                string driverPath =
                    @"C:'Development2'iRePORT'src'test'csharp'Nete.Ireport.EndToEndTests'bin'Debug'geckodriver.exe";
                FirefoxDriverService driverService = FirefoxDriverService.CreateDefaultService();
                driverService.FirefoxBinaryPath = driverPath;
                driverService.Port = 7500;
                FirefoxOptions ffOptions = new FirefoxOptions();
                ffOptions.IsMarionette = true;
                driver = new FirefoxDriver(driverService, ffOptions, TimeSpan.FromSeconds(30));
                // driver = new FirefoxDriver(new FirefoxOptions());
                Log.Info("Started");
                break;

我花了很多时间在这上面,我觉得我很接近了。有人知道我少了什么吗?


我现在读到的东西让我想起了这句话;

driverService.FirefoxBinaryPath = driverPath;

指向要安装的Firefox版本。现在我已经把驱动路径和可执行文件名放到了driverService构造函数中,如下所示:

case WebDriverType.Firefox:
                Log.Info("Starting Firefox ...");
                //string driverPath =
                //    $"{Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase)}''wires.exe";
                string driverPath =
                    @"C:'Development2'iRePORT'src'test'csharp'Nete.Ireport.EndToEndTests'bin'Debug";
                string driverExecutableName = "geckodriver.exe";
                FirefoxDriverService driverService = FirefoxDriverService.CreateDefaultService(driverPath, driverExecutableName);
                // Don't do this!!! This is the executable to the Firefox Version executable.
                //driverService.FirefoxBinaryPath = driverPath;
                driverService.Port = 7500;
                FirefoxOptions ffOptions = new FirefoxOptions();
                ffOptions.IsMarionette = true;
                driver = new FirefoxDriver(driverService, ffOptions, TimeSpan.FromSeconds(30));
                // driver = new FirefoxDriver(new FirefoxOptions());
                Log.Info("Started");
                break;

所以现在我又得到这个错误:其他信息:无法在http://localhost:7500/

上启动驱动程序服务

如果我有:driverService。端口= 7200;它说"未找到实体"。我相信这意味着它找不到Gecko.exe。如果我有:driverService。端口= 7500;它说:其他信息:无法在http://localhost:7500/上启动驱动程序服务

为什么Firefox 48的Selenium GECKO驱动程序不能启动服务器?

试试Selenium 3.0.0。我也有这个问题,但我终于管理所有的东西从2.53.1切换到3.0.0