问题描述
异常堆栈跟踪:
OpenQA.Selenium.WebDriverException:无法在45000毫秒内启动套接字.尝试连接到以下地址:127.0.0.1:7055 在OpenQA.Selenium.Firefox.FirefoxDriverServer.ConnectToBrowser(TimeSpan timeToWait) 在OpenQA.Selenium.Firefox.FirefoxDriverServer.Start() 在OpenQA.Selenium.Firefox.FirefoxDriverCommandExecutor.Execute(Command commandToExecute) 在OpenQA.Selenium.Remote.RemoteWebDriver.Execute(String driverCommandToExecute,Dictionary'2 parameters) 在OpenQA.Selenium.Remote.RemoteWebDriver.StartSession(ICapabilities wantedCapabilities) 在OpenQA.Selenium.Remote.RemoteWebDriver..ctor(ICommandExecutor commandExecutor,ICapabilities requiredCapabilities) 在DtvAutomation.Selenium.Api.SeleniumFirefoxTest.CreateWebDriver() 在DtvAutomation.Selenium.Api.SeleniumTest'1.Run()
OpenQA.Selenium.WebDriverException: Failed to start up socket within 45000 ms. Attempted to connect to the following addresses: 127.0.0.1:7055 at OpenQA.Selenium.Firefox.FirefoxDriverServer.ConnectToBrowser(TimeSpan timeToWait) at OpenQA.Selenium.Firefox.FirefoxDriverServer.Start() at OpenQA.Selenium.Firefox.FirefoxDriverCommandExecutor.Execute(Command commandToExecute) at 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构造函数:
The code that throws the exception is calling the Firefox WebDriver constructor:
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-"WCF应用程序服务"项目中的硒2.46(通过NuGet程序包). Firefox是38.0.5(最新).当我从Visual Studio(调试模式)启动WCF时,一切正常,没有例外.当我将WCF发布到本地IIS时,会引发此错误.
I am using selenium 2.46 (via NuGet package) from a Visual Studio 2013 - "WCF Application Service" project. Firefox is 38.0.5 (latest).When I start the WCF from Visual Studio (debug mode) everything works fine - no exceptions. When I publish the WCF to local IIS it throws this error.
我尝试了以下操作:
- 更新的NuGet软件包-确保我是最新的
- 将Firefox降级到版本34.0.5
- 将Firefox升级到最新版本
- 从防火墙打开了端口7055
- 使用管理员帐户更改IIS应用程序/应用程序池的凭据
- 在例外情况下,请尝试使用其他端口初始化WebDriver
这些似乎都不起作用.有任何想法可能是什么问题吗?
None of these seem to work.Any ideas what could be the problem?
推荐答案
我遇到了同样的问题.将应用程序池标识更改为LocalSystem之类的问题可以解决此问题,但是您不想在生产中这样做.
I had the same issue. Changing the app pool identity to something like LocalSystem solved the issue, but you don't want to do that in production.
相反,我在应用程序池的高级设置"中找到了一个设置为False
的设置LoadUserProfile
.如果将其设置为True
,则应用程序池将加载用户配置文件,从而消除了Selenium问题.
Instead I found a setting, LoadUserProfile
, on the Application Pool's Advanced Settings, that was set to False
. If you set it to True
, the application pool loads a user profile which in turn gets rid of the Selenium issue.
您至少需要运行IIS 7,并且可以阅读有关设置的更多信息此处.
You need to run at least IIS 7, and you can read more about the setting here.
这篇关于WCF中的Selenium Firefox WebDriver抛出“未能在45000毫秒内启动套接字".的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!