Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change browser language of webdriverio

I would like to change browser language. but it is not working. default browser language is displayed..

capabilities: [{
    browserName: 'chrome',
    chromeOptions: {
        args: ['--lang=ja']
    }
}],
like image 459
Tomo Avatar asked Jan 30 '17 07:01

Tomo


2 Answers

If anyone is still interested in making this work, the WebdriverIO implementation would be:

capabilities: [{
    browserName: 'chrome',
    'goog:chromeOptions': {
        args: [ '--your-args-go-here',
                '--like-so',
                '--and-so-and-so' 
                // e.g: '--headless', '--disable-gpu', '--start-fullscreen' 
        ],
        prefs: {
            'intl.accept_languages': 'ru,RU'
        }
    }
}]
  • For the full list of Chromium switches (args array values), click here.
  • For the full list of Chromium preferences (prefs object properties), click here.

Note: another useful resource (which is always up to date) for Chromium switches is Peter Beverloo's Chromium CLI Switches portal.

Using the above Chrome config in the wdio.conf.js & running an Instagram login test will successfully convert the locale of the page to Russian, as seen below:

enter image description here

like image 189
iamdanchiv Avatar answered Nov 18 '22 11:11

iamdanchiv


could you try this instead?

options = webdriver.ChromeOptions()
options.add_experimental_option('prefs', {'intl.accept_languages': 'en,en_US'})
driver = webdriver.Chrome(chrome_options=options)

check on webdriver io how to use add_experimental_option

like image 25
rodrigo rodrigues Avatar answered Nov 18 '22 11:11

rodrigo rodrigues