selenium-chromedriverwebdriver-io

Parameter to pass in wdio.conf.ts to allow third party cookies


In my webdriverio automation, I am trying to start a chrome session which allows all cookies (refer the attached pic).

I tried my luck with the below capabilities in wdio.conf.ts.

    capabilities: [{

        // maxInstances can get overwritten per capability. So if you have an in-house Selenium
        // grid with only 5 firefox instances available you can make sure that not more than
        // 5 instances get started at a time.
        maxInstances: 5,
        browserName: 'chrome',
        acceptInsecureCerts: true,
        'goog:chromeOptions': {
            args: [
                'disable-blink-features=AutomationControlled',
                'incognito=false'
            ],
            prefs: {
                'profiles': {
                    clear_site_data_on_exit: true,
                    block_third_party_cookies: false
                }
            }
        }

But I don't see it working.

Is there anything that I am missing:

enter image description here


Solution

  • You need to set the pref object like this - I have given JSON values, and you can parse them into an object inside the prefs

    "profile.default_content_setting_values.cookies": 1
    "profile.block_third_party_cookies": false
    "network.cookie.cookieBehavior": 0
    

    here is what it should look like in Typescript or JavaScript.

    prefs: {
      profile: {
        default_content_setting_values: { cookies: 1 }, // Allow all cookies
        block_third_party_cookies: false
      },
      network: {
        cookie: {
          cookieBehavior: 0 // Allow all cookies
        }
      }
    }