mirror of
https://github.com/teamcapybara/capybara.git
synced 2022-11-09 12:08:07 -05:00
Node#visible?
This commit is contained in:
parent
4c29fd9581
commit
42c97832ce
6 changed files with 29 additions and 1 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -42,6 +42,10 @@ class Capybara::Driver::Selenium < Capybara::Driver::Base
|
|||
def tag_name
|
||||
node.tag_name
|
||||
end
|
||||
|
||||
def visible?
|
||||
node.displayed?
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
|
|
|
@ -37,4 +37,8 @@ class Capybara::Node
|
|||
def tag_name
|
||||
raise "Not implemented"
|
||||
end
|
||||
|
||||
def visible?
|
||||
raise "Not implemented"
|
||||
end
|
||||
end
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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>
|
Loading…
Reference in a new issue