Class: PortalModule::Pages::LoginPage

Inherits:
Object
  • Object
show all
Includes:
PageObject
Defined in:
lib/portal_module/pages/login_page.rb

Instance Method Summary collapse

Instance Method Details

#allow_password_entryObject



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/portal_module/pages/login_page.rb', line 52

def allow_password_entry
  # We used to have to click on the password mask before the page would let us enter the password itself:
  #
  # # For some unknown reason, we must click on a password mask input before
  # # we can access the password field itself.
  #   password_mask_element.click
  #
  # Now, we have to use javascript to hide the mask and display the password field.
  hide_mask_script = <<EOS
pwdmasks = document.getElementsByClassName('passwordmask');
pwdmasks[0].style.display = 'none';
pwds = document.getElementsByClassName('password');
pwds[0].style.display = 'block';
EOS

  @browser.execute_script(hide_mask_script)
end

#get_dynamic_urlObject



17
18
19
# File 'lib/portal_module/pages/login_page.rb', line 17

def get_dynamic_url
  PortalModule.configuration.base_url
end

#login_as(username, password) ⇒ Object

Raises:

  • (ArgumentError)


26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/portal_module/pages/login_page.rb', line 26

def (username, password)
  if !self.username? && current_url == PortalModule.configuration.base_url + '/User/AppLogin.aspx'
    # We're still logged in.
    return
  end

  raise ArgumentError.new("Missing username for login.\nHave you set the HSBC_envname_USER environment variable?") if username.nil?

  raise ArgumentError.new("Missing password for login.\nHave you set the HSBC_envname_PASSWORD environment variable?") if password.nil?

  unless current_url.downcase.include? get_dynamic_url.downcase
    navigate_to get_dynamic_url
  end

  self.username = username

  allow_password_entry

  self.password = password
  
end

#logoutObject



48
49
50
# File 'lib/portal_module/pages/login_page.rb', line 48

def logout
  navigate_to get_dynamic_url + '/User/AppLogout.aspx'
end