Skip to content

Instantly share code, notes, and snippets.

@elgalu
Last active August 29, 2015 14:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elgalu/11296314 to your computer and use it in GitHub Desktop.
Save elgalu/11296314 to your computer and use it in GitHub Desktop.
/**
* @name waitForUrlToChangeTo
* @description Wait until the URL changes to match a provided regex
* @param {RegExp} urlRegex wait until the URL changes to match this regex
* @returns {!webdriver.promise.Promise} Promise
*/
function waitForUrlToChangeTo(urlRegex) {
var currentUrl;
return browser.getCurrentUrl().then(function storeCurrentUrl(url) {
currentUrl = url;
}
).then(function waitForUrlToChangeTo() {
return browser.wait(function waitForUrlToChangeTo() {
return browser.getCurrentUrl().then(function compareCurrentUrl(url) {
return urlRegex.test(url);
}, function() {
return waitForUrlToChangeTo();
});
});
}
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment