How can I disable Chrome experimental option same-site-by-default-cookies in Java Selenium?

Jason Law :

I want to disable Chrome experimental option same-site-by-default-cookies and cookies-without-same-site-must-be-secure.

From How to set Chrome experimental option same-site-by-default-cookie in python selenium - Stack Overflow, I know how I can enable, but what should I do if I want to disable?

Rahul L :

You can disable by using same-site-by-default-cookies@2 & cookies-without-same-site-must-be-secure@2. Tested on Version 80.0.3987.122 (Official Build) (64-bit)

ChromeOptions options = new ChromeOptions();
HashMap<String, Object> chromeLocalStatePrefs = new HashMap<String, Object>();
List<String> experimentalFlags = new ArrayList<String>();
experimentalFlags.add("same-site-by-default-cookies@2");
experimentalFlags.add("cookies-without-same-site-must-be-secure@2");
chromeLocalStatePrefs.put("browser.enabled_labs_experiments", experimentalFlags);
options.setExperimentalOption("localState", chromeLocalStatePrefs);

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=25342&siteId=1