I'm trying to verify that an account was created successfully, but after clicking the submit button, I need to wait until the next page has loaded and verify that the user ended up at the correct URL.
I'm using pollUntil
to check the URL client side, but that results in Detected a page unload event; script execution does not work across page loads.
in Safari at least. I can add a sleep, but I was wondering if there is a better way.
Questions:
How can you poll on something like
this.remote.getCurrentUrl()
? Basically I want to do something likethis.remote.waitForCurrentUrlToEqual(...)
, but I'm also curious how to poll on anything from Selenium commands vs using pollUntil which executes code in the remote browser.I'm checking to see if the user ended up at a protected URL after logging in here. Is there a better way to check this besides polling?
Best practices: do I need to make an assertion with Chai or is it even possible when I'm polling and waiting for stuff as my test? For example, in this case, I'm just trying to poll to make sure we ended up at the right URL within 30 seconds and I don't have an explicit assertion. I'm just assuming the test will fail, but it won't say why. If the best practice is to make an assertion here, how would I do it here or any time I'm using wait?
Here's an example of my code:
'create new account': function() {
return this.remote
// Hidden: populate all account details
.findByClassName('nextButton')
.click()
.end()
.then(pollUntil('return location.pathname === "/protected-page" ? true : null', [], 30000));
}