Permalink
Browse files

Explain the difference between find and locate

  • Loading branch information...
1 parent 0768599 commit 322ecd31b671a6e34a0631a8512a5730bc33dd8b @jnicklas committed Jul 10, 2010
Showing with 7 additions and 0 deletions.
  1. +7 −0 README.rdoc
View
7 README.rdoc
@@ -130,7 +130,9 @@ The {capybara-envjs driver}[http://github.com/smparkes/capybara-envjs]
uses the envjs gem ({GitHub}[http://github.com/smparkes/env-js],
{rubygems.org}[http://rubygems.org/gems/envjs]) to interpret
JavaScript outside the browser. The driver is installed by installing the capybara-envjs gem:
+
gem install capybara-envjs
+
More info about the driver and env.js are available through the links above. The envjs gem only supports
Ruby 1.8.7 at this time.
@@ -252,6 +254,11 @@ You can also find specific elements, in order to manipulate them:
locate("//*[@id='overlay'").find("//h1").click
all('a').each { |a| a[:href] }
+Note that there's a difference between <tt>locate</tt> and <tt>find</tt>. <tt>locate</tt>
+will wait for an element to appear on the page, as explained in the AJAX section. If the element
+does not appear it will raise an error. <tt>find</tt> will check if the element is there and
+immediately return nil if it is not.
+
=== Scripting
In drivers which support it, you can easily execute JavaScript:

0 comments on commit 322ecd3

Please sign in to comment.