For the emails, you can use a package called mail-listener. You can follow the instructions on this answer, I've done it myself and it was relatively easy to setup. Then you can get the password from the parsed email.
And as far as switching to other tabs, you can use getAllWindowHandles()
, something like this:
browser.getAllWindowHandles().then(function (handles) {
newWindowHandle = handles[1];
browser.switchTo().window(newWindowHandle).then(function () {
// do stuff
});
});
Since it's non-Angular page, you'll need to set browser.ignoreSynchronization = true
. You can do this in the function when you switch window handles, or you may even want to do it right before that step. You'll need to use some Expected Conditions to control test flow. Find the necessary elements you need to interact with on the non-Angular page, i.e.:
var EC = protractor.ExpectedConditions;
var el = element(by.id('loginForm'));
browser.wait(EC.visibilityOf(el));
// do stuff
Edit:
To open a new tab yourself via Protractor, you can use executeScript()
. i.e.
browser.executeScript("window.open('http://www.google.com')");
Edit 2:
For setting up mail-listener, the code provided in the linked question was pretty much copy/paste for me with the exception of username
, password
, and host
. The username/password will be the same user you are trying to login as. For host, it varies by email server. You should be able to find it by googling "imap host for microsoft exchange (or whatever server you are using)" or going to the settings of that email server.
Only other code I really added to that function was logging errors which might help identify your problem and why you can't connect. You can put this in the onPrepare()
function of your config file:
mailListener.on("error", function(err){
console.log(err);
});