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

可紊 提交于 2019-12-03 14:28:33

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

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

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

This ended up being the correct syntax, thanks Christian!

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

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'],
    },
  }]

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

capabilities: [{
    browserName: 'chrome',
    chromeOptions: {
            "args" : ["start-fullscreen"],
            "prefs" : {
                    'profile.managed_default_content_settings.javascript': 2
            }
    }
}]
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!