- Added waitUrl helper.

This commit is contained in:
Gunther Brunner
2014-08-27 16:34:47 +09:00
parent b1afa8076c
commit 5941030743
5 changed files with 50 additions and 7 deletions

View File

@@ -0,0 +1,22 @@
/**
* @name waitUrl
*
* @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
*/
module.exports = function waitUrl(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)
})
})
}
)
}