Class: Chop::Form::TagField
- Inherits:
-
Field
- Object
- Field
- Chop::Form::TagField
- Defined in:
- lib/bard/tag_field/cucumber.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.css_selector ⇒ Object
2 3 4 |
# File 'lib/bard/tag_field/cucumber.rb', line 2 def self.css_selector "input-tag" end |
Instance Method Details
#diff_value ⇒ Object
14 15 16 |
# File 'lib/bard/tag_field/cucumber.rb', line 14 def diff_value get_value.join(", ") end |
#fill_in! ⇒ Object
37 38 39 |
# File 'lib/bard/tag_field/cucumber.rb', line 37 def fill_in! session.execute_script("document.getElementById('#{field[:id]}').value = #{set_value.to_json}") end |
#get_value ⇒ Object
10 11 12 |
# File 'lib/bard/tag_field/cucumber.rb', line 10 def get_value field.all("tag-option").map(&:text) end |
#matches? ⇒ Boolean
6 7 8 |
# File 'lib/bard/tag_field/cucumber.rb', line 6 def matches? field.tag_name == "input-tag" end |
#set_value ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/bard/tag_field/cucumber.rb', line 18 def set_value values = if field[:multiple] value.to_s.split(", ").map(&:strip) else [value.to_s.strip] end # Resolve display labels to submit values using datalist = field.all("datalist option", visible: false) if .any? label_to_value = .each_with_object({}) do |opt, hash| hash[opt[:innerText]] = opt[:value] end values = values.map { |v| label_to_value[v] || v } end field[:multiple] ? values : values.first end |