Class: Capybara::ReactDatetime::Picker
- Inherits:
-
Object
- Object
- Capybara::ReactDatetime::Picker
- Defined in:
- lib/capybara-react-datetime.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
60 61 62 |
# File 'lib/capybara-react-datetime.rb', line 60 def initialize @element = find_picker end |
Instance Method Details
#find_day(value) ⇒ Object
Get the day we want to click on
95 96 97 98 99 100 101 102 103 |
# File 'lib/capybara-react-datetime.rb', line 95 def find_day(value) day_xpath = <<-eos .//*[contains(concat(' ', @class, ' '), ' rdtDay ') and not(contains(concat(' ', @class, ' '), ' rdtOld ')) and not(contains(concat(' ', @class, ' '), ' rdtNew ')) and normalize-space(text())='#{value}'] eos days.find :xpath, day_xpath end |
#find_month(value) ⇒ Object
Get the month we want to click on
88 89 90 |
# File 'lib/capybara-react-datetime.rb', line 88 def find_month(value) months.find ".rdtMonth[data-value='#{value - 1}']" end |
#find_year(value) ⇒ Object
Get the year we want to click on
81 82 83 |
# File 'lib/capybara-react-datetime.rb', line 81 def find_year(value) years.find '.rdtYear', text: value end |
#goto_decade_panel ⇒ Object
Reveals the decade panel
65 66 67 68 |
# File 'lib/capybara-react-datetime.rb', line 65 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
72 73 74 75 76 |
# File 'lib/capybara-react-datetime.rb', line 72 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 |