Module: ServerAuthentication
- Defined in:
- lib/plc/server_authentication.rb
Instance Method Summary collapse
- #fill_in_login_field ⇒ Object
- #get_variable_page ⇒ Object
- #logged_in? ⇒ Boolean
- #login ⇒ Object
- #login_button ⇒ Object
- #login_field ⇒ Object
- #login_form ⇒ Object
- #logout ⇒ Object
- #submit_login_form ⇒ Object
Instance Method Details
#fill_in_login_field ⇒ Object
19 20 21 |
# File 'lib/plc/server_authentication.rb', line 19 def fill_in_login_field login_field.set "admin" end |
#get_variable_page ⇒ Object
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
39 40 41 |
# File 'lib/plc/server_authentication.rb', line 39 def logged_in? browser..select {|| .text == "Log out"}.count > 0 end |
#login ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/plc/server_authentication.rb', line 7 def login unless logged_in? get_variable_page unless @browser.url == Plc::VARIABLE_PAGE_URL fill_in_login_field submit_login_form logged_in? ? "logged in as admin" : LoginError else "already logged in" end end |
#login_button ⇒ Object
35 36 37 |
# File 'lib/plc/server_authentication.rb', line 35 def browser..select {| | .text == "Log in"}.first end |
#login_field ⇒ Object
31 32 33 |
# File 'lib/plc/server_authentication.rb', line 31 def login_field browser.text_fields.select {|input| input.name == "Login" }.first end |
#login_form ⇒ Object
27 28 29 |
# File 'lib/plc/server_authentication.rb', line 27 def login_form browser.forms.select {|form| form.name == "LoginForm" }.first end |
#logout ⇒ Object
43 44 45 46 |
# File 'lib/plc/server_authentication.rb', line 43 def logout browser..select {|| .text == "Log out"}.first.click if logged_in? "logged out of admin" end |
#submit_login_form ⇒ Object
23 24 25 |
# File 'lib/plc/server_authentication.rb', line 23 def submit_login_form .click end |