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

后端 未结 8 1655
时光取名叫无心
时光取名叫无心 2020-11-27 20:43

I\'m using selenium chromedriver for automating web application. In my application, I need to download xml files. But when I download xml file, I get \'This type of file can

8条回答
  •  一生所求
    2020-11-27 21:36

    I am posting below the complete code that got file download working for me: Hope it helps :-) I am using Java-Selenium

    System.setProperty("webdriver.chrome.driver", "C:/chromedriver/chromedriver.exe");
            String downloadFilepath = "D:/MyDeskDownload";
            HashMap chromePrefs = new HashMap();
            chromePrefs.put("profile.default_content_settings.popups", 0);
            chromePrefs.put("download.default_directory", downloadFilepath);
            chromePrefs.put("safebrowsing.enabled", "true"); 
            ChromeOptions options = new ChromeOptions();
            options.setExperimentalOption("prefs", chromePrefs);
            DesiredCapabilities cap = DesiredCapabilities.chrome();
            cap.setCapability(CapabilityType.ACCEPT_SSL_CERTS, true);
            cap.setCapability(ChromeOptions.CAPABILITY, options);
            WebDriver driver = new ChromeDriver(cap);
    

提交回复
热议问题