protractor remote tests multibrowser

2019-04-02 09:25发布

问题:

I'm new to Protractor. Could you please advise if there is any way to run protractor E2E tests on multiple remote hosts (Ubuntu - Firefox,chrome, Windows - IE, Chrome, firefox, Mac - Firefox, Chrome, Mobile - Android device, Mobile - iOS etc..), with multi browsers. Please share sample config to specify remote hosts.

Due to licensing costs not considering to use saucelabs, planning to setup in local test environment.

Currently I'm able to run protractor E2E tests, with multibrowsers on one host only. (eg: Mac - Firefox, Chrome, Safari) using following config in conf.js

multiCapabilities: [ { 'browserName': 'chrome', 'chromeOptions': { 'args': ['no-sandbox','no-default-browser-check', 'no-first-run', 'disable-default-apps'] }, version: '', platform: 'ANY' },

{
      'browserName': 'safari'
},
{
      'browserName': 'firefox'
}]

Thanks in advance.

回答1:

Step 1: On multiple machines, start up selenium webdriver, and make sure they are accessible from the machine you're kicking off protractor

Step 2: https://github.com/angular/protractor/blob/master/docs/referenceConf.js#L136 Set appropriate seleniumAddress for each browser.

multiCapabilities: [{
  browserName: chrome,
  seleniumAddress: $HOST_A:1234,
  specs: ['testA.js']
}, {
  browserName: chrome,
  seleniumAddress: $HOST_B:1234,
  specs: ['testB.js']
}]

Side note, likely, those selenium addresses are not static. You can return the multiCapabilities object as a promise via getMultiCapabilities (https://github.com/angular/protractor/blob/master/docs/referenceConf.js#L152)

To do any other fancy things, you might need to interact with runner.js (https://github.com/angular/protractor/blob/master/lib/runner.js) directly