The Question:
What is the canonical way to write multi browser window tests in Protractor - the tests that involve multiple sessions fired up interacting with one another?
The Story:
The main concern is: when you fork a new browser via browser.forkNewDriverInstance(true)
, all of the global Protractor objects like element()
and element.all()
are still tied to the first/parent browser. This makes it difficult to follow the Page Object pattern since all of the definitions there are using global element
and element.all()
. For instance, we cannot use this page object for the forked browsers:
var MyPageObject = function () {
this.tabs = element.all(by.repeater("caseHistoryItem in caseViewCtrl.caseHistory"));
this.activeCaseTab = element(by.css("ul#casesList li.active tab-heading.ap-tab-heading"));
}
The Test Case:
Just to make this a bit clearer, here is one of test cases we need to implement. A regular user logs into the application. Then, in a different browser an admin user logs into the application. An admin user closes the regular user's session through the admin tools. Confirm that regular user's session was properly closed.