I am trying to use Selenium with Java with update chrome version 86 for automation, but it shows third-party cookies disable. The site I am working on needs 3rd party cookies.
I tries to enable cookies using following code:
ChromeOptions options = new ChromeOptions();
options.addArguments("incognito");
options.addArguments("start-maximized");
// options.addArguments("disable-infobars");
options.addArguments("ignore-certificate-errors");
options.addArguments("disable-popup-blocking");
options.addArguments("disable-extensions");
options.addArguments("disable-notifications");
options.addArguments("no-sandbox");
options.addArguments("allow-running-insecure-content");
options.setAcceptInsecureCerts(true);
options.setExperimentalOption("excludeSwitches", Collections.singletonList("enable-automation"));
HashMap<String, Object> prefs = new HashMap<String, Object>();
prefs.put("profile.default_content_settings.cookies", 0);
options.setExperimentalOption("prefs", prefs);
Boolean headless = Boolean.valueOf(ApplicationProperties.getInstance().getProperty("headless"));
if (Boolean.TRUE.equals(headless)) {
options.addArguments("headless");
options.addArguments("window-size=1600x1200");
}
options.setCapability(ChromeOptions.CAPABILITY, options);
options.setCapability(CapabilityType.UNEXPECTED_ALERT_BEHAVIOUR,
UnexpectedAlertBehaviour.IGNORE);````
Not enabling cookies. Guide me what to do?
Code in Kotlin the looks like