Method: Capybara::Node::Simple#value
- Defined in:
- lib/capybara/node/simple.rb
#value ⇒ String
Returns The value of the form element.
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/capybara/node/simple.rb', line 77 def value if tag_name == 'textarea' native.content elsif tag_name == 'select' if native['multiple'] == 'multiple' native.xpath(".//option[@selected='selected']").map { |option| option[:value] || option.content } else option = native.xpath(".//option[@selected='selected']").first || native.xpath(".//option").first option[:value] || option.content if option end elsif tag_name == 'input' && %w(radio checkbox).include?(native[:type]) native[:value] || 'on' else native[:value] end end |