Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- chalk = require('chalk') # include chalk package
- # allows us to write to console in color
- webdriverio = require('webdriverio') # include webdriverio libraries
- # must have selenium standalone server running
- Browser = (options, data) ->
- @o = webdriverio.remote(options).init().url(data.uri||'https://google.com/')
- # create webdriver instance
- @o._props = data
- # webdriver constants
- @o._cache = {}
- # store in session data
- return @o
- # browser wrapper for webdriverio
- beta = new Browser({ desiredCapabilities: browserName: 'phantomjs' },
- uri: ''
- username: 'jnolette'
- password: 'test')
- # instantiate our new browser
- beta.getTitle().then (title) ->
- console.log chalk.yellow('Landed On: ', title)
- this._cache.title = title
- return
- .setValue('#username', beta._props.username).then () ->
- console.log chalk.blue('Login Username Specified')
- return
- .setValue('#password', beta._props.password).then () ->
- console.log chalk.blue('Login Password Specified')
- return
- .submitForm('#form_login').then () ->
- console.log chalk.yellow('Login Processed')
- return
- .waitUntil (->
- @getTitle != @_cache.title
- 1500)
- .getTitle().then (title) ->
- console.log chalk.yellow('Redirected To: ', title)
- this._cache.title = title
- return
- .end().then () ->
- console.log( chalk.red('Terminating Session... Bye =)') )
- return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement