How to open multiple windows or use multiple instances

If for some crazy reason I need to open 100 windows / tabs and go to 100 different links in them, how can I do this? Can I run certain tests at the same time in all 100 of them?

let's say I have an array ['a', 'b', 'c', 'd', 'e'], I need to check if any form works for all of these values. How can I open 5 instances (or windows or everything that can be controlled independently of the rest) and check them at the same time? eg:

  • find the text input field of the form,
  • change the text value to one of the array
  • click submit
  • fulfill a certain statement, etc. and all this in parallel. Testing all array values ​​at once, not one by one

upd: I think I can open several tabs using

browser.executeScript("window.open('https://angularjs.org/', 'tab" + i + "')")

but this does not allow me to really run tests in parallel, since I will have to switch from tab to tab if all tabs are open and loaded:

1) select a value from the array 2) change the input field 3) click the "Send" button 4) go to the next tab 5) repeat

Yes, it will still be faster than testing in just one tab, looping through an array and resetting the page every time, but I need to find a better way

+3
source share
1 answer

, 100 , . , , .

.

1) multiCapabilities: . (, , ).

exports.config = {
  specs: [
    // leave this empty if you have no shared tests. 
  ],

  multiCapabilities: [{
    'browserName': 'chrome',
    'specs': ['test1.js']
  }, {
    'browserName': 'chrome',
    'specs': ['test2.js']
  }, {
    'browserName': 'chrome',
    'specs': ['test3.js']
  }],
};

Doc: https://github.com/angular/protractor/blob/master/docs/referenceConf.js

2) browser.forkNewDriverInstance(): , n . , , 1 , 1 100 , .

var runtest = function(input, output) {
  var newBrowser = browser.forkNewDriverInstance(true); // true means use same url
  // note I used newBrowser.element instead of element, because you are accessing the new browser. 
  newBrowser.element(by.model(...)).sendKeys(input).click();
  expect(newBrowser.element(by.css('blah')).getText()).toEqual(output);
};

describe('...', function() {
  it('spawn browsers', function() {
    browser.get(YOUR_COMMON_URL);

    runtest('input1', 'output1');
    runtest('input2', 'output2');
    runtest('input3', 'output3');
    runtest('input4', 'output4');
  });
});

Doc: https://github.com/angular/protractor/blob/master/docs/browser-setup.md#using-multiple-browsers-in-the-same-test

+10

All Articles