admin管理员组

文章数量:1022679

I want to run protractor test using Firefox and phantomJS instead of chrome. However it will only run when I specify the 'chromeOnly: true' option and specify Chrome as the browser.

Otherwise it will crash and throw the error 'unable to start Webdriver Session'.

My protractor config:

'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
  }
};

I want to run protractor test using Firefox and phantomJS instead of chrome. However it will only run when I specify the 'chromeOnly: true' option and specify Chrome as the browser.

Otherwise it will crash and throw the error 'unable to start Webdriver Session'.

My protractor config:

'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
  }
};
Share Improve this question asked Mar 31, 2015 at 8:57 JelleJelle 1,0602 gold badges14 silver badges22 bronze badges 1
  • What protractor and firefox versions are you using? Thanks. – alecxe Commented Mar 31, 2015 at 16:46
Add a ment  | 

3 Answers 3

Reset to default 3

The "chromeOnly" option means "connect directly to chrome" (vs. using a selenium server). When you remove that option, Protractor is expecting to talk to a selenium server to control a browser. See https://github./angular/protractor/blob/master/docs/server-setup.md.

Since Firefox now also supports a "direct connect" mode, the "chromeOnly" configuration option has been renamed to "directConnect". See https://github./angular/protractor/mit/3c048585ac811726d6c6d493ed6d43f6a3570bee

To use Firefox directly you can either leave the mis-named "chromeOnly" option set, or switch to "directConnect". Or, you can use Firefox via a selenium server (which just means you need to start the selenium server up, see the server-setup.md doc listed above).

Notice using phantomjs with protractor is disregarded. Taken from http://angular.github.io/protractor/#/browser-setup

Add phantomjs to the driver capabilities, and include a path to the binary if using local installation:

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./detro/ghostdriver#faq
   */
  'phantomjs.ghostdriver.cli.args': ['--loglevel=DEBUG']
}

use

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

I want to run protractor test using Firefox and phantomJS instead of chrome. However it will only run when I specify the 'chromeOnly: true' option and specify Chrome as the browser.

Otherwise it will crash and throw the error 'unable to start Webdriver Session'.

My protractor config:

'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
  }
};

I want to run protractor test using Firefox and phantomJS instead of chrome. However it will only run when I specify the 'chromeOnly: true' option and specify Chrome as the browser.

Otherwise it will crash and throw the error 'unable to start Webdriver Session'.

My protractor config:

'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
  }
};
Share Improve this question asked Mar 31, 2015 at 8:57 JelleJelle 1,0602 gold badges14 silver badges22 bronze badges 1
  • What protractor and firefox versions are you using? Thanks. – alecxe Commented Mar 31, 2015 at 16:46
Add a ment  | 

3 Answers 3

Reset to default 3

The "chromeOnly" option means "connect directly to chrome" (vs. using a selenium server). When you remove that option, Protractor is expecting to talk to a selenium server to control a browser. See https://github./angular/protractor/blob/master/docs/server-setup.md.

Since Firefox now also supports a "direct connect" mode, the "chromeOnly" configuration option has been renamed to "directConnect". See https://github./angular/protractor/mit/3c048585ac811726d6c6d493ed6d43f6a3570bee

To use Firefox directly you can either leave the mis-named "chromeOnly" option set, or switch to "directConnect". Or, you can use Firefox via a selenium server (which just means you need to start the selenium server up, see the server-setup.md doc listed above).

Notice using phantomjs with protractor is disregarded. Taken from http://angular.github.io/protractor/#/browser-setup

Add phantomjs to the driver capabilities, and include a path to the binary if using local installation:

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./detro/ghostdriver#faq
   */
  'phantomjs.ghostdriver.cli.args': ['--loglevel=DEBUG']
}

use

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

本文标签: javascriptProtractor only runs ChromeStack Overflow