title: Selenium Python: Switch window and find element
body: <p>I am downloading an excel report from a URL. When I click excel download, a new window pops up with a 'in progress' message initially and followed by a 'completion' message.
  I want to close Chrome session after completing the download.
  I am using below code but somehow I am unable to locate element on new window. Kindly advise where am I wrong.
  (PS: I can't share URL)</p>
  <pre><code>    #Excel Download
      link = driver.find_elements_by_xpath(&quot;//img[@alt='Export to Excel']&quot;)[0]
      link.click()
      driver.switch_to_window
      time.sleep (5)
      element = WebDriverWait(driver, 60).until(EC.visibility_of_element_located((By.ID,&quot;_NS__workingMsg&quot;)))
      element = WebDriverWait(driver, 60).until(EC.presence_of_element_located((By.XPATH,&quot;//*[text()='Your report is ready and will download to your Web browser in a few moments.']&quot;)))
      time.sleep (2)
      driver.close()
  </code></pre>