title: How to change the target directory for a screenshot using Selenium webdriver in Firefox or Chrome
body: <p>I want to make a screenshot of a webpage and save it in a <strong>custom location</strong> using <em>Selenium webdriver with Python</em>. I tried saving the screenshot to a custom location using both Firefox and Chrome but it always saves the screenshot in the project dir. Here is my Firefox version:</p>
  
  <pre><code>from selenium import webdriver
  from selenium.webdriver.firefox.firefox_binary import FirefoxBinary
  
  profile = webdriver.FirefoxProfile()
  profile.set_preference("browser.download.folderList", 2)
  profile.set_preference("browser.download.dir", 
  'C:\\Users\\User\\WebstormProjects')
  binary = FirefoxBinary("C:\\Program Files\\Mozilla Firefox\\firefox.exe")
  
  
  def foxScreen():
      driver = webdriver.Firefox(firefox_binary=binary, 
      firefox_profile=profile)
      driver.get("http://google.com")
      driver.save_screenshot("foxScreen.png")
      driver.quit()
  
  
  if __name__ == '__main__':
      foxScreen()
  </code></pre>
  
  <p>And here is my Chrome version:</p>
  
  <pre><code>from selenium import webdriver
  
  options = webdriver.ChromeOptions()
  prefs = {"download.default_directory": r'C:\\Users\\User\\WebstormProjects',
           "directory_upgrade": True}
  options.add_experimental_option("prefs", prefs)
  chromedriver = 
  "C:\\Users\\User\\Downloads\\chromedriver_win32\\chromedriver.exe"
  
  
  def chromeScreen():
      driver = webdriver.Chrome(chrome_options=options, 
                                executable_path=chromedriver)
      driver.get("http://google.com")
      driver.save_screenshot("chromeScreen.png")
      driver.quit()
  
  
  if __name__ == '__main__':
      chromeScreen()
  </code></pre>
  
  <p>I have tried different notations for the location I want the screenshot saved to but that does not seem to help. What should I change so it does not save the screenshot to the project directory but to a given custom location? </p>