title: How to scroll a div when ajax is used to load data in python selenium
body: <p>I am working on python selenium with chrome webdriver in window 8. I faced a <a href="https://www.google.com/search?q=a1%20plumbing%20boise&amp;gws_rd=ssl#gws_rd=ssl&amp;lrd=0x54aeff4cb0b24461:0x23720b81e2bed658,1" rel="nofollow noreferrer">page</a> that loads data while scrolling using ajax.I tried injecting <a href="https://stackoverflow.com/questions/10503606/scroll-to-bottom-of-div-on-page-load-jquery/11551414#11551414">jquery</a> and the following links do not work for me.
   <a href="https://stackoverflow.com/questions/26189431/selenium-firefox-webdrive-using-python-scrolling-in-div">Link 1</a> <a href="https://stackoverflow.com/questions/21753130/scrolling-down-a-page-with-selenium-webdriver">Link 2</a> <a href="https://stackoverflow.com/questions/14583560/selenium-retrieve-data-that-loads-while-scrolling-down/14586679#14586679">Link 3</a></p>
  
  <p>Can any one give me a right path to follow.</p>
  
  <p>EDIT-------------</p>
  
  <p>This is my partial code after alecxe's answer</p>
  
  <pre><code>    nam = driver.find_element(By.CLASS_NAME ,'_wu')
  
      #get length of review
      revcnt = driver.find_element(By.XPATH ,"//span[@class='_Mnc _yz']")
      revcnt = int(revcnt.text.replace(" reviews","").strip())
      print revcnt
      # wait for reviews to appear
      wait = WebDriverWait(driver, 10)
      wait.until(EC.visibility_of_element_located((By.CSS_SELECTOR, "span.review-snippet")))
      #reviews=[]
      while True:
          reviews = driver.find_elements_by_css_selector("div._ju")
          if len(reviews)&lt;revcnt:
              driver.execute_script("arguments[0].scrollIntoView();", reviews[-1])
          else:
              driver.quit()
          print len(reviews)
  </code></pre>
  
  <p>But problem in escaping from while loop!</p>
  
  <p>I tried <a href="https://stackoverflow.com/questions/31371460/phantomjs-acts-differently-than-firefox-webdriver/31372604#31372604">it</a>.</p>