Lets say I am working on a chat application, where a user (X) can login to the application and send a message to another user (Y).
I am now trying to automate the test to send and receive messages, with the following steps:
1. X Logs in with his username/password.
2. Selects Y from a list and sends a "Test Message" to Y.
3. X signs out.
4. Y logs in with his username/password.
5. Checks if he has received the message from X.
6. Y replies to X with "Reply to Test Message".
7. Y signs out.
8. X logs in, and checks if he got the reply.
If I were to do this manually, I would just open two windows (one of them in incognito), login as X on one and as Y on the other and verify the results.
So, few questions: 1. Does protractor allow a way in which a new window can be opened without any clicking anywhere? Just a function to spawn a new window programmatically? 2. Is it possible to have these windows not share the session of the user (kinda like incognito)?
The following works fine for me.
browser.executeScript('window.open()').then(function () {
browser.getAllWindowHandles().then(function (handles) {
var secondWindow = handles[1];
browser.switchTo().window(secondWindow).then(function () {
return browser.get(newPageToOpen);
});
});
});
Hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With