title: Error when scrolling in selenium with python
body: <p>I am trying to scroll to the bottom of the page, as I usually do. But on this website it seems not to work. It's one of those where you need to scroll to the bottom in order to load new links. </p>
  
  <p>This is the command I am using:</p>
  
  <pre class="lang-py prettyprint-override"><code>browser.execute_script("window.scrollTo(0, document.body.scrollHeight);")
  </code></pre>
  
  <p>The error I am getting is:</p>
  
  <pre class="lang-py prettyprint-override"><code>Traceback (most recent call last):
    File "/somePathTo/someProgram.py", line 12, in &lt;module&gt;
      browser.execute_script("window.scrollTo(0,document.body.scrollHeight);")
    File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 636, in execute_script
      'args': converted_args})['value']
    File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/selenium/webdriver/remote/webdriver.py", line 321, in execute
      self.error_handler.check_response(response)
    File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/selenium/webdriver/remote/errorhandler.py", line 242, in check_response
      raise exception_class(message, screen, stacktrace)
  selenium.common.exceptions.WebDriverException: Message: unknown error: Cannot read property 'offsetTop' of null
    (Session info: chrome=73.0.3683.86)
    (Driver info: chromedriver=72.0.3626.69 (3c16f8a135abc0d4da2dff33804db79b849a7c38),platform=Mac OS X 10.14.3 x86_64)
  </code></pre>
  
  <p>Any other scroll does not work as well, something is wrong with the JS script... 
  I don't know what element is null and therefore can't have the 'offsetTop' property... maybe I should identify some element that can have that property, but I don't know much more about JS than this script</p>
  
  <p>EDIT:
  I did solve my specific problem with this code</p>
  
  <pre class="lang-py prettyprint-override"><code>browser.execute_script('arguments[0].scrollIntoView(true);', target)
  </code></pre>
  
  <p>where target is an element to the bottom. However, I would like to know what the issue is with the JS code. </p>