Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- TLO::login = (username, password) ->
- console.log chalk.bgYellow('TLO.login(...)')
- a = this
- return new Promise (resolve, reject) ->
- if !a.browser.isExisting '#form_login'
- reject {
- error: true
- message: 'Login Failed'
- } # failed to login
- else
- a.cache.user = username
- console.log chalk.yellow('Redirecting To Login Page')
- a.browser.url(a.endpoints.login)
- chain = a.browser.setValue('#username', username).then () ->
- console.log chalk.blue('Login Username Specified')
- .getValue('#username').then (value) ->
- console.log chalk.cyan('Username Verified As: ', value)
- .setValue('#password', password).then () ->
- console.log chalk.blue('Login Password Specified')
- .getValue('#password').then (value) ->
- console.log chalk.cyan('Password Verified As: ', value)
- .click('input.button.btnss').then () ->
- console.log chalk.yellow('Login Processed')
- # form submit not working, click had to be used
- .getTitle().then (title) ->
- console.log chalk.yellow('Redirected To: ', title)
- .waitForVisible('#versionInfo', 1500).then () ->
- a.cache.loggedIn = true
- .getText('#versionInfo').then (text) ->
- a.version = text
- console.log chalk.green text
- .catch (error) ->
- console.log chalk.bgRed(error) # error encountered in promise chain
- ---------------------------------------------------------------------------------------------------------------------------------------
- tlo = new TLO beta
- tlo.login('jnolette', 'test')
- .then (result) ->
- if ( result && !result.error )
- console.log chalk.green(result.message)
- else if ( result && result.error )
- console.log chalk.red(result.message) # error encountered was expected
- else
- console.log chalk.bgRed('Unhandeled Error Has Occured #001') # codepath error #001
- .catch (error) ->
- console.log chalk.bgRed(error) # error encountered in promise
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement