The following question and answer suggests various ways of suppressing the message "this type of file can harm your computer" but I am still having an issue with .vsd files ( microsoft visio )
How to disable 'This type of file can harm your computer' pop up
I have already tried all the solutions provided in the above link.
Map<String, Object> prefsMap = new HashMap<String, Object>();
prefsMap.put("profile.default_content_settings.popups", 0);
prefsMap.put("download.default_directory", fileDownloadPath);
prefsMap.put("plugins.always_open_pdf_externally", true);
prefsMap.put("safebrowsing.enabled", "true");
//assign driver properties
ChromeOptions option = new ChromeOptions();
option.setExperimentalOption("prefs", prefsMap);
option.addArguments("--test-type");
option.addArguments("--disable-extensions");
option.addArguments("--safebrowsing-disable-download-protection");
option.addArguments("--safebrowsing-disable-extension-blacklist");
WebDriver driver = new ChromeDriver(option);
Please guide me if I am missing something so that I could download .vsd files without displaying the warning message.
As suggested I tried the solution at the following URL
I have changed the code to download a vsd file from a public site
public class LocalDownloadTest {
public static void main(String[] args) throws InterruptedException
{
//Chrome driver and set download directory
System.setProperty("webdriver.chrome.driver", "C:\\chromedriver.exe");
String fileDownloadPath = "C:\\Users\\Public\\Downloads";
//String linkText = "default";
//Set properties to supress popups
Map<String, Object> prefsMap = new HashMap<String, Object>();
prefsMap.put("profile.default_content_settings.popups", 0);
prefsMap.put("download.default_directory", fileDownloadPath);
prefsMap.put("download.prompt_for_download", false);
prefsMap.put("download.extensions_to_open", "vsd");
prefsMap.put("download.extensions_to_open", "vsdx");
prefsMap.put("plugins.always_open_pdf_externally", true);
prefsMap.put("plugins.always_open_vsd_externally", true);
prefsMap.put("safebrowsing.enabled", "true");
//assign driver properties
ChromeOptions option = new ChromeOptions();
option.setExperimentalOption("prefs", prefsMap);
option.addArguments("--test-type");
option.addArguments("--disable-extensions");
option.addArguments("--safebrowsing-disable-download-protection");
option.addArguments("--safebrowsing-disable-extension-blacklist");
WebDriver driver = new ChromeDriver(option);
//download file from portal
driver.get("https://www.stakeholdermap.com/business-analysis/raise-purchase-order-flow-chart.html");
driver.manage().timeouts().implicitlyWait(4, TimeUnit.SECONDS);
driver.manage().window().maximize();
driver.findElement(By.xpath("//a[contains(@href, '.vsd')]")).click();
}
}
I am still getting the warning message. It has taken a lot of my time and effort for hit and trial but the problem hasn't been solved yet. Please advise some workaround for this.