Aleksandar Todorov
Aleksandar Todorov

Reputation: 19

Protractor- How can I start the test on multiple browsers and then continue only one of the browsers

I start my automation test on three browsers but after that i want to continue on only one browser. Is it possible?

// spec.js
multiCapabilities:[{
'browserName': 'MicrosoftEdge',
},
{
'browserName' : 'chrome',
},
{
'browserName' : 'firefox',
}],
describe('Protractor Demo App', function() {
    it('should have a title', function() {
    browser.driver.get('http://preg.fxgm.com/aserving/4/1/blg/1/s/LOC-5675/index.html');
    browser.ignoreSynchronization = true;


    browser.sleep(5000);
    browser.driver.findElement(protractor.By.id('submit_button')).click();
    browser.sleep(2500);

I would like to continue only with Chrome browser.

Upvotes: 0

Views: 203

Answers (2)

Sameera De Silva
Sameera De Silva

Reputation: 1980

This is the Completed answer , I further elaborated M Hudson's original answer to make it up to date and with current latest protractor version and error free . This config.js is tested and verified . Open the cmd where config.js exists and run protractor configfilename.js

exports.config = {
  framework: 'jasmine',
  directConnect: false,


  multiCapabilities: [{
      browserName: 'firefox',
      'moz:firefoxOptions': {
            args: ['--verbose'],
            binary: 'C:/Program Files/Mozilla Firefox/firefox.exe'
       //Need to start cmd via admin mode to avoid permission error
        },
      specs: ['src/com/sam/scriptjs/draganddrop.spec.js']
    }, 
    {
        browserName : 'chrome',
        chromeOptions: {
            args: [ "--start-maximized" ]
                     },
        specs: ['src/com/sam/scriptjs/iframes.spec.js']

    }],         
     seleniumAddress: 'http://localhost:4444/wd/hub'

}

Upvotes: 0

M. Hudson
M. Hudson

Reputation: 899

You want to create a config file and split out multiCapabilities into that, out of spec.js which should just contain your specs.

For example, create conf.js and add:

exports.config = {
    seleniumAddress: 'http://localhost:4444/wd/hub',
    multiCapabilities: [{
        browserName : 'MicrosoftEdge',
    },{
        browserName : 'chrome',
        specs: 'spec.js',
    },
    {
        browserName : 'firefox',
    }]
};

Then specify conf.js when you run protractor:

> protractor conf

Unless you give firefox and edge something to do, (i.e. add specs parameters to the relevant sections), they will complain that no specs were found but they will still run.

Upvotes: 1

Related Questions