mirror of
https://github.com/DeviceFarmer/stf.git
synced 2026-04-17 15:43:25 +02:00
52 lines
1.2 KiB
JavaScript
52 lines
1.2 KiB
JavaScript
module.exports = function LoginPage() {
|
|
this.login = browser.params.login
|
|
|
|
this.get = function () {
|
|
return browser.get(this.login.url)
|
|
}
|
|
|
|
this.username = element(by.model('username'))
|
|
|
|
if (this.login.method === 'ldap') {
|
|
this.password = element(by.model('password'))
|
|
} else {
|
|
this.email = element(by.model('email'))
|
|
}
|
|
|
|
|
|
this.setName = function (username) {
|
|
return this.username.sendKeys(username)
|
|
}
|
|
this.setEmail = function (email) {
|
|
return this.email.sendKeys(email)
|
|
}
|
|
this.setPassword = function (password) {
|
|
return this.password.sendKeys(password)
|
|
}
|
|
this.submit = function () {
|
|
return this.username.submit()
|
|
}
|
|
this.doLogin = function () {
|
|
this.get()
|
|
this.setName(this.login.username)
|
|
if (this.login.method === 'ldap') {
|
|
this.setPassword(this.login.password)
|
|
} else {
|
|
this.setEmail(this.login.email)
|
|
}
|
|
|
|
this.submit()
|
|
|
|
return browser.driver.wait(function () {
|
|
return browser.driver.getCurrentUrl().then(function (url) {
|
|
return /devices/.test(url)
|
|
})
|
|
})
|
|
}
|
|
this.cleanUp = function () {
|
|
this.username = null
|
|
this.password = null
|
|
this.email = null
|
|
}
|
|
}
|