2

I need to uncheck "Ask where to save each file before downloading" Chrome setting via selenium:

enter image description here

I don't even know where to start since the documentation page doesn't contain the list of all available options. And, I haven't found the appropriate setting among chrome://flags/.

As far as I understand, I need to instantiate Chrome Options or Desired Capabilities, set a particular option/capability and pass the Chrome Options or Desired Capabilities instance to the ChromeDriver constructor.

Note that for Firefox the situation is different, there is an about:config page where you can easily find a setting and set it via Firefox Profile. Pretty straightforward.


I'm using python bindings, but it is not a requirement, the question is more or less generic.

alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195

1 Answers1

2

This was solved by inspecting the element source of this particular Chrome Setting: enter image description here

The inspected HTML for it:

<div class="checkbox">
    <span class="controlled-setting-with-label">
      <input id="prompt-for-download" type="checkbox" pref="download.prompt_for_download" metric="Options_AskForSaveLocation">
      <span>
        <label for="prompt-for-download" i18n-content="downloadLocationAskForSaveLocation">Ask where to save each file before downloading</label>
        <span class="bubble-button controlled-setting-indicator" pref="download.prompt_for_download">
        <div tabindex="0" role="button"></div></span>
      </span>
    </span>
</div>

As you can see, input element has pref="download.prompt_for_download" attribute. Eureka!


Now we can set the option, example using Python:

from selenium import webdriver

options = webdriver.ChromeOptions()
prefs = {'download.prompt_for_download': False}
options.add_experimental_option("prefs", prefs)

driver = webdriver.Chrome(chrome_options=options)
driver.get('http://stackoverflow.com')
alecxe
  • 462,703
  • 120
  • 1,088
  • 1,195