Class: Avmtrf1::CheckPoint::Session

Inherits:
Object
  • Object
show all
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'

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.by_ad_user(ad_user, driver_options = {}) ⇒ Object


17
18
19
20
21
22
23
# File 'lib/avmtrf1/check_point/session.rb', line 17

def by_ad_user(ad_user, driver_options = {})
  new(
    ad_user.username_with_domain,
    ad_user.password,
    driver_options
  )
end

.by_default_ad_user(driver_options = {}) ⇒ Object


25
26
27
# File 'lib/avmtrf1/check_point/session.rb', line 25

def by_default_ad_user(driver_options = {})
  by_ad_user(::Avmtrf1.ad_user, driver_options)
end

Instance Method Details

#logged?Boolean

Returns:

  • (Boolean)

32
33
34
35
# File 'lib/avmtrf1/check_point/session.rb', line 32

def logged?
  session.navigate.to LOGIN_URL
  title_text == LOGGED_TITLE_TEXT
end

#loginObject


37
38
39
# File 'lib/avmtrf1/check_point/session.rb', line 37

def 
  ::Avmtrf1::CheckPoint::Session::Login.new(self)
end

#title_textObject


41
42
43
44
45
46
47
48
49
50
51
# File 'lib/avmtrf1/check_point/session.rb', line 41

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