7

I need chrome to run with disable-web-security flag for my UI tests. How can I inject any commands using wdio.config file (http://webdriver.io/).

  capabilities: [{
        browserName: 'chrome'
    }]
ChristianB
  • 1,925
  • 13
  • 25
Michal
  • 275
  • 3
  • 11

4 Answers4

13

You can set any chrome flags within the desired capabilities using goog:chromeOptions

capabilities: [{
    browserName: 'chrome',
    'goog:chromeOptions': {
        args: ['disable-web-security']
    }
}]

Check out the chromedriver docs for more information on the chromeOptions object.

vipulgupta2048
  • 99
  • 3
  • 13
ChristianB
  • 1,925
  • 13
  • 25
6

This ended up being the correct syntax, thanks Christian!

  capabilities: [{
        browserName: 'chrome',
         'goog:chromeOptions': {
            args: ['--disable-web-security']
        }
    }]
vipulgupta2048
  • 99
  • 3
  • 13
Michal
  • 275
  • 3
  • 11
5

Something has been changed because in @wdio/cli version 5.11.13 and chromedriver version 76.0.0 I cannot pass parameter chromeOptions - result: invalid argument: unrecognized capability: chromeOptions.

I did some research and passing goog:chromeOptions works:

  capabilities: [{
    browserName: 'chrome',
    'goog:chromeOptions': {
      args: ['--disable-web-security'],
    },
  }]
pawelbylina
  • 1,039
  • 7
  • 11
0

If you want to disable javascript in the browser using webdriverio, in your wdio.config you'll need

capabilities: [{
    browserName: 'chrome',
     'goog:chromeOptions': {
            "args" : ["start-fullscreen"],
            "prefs" : {
                    'profile.managed_default_content_settings.javascript': 2
            }
    }
}]
vipulgupta2048
  • 99
  • 3
  • 13
Joviano Dias
  • 724
  • 7
  • 11