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

Added a note about the XPath // confusion

This commit is contained in:
Jonas Nicklas 2010-07-10 17:15:57 +02:00
parent 970fd497a2
commit 6c5935cb0f

View file

@ -379,6 +379,20 @@ moving from Webrat and used CSS a lot, or simply generally prefer CSS:
find('ul li').text
locate('input#name').value
== Beware the XPath // trap
In XPath the expression // means something very specific, and it might not be what
you think. Contrary to common belief, // means "anywhere in the document" not "anywhere
in the current context". As an example:
page.find('//body').all('//script')
You might expect this to find all script tags in the body, but actually, it finds all
script tags in the entire document, not only those in the body! What you're looking
for is the .// expression which means "any descendant of the current node":
page.find('//body').all('.//script')
== Gotchas:
* Domain names (including subdomains) don't work under rack-test. Since it's a