我无法在firefox中运行量角器测试,但在chrome中运行良好

时间:2016-05-11 15:57:05

标签: protractor

当我尝试在firefox中运行Protractor e2e测试时,它会启动浏览器,但我的测试脚本不会被执行。

我使用的是带有firefox版本46.0.1和Selenium 2.53.0的Windows Server 2012 R2机器。

它给了我以下错误:

Using FirefoxDriver directly...
[launcher] Running 1 instances of WebDriver

code\ui\dgui\node_modules\protractor\node_modules\selenium-webdriver\http\util.js:89
          Error('Timed out waiting for the WebDriver server at ' + url));
          ^
Error: Timed out waiting for the WebDriver server at http://127.0.0.1:58798/hub

我尝试过运行Selenium独立

    code\ui\dgui\node_modules\protractor\selenium>java -jar selenium-server-standalone-2.53.0.jar
    09:37:21.214 INFO - Launching a standalone Selenium Server
    09:37:21.285 INFO - Java: Oracle Corporation 25.91-b14
    09:37:21.285 INFO - OS: Windows Server 2012 R2 6.3 amd64
    09:37:21.293 INFO - v2.53.0, with Core v2.53.0. Built from revision 35ae25b
    09:37:21.332 INFO - Driver class not found: com.opera.core.systems.OperaDriver
    09:37:21.332 INFO - Driver provider com.opera.core.systems.OperaDriver is not registered
    09:37:21.336 INFO - Driver provider org.openqa.selenium.safari.SafariDriver registration is skipped:
    registration capabilities Capabilities [{browserName=safari, version=, platform=MAC}] does not match the current platform WIN8
    09:37:21.336 INFO - Driver class not found: org.openqa.selenium.htmlunit.HtmlUnitDriver
    09:37:21.336 INFO - Driver provider org.openqa.selenium.htmlunit.HtmlUnitDriver is not registered
09:37:21.434 INFO - RemoteWebDriver instances should connect to: http://127.0.0.1:4444/wd/hub
09:37:21.434 INFO - Selenium Server is up and running

我正在使用npm run e2e命令执行我的测试

我的配置文件:

exports.config = {

  allScriptsTimeout: 30000,

  suites: {
      test Suit: 'e2e/TestSuites/Tests/*.js',
  },

   multiCapabilities: [

    // We will want to eventually include the following options to split out tests to multiple instances

    {'browserName': 'firefox'}
  ],


  // only for firefox and chrome - IE will require using a selenium server

  directConnect : true,  

  // make sure that the baseURL reflects the configuration of the web server

  baseUrl: 'http://10.26.5.13:8000/',


  framework: 'jasmine2',

  jasmineNodeOpts: {
    defaultTimeoutInterval: 30000
  },


  onPrepare: function() {     
    var jasmineReporters = require('jasmine-reporters');

    browser.driver.manage().window().maximize();

    return browser.getProcessedConfig().then(function(config) {

      var browserName = config.capabilities.browserName;


      var junitReporter = new jasmineReporters.JUnitXmlReporter({
             consolidateAll: true,
             savePath: 'tests/test-results',
             // this will produce distinct xml files for each capability
             filePrefix: browserName + '-xmloutput',
             modifySuiteName: function(generatedSuiteName, suite) {
                 // this will produce distinct suite names for each capability,
                 // e.g. 'firefox.login tests' and 'chrome.login tests'
                 return browserName + '.' + generatedSuiteName;
             }

         });
         jasmine.getEnv().addReporter(junitReporter);
    });    

  }, 

  resultJsonOutputFile: 'tests/test-results/output.json'

};

4 个答案:

答案 0 :(得分:2)

找到此链接:https://github.com/angular/protractor/issues/3182

我也面临着类似的问题。

我尝试安装Firefox v44.0.2,然后执行我的脚本,它运行了。

我之前使用的是Firefox v46,我的脚本没有使用Firefox v46执行。

答案 1 :(得分:1)

与firefox版本49.0.2和Selenium 2.52.0有同样的问题 我安装了Firefox portable 46,一切都适合我。

在我的protractor.config文件中,我设置了:

...
    capabilities: {
    // FIREFOX portable in version 46.0.1
    'browserName': 'firefox',
    "firefox_binary": "C:/DEV/FirefoxPortable64-46.0.1/FirefoxPortable64/FirefoxPortable.exe",
    "binary_": "C:/DEV/FirefoxPortable64-46.0.1/FirefoxPortable64/FirefoxPortable.exe"
},
// tells protractor to directly connect to the webdriver
directConnect: true
...

我在这里下载了Firefox Portable:http://www.m64.info/index.php/firefox-64-bit-portable 这也是一个很好的机会,有一个以上版本的Firefox“安装”:-) 希望有人会帮助它!

答案 2 :(得分:1)

在此处关注量角器设置: http://www.protractortest.org/#/tutorial#setup

这些版本对我有用:

Node: v6.9.4
NPM: v3.10.10
Protractor: v5.1.0
Selenium WebDriver: 3.0.1
Firefox: 51.0.1

conf.js:

exports.config = {
  framework: 'jasmine',
  // no need for seleniumAddress for firefox and chrome
  specs: ['spec.js'],
  capabilities: {
    browserName: 'firefox',
    firefoxPath: 'C:/Program Files/Mozilla Firefox/firefox.exe'
  },
  directConnect: true // for firefox and chrome
}

https://github.com/angular/protractor/blob/master/lib/config.ts

答案 3 :(得分:0)

将二进制(firefox.exe)位置添加为moz:firefoxOptions功能

[3,4,5]