Tomo
Tomo

Reputation: 51

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

Upvotes: 5

Views: 3612

Answers (2)

iamdanchiv
iamdanchiv

Reputation: 4112

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

Upvotes: 5

rodrigo rodrigues
rodrigo rodrigues

Reputation: 21

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

Upvotes: 1

Related Questions