Method: Capybara::Node::Simple#visible?
- Defined in:
- lib/capybara/node/simple.rb
#visible?(check_ancestors = true) ⇒ Boolean
Whether or not the element is visible. Does not support CSS, so the result may be inaccurate.
102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/capybara/node/simple.rb', line 102 def visible?(check_ancestors = true) return false if (tag_name == 'input') && (native[:type]=="hidden") if check_ancestors #check size because oldest supported nokogiri doesnt support xpath boolean() function native.xpath("./ancestor-or-self::*[contains(@style, 'display:none') or contains(@style, 'display: none') or @hidden or name()='script' or name()='head']").size() == 0 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 |