1
0
Fork 0
mirror of https://github.com/teamcapybara/capybara.git synced 2022-11-09 12:08:07 -05:00

Node#visible?

This commit is contained in:
Lenny Marks 2009-12-22 15:13:55 -05:00
parent 4c29fd9581
commit 42c97832ce
6 changed files with 29 additions and 1 deletions

View file

@ -36,6 +36,10 @@ class Capybara::Driver::Celerity < Capybara::Driver::Base
# there has to be something better... # there has to be something better...
node.to_xml[/^\s*<([a-z0-9\-\:]+)/, 1] node.to_xml[/^\s*<([a-z0-9\-\:]+)/, 1]
end end
def visible?
node.visible?
end
end end
attr_reader :app, :rack_server attr_reader :app, :rack_server

View file

@ -47,6 +47,10 @@ class Capybara::Driver::RackTest < Capybara::Driver::Base
node.node_name node.node_name
end end
def visible?
node.xpath("./ancestor-or-self::*[contains(@style, 'display:none')]").size == 0
end
private private
def type def type

View file

@ -43,6 +43,10 @@ class Capybara::Driver::Selenium < Capybara::Driver::Base
node.tag_name node.tag_name
end end
def visible?
node.displayed?
end
private private
def type def type

View file

@ -37,4 +37,8 @@ class Capybara::Node
def tag_name def tag_name
raise "Not implemented" raise "Not implemented"
end end
def visible?
raise "Not implemented"
end
end end

View file

@ -62,6 +62,14 @@ shared_examples_for 'driver' do
@driver.find('//a')[1].tag_name.should == 'a' @driver.find('//a')[1].tag_name.should == 'a'
@driver.find('//p')[1].tag_name.should == 'p' @driver.find('//p')[1].tag_name.should == 'p'
end end
it "should extract node visibility" do
@driver.find('//a')[0].should be_visible
@driver.find('//*[@id="hidden"]')[0].should_not be_visible
@driver.find('//*[@id="hidden_via_ancestor"]')[0].should_not be_visible
end
end end
end end

View file

@ -17,3 +17,7 @@
<p> <p>
<input type="text" id="test_field" value="monkey"/> <input type="text" id="test_field" value="monkey"/>
</p> </p>
<div id="hidden" style="display:none;">
<div id="hidden_via_ancestor">Inside element with hidden ancestor</div>
</div>