Reputation: 2148
I am trying to write e2e tests for logging into my app with auth0. When the user inputs their credentials and clicks to log in, auth0 loads a popup which I assume is verifying their details and when this closes, I know if the login attempt has succeeded or failed. Currently to get the test to work I am calling
browser.sleep(4000).then(....
To make it wait 4s for the popup to open and process their data and then close. But that seems like a bad way to do it. Ideally I'd like to listen for the close event on the popup window, but I am not sure how to do this? Anyone have any ideas?
Thanks!
Upvotes: 1
Views: 1466
Reputation: 6962
Try using wait() function of protractor to check for the presence of elements. Here's the link to it - Protractor wait and then verify the element's presence by its visibility or invisibility. Below is the sample -
var ele = //you element's locator
var EC = protractor.ExpectedConditions;
browser.wait(EC.visibilityOf(ele),10000).then(function(){
//verify the body details of popup
browser.wait(EC.invisibilityOf(ele),10000).then(function(){
console.log('element opened and closed');
});
});
Alternatively, if the pop up that you get is an alert then you can check for the presence of alert and then verify things as you want. More info on alert. Hope this helps.
Upvotes: 1