mirror of
https://github.com/DeviceFarmer/stf.git
synced 2026-04-18 13:53:22 +02:00
23 lines
633 B
JavaScript
23 lines
633 B
JavaScript
/**
|
|
* @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)
|
|
})
|
|
})
|
|
}
|
|
)
|
|
}
|