title: Locating Lazy Load Elements While Scrolling in PhantomJS in Python
body: <p>I'm using python and Webdriver to scrape data from a page that dynamically loads content as the user scrolls down the page (lazy load). I have a total of 30 data elements, while only 15 are displayed without first scrolling down.</p>
  
  <p>I am locating my elements, and getting their values in the following way, after scrolling to the bottom of the page multiple times until each element has loaded:</p>
  
  <pre><code># Get All Data Items
  all_data = self.driver.find_elements_by_css_selector('div[some-attribute="some-attribute-value"]')
  
  # Iterate Through Each Item, Get Value
  data_value_list = []
  for d in all_data:
      # Get Value for Each Data item
      data_value = d.find_element_by_css_selector('div[class="target-class"]').get_attribute('target-attribute')
  
      #Save Data Value to List
      data_value_list.append(data_value)
  </code></pre>
  
  <p>When I execute the above code using ChromeDriver, while leaving the browser window up on my screen, I get all 30 data values to populate my <code>data_value_list</code>. When I execute the above code using ChromeDriver, with the window minimized, my list <code>data_value_list</code> is only populated with the initial 15 data values. </p>
  
  <p>The same issue occurs while using PhantomJS, limiting my <code>data_value_list</code> to only the initially-visible data values on the page. </p>
  
  <p>Is there away to load these types of elements while having the browser minimized and, ideally—while utilizing PhantomJS?</p>
  
  <p>NOTE: I'm using an action chain to scroll down using the following approach <code>.send_keys(Keys.PAGE_DOWN).perform()</code> for a calculated number of times.</p>