ReverseEngineer
ReverseEngineer

Reputation: 559

ChromeOption '--safebrowsing-disable-download-protection' doesn't disables the download warning in Chrome version 67.x

I am trying to use Selenium webdriver to automate some of the work. My automation includes downloading some .msg outlook email file from the web attached by somebody else. Downloading the .msg file prompted a warning from Chrome saying "This type of file can harm the computer...". Using the ChromeOptions to add argument --safebrowsing-disable-download-protection does not work, the download still prompted the warning with the argument added into the chrome options, any help will be appreciated.

Code trial:

from selenium import webdriver
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--safebrowsing-disable-download-protection')
driver = webdriver.Chrome(chrome_options=chrome_options)

printing the chrome_options.arguments shows that the '--safebrowsing-disable-download-protection' is added into the arguments, but when I started to download the .msg files using Selenium, I still receive the same warning.

Something to note, when i manually run chrome.exe via cmd using the '--safebrowsing-disable-download-protection', downloading without warning works.

Upvotes: 7

Views: 17700

Answers (3)

lglowka
lglowka

Reputation: 21

This should work

    driver = webdriver.Chrome(chromeDriver, options=options)
    params = {'behavior' : 'allow', 'downloadPath':r"C:\Users\downloads"}
    driver.execute_cdp_cmd('Page.setDownloadBehavior', params)

Upvotes: 2

Andrei
Andrei

Reputation: 5637

You can try this:

from selenium import webdriver
from selenium.webdriver.chrome.options import Options

chrome_options = Options()
chrome_options.add_experimental_option("prefs", {
  "download.default_directory": r"C:\Users\downloads",
  "download.prompt_for_download": False,
  "download.directory_upgrade": True,
  "safebrowsing.enabled": False
})

driver = webdriver.Chrome(chrome_options=chrome_options)

Upvotes: 1

undetected Selenium
undetected Selenium

Reputation: 193088

As per your code trials as you are trying to implement --safebrowsing-disable-download-protection through ChromeOptions() but it is worth to mention the following points:

Conclusion

As per the points mentioned above the ChromeOption --safebrowsing-disable-download-protection is no more an effective/valid ChromeOption and should be handled by PVer4 by default for desktop platforms.

Upvotes: 1

Related Questions