Module: ServerAuthentication

Defined in:
lib/plc/server_authentication.rb

Instance Method Summary collapse

Instance Method Details

#fill_in_login_fieldObject



19
20
21
# File 'lib/plc/server_authentication.rb', line 19

def 
  .set "admin"
end

#get_variable_pageObject



3
4
5
# File 'lib/plc/server_authentication.rb', line 3

def get_variable_page
  browser.goto Plc::VARIABLE_PAGE_URL
end

#logged_in?Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/plc/server_authentication.rb', line 39

def logged_in?
  browser.buttons.select {|button| button.text == "Log out"}.count > 0  
end

#loginObject



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/plc/server_authentication.rb', line 7

def 
  unless logged_in? 
    get_variable_page unless @browser.url == Plc::VARIABLE_PAGE_URL
    
    
  
    logged_in? ? "logged in as admin" : LoginError 
  else
     "already logged in"
  end    
end

#login_buttonObject



35
36
37
# File 'lib/plc/server_authentication.rb', line 35

def 
  browser.buttons.select {|button | button.text == "Log in"}.first
end

#login_fieldObject



31
32
33
# File 'lib/plc/server_authentication.rb', line 31

def 
  browser.text_fields.select {|input| input.name == "Login" }.first
end

#login_formObject



27
28
29
# File 'lib/plc/server_authentication.rb', line 27

def 
  browser.forms.select {|form| form.name == "LoginForm" }.first
end

#logoutObject



43
44
45
46
# File 'lib/plc/server_authentication.rb', line 43

def logout 
  browser.buttons.select {|button| button.text == "Log out"}.first.click if logged_in?
  "logged out of admin"
end

#submit_login_formObject



23
24
25
# File 'lib/plc/server_authentication.rb', line 23

def 
  .click
end