title: selenium to scroll to top of page
body: <p>I am trying to scroll Up in a whats app conversation so I record the entire chat (into csv).</p>
  
  <pre><code>chrome_options = Options()
  chrome_options.add_argument("--user-data-dir=chrome-data") #saves login 
  driver = webdriver.Chrome(chrome_options=chrome_options)
  driver.get('https://web.whatsapp.com/')
  #choose converstaion
  #scroll to top not working
  </code></pre>
  
  <p>Here is what I tried but it didn't work, Ideally I will run headless so I prefer not to use <code>pyautogui</code> </p>
  
  <pre><code>def scroll_to_top():
      driver.execute_script("window.scrollTo(0, -document.body.scrollHeight);")
      time.sleep(4)
  
  #driver.execute_script("window.scrollTo(0, 0);")
  #bd = driver.find_element_by_xpath('//body')
  #bd.click()
  #bd.send_keys(Keys.CONTROL+Keys.HOME) #throws element not interact-able
  </code></pre>
  
  <p>Any help is appreciated </p>