title: Python selenium webdriver: list index out of range
body: <p>I have following code to scroll down a javascript enabled website. Problem is when the <code>newHeight</code> reaches around <code>229275</code> I get list out of range on the line              <code>browser.find_elements_by_class_name('alt')[0].click()</code>. But why I am getting this error and how can I solve this?</p>
  
  <p>My code:</p>
  
  <pre><code>browser = webdriver.PhantomJS("phantomjs")
      browser.get(url)
          while True:            
           time.sleep(pause)
           newHeight = browser.execute_script("return document.body.scrollHeight")
           print newHeight
           browser.find_elements_by_class_name('alt')[0].click()
  </code></pre>