class Capybara::Node::Simple
def ==(other)
def ==(other) eql?(other) || (other.respond_to?(:native) && native == other.native) end
def [](name)
-
(String)
- The value of the attribute
Parameters:
-
name
(Symbol
) -- The attribute name to retrieve
def [](name) attr_name = name.to_s if attr_name == 'value' value elsif (tag_name == 'input') && (native[:type] == 'checkbox') && (attr_name == 'checked') native['checked'] == 'checked' else native[attr_name] end end
def allow_reload!(*)
def allow_reload!(*) # no op end
def checked?
-
(Boolean)
- Whether the element is checked
def checked? native.has_attribute?('checked') end
def disabled?
-
(Boolean)
- Whether the element is disabled
def disabled? native.has_attribute?('disabled') && %w[button input select textarea optgroup option menuitem fieldset].include?(tag_name) end
def find_css(css, **_options)
- Api: - private
def find_css(css, **_options) native.css(css) end
def find_xpath(xpath, **_options)
- Api: - private
def find_xpath(xpath, **_options) native.xpath(xpath) end
def initial_cache
- Api: - private
def initial_cache {} end
def initialize(native)
def initialize(native) native = Capybara::HTML(native) if native.is_a?(String) @native = native end
def inspect
def inspect %(#<Capybara::Node::Simple tag="#{tag_name}" path="#{path}">) end
def multiple?
def multiple? native.has_attribute?('multiple') end
def option_value(option)
def option_value(option) return nil if option.nil? option[:value] || option.content end
def path
-
(String)
- An XPath expression
def path native.path end
def readonly?
def readonly? native.has_attribute?('readonly') end
def selected?
-
(Boolean)
- Whether the element is selected
def selected? native.has_attribute?('selected') end
def session_options
- Api: - private
def session_options Capybara.session_options end
def synchronize(_seconds = nil)
def synchronize(_seconds = nil) yield # simple nodes don't need to wait end
def tag_name
-
(String)
- The tag name of the element
def tag_name native.node_name end
def text(_type = nil, normalize_ws: false)
-
(String)
- The text of the element
def text(_type = nil, normalize_ws: false) txt = native.text normalize_ws ? txt.gsub(/[[:space:]]+/, ' ').strip : txt end
def title
-
(String)
- The title of the document
def title native.title end
def value
-
(String)
- The value of the form element
def value if tag_name == 'textarea' native['_capybara_raw_value'] elsif tag_name == 'select' selected_options = find_xpath('.//option[@selected]') if multiple? selected_options.map(&method(:option_value)) else option_value(selected_options.first || find_xpath('.//option').first) end elsif tag_name == 'input' && %w[radio checkbox].include?(native[:type]) native[:value] || 'on' else native[:value] end end
def visible?(check_ancestors = true) # rubocop:disable Style/OptionalBooleanParameter
-
(Boolean)
- Whether the element is visible
Parameters:
-
check_ancestors
(Boolean
) -- Whether to inherit visibility from ancestors
def visible?(check_ancestors = true) # rubocop:disable Style/OptionalBooleanParameter return false if (tag_name == 'input') && (native[:type] == 'hidden') return false if tag_name == 'template' if check_ancestors !find_xpath(VISIBILITY_XPATH) else # No need for an xpath if only checking the current element !(native.key?('hidden') || /display:\s?none/.match?(native[:style] || '') || %w[script head style].include?(tag_name)) end end