WebDriverIO Selenium passes command line arguments to Chrome from config.js file

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

capabilities: [{ browserName: 'chrome' }] 
+6
source share
4 answers

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

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

Refer to the chromedriver docs for more information on the chromeOptions object.

+11
source

In the end, it was the correct syntax, thanks to Christian!

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

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

I did some research and passed goog:chromeOptions work:

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

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

 capabilities: [{ browserName: 'chrome', chromeOptions: { "args" : ["start-fullscreen"], "prefs" : { 'profile.managed_default_content_settings.javascript': 2 } } }] 
0
source

Source: https://habr.com/ru/post/1232102/


All Articles