2015-03-31 51 views
0

我想运行使用Firefox和phantomJS而不是铬的量角器测试。但是,只有当我指定'chromeOnly:true'选项并将Chrome指定为浏览器时,它才会运行。量角器只能运行Chrome

否则它会崩溃并抛出错误“无法启动Webdriver会话”。

我量角器配置:

'use strict'; 

var paths = require('./.yo-rc.json')['generator-gulp-angular'].props.paths; 

// An example configuration file. 
exports.config = { 
    // The address of a running selenium server. 
    seleniumAddress: 'http://localhost:4444/wd/hub', 
    //seleniumServerJar: deprecated, this should be set on node_modules/protractor/config.json 

    // Capabilities to be passed to the webdriver instance. 
    capabilities: { 
    'browserName': 'firefox' 
    }, 
    //chromeOnly: true, 

    baseUrl: 'http://localhost:8000/', 

    framework: 'jasmine', 

    // Spec patterns are relative to the current working directly when 
    // protractor is called. 
    specs: [paths.e2e + '/**/*.js'], 

    // Options to be passed to Jasmine-node. 
    jasmineNodeOpts: { 
    showColors: true, 
    defaultTimeoutInterval: 30000 
    } 
}; 
+0

你正在使用什么量角器和火狐版本?谢谢。 – alecxe 2015-03-31 16:46:30

回答

1

使用注意事项与量角器phantomjs被忽略。 从http://angular.github.io/protractor/#/browser-setup两者

添加phantomjs到驱动程序的功能时,如果使用本地安装包括二进制的路径:

capabilities: { 
    'browserName': 'phantomjs', 

    /* 
    * Can be used to specify the phantomjs binary path. 
    * This can generally be ommitted if you installed phantomjs globally. 
    */ 
    'phantomjs.binary.path': require('phantomjs').path, 

    /* 
    * Command line args to pass to ghostdriver, phantomjs's browser driver. 
    * See https://github.com/detro/ghostdriver#faq 
    */ 
    'phantomjs.ghostdriver.cli.args': ['--loglevel=DEBUG'] 
} 
0

使用

multiCapabilities : [ 
      { 
      'browserName' : 'chrome', 
      'chromeOptions' : { 
       'binary' : 'chrome.exe', 
       'args' : [], 
       'extensions' : [] 
      }, 
      { 
       'browserName' : 'firefox', 
       'chromeOptions' : { 
        'binary' : 'path to firefox.exe', 
        'args' : [], 
        'extensions' : [] 
      }... 
     } 
2

的 “chromeOnly”选项意味着“直接连接到铬”(与使用硒服务器相比)。当你删除这个选项时,Protractor希望与selenium服务器通信以控制浏览器。请参阅https://github.com/angular/protractor/blob/master/docs/server-setup.md

由于Firefox现在还支持“直接连接”模式,因此“chromeOnly”配置选项已重命名为“directConnect”。请参阅https://github.com/angular/protractor/commit/3c048585ac811726d6c6d493ed6d43f6a3570bee

要直接使用Firefox,您可以设置错误的“chromeOnly”选项或切换到“directConnect”。或者,您可以通过硒服务器使用Firefox(这意味着您需要启动硒服务器,请参阅上面列出的server-setup.md文件)。

+0

这些都是好的,但我不确定这是关于设置。 “无法启动Webdriver会话”错误使我认为这是硒js绑定和firefox之间的兼容性问题.. – alecxe 2015-03-31 23:39:40