Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WebDriverIO Selenium pass command line arguments into Chrome from config.js file

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'
    }]
like image 573
Michal Avatar asked Sep 23 '15 13:09

Michal


3 Answers

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.

like image 109
ChristianB Avatar answered Oct 21 '22 09:10

ChristianB


This ended up being the correct syntax, thanks Christian!

  capabilities: [{
        browserName: 'chrome',
         'goog:chromeOptions': {
            args: ['--disable-web-security']
        }
    }]
like image 7
Michal Avatar answered Oct 21 '22 08:10

Michal


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'],
    },
  }]
like image 5
pawelbylina Avatar answered Oct 21 '22 09:10

pawelbylina