inputs of type hidden should not be visisble

This commit is contained in:
Thomas Walpole 2016-03-04 11:30:51 -08:00
parent 1abfda0ac1
commit 1ed280591f
3 changed files with 4 additions and 0 deletions

View File

@ -99,6 +99,8 @@ module Capybara
# @return [Boolean] Whether the element is visible
#
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

View File

@ -177,6 +177,7 @@ Capybara::SpecHelper.spec "node" do
expect(@session.find('//div[@id="hidden_via_ancestor"]')).not_to be_visible
expect(@session.find('//div[@id="hidden_attr"]')).not_to be_visible
expect(@session.find('//a[@id="hidden_attr_via_ancestor"]')).not_to be_visible
expect(@session.find('//input[@id="hidden_input"]')).not_to be_visible
end
it "should be boolean" do

View File

@ -109,6 +109,7 @@ banana</textarea>
</div>
<input type="text" disabled="disabled" name="disabled_text" value="This is disabled"/>
<input type="hidden" id="hidden_input" name="hidden_input" value="This is a hidden input"/>
<div>
<a id="link_placeholder">No href</a>