class Capybara::Node::Simple

def visible?(check_ancestors = true)

Returns:
  • (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
    !find_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