title: How can I force Selenium to run tests only after $(document).ready() has completed?
body: <p>Our site does a lot of JavaScript/jQuery work in the $(document).ready() function, setting up buttons, loading content via ajax, etc.  Selenium waits until the DOM is loaded, but then proceeds to test before .ready() has completed.</p>
  
  <p>A partial solution seems to be using a check to see if the browser has pending ajax requests:</p>
  
  <pre><code>selenium.browserbot.getCurrentWindow().jQuery.active == 0
  </code></pre>
  
  <p>However that doesn't ensure that we aren't still setting up bindings for buttons and things.</p>
  
  <p>Any help will be <strong>greatly</strong> appreciated.  The current 'best' suggestion is adding an element to the page at the end of the .ready() method, which Selenium can catch as a signal to start working, but the idea of adding code like this for testing purposes seems sketchy at best.</p>