title: Why can't Selenium find dynamically added DOM elements?
body: <p>I added a DOM element (a link) with jQuery.  I can see the element in Firebug, but for some reason Selenium can't find it.  What is going on here?</p>
  
  <p>Note: there is no AJAX involved, so the DOM element is added almost immediately.</p>
  
  <p>== EDIT ==</p>
  
  <p>Here's some code (using jQuery) that appends a link to the end of the document:</p>
  
  <pre><code>$element = $("&lt;a id="foo" href="#"&gt;&lt;/a&gt;");
  $element.appendTo($("body"));
  </code></pre>
  
  <p>I'm using Capybara (with Selenium) to find the link and click it, like so:</p>
  
  <pre><code>find("#foo").click
  </code></pre>
  
  <p>I was having no problems with Capybara or Selenium until I started adding elements to the DOM with jQuery.</p>