Class: AdminModule::Pages::LoginPage

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

Instance Method Summary collapse

Instance Method Details

#allow_password_entryObject



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

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



19
20
21
# File 'lib/admin_module/pages/login_page.rb', line 19

def get_dynamic_url
  AdminModule.configuration.base_url
end

#login_as(username, password) ⇒ Object

Raises:

  • (ArgumentError)


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

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

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

  raise ArgumentError.new("Missing password for login.\nHave you set the $CLIENT_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



50
51
52
# File 'lib/admin_module/pages/login_page.rb', line 50

def logout
  navigate_to get_dynamic_url + '/user/logout.aspx'
end