Advertisement
Guest User

Untitled

a guest
Aug 31st, 2016
312
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. chalk = require('chalk') # include chalk package
  2.   # allows us to write to console in color
  3. webdriverio = require('webdriverio') # include webdriverio libraries
  4.   # must have selenium standalone server running
  5.  
  6. Browser = (options, data) ->
  7.   @o = webdriverio.remote(options).init().url(data.uri||'https://google.com/')
  8.     # create webdriver instance
  9.   @o._props = data
  10.     # webdriver constants
  11.   @o._cache = {}
  12.     # store in session data
  13.   return @o
  14. # browser wrapper for webdriverio
  15.  
  16. beta = new Browser({ desiredCapabilities: browserName: 'phantomjs' },
  17.   uri: ''
  18.   username: 'jnolette'
  19.   password: 'test')
  20. # instantiate our new browser
  21.  
  22. beta.getTitle().then (title) ->
  23.   console.log chalk.yellow('Landed On: ', title)
  24.   this._cache.title = title
  25.   return
  26.  
  27. .setValue('#username', beta._props.username).then () ->
  28.   console.log chalk.blue('Login Username Specified')
  29.   return
  30.  
  31. .setValue('#password', beta._props.password).then () ->
  32.   console.log chalk.blue('Login Password Specified')
  33.   return
  34.  
  35. .submitForm('#form_login').then () ->
  36.   console.log chalk.yellow('Login Processed')
  37.   return
  38.  
  39. .waitUntil (->
  40.   @getTitle != @_cache.title
  41. 1500)
  42.  
  43. .getTitle().then (title) ->
  44.   console.log chalk.yellow('Redirected To: ', title)
  45.   this._cache.title = title
  46.   return
  47.  
  48. .end().then () ->
  49.   console.log( chalk.red('Terminating Session... Bye =)') )
  50.   return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement