title: how to switch download directory using selenium / firefox / python?
body: <p>I know this question has been asked before...but I've tried multiple approaches and for some reason anything I download from the driver keeps going to my Downloads folder.</p>
  
  <p>Basically I navigate to a website and download something by clicking a download link like so:</p>
  
  <pre><code>result.click()
  </code></pre>
  
  <p>This downloads the file fine. But I want to download it to a specific directory. I've tried doing these approaches to change the download directory:</p>
  
  <pre><code>driver = webdriver.Firefox()
  profile = webdriver.FirefoxProfile()
  
  driver.command_executor._commands["SET_CONTEXT"] = ("POST", "/session/$sessionId/moz/context")
  driver.execute("SET_CONTEXT", {"context": "chrome"})
  driver.execute_script("""
    Services.prefs.setBoolPref('browser.download.useDownloadDir', true);
    Services.prefs.setStringPref('browser.download.dir', arguments[0]);
    """, directory)
  
  driver.execute("SET_CONTEXT", {"context": "content"})
  </code></pre>
  
  <p>and</p>
  
  <pre><code>profile.set_preference("browser.download.folderList", 2)
  profile.set_preference("browser.download.manager.showWhenStarting", False)
  profile.set_preference("browser.download.dir", directory)
  profile.set_preference("browser.helperApps.neverAsk.saveToDisk", "application/x-gzip")
  </code></pre>
  
  <p>Where <code>directory</code> is my desired location.</p>
  
  <p>Neither of these worked...can anyone explain why or show me how to actually achieve this?</p>
  
  <p>Thanks</p>