Selenium Download Keep and Discard Problem cer or xml extensions

0 votes

I am working with Selenium and javaJava.ı have a problem with downloading something from the software I am working on. Chrome asks me the security question in order to download (Keep or Discard) So I did try a few methods to get rid of this problem in chrome but I couldn't find a solution and this is important for me to continue to develop automation, that's why I wanted to ask if You know a solution to this issue. I download the XML file or cer file, I get a 'This type of file can harm your computer' pop up. I want to disable this pop up using selenium chromedriver and I want these types of files to be downloaded always. How can this be done? Chrome version:80.0 Selenium version: 3.8.1 Chromedriver version: 2.42, I found these codes but cap object in DesiredCapabilities doesn't work with Chromedriver anymore;

HashMap<String, Object> chromePrefs = new HashMap<String, Object>();
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); //this driver doesnt work anymore 
Also If I try without Capability object, I get to download cer extension file but I get "Failed -Download Error " failure.If I dont write default directory for the download , then CHROME again ask me the Keep/Discard Security question. I need to solve this problem since without dowloaded object I cant go on the other tests.I hope to get a reply from you. Thank you.

Jan 6, 2021 in Software Testing by Merve

edited Mar 4, 2025 712 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP