Class: Avmtrf1::CheckPoint::Session
- Inherits:
-
Object
- Object
- Avmtrf1::CheckPoint::Session
- Defined in:
- lib/avmtrf1/check_point/session.rb,
lib/avmtrf1/check_point/session/login.rb
Defined Under Namespace
Classes: Login
Constant Summary collapse
- ROOT_URL =
'https://cp.trf1.jus.br'
- LOGIN_URL =
"#{ROOT_URL}/connect/PortalMain"
- LOGGED_TITLE_TEXT =
'Network Access Granted'
Instance Attribute Summary collapse
-
#password ⇒ Object
readonly
Returns the value of attribute password.
-
#session ⇒ Object
readonly
Returns the value of attribute session.
-
#username ⇒ Object
readonly
Returns the value of attribute username.
Class Method Summary collapse
- .by_ad_user(ad_user, driver_options = {}) ⇒ Object
- .by_default_ad_user(driver_options = {}) ⇒ Object
Instance Method Summary collapse
-
#initialize(username, password, driver_options = {}) ⇒ Session
constructor
A new instance of Session.
- #logged? ⇒ Boolean
- #login ⇒ Object
- #title_text ⇒ Object
Constructor Details
#initialize(username, password, driver_options = {}) ⇒ Session
Returns a new instance of Session.
29 30 31 32 33 34 35 |
# File 'lib/avmtrf1/check_point/session.rb', line 29 def initialize(username, password, = {}) @username = username @password = password @session = ::Aranha::Selenium::Session.new( .merge(accept_insecure_certs: true) ) end |
Instance Attribute Details
#password ⇒ Object (readonly)
Returns the value of attribute password.
27 28 29 |
# File 'lib/avmtrf1/check_point/session.rb', line 27 def password @password end |
#session ⇒ Object (readonly)
Returns the value of attribute session.
27 28 29 |
# File 'lib/avmtrf1/check_point/session.rb', line 27 def session @session end |
#username ⇒ Object (readonly)
Returns the value of attribute username.
27 28 29 |
# File 'lib/avmtrf1/check_point/session.rb', line 27 def username @username end |
Class Method Details
.by_ad_user(ad_user, driver_options = {}) ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/avmtrf1/check_point/session.rb', line 14 def by_ad_user(ad_user, = {}) new( ad_user.username_with_domain, ad_user.password, ) end |
Instance Method Details
#logged? ⇒ Boolean
37 38 39 40 |
# File 'lib/avmtrf1/check_point/session.rb', line 37 def logged? session.navigate.to LOGIN_URL title_text == LOGGED_TITLE_TEXT end |
#login ⇒ Object
42 43 44 |
# File 'lib/avmtrf1/check_point/session.rb', line 42 def login ::Avmtrf1::CheckPoint::Session::Login.new(self) end |
#title_text ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/avmtrf1/check_point/session.rb', line 46 def title_text result_text = nil session.wait.until do element = session.find_element(id: 'usercheck_title_div') return false unless element result_text = element.text.strip result_text.present? end result_text end |