Define download directory for chromedriver selenium with python

前端 未结 3 2012
[愿得一人]
[愿得一人] 2021-02-04 15:54

Everything is in the title!

Is there a way to define the download directory for selenium-chromedriver used with python?

In spite of many research, I haven\'t fou

3条回答
  •  长发绾君心
    2021-02-04 16:29

    For chromedriver1 create a new profile, and inside that profile set download.default_directory to the desired location, and set this profile for chrome using chrome.profile. The selenium-chromedriver package should have some methods for creating new profiles (at least it does with ruby), as they need some special handling.

    Chromedriver2 doesn't support setting the profile. You can set preferences with it. If you want to set the download directory this is how you do it:

    prefs: { download: { default_directory: "/tmp" } }
    

    The ruby selenium-webdriver doesn't support this feature yet, the python variant might do however.

提交回复
热议问题