title: Selenium error message "selenium.webdriver has no attribute execute script"
body: <p>I am using selenium to scrape an infinite scrolling page.</p>
  
  <p>I am trying to use this code:</p>
  
  <pre><code>import time
  import pandas as np
  import numpy as np
  
  from selenium import webdriver
  from selenium.webdriver.common.keys import Keys
  from selenium.webdriver.common.by import By
  
  browser = webdriver.Chrome()
  url = 'https://twitter.com/search?f=tweets&amp;q=csubwaystats%20since%3A2018-05-28%20until%3A2018-08-28'
  
  browser.get(url)
  time.sleep(1)
  
  SCROLL_PAUSE_TIME = 0.5
  
  # Get scroll height
  last_height = webdriver.execute_script("return document.body.scrollHeight")
  
  while True:
      # Scroll down to bottom
      webdriver.execute_script("window.scrollTo(0,document.body.scrollHeight);")
  
      # Wait to load page
      time.sleep(SCROLL_PAUSE_TIME)
  
      # Calculate new scroll height and compare with last scroll height
      new_height = webdriver.execute_script("return document.body.scrollHeight")
      if new_height == last_height:
          break
      last_height = new_height
  </code></pre>
  
  <p>I obtained this code from multiple sources, the most recent being:</p>
  
  <p><a href="https://stackoverflow.com/questions/20986631/how-can-i-scroll-a-web-page-using-selenium-webdriver-in-python/47202073#47202073">How can I scroll a web page using selenium webdriver in python?</a></p>
  
  <p>I updated it to include "webdriver" instead of "driver" because I import selenium as webdriver. It doesn't work otherwise.</p>
  
  <p>My issue is that when I run the code I get:</p>
  
  <pre><code>AttributeError: module 'selenium.webdriver' has no attribute 'execute_script'
  </code></pre>
  
  <p>I don't really understand what this means and how to fix it? I haven't been able to find information on this.</p>
  
  <p>I am new to python and so am probably missing something obvious but any advice would be appreciated.</p>