mirror of
https://github.com/DeviceFarmer/stf.git
synced 2026-04-27 19:25:13 +02:00
- Added waitUrl helper.
This commit is contained in:
@@ -21,6 +21,19 @@ describe('Control Page', function () {
|
||||
|
||||
it('should control an usable device', function () {
|
||||
deviceListPage.controlAvailableDevice()
|
||||
|
||||
browser.waitUrl(/control/)
|
||||
|
||||
//browser.debugger();
|
||||
//console.log('after')
|
||||
|
||||
|
||||
//browser.driver.wait(function () {
|
||||
// return browser.driver.getCurrentUrl().then(function (url) {
|
||||
// return /control/.test(url)
|
||||
// })
|
||||
//})
|
||||
|
||||
browser.getLocationAbsUrl().then(function (newUrl) {
|
||||
expect(newUrl).toMatch(protractor.getInstance().baseUrl + 'control')
|
||||
})
|
||||
|
||||
@@ -18,6 +18,6 @@ module.exports = function DeviceListPage() {
|
||||
return this.devicesUsable.first()
|
||||
}
|
||||
this.controlAvailableDevice = function () {
|
||||
this.availableDevice().click()
|
||||
return this.availableDevice().click()
|
||||
}
|
||||
}
|
||||
|
||||
22
res/test/e2e/helpers/wait-url.js
Normal file
22
res/test/e2e/helpers/wait-url.js
Normal 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)
|
||||
})
|
||||
})
|
||||
}
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user