Module: Watir::Container
- Defined in:
- lib/watir-formhandler/container.rb
Constant Summary collapse
Instance Method Summary collapse
-
#field(label, start_node: nil, placeholder: false, id: false) ⇒ Watir::Element
Searches for the specified label and returns the form field belonging to it, identified by the ‘for’ attribute of the label.
-
#fill_in(label, value, start_node: nil, placeholder: false, id: false) ⇒ Object
Fills in the given value(s) to the passed attribute.
-
#option_group(*args) ⇒ OptionGroup
Returns an OptionGroup.
-
#value_of(label, start_node: nil, placeholder: false, id: false) ⇒ String, ...
Returns the current value of the specified form field.
Instance Method Details
#field(label, start_node: nil, placeholder: false, id: false) ⇒ Watir::Element
Searches for the specified label and returns the form field belonging to it, identified by the ‘for’ attribute of the label. Alternatively, you may pass a Watir::Label.
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/watir-formhandler/container.rb', line 17 def field(label, start_node: nil, placeholder: false, id: false) start_node ||= self if placeholder start_node.element(placeholder: label).to_subtype elsif id start_node.element(id: label).to_subtype else field_label = label.respond_to?(:for) ? label : start_node.label(text: label) determine_field(start_node, field_label) end end |
#fill_in(label, value, start_node: nil, placeholder: false, id: false) ⇒ Object
Fills in the given value(s) to the passed attribute. It therefore accepts the same parameters as the #field method.
39 40 41 42 43 44 45 |
# File 'lib/watir-formhandler/container.rb', line 39 def fill_in(label, value, start_node: nil, placeholder: false, id: false) field(label, start_node: start_node, placeholder: placeholder, id: id ).set(value) end |
#option_group(*args) ⇒ OptionGroup
Returns an OptionGroup
67 68 69 70 71 72 73 74 |
# File 'lib/watir-formhandler/container.rb', line 67 def option_group(*args) selector = if args.first.respond_to?(:elements) args.first else extract_selector(args) end OptionGroup.new(self, selector) end |
#value_of(label, start_node: nil, placeholder: false, id: false) ⇒ String, ...
Returns the current value of the specified form field. It therefore accepts the same parameters as the #field method.
56 57 58 59 60 61 62 |
# File 'lib/watir-formhandler/container.rb', line 56 def value_of(label, start_node: nil, placeholder: false, id: false) field(label, start_node: start_node, placeholder: placeholder, id: id ).field_value end |