Reputation: 1267
During E2E testing of an angular web chat program, using protractor as the E2E framework, I would like to open two browsers and control each of them during the test so I can mimic a real chat and verify all expectations are fulfilled.
Is this possible? I know I can run the test in parallel on several browsers using the multi capabilities configuration segment but here I want to run multiple browsers as part of the test and perform different exceptions checks.
Any help will be most welcome,
Thanks
Alon
Upvotes: 4
Views: 738
Reputation: 1629
Yes, you can have control over multiple browsers by forking a driver:
browser.get('http://www.angularjs.org');
browser.addMockModule('moduleA', "angular.module('moduleA', []).value('version', '3');");
// To create a new browser.
var browser2 = browser.forkNewDriverInstance();
// To create a new browser with url as 'http://www.angularjs.org':
var browser3 = browser.forkNewDriverInstance(true);
Note that if you use global variables or $ or $$ you have to prepare a new replacement as well
var element2 = browser2.element;
var $2 = browser2.$;
var $$2 = browser2.$$;
element2(by.model(...)).click();
$2('.css').click();
$$2('.css').click();
https://www.protractortest.org/#/browser-setup#using-multiple-browsers-in-the-same-test
Upvotes: 0
Reputation: 6034
Here's an example that does exactly what you want (i.e. test an instant messenger)
See https://github.com/angular/protractor/blob/master/spec/interactionConf.js and https://github.com/angular/protractor/blob/master/spec/interaction/interaction_spec.js#L51
To run the instant messenger test app that I'm testing against, checkout the protractor github project and run npm start
Upvotes: 1