Class: Capybara::BootstrapDatepicker::Picker
- Inherits:
-
Object
- Object
- Capybara::BootstrapDatepicker::Picker
- Defined in:
- lib/capybara-bootstrap-datepicker.rb
Overview
The Picker class interacts with the datepicker
Instance Method Summary collapse
-
#find_day(value) ⇒ Object
Get the day we want to click on.
-
#find_month(value) ⇒ Object
Get the month we want to click on.
-
#find_year(value) ⇒ Object
Get the year we want to click on.
-
#goto_decade_panel ⇒ Object
Reveals the decade panel.
-
#initialize ⇒ Picker
constructor
Initializes the picker.
-
#navigate_through_decades(value) ⇒ Object
Navigates through the decade panels until the correct one.
Constructor Details
#initialize ⇒ Picker
Initializes the picker
58 59 60 |
# File 'lib/capybara-bootstrap-datepicker.rb', line 58 def initialize @element = find_picker end |
Instance Method Details
#find_day(value) ⇒ Object
Get the day we want to click on
93 94 95 96 97 98 99 100 101 102 |
# File 'lib/capybara-bootstrap-datepicker.rb', line 93 def find_day(value) day_xpath = <<-XPATH .//*[contains(concat(' ', @class, ' '), ' day ') and not(contains(concat(' ', @class, ' '), ' old ')) and not(contains(concat(' ', @class, ' '), ' new ')) and normalize-space(text())='#{value}'] XPATH days.find :xpath, day_xpath end |
#find_month(value) ⇒ Object
Get the month we want to click on
86 87 88 |
# File 'lib/capybara-bootstrap-datepicker.rb', line 86 def find_month(value) months.find ".month:nth-child(#{value})" end |
#find_year(value) ⇒ Object
Get the year we want to click on
79 80 81 |
# File 'lib/capybara-bootstrap-datepicker.rb', line 79 def find_year(value) years.find '.year', text: value end |
#goto_decade_panel ⇒ Object
Reveals the decade panel
63 64 65 66 |
# File 'lib/capybara-bootstrap-datepicker.rb', line 63 def goto_decade_panel current_month.click if days.visible? current_year.click if months.visible? end |
#navigate_through_decades(value) ⇒ Object
Navigates through the decade panels until the correct one
70 71 72 73 74 |
# File 'lib/capybara-bootstrap-datepicker.rb', line 70 def navigate_through_decades(value) decade_start, decade_end = current_decade_minmax goto_prev_decade(value, decade_start) if value < decade_start goto_next_decade(decade_end, value) if value > decade_end end |