WebDriverIO Selenium pass command line arguments i

2019-03-28 13:27发布

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

3条回答
太酷不给撩
2楼-- · 2019-03-28 14:00

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
            }
    }
}]
查看更多
疯言疯语
3楼-- · 2019-03-28 14:03

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.

查看更多
SAY GOODBYE
4楼-- · 2019-03-28 14:20

This ended up being the correct syntax, thanks Christian!

  capabilities: [{
        browserName: 'chrome',
        "chromeOptions": {
            args: ['--disable-web-security']
        }
    }]
查看更多
登录 后发表回答