0

I am trying to export data from excel in an application which exports XML file as default. When I click the export button it opens a new chrome window & it has a warning message "This file can harm your computer" with options Keep Or Discard. I want XML files to be downloaded automatically without this prompt. How can I achieve this?

1 Answers1

0

It can be controlled via chromeoptions.

--safebrowsing-disable-download-protection

In Java,

ChromeOptions options = new ChromeOptions();
options.addArguments("--safebrowsing-disable-download-protection");
ChromeDriver driver = new ChromeDriver(options);

Check here for more info.

https://peter.sh/experiments/chromium-command-line-switches/

vins
  • 15,030
  • 3
  • 36
  • 47
  • This did not work. I still see the warning message. I also tried driver.SwitchTo().Window(driver.WindowHandles[1]); Actions act = new Actions(driver); act.SendKeys(Keys.Tab).Perform(); act.SendKeys(driver.FindElement(By.XPath("//body")),Keys.Enter).Perform(); – Sanket Thotange Jun 30 '18 at 14:10
  • Hi @vins using options.AddUserProfilePreference("safebrowsing.enabled","false"); did the trick. Thanks for the heads up. – Sanket Thotange Jun 30 '18 at 14:36