Guest User

Untitled

a guest
Jun 11th, 2018
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.39 KB | None | 0 0
  1. #Author:: Rich Downie(mailto:rich@visualcv.com)
  2. #Name:: login.rb
  3. #
  4. #Description:: This script logs into the application.
  5. #It is a requirement for other scripts to run, so it
  6. #is called in other scripts to login.
  7.  
  8. #require 'test/unit'
  9.  
  10. if PLATFORM =~ /win32|cygwin/
  11. require 'win32ole'
  12. require 'clear_cache'
  13. end
  14.  
  15. require 'watir'
  16. require 'delete'
  17. require 'sleep'
  18. require 'cv_online'
  19. require 'delete'
  20.  
  21. $LOAD_PATH << File.dirname(__FILE__)
  22.  
  23. Watir::Browser.default = 'firefox'
  24. @CWD = Dir.getwd
  25. if @CWD.index('watir')
  26. Watir.options_file = @CWD + "/../../config/watir/watir_options.yml"
  27. else
  28. Watir.options_file = Dir.getwd + "/config/watir/watir_options.yml"
  29. end
  30.  
  31. @@config = YAML.load_file(Watir.options_file)
  32.  
  33. @@test_host = @@config['url']['host']
  34. @@test_path = @@config['url']['path']
  35. @@test_url = @@test_host + @@test_path
  36. @@pro_user = @@config['pro']['user']
  37. @@pro_pass = @@config['pro']['pass']
  38. @@share_user = @@config['share']['user']
  39. @@share_pass = @@config['share']['pass']
  40. @@company_user = @@config['company']['user']
  41. @@company_pass = @@config['company']['pass']
  42. @@new_pass = @@config['new_pass']
  43. @@comp_reg_path = @@config['comp_reg_path']
  44. @@port_user = @@config['port']['user']
  45. @@port_pass = @@config['port']['pass']
  46. #~ @@round_user = @@config['round']['user']
  47. #~ @@round_pass = @@config['round']['pass']
  48. @@opps_user = @@config['opps']['user']
  49. @@opps_pass = @@config['opps']['pass']
  50. @@oppspro_user = @@config['oppspro']['user']
  51. @@oppspro_pass = @@config['oppspro']['pass']
  52. @@browser = @@config['browser']
  53. @@version = @@config['version']
  54. @@admin_user = @@config['admin']['user']
  55. @@admin_pass = @@config['admin']['pass']
  56.  
  57. class AlreadyAMember
  58.  
  59. def test_signup
  60. $browser = Watir::Browser.new
  61. $browser.goto(@@test_url)
  62. if @@test_url == "staging.heidrickcv.com/login" then
  63. $browser.link(:text, "Continue to this website (not recommended).").click
  64. $browser.link(:text, "Join today").click
  65. else
  66. $browser.link(:text, "Join today").click
  67. end
  68. end
  69.  
  70. end
  71.  
  72. class ForgotYourLoginName
  73. def test_forgot_login
  74. $browser = Watir::Browser.new
  75. $browser.goto(@@test_url)
  76. if $browser.link(:text, "Continue to this website (not recommended).").exists? then
  77. $browser.link(:text, "Continue to this website (not recommended).").click
  78. else
  79. $browser.link(:text, "Forgot Your Login Name?").click
  80. end
  81. end
  82. end
  83.  
  84. class ForgotYourPassword
  85. def test_forgot_password
  86. $browser = Watir::Browser.new
  87. $browser.goto(@@test_url)
  88. if $browser.link(:text, "Continue to this website (not recommended).").exists? then
  89. $browser.link(:text, "Continue to this website (not recommended).").click
  90. $browser.link(:text, "Forgot Your Password?").click
  91. else
  92. $browser.link(:text, "Forgot Your Password?").click
  93. end
  94. end
  95. end
  96.  
  97. class Runner
  98. def test_openApp(username, password)
  99. $browser = Watir::Browser.new
  100. puts "**********************************************************************************"
  101. puts "Logging into (#{@@test_host.upcase}#{@@test_path.upcase}) as #{username.upcase} with #{@@browser.upcase} #{@@version}"
  102. $browser.goto(@@test_url)
  103. if @@version == 6 then
  104. $browser.text_field(:id, "login").set(username)
  105. $browser.text_field(:id, "password").set(password)
  106. $browser.image(:index, 1).click_no_wait
  107. Popups.new.test_ie_security_prompt
  108. sleep 12
  109. CvCheck.new.set_online
  110. DeleteCV.new.test_delete
  111. else
  112. sleep 2
  113. $browser.text_field(:id, "login").set(username)
  114. $browser.text_field(:id, "password").set(password)
  115. $browser.image(:index, 1).click
  116. end
  117. CvCheck.new.set_online
  118. DeleteCV.new.test_delete
  119. end
  120. end
  121.  
  122. class Login
  123. def test_login(username, password)
  124. puts "Logging into #{@@test_host.upcase} as #{username.upcase} with #{@@browser.upcase} #{@@version}"
  125. if @@version == 6 then
  126. $browser.text_field(:id, "login").set(username)
  127. $browser.text_field(:id, "password").set(password)
  128. $browser.image(:index, 1).click_no_wait
  129. Popups.new.test_ie_security_prompt
  130. Sleep.new.ai("Professionals")
  131. else
  132. sleep 2
  133. $browser.text_field(:id, "login").set(username)
  134. $browser.text_field(:id, "password").set(password)
  135. $browser.image(:index, 1).click
  136. DeleteCV.new.test_delete
  137. end
  138. end
  139. end
Add Comment
Please, Sign In to add comment