class Capybara::Node::Simple
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' and native[:type] == 'checkbox' and 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') end
def find_css(css)
- Api: - private
def find_css(css) native.css(css) end
def find_xpath(xpath)
- Api: - private
def find_xpath(xpath) native.xpath(xpath) 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 path
-
(String)- An XPath expression
def path native.path 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)
-
(String)- The text of the element
def text(_type = nil) native.text 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' 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
def visible?(check_ancestors = true)
-
(Boolean)- Whether the element is visible
Parameters:
-
check_ancestors(Boolean) -- Whether to inherit visibility from ancestors
def visible?(check_ancestors = true) return false if (tag_name == 'input') && (native[:type] == "hidden") if check_ancestors !native.xpath("boolean(./ancestor-or-self::*[contains(@style, 'display:none') or contains(@style, 'display: none') or @hidden or name()='script' or name()='head'])") else # No need for an xpath if only checking the current element !(native.has_attribute?('hidden') || (native[:style] =~ /display:\s?none/) || %w[script head].include?(tag_name)) end end