Guest User

Untitled

a guest
Oct 22nd, 2018
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. require 'watir-webdriver/extensions/alerts'
  2. class AnatomyOneLogin
  3. attr_accessor :username, :password
  4.  
  5. def initialize(username, password)
  6. @username = username
  7. @password = password
  8. end
  9.  
  10. def login
  11. Watir::Wait.until { $browser.text_field(:id, "username-field").exists? }
  12. $browser.text_field(:id, "username-field").set($credentials[@username])
  13. $browser.text_field(:id, "pseudo").click
  14. Watir::Wait.until { $browser.text_field(:id, "password-field").visible? }
  15. $browser.text_field(:id, "password-field").set($credentials[@password])
  16. if @username == "Incorrect Username" || @password == "Incorrect Password"
  17. $browser.button(:id, "goButton").click
  18. Watir::Wait.until { $browser.div(:class, "incorrect-inner").visible? }
  19. else
  20. $browser.button(:id, "goButton").click
  21. Watir::Wait.until { $elements["Regional Button"].exists? }
  22. end
  23. end
  24.  
  25. def local_login
  26. $browser.goto("#{$env}.anatomyone-int.com/locallogin")
  27. Watir::Wait.until{ $browser.text_field(:id, "username").exists? }
  28. $browser.text_field(:id, "username").set("qa.a1")
  29. $browser.text_field(:id, "password").set("Passw0rd")
  30. $browser.button(:id, "loginButton").click
  31. end
  32.  
  33. end
Add Comment
Please, Sign In to add comment