【问题标题】:selenium not finding firefox - using teststack.selenoselenium 找不到 firefox - 使用 teststack.seleno
【发布时间】:2015-12-06 07:33:22
【问题描述】:

我的 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 Files (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

【问题讨论】:

  • 我真的希望这有一个快速的解决方案。似乎没有关于测试堆栈配置的全面文档。不是被广泛使用吗?有没有好的选择?这一切都是在最近一次更新之后开始的

标签: c# selenium selenium-webdriver seleno


【解决方案1】:

我发现这是possiblybug

我发现提供 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/")));

【讨论】:

  • 我遇到了类似的问题,这是我使用的修复程序。现在在生产中工作正常:)
猜你喜欢
  • 2021-07-05
  • 1970-01-01
  • 2016-03-31
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-05-10
  • 2019-12-25
  • 2021-04-23
相关资源
最近更新 更多