异常堆栈跟踪:
OpenQA.Selenium.WebDriverException:无法在45000毫秒内启动套接字 . 在OpenQA.Selenium.Firefox.FirefoxDriverCommandExecutor.Execute(在OpenQA.Selenium.Firefox.Firefox.FirefoxDriverServer.Start()的OpenQA.Selenium.Firefox.FirefoxDriverServer.ConnectToBrowser(TimeSpan timeToWait)上连接到以下地址:127.0.0.1:7055:命令commandToExecute)在OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute,Dictionary '2 parameters) at OpenQA.Selenium.Remote.RemoteWebDriver.StartSession(ICapabilities desiredCapabilities) at OpenQA.Selenium.Remote.RemoteWebDriver..ctor(ICommandExecutor commandExecutor, ICapabilities desiredCapabilities) at DtvAutomation.Selenium.Api.SeleniumFirefoxTest.CreateWebDriver() at DtvAutomation.Selenium.Api.SeleniumTest' 1.Run()
抛出异常的代码是调用Firefox WebDriver构造函数:
protected override FirefoxDriver CreateWebDriver()
{
lock(this.syncRoot)
{
var ffBinary = new FirefoxBinary();
var ffProfile = new FirefoxProfile();
return new FirefoxDriver(
binary: ffBinary,
profile: ffProfile,
commandTimeout: TimeSpan.FromMinutes(2));
}
}
我正在使用Visual Studio 2013中的selenium 2.46(通过NuGet包) - “WCF应用程序服务”项目 . Firefox是38.0.5(最新) . 当我从Visual Studio(调试模式)启动WCF时,一切正常 - 没有例外 . 当我将WCF发布到本地IIS时,它会抛出此错误 .
我尝试了以下事项:
-
更新了NuGet包 - 确保我是最新的
-
将Firefox降级为版本34.0.5
-
将Firefox升级到最新版本
-
从防火墙打开端口7055
-
更改IIS应用程序/应用程序池的凭据,使用管理员帐户
-
在异常时,重新尝试使用其他端口初始化WebDriver
这些似乎都不起作用 . 任何想法可能是什么问题?
4 回答
我遇到过同样的问题 . 将应用程序池标识更改为类似LocalSystem的问题解决了该问题,但您不希望在 生产环境 中执行此操作 .
相反,我在应用程序池的高级设置中找到了一个设置
LoadUserProfile
,设置为False
. 如果将其设置为True
,则应用程序池会加载用户配置文件,从而消除Selenium问题 .您需要至少运行IIS 7,并且可以阅读有关设置here的更多信息 .
我有同样的问题,解决方案是将应用程序池标识从“ApplicationPoolIdentity”切换到更强大的用户 .
我刚遇到了类似的问题 . 我使用的是Selenium Webdriver Nuget Package v2.48 Firefox 41.0版
最初,我认为这是FF和Webdriver之间版本冲突的问题,我将Webdriver升级到这个版本 . 没有固定的 . 接下来,我将FF降级到31.0 . 没有固定的 . 第三,我想到了最近的变化,这是我的这一行代码
在这段代码中
注释掉SetPreference方法后 Success! Firefox was opening as expected.
我认为问题状态与firefox webdriver的超时 . 您可以使用以下内容,其中包括Firefox配置文件和TimeSpan,这可能会减少Firefox Web驱动程序的超时 .