0

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

How to download XML files avoiding the popup This type of file may harm your computer through ChromeDriver and Chrome using Selenium in Python

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.

Prem
  • 355
  • 2
  • 17
  • @DebanjanB this is not a duplicate entry. I have tried solutions posted on the link that you suggested and still having issues – Prem Sep 13 '19 at 10:49
  • Can you update the question with some demo links to download `vsd` files? – undetected Selenium Sep 13 '19 at 12:34
  • @DebanjanB I have added the working code to download a vsd file from some public site. I can still see the keep, discard dialogue while trying to download the file. – Prem Sep 16 '19 at 00:17
  • @DebanjanB can you please have a look at the working example in the question to download .vsd file. – Prem Sep 16 '19 at 23:19

0 Answers0