Trouble modifying the language option in selenium python bindings
I think your syntax for setting the language is off. Instead of
chrome_options.add_argument("accept-language=en-US")
Try
chrome_options.add_experimental_option('prefs', {'intl.accept_languages': 'en,en_US'})
Second Round
Looks like english isn't available in 'intl.accept_languages'
yet. But after a little more searching I found the following might work--give it a try?
chrome_options.add_argument("--lang=en-US")
Third round
Try using --lang=en-GB as Fenio suggests:
chrome_options.add_argument("--lang=en-GB")
Not Working:
I've tried the --lang, but it didn't worked for me:
chrome_options.add_argument("--lang=en")
OR
chrome_options.add_argument("--lang=en-US")
Working Solution:
After some research I found that to solve this, we have to use the experimental option intl.accept_languages:
options = webdriver.ChromeOptions()
options.add_experimental_option('prefs', {'intl.accept_languages': 'en,en_US'})
driver = webdriver.Chrome(chrome_options=options)
Note: To use above, your website should need to support the same.
There is one more way to achieve the same by translating your native language page to english:
Try using below code:
prefs = {
"translate_whitelists": {"your native language":"en"},
"translate":{"enabled":"True"}
}
options.add_experimental_option("prefs", prefs)