Module: WatirPump::Components::RadioGroup
- Included in:
- WatirPump::Component
- Defined in:
- lib/watir_pump/components/radio_group.rb
Instance Method Summary collapse
- #radio_accessor(name, *args) ⇒ Object (also: #radio_group)
- #radio_reader(name, *args) ⇒ Object
-
#radio_writer(name, *args) ⇒ Object
rubocop:disable Metrics/AbcSize.
Instance Method Details
#radio_accessor(name, *args) ⇒ Object Also known as: radio_group
32 33 34 35 |
# File 'lib/watir_pump/components/radio_group.rb', line 32 def radio_accessor(name, *args) radio_reader(name, *args) radio_writer(name, *args) end |
#radio_reader(name, *args) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/watir_pump/components/radio_group.rb', line 6 def radio_reader(name, *args) form_field_readers << name define_method name do |*loc_args| list = find_element(:radios, args, loc_args) selected = list.find(&:set?) if selected return selected.parent.text if selected&.parent&.tag_name == 'label' return root.label(for: selected.id).text end end end |
#radio_writer(name, *args) ⇒ Object
rubocop:disable Metrics/AbcSize
18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/watir_pump/components/radio_group.rb', line 18 def radio_writer(name, *args) # rubocop:disable Metrics/AbcSize form_field_writers << name define_method "#{name}=" do |value| list = find_element(:radios, args) # <label>value<input /></label> if list.first.parent.tag_name == 'label' list.find { |el| el.parent.text == value }.set else # <label for='a'>value</label><input id='a' /> list.find { |el| el.id == root.label(text: value).for }.set end end end |