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...
node.to_xml[/^\s*<([a-z0-9\-\:]+)/, 1]
end
def visible?
node.visible?
end
end
attr_reader :app, :rack_server

View File

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

View File

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

View File

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

View File

@ -62,6 +62,14 @@ shared_examples_for 'driver' do
@driver.find('//a')[1].tag_name.should == 'a'
@driver.find('//p')[1].tag_name.should == 'p'
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

View File

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