stack: OpenJDK Zulu21.40+17-CA (build 21.0.6+7-LTS), Google Chrome 134.0.6998.117 (stable), Gradle, Junit5, Fedora 41 (the same thing happened on windows 11)
the problem: I am writing autotests for an http site, and before the current chrome version, I could not, for example, download images due to a warning from the chrome security system due to the fact that my site, I think, is on http, not https. I tried to find a solution for this problem, but after trying it out:
public ChromeOptions getChromeOptions() {
ChromeOptions options = new ChromeOptions();
options.addArguments("--disable-safe-browsing-api");
options.addArguments("--safebrowsing-disable-download-protection");
String projectPath = System.getProperty("user.dir");
String downloadFilepath = projectPath + "\\downloads";
HashMap<String, Object> chromePrefs = new HashMap<>();
chromePrefs.put("profile.default_content_settings.popups", 0);
chromePrefs.put("download.default_directory", downloadFilepath);
chromePrefs.put("safebrowsing.enabled", "false");
chromePrefs.put("download.prompt_for_download", "false");
options.setExperimentalOption("prefs", chromePrefs);
return options;
}
this is how my browser initialization goes:
public void initDriver() {
if (driver == null) {
ChromeOptions options = getChromeOptions();
driver = new ChromeDriver(options);
properties();
}
}
with all these attempts, I can't get around the chrome protection, which would allow me to work with the http site fully. Now, with a recent update, they have completely closed access to non-https sites with a security system. here is what is displayed in the window when launching the autotest:
Secure connection is not supported for the abracadabra website Hackers can intercept and change the information that you exchange with this site.We recommend visiting this page later if you are connected to a public network. It is safest to use a reliable Wi-Fi network, such as a home or work network.You can also suggest that the website owner switch to HTTPS. Read more about this warning… Go to the website (button) Back (button)
I need a solution not in the format - we advise you to upgrade to an older version of chrome or generally to another browser, but in the context of the current stack. Maybe there are some other chrome options options that I'm not aware of.
Due to security reasons, in latest versions of chrome direct downloads is disabled. When download happens it gives a warning to keep the files, one can't select/interact with that keep option from the popup using chrome driver.
For bypassing the same you need this chrome option to be set while creating driver
String insecureURLPath = "PROVIDE_APPLICATION_ROOT_URL"
options.addArguments("--unsafely-treat-insecure-origin-as-secure=" + insecureURLPath);
Note: URL provided here can be different from you main application URL depending on your application.
In your case you can remove the 2 options you are using.