title: Scrolling an ajax page completely using selenium webdriver
body: <p>I am trying to scroll a page completely using this code:</p>
  
  <pre><code>JavascriptExecutor js = (JavascriptExecutor) Browser;
  js.executeScript("javascript:window.onload=toBottom();"+
                                             "function toBottom(){" +"window.scrollTo(0,Math.max(document.documentElement.scrollHeight," +"document.body.scrollHeight,document.documentElement.clientHeight));" +"}");
  js.executeScript("window.status = 'fail';");
  
  //Attach the Ajax call back method
  js.executeScript( "$(document).ajaxComplete(function() {" + "status = 'success';});");
  js.executeScript("window.status = 'fail';");
  
  //Attach the Ajax call back method
  js.executeScript( "$(document).ajaxComplete(function() {" +"status = 'success';});");
  </code></pre>
  
  <p>This code works fine and scroll the page for the first attempt but when page is scrolled down, new data appears at the page and this code failed to scroll it again.
  So what I need is that someone will help me to scroll the page till end until scrolling is completed.</p>
  
  <p>Do I use any loop for this?</p>
  
  <p>Help/Suggestions/Response will be appreciated!</p>