Last active
August 29, 2015 14:00
-
-
Save elgalu/11296314 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @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