0

I am using Selenium chrome driver to automate download of xml file. But somehow the download is prompting "this type of file can harm your computer.Do you want to keep the file anyway?" How can i remove this prompt. Below is the chrome option parameter i am using.

$ChromeOptions = New-Object OpenQA.Selenium.Chrome.ChromeOptions
$ChromeOptions.AddArguments(@(
    "--disable-extensions",
    "--safebrowsing-disable-download-protection",
    "--safebrowsing-disable-extension-blacklist",
    "--disable-download-protection",
    "--disable-notifications",
    "--ignore-certificate-errors"))
$ChromeDriver = New-Object OpenQA.Selenium.Chrome.ChromeDriver($chromeOptions)
$ChromeDriver.Navigate().GoToURL($YourURL)

Most of the site do not provide powershell version of the code but Python code is available

[Link] How to disable 'This type of file can harm your computer' pop up

Enigma
  • 123
  • 1
  • 13
  • Why are you using Selenium to download, vs directly using the Invoke-* or .Net WQebClient to download directly, thus not needing to use a browser? [3 ways to download files with PowerShell](https://blog.jourdant.me/post/3-ways-to-download-files-with-powershell) – postanote May 05 '20 at 23:55
  • I use ```$link = $ChromeDriver.FindElementByXPath("//*[@id='i80c4de72-e9ad-4ae5-a890-1e1ccf75033d']/div[1]/span[2]")``` to get the link details from the webpage and then ```$link.click()``` to download the .xml file. It works fine except asking for download confirmation. – Enigma May 06 '20 at 07:57
  • Is this an internal or external site? If external what is the URL, and does it require auth? – postanote May 06 '20 at 20:44
  • Its an internal site and no authentication required. I am using Google Version 80.0.3987.122 (Official Build) (32-bit) and ChromeDriver 80.0.3987.106. Interesting to know that if i initiate the same download from chrome browser, the .xml file gets downloaded without asking for confirmation. that means there is some option parameter in chrome driver i need to disable. Any help will be much appreciated. – Enigma May 07 '20 at 22:16

0 Answers0