由于这个错误,我的selenium测试都失败了。
{“系统找不到指定的文件”}
我的初始化代码非常简单:
public static class Host
{
private static readonly SelenoHost SelenoHost = new SelenoHost();
static Host()
{
Instance.Run(
configure => configure
.UsingLoggerFactory(new ConsoleFactory())
.WithWebServer(new InternetWebServer("http://localhost:9000/")));
Instance.Application.Browser.Manage().Window.Size = new Size(1500, 1000);
}
public static SelenoHost Instance => SelenoHost;
}}
Firefox安装在默认位置(C:\Program (x86)\Mozilla Firefox\firefox.exe),并更新为最新版本(42)。我正在使用Windows 10操作系统。
我用的是工作室2015.1
如果有帮助,这就是堆栈跟踪。
at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)
at OpenQA.Selenium.Firefox.Internal.Executable.LocateFirefoxBinaryFromPlatform()
at OpenQA.Selenium.Firefox.Internal.Executable..ctor(String userSpecifiedBinaryPath)
at OpenQA.Selenium.Firefox.FirefoxBinary..ctor(String pathToFirefoxBinary)
at TestStack.Seleno.Configuration.BrowserFactory.<FireFox>b__b() in c:\ConsoleBuildAgent\work\6625a30e8ee728ba\src\TestStack.Seleno\Configuration\BrowserFactory.cs:line 73
at TestStack.Seleno.Configuration.WebDriverBuilder`1.CreateWebDriver() in c:\ConsoleBuildAgent\work\6625a30e8ee728ba\src\TestStack.Seleno\Configuration\WebDriverBuilder.cs:line 88
at TestStack.Seleno.Configuration.BrowserFactory.FireFox() in c:\ConsoleBuildAgent\work\6625a30e8ee728ba\src\TestStack.Seleno\Configuration\BrowserFactory.cs:line 73
at System.Lazy`1.CreateValue()
at System.Lazy`1.LazyInitValue()
at Autofac.Builder.RegistrationBuilder.<>c__DisplayClass1`1.<ForDelegate>b__0(IComponentContext c, IEnumerable`1 p) in c:\ConsoleBuildAgent\work\6625a30e8ee728ba\src\TestStack.Seleno\Configuration\Interceptors\SelenoReceivedException.cs:line 0
at Autofac.Core.Activators.Delegate.DelegateActivator.ActivateInstance(IComponentContext context, IEnumerable`1 parameters) in c:\ConsoleBuildAgent\work\6625a30e8ee728ba\src\TestStack.Seleno\Configuration\Interceptors\SelenoReceivedException.cs:line 0
at Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable`1 parameters) in c:\ConsoleBuildAgent\work\6625a30e8ee728ba\src\TestStack.Seleno\Configuration\Interceptors\SelenoReceivedException.cs:line 0
at Autofac.Core.Lifetime.LifetimeScope.GetOrCreateAndShare(Guid id, Func`1 creator) in c:\ConsoleBuildAgent\work\6625a30e8ee728ba\src\TestStack.Seleno\Configuration\Interceptors\SelenoReceivedException.cs:line 0
at Autofac.Core.Resolving.InstanceLookup.Execute() in c:\ConsoleBuildAgent\work\6625a30e8ee728ba\src\TestStack.Seleno\Configuration\Interceptors\SelenoReceivedException.cs:line 0
at Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, IComponentRegistration registration, IEnumerable`1 parameters) in c:\ConsoleBuildAgent\work\6625a30e8ee728ba\src\TestStack.Seleno\Configuration\Interceptors\SelenoReceivedException.cs:line 0
at Autofac.Core.Resolving.ResolveOperation.Execute(IComponentRegistration registration, IEnumerable`1 parameters) in c:\ConsoleBuildAgent\work\6625a30e8ee728ba\src\TestStack.Seleno\Configuration\Interceptors\SelenoReceivedException.cs:line 0发布于 2015-12-09 03:46:26
我发现提供一个WebDriver和默认配置文件似乎可以缓解这个问题。此解决方案允许运行Firefox的单个实例。如果存在一个现有实例(打开),则在创建驱动程序时抛出一个不同的错误。
An exception of type 'OpenQA.Selenium.WebDriverException' occurred in
WebDriver.dll but was not handled in user code
Additional information:
Unable to bind to locking port 7054 within 45000 milliseconds只要确保在运行测试之前关闭所有firefox实例,以下代码就能工作:
Instance.Run(
configure => configure
.WithRemoteWebDriver(
() => new FirefoxDriver(
new FirefoxBinary(@"C:\Program Files (x86)\Mozilla Firefox\firefox.exe"),
new FirefoxProfile()))
.UsingLoggerFactory(new ConsoleFactory())
.WithWebServer(new InternetWebServer("http://localhost:9000/")));https://stackoverflow.com/questions/34115127
复制相似问题