Class: Capybara::Node::Element

Inherits:
Object
  • Object
show all
Includes:
Cornucopia::Capybara::FinderExtensions, Cornucopia::Capybara::MatcherExtensions
Defined in:
lib/cornucopia/capybara/install_finder_extensions.rb,
lib/cornucopia/capybara/install_matcher_extensions.rb

Instance Method Summary collapse

Methods included from Cornucopia::Capybara::MatcherExtensions

#__cornucopia_assert_selector_function, #assert_no_selector, #assert_selector, #has_no_selector?, #has_selector?

Methods included from Cornucopia::Capybara::FinderExtensions

#__cornucopia_finder_function, #all, #find

Instance Method Details

#select_value(values) ⇒ Object

select_value finds the option with the value #value then calls select_option on that item.

select_value only works on select boxes.



50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/cornucopia/capybara/install_finder_extensions.rb', line 50

def select_value(values)
  raise "select_value is only valid for select items" unless self.tag_name == "select"

  if values.is_a?(Array)
    values.each do |value|
      html_safe_value = "".html_safe + value.to_s
      self.find("option[value=\"#{html_safe_value}\"]", visible: false).select_option
    end
  else
    html_safe_value = "".html_safe + values.to_s
    self.find("option[value=\"#{html_safe_value}\"]", visible: false).select_option
  end
end

#value_text ⇒ Object

value_text returns the text for the selected items in the select box instead of the value(s)

value_text only works on select boxes.



67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/cornucopia/capybara/install_finder_extensions.rb', line 67

def value_text
  raise "value_text is only valid for select items" unless self.tag_name == "select"

  values = self.value
  if values.is_a?(Array)
    values.map do |value|
      self.find("option[value=\"#{value}\"]", visible: false).text
    end
  else
    self.find("option[value=\"#{values}\"]", visible: false).text
  end
end