0

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?

Jason Law
  • 965
  • 1
  • 9
  • 21

3 Answers3

5

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();
Map<String, Object> chromeLocalStatePrefs = new HashMap<>();
List<String> experimentalFlags = new ArrayList<>();
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);
ymajoros
  • 2,454
  • 3
  • 34
  • 60
Rahul L
  • 4,249
  • 15
  • 18
3

In case someone needs to implement it in C#:

var chromeOptions = new ChromeOptions();
var experimentalFlags = new List<string>();
experimentalFlags.Add("same-site-by-default-cookies@2");
experimentalFlags.Add("cookies-without-same-site-must-be-secure@2");
chromeOptions.AddLocalStatePreference("browser.enabled_labs_experiments", 
    experimentalFlags);
Vlad Setchin
  • 121
  • 1
  • 5
1

Modified above for Ruby + capybara as below

options = Selenium::WebDriver::Chrome::Options.new(
    args:
      [
        "disable-dev-shm-usage",
        "disable-infobars",
        "disable-notifications",
        "disable-plugins",
        "disable-save-password-bubble",
        "enable-automation",
        "no-sandbox",
        "start-maximized",
        "window-size=1024,768"
      ],
    options: {"localState" => { "browser.enabled_labs_experiments" => ['same-site-by-default-cookies@2','cookies-without-same-site-must-be-secure@2'] }}
  )
Prashant Kajale
  • 473
  • 4
  • 8