Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Author:: Rich Downie(mailto:rich@visualcv.com)
- #Name:: login.rb
- #
- #Description:: This script logs into the application.
- #It is a requirement for other scripts to run, so it
- #is called in other scripts to login.
- #require 'test/unit'
- if PLATFORM =~ /win32|cygwin/
- require 'win32ole'
- require 'clear_cache'
- end
- require 'watir'
- require 'delete'
- require 'sleep'
- require 'cv_online'
- require 'delete'
- $LOAD_PATH << File.dirname(__FILE__)
- Watir::Browser.default = 'firefox'
- @CWD = Dir.getwd
- if @CWD.index('watir')
- Watir.options_file = @CWD + "/../../config/watir/watir_options.yml"
- else
- Watir.options_file = Dir.getwd + "/config/watir/watir_options.yml"
- end
- @@config = YAML.load_file(Watir.options_file)
- @@test_host = @@config['url']['host']
- @@test_path = @@config['url']['path']
- @@test_url = @@test_host + @@test_path
- @@pro_user = @@config['pro']['user']
- @@pro_pass = @@config['pro']['pass']
- @@share_user = @@config['share']['user']
- @@share_pass = @@config['share']['pass']
- @@company_user = @@config['company']['user']
- @@company_pass = @@config['company']['pass']
- @@new_pass = @@config['new_pass']
- @@comp_reg_path = @@config['comp_reg_path']
- @@port_user = @@config['port']['user']
- @@port_pass = @@config['port']['pass']
- #~ @@round_user = @@config['round']['user']
- #~ @@round_pass = @@config['round']['pass']
- @@opps_user = @@config['opps']['user']
- @@opps_pass = @@config['opps']['pass']
- @@oppspro_user = @@config['oppspro']['user']
- @@oppspro_pass = @@config['oppspro']['pass']
- @@browser = @@config['browser']
- @@version = @@config['version']
- @@admin_user = @@config['admin']['user']
- @@admin_pass = @@config['admin']['pass']
- class AlreadyAMember
- def test_signup
- $browser = Watir::Browser.new
- $browser.goto(@@test_url)
- if @@test_url == "staging.heidrickcv.com/login" then
- $browser.link(:text, "Continue to this website (not recommended).").click
- $browser.link(:text, "Join today").click
- else
- $browser.link(:text, "Join today").click
- end
- end
- end
- class ForgotYourLoginName
- def test_forgot_login
- $browser = Watir::Browser.new
- $browser.goto(@@test_url)
- if $browser.link(:text, "Continue to this website (not recommended).").exists? then
- $browser.link(:text, "Continue to this website (not recommended).").click
- else
- $browser.link(:text, "Forgot Your Login Name?").click
- end
- end
- end
- class ForgotYourPassword
- def test_forgot_password
- $browser = Watir::Browser.new
- $browser.goto(@@test_url)
- if $browser.link(:text, "Continue to this website (not recommended).").exists? then
- $browser.link(:text, "Continue to this website (not recommended).").click
- $browser.link(:text, "Forgot Your Password?").click
- else
- $browser.link(:text, "Forgot Your Password?").click
- end
- end
- end
- class Runner
- def test_openApp(username, password)
- $browser = Watir::Browser.new
- puts "**********************************************************************************"
- puts "Logging into (#{@@test_host.upcase}#{@@test_path.upcase}) as #{username.upcase} with #{@@browser.upcase} #{@@version}"
- $browser.goto(@@test_url)
- if @@version == 6 then
- $browser.text_field(:id, "login").set(username)
- $browser.text_field(:id, "password").set(password)
- $browser.image(:index, 1).click_no_wait
- Popups.new.test_ie_security_prompt
- sleep 12
- CvCheck.new.set_online
- DeleteCV.new.test_delete
- else
- sleep 2
- $browser.text_field(:id, "login").set(username)
- $browser.text_field(:id, "password").set(password)
- $browser.image(:index, 1).click
- end
- CvCheck.new.set_online
- DeleteCV.new.test_delete
- end
- end
- class Login
- def test_login(username, password)
- puts "Logging into #{@@test_host.upcase} as #{username.upcase} with #{@@browser.upcase} #{@@version}"
- if @@version == 6 then
- $browser.text_field(:id, "login").set(username)
- $browser.text_field(:id, "password").set(password)
- $browser.image(:index, 1).click_no_wait
- Popups.new.test_ie_security_prompt
- Sleep.new.ai("Professionals")
- else
- sleep 2
- $browser.text_field(:id, "login").set(username)
- $browser.text_field(:id, "password").set(password)
- $browser.image(:index, 1).click
- DeleteCV.new.test_delete
- end
- end
- end
Add Comment
Please, Sign In to add comment