Fix basics nodes

This commit is contained in:
Jonas Nicklas 2013-02-15 22:14:07 +01:00
parent 0303ed84c5
commit c6cd6acad3
2 changed files with 12 additions and 7 deletions

View File

@ -130,9 +130,10 @@ module Capybara
yield # simple nodes don't need to wait
end
def all(*args)
query = Capybara::Query.new(*args)
elements = native.xpath(query.xpath).map do |node|
private
def resolve_query(query, exact=nil)
elements = native.xpath(query.xpath(exact)).map do |node|
self.class.new(node)
end
Capybara::Result.new(elements, query)

View File

@ -10,7 +10,7 @@ describe Capybara do
<p>Yes it is</p>
</div>
<div id="footer" style="display: none">
<div id="footer">
<p>c2010</p>
<p>Jonas Nicklas</p>
<input type="text" name="foo" value="bar"/>
@ -20,6 +20,10 @@ describe Capybara do
</select>
</div>
<div id="hidden" style="display: none">
<p id="secret">Secret</p>
</div>
<section>
<div class="subsection"></div>
</section>
@ -56,8 +60,8 @@ describe Capybara do
end
it "allows finding only visible nodes" do
string.all('//p', :text => 'c2010', :visible => true).should be_empty
string.all('//p', :text => 'c2010', :visible => false).should have(1).element
string.all(:css, '#secret', :visible => true).should be_empty
string.all(:css, '#secret', :visible => false).should have(1).element
end
it "allows finding elements and extracting text from them" do
@ -83,7 +87,7 @@ describe Capybara do
it "allows finding elements and checking if they are visible" do
string.find('//h1').should be_visible
string.find('//input').should_not be_visible
string.find(:css, "#secret", :visible => false).should_not be_visible
end
end
end