Selenium Webdriver in Python - files download directory change in Chrome preferences

前端 未结 6 1593
逝去的感伤
逝去的感伤 2020-11-27 05:09

I\'m using Selenium Webdriver (in Python) to automate the downloading of thousands of files. I want to set Chrome\'s download folder programmatically. After reading this, I

6条回答
  •  感动是毒
    2020-11-27 05:24

    I think you also need

    "directory_upgrade": true
    

    Using the dictionary directly in a Chrome 'Prefrences' file, on a local windows install of chrome Version 28.0.1500.95 m, with the following download options:

       "download": {
          "default_directory": "C:\\Users\\rdub\\Desktop",
          "extensions_to_open": ""
       },
    

    I get the default location, versus the desktop. When I change it to this:

       "download": {
          "default_directory": "C:\\Users\\rdub\\Desktop",
          "directory_upgrade": true,
          "extensions_to_open": ""
       },
    

    I get the desktop location.

    Try the following:

    desired_caps = {'prefs': {'download': {'default_directory': '/Users/thiagomarzagao/Desktop/downloaded_files/', "directory_upgrade": true, "extensions_to_open": ""}}}
    

提交回复
热议问题