首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >selenium没有找到firefox -使用teststack.seleno

selenium没有找到firefox -使用teststack.seleno
EN

Stack Overflow用户
提问于 2015-12-06 07:33:22
回答 1查看 645关注 0票数 0

由于这个错误,我的selenium测试都失败了。

{“系统找不到指定的文件”}

我的初始化代码非常简单:

代码语言:javascript
复制
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

如果有帮助,这就是堆栈跟踪。

代码语言:javascript
复制
   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
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2015-12-09 03:46:26

我发现这是有可能 a 错误

我发现提供一个WebDriver和默认配置文件似乎可以缓解这个问题。此解决方案允许运行Firefox的单个实例。如果存在一个现有实例(打开),则在创建驱动程序时抛出一个不同的错误。

代码语言:javascript
复制
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实例,以下代码就能工作:

代码语言:javascript
复制
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/")));
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/34115127

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档