title: Downloading file through Selenium Webdriver in python
body: <p>I am writing a program to automate web interaction through selenium webdriver in python. I got stuck in last step when I click on the "download" button through script, a window pop-up occours on the screen,with default option "Open with" selected. I want my program to first click on the option "save file" and then click on "OK". I have used following piece of code to set up Firefox profile </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',"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet")
  </code></pre>
  
  <p>One of my observation is that when the window popup is like this</p>
  
  <p><a href="https://i.stack.imgur.com/Jre5Z.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Jre5Z.png" alt="enter image description here"></a></p>
  
  <p>with option "Do this automatically for files like this from now on" is clickable (via checkbox) then the above piece of code works perfect, but when the same option is not clickable (as shown in the image below) then above code for setting profile fails.
  Can anyone help me in this situation?</p>
  
  <p><a href="https://i.stack.imgur.com/njB30.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/njB30.png" alt="enter image description here"></a></p>