title: How to save file automatically after a new window opens in Selenium
body: <p>I am currently generating reports on a website, and when i click the export link it opens a new window. The new window opens another window that asks if i want to open with excel or save file. </p>
  
  <p>I want it to save the file automatically to my given location.</p>
  
  <p>I was able to do this for other websites that do not open a new window to download.</p>
  
  <p><a href="https://i.stack.imgur.com/WB0fC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/WB0fC.png" alt=""></a></p>
  
  <p>after I click export to csv, the window with "your download is running.." pops up. Then the save or open window pops up.</p>
  
  <p>This is my current profile settings for my webdrive:</p>
  
  <pre><code>profile = webdriver.FirefoxProfile()
  profile.set_preference('browser.download.folderList', 2)
  profile.set_preference('browser.download.manager.showWhenStarting', False)
  profile.set_preference('browser.download.dir', os.getcwd())
  profile.set_preference('browser.helperApps.neverAsk.saveToDisk', 'text/csv/xls')
  </code></pre>
  
  <p>Thanks</p>