2015-03-31 46 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