量角器没有为Firefox找到GeckoDriver

时间:2018-03-21 17:15:18

标签: angular firefox protractor geckodriver

我正在尝试为新项目设置Protractor。我们的要求包括对大多数流行浏览器(Chrome,Firefox,IE,Safari)的端到端测试。

设置Chrome测试15秒后,我已经卡住了一整天,试图让Firefox驱动程序正常工作。这是我目前的配置:

exports.config = {
  allScriptsTimeout: 11000,
  specs: [
    './e2e/**/*.e2e-spec.ts'
  ],
  multiCapabilities: [
    {
      browserName: 'chrome',
      chromeOptions: {
        args: ['--headless', 'no-sandbox', '--disable-gpu',
          '--window-size=1200x900']
      }
    },
    {
      browserName: 'firefox'
    }
  ],
  directConnect: false,
  chromeDriver: './node_modules/protractor/node_modules/webdriver-manager/selenium/chromedriver_2.37',
  firefoxPath: './node_modules/protractor/node_modules/webdriver-manager/selenium/geckodriver-v0.20.0',
  seleniumAddress:
    'http://localhost:4444/wd/hub',
  baseUrl:
    'http://localhost:4200/',
  framework:
    'jasmine',
  jasmineNodeOpts:
    {
      showColors: true,
      defaultTimeoutInterval:
        30000,
      print:
        function () {
        }
    }
  ,
  onPrepare() {
    require('ts-node').register({
      project: 'e2e/tsconfig.e2e.json'
    });
    jasmine.getEnv().addReporter(
      new SpecReporter({spec: {displayStacktrace: true}}));
  }
}

问题是,我收到以下错误:

SessionNotCreatedError: Expected browser binary location, but unable to find binary in default location, no 'moz:firefoxOptions.binary' capability provided, and no binary flag set on the command line

我已经完成了webdriver-manager update并且所有驱动程序都存在于node_modules中。它们无法被发现或使用。

这是ng e2e的整个输出:

** NG Live Development Server is listening on localhost:49152, open your browser on http://localhost:49152/ **
Date: 2018-03-21T16:46:44.040Z                                                          
Hash: 3bda6edf1fc2359b155e
Time: 11716ms
chunk {inline} inline.bundle.js, inline.bundle.js.map (inline) 3.89 kB [entry] [rendered]
chunk {main} main.bundle.js, main.bundle.js.map (main) 8.44 kB [initial] [rendered]
chunk {polyfills} polyfills.bundle.js, polyfills.bundle.js.map (polyfills) 202 kB [initial] [rendered]
chunk {styles} styles.bundle.js, styles.bundle.js.map (styles) 435 kB     [initial] [rendered]
chunk {vendor} vendor.bundle.js, vendor.bundle.js.map (vendor) 3.64 MB     [initial] [rendered]
(node:95425) DeprecationWarning: os.tmpDir() is deprecated. Use os.tmpdir() instead.

webpack: Compiled successfully.
[17:46:44] I/update - chromedriver: file exists /Users/xyz/Projects/xyz/node_modules/protractor/node_modules/webdriver-manager/selenium/chromedriver_2.37.zip
[17:46:44] I/update - chromedriver: unzipping chromedriver_2.37.zip
[17:46:44] I/update - chromedriver: setting permissions to 0755 for /Users/xyz/Projects/xyz/node_modules/protractor/node_modules/webdriver-manager/selenium/chromedriver_2.37
[17:46:44] I/update - chromedriver: chromedriver_2.37 up to date
[17:46:45] I/launcher - Running 2 instances of WebDriver
[17:46:45] I/testLogger - 
------------------------------------

[17:46:45] I/testLogger - [firefox #11] PID: 95431
[firefox #11] Specs: /Users/xyz/Projects/xyz/e2e/app.e2e-spec.ts
[firefox #11] 
[firefox #11] (node:95431) DeprecationWarning: os.tmpDir() is deprecated. Use os.tmpdir() instead.
[firefox #11] [17:46:45] I/hosted - Using the selenium server at http://localhost:4444/wd/hub
[firefox #11] 
[firefox #11] /Users/xyz/Projects/xyz/node_modules/selenium-webdriver/lib/error.js:505
[firefox #11]         throw new ctor(message);
[firefox #11]               ^
[firefox #11] SessionNotCreatedError: Expected browser binary location, but unable to find binary in default location, no 'moz:firefoxOptions.binary' capability provided, and no binary flag set on the command line
[firefox #11] Build info: version: '3.11.0', revision: 'e59cfb3', time: '2018-03-11T20:33:15.31Z'
[firefox #11] System info: host: 'MacBook-Pro.local', os.name: 'Mac OS X', os.arch: 'x86_64', os.version: '10.13.1', java.version: '1.8.0_112'
[firefox #11] Driver info: driver.version: unknown
[firefox #11] remote stacktrace: 
[firefox #11]     at Object.checkLegacyResponse (/Users/xyz/Projects/xyz/node_modules/selenium-webdriver/lib/error.js:505:15)
[firefox #11] From: Task: WebDriver.createSession()

[17:46:45] I/testLogger - 

[17:46:45] E/launcher - Runner process exited unexpectedly with error code: 1
[17:46:45] I/launcher - 1 instance(s) of WebDriver still running
.[17:46:48] I/testLogger - 
------------------------------------

[17:46:48] I/testLogger - [chrome #01] PID: 95430
[chrome #01] Specs: /Users/xyz/Projects/xyz/e2e/app.e2e-spec.ts
[chrome #01] 
[chrome #01] (node:95430) DeprecationWarning: os.tmpDir() is deprecated. Use os.tmpdir() instead.
[chrome #01] [17:46:45] I/hosted - Using the selenium server at http://localhost:4444/wd/hub
[chrome #01] Jasmine started
[chrome #01] 
[chrome #01]   xyz App
[chrome #01]     ✓ should display welcome message
[chrome #01] 
[chrome #01] Executed 1 of 1 spec SUCCESS in 2 secs.

[17:46:48] I/testLogger - 

[17:46:48] I/launcher - 0 instance(s) of WebDriver still running
[17:46:48] I/launcher - firefox #11 failed with exit code: 1
[17:46:48] I/launcher - chrome #01 passed
[17:46:48] I/launcher - overall: 1 process(es) failed to complete
[17:46:48] E/launcher - Process exited with error code 100

有人有任何提示吗?

2 个答案:

答案 0 :(得分:1)

原来我没有安装Firefox(浏览器本身)。我错误地确信安装的驱动程序是浏览器的独立版本,但它实际上只是一个包装器。

答案 1 :(得分:0)

multiCapabilities: [{ 'browserName': 'chrome' }, { 'browserName': 'firefox' }],

对于chrome,firefox,无需添加驱动程序/ exe文件简化multiCapabilities我们添加浏览器名称。