title: Selenium execute javascript only if DOM completely loaded
body: <p>I am trying get innerHeight, scrollHeight and scrollTop of a new page after user click the url, </p>
  
  <pre><code>driver.switch_to_window(driver.window_handles[-1]) # switch to newest window after user click some link
  WebDriverWait(driver, 20).until(EC.presence_of_element_located((By.TAG_NAME, 'body')))
  
  documentElement = driver.execute_script("return document.documentElement.scrollTop")
  innerHeight = driver.execute_script("return window.innerHeight")
  pageHeight = driver.execute_script("return document.body.scrollHeight")
  </code></pre>
  
  <p>However, These script return wrong value because it executed before the new page is completely loaded. How can I get the correct values?</p>