Class: Avmtrf1::Forponto::Session
- Inherits:
-
Object
- Object
- Avmtrf1::Forponto::Session
- Defined in:
- lib/avmtrf1/forponto/session.rb
Instance Attribute Summary collapse
-
#codigo ⇒ Object
readonly
Returns the value of attribute codigo.
-
#matricula ⇒ Object
readonly
Returns the value of attribute matricula.
-
#root_url ⇒ Object
readonly
Returns the value of attribute root_url.
-
#sub ⇒ Object
readonly
Returns the value of attribute sub.
Instance Method Summary collapse
- #go_to_login_form ⇒ Object
-
#initialize(root_url, matricula, codigo) ⇒ Session
constructor
A new instance of Session.
- #interval_data(start_date, end_date) ⇒ Object
- #interval_source_code(start_date, end_date) ⇒ Object
- #login(start_date, end_date) ⇒ Object
- #login_fill_codigo ⇒ Object
- #login_fill_end_date(end_date) ⇒ Object
- #login_fill_matricula ⇒ Object
- #login_fill_start_date(start_date) ⇒ Object
Constructor Details
#initialize(root_url, matricula, codigo) ⇒ Session
Returns a new instance of Session.
10 11 12 13 14 15 16 17 |
# File 'lib/avmtrf1/forponto/session.rb', line 10 def initialize(root_url, matricula, codigo) @root_url = root_url @matricula = matricula @codigo = codigo @sub = ::Aranha::Selenium::Session.new( user_agent: 'Mozilla/5.0 (Windows NT 6.1; WOW64; Trident/7.0; rv:11.0) like Gecko' ) end |
Instance Attribute Details
#codigo ⇒ Object (readonly)
Returns the value of attribute codigo.
8 9 10 |
# File 'lib/avmtrf1/forponto/session.rb', line 8 def codigo @codigo end |
#matricula ⇒ Object (readonly)
Returns the value of attribute matricula.
8 9 10 |
# File 'lib/avmtrf1/forponto/session.rb', line 8 def matricula @matricula end |
#root_url ⇒ Object (readonly)
Returns the value of attribute root_url.
8 9 10 |
# File 'lib/avmtrf1/forponto/session.rb', line 8 def root_url @root_url end |
#sub ⇒ Object (readonly)
Returns the value of attribute sub.
8 9 10 |
# File 'lib/avmtrf1/forponto/session.rb', line 8 def sub @sub end |
Instance Method Details
#go_to_login_form ⇒ Object
19 20 21 22 |
# File 'lib/avmtrf1/forponto/session.rb', line 19 def go_to_login_form sub.navigate.to root_url sub.wait_for_click(xpath: '//a[text() = "COLABORADOR"]') end |
#interval_data(start_date, end_date) ⇒ Object
33 34 35 36 37 |
# File 'lib/avmtrf1/forponto/session.rb', line 33 def interval_data(start_date, end_date) tempfile = '/tmp/forponto.html' ::File.write(tempfile, interval_source_code(start_date, end_date)) ::Avmtrf1::Forponto::Parsers::Espelho.new("file://#{tempfile}").data end |
#interval_source_code(start_date, end_date) ⇒ Object
39 40 41 42 43 44 |
# File 'lib/avmtrf1/forponto/session.rb', line 39 def interval_source_code(start_date, end_date) login(start_date, end_date) sub.switch_to.frame(sub.wait_for_element(xpath: '//frame[@name="topFrame"]')) sub.wait_for_element(xpath: '//form[@name="frmjustificativa"]') sub.current_source end |
#login(start_date, end_date) ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/avmtrf1/forponto/session.rb', line 24 def login(start_date, end_date) go_to_login_form login_fill_matricula login_fill_codigo login_fill_start_date(start_date) login_fill_end_date(end_date) sub.wait_for_click(xpath: '//input[@name="ok"]') end |
#login_fill_codigo ⇒ Object
50 51 52 |
# File 'lib/avmtrf1/forponto/session.rb', line 50 def login_fill_codigo sub.wait_for_element(xpath: '//input[@name="deEdtFunConsulta"]').send_keys(codigo) end |
#login_fill_end_date(end_date) ⇒ Object
60 61 62 63 64 |
# File 'lib/avmtrf1/forponto/session.rb', line 60 def login_fill_end_date(end_date) sub.wait_for_element(xpath: '//input[@name="deEdtDataAte"]').send_keys( end_date.strftime('%d/%m/%Y') ) end |
#login_fill_matricula ⇒ Object
46 47 48 |
# File 'lib/avmtrf1/forponto/session.rb', line 46 def login_fill_matricula sub.wait_for_element(xpath: '//input[@name="deEdtFunCrachaSel"]').send_keys(matricula) end |
#login_fill_start_date(start_date) ⇒ Object
54 55 56 57 58 |
# File 'lib/avmtrf1/forponto/session.rb', line 54 def login_fill_start_date(start_date) sub.wait_for_element(xpath: '//input[@name="deEdtDataDe"]').send_keys( start_date.strftime('%d/%m/%Y') ) end |