I\'m trying to test my website with selenium but I don\'t manage to change the language of the browser. I tried with firefox, changing the profile also but it\'s not working.
This code apply to the simplest use case with browser running on local machine.
For Firefox:
from selenium import webdriver
browser_locale = 'fr'
gecko_driver_path = 'geckodriver64.exe'
profile = webdriver.FirefoxProfile()
profile.set_preference('intl.accept_languages', browser_locale)
browser = webdriver.Firefox(executable_path=gecko_driver_path,
firefox_profile=profile)
browser.get('https://google.com/')
For Chrome:
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
browser_locale = 'fr'
chrome_driver_path = 'chromedriver.exe'
options = Options()
options.add_argument("--lang={}".format(browser_locale))
browser = webdriver.Chrome(executable_path=chrome_driver_path,
chrome_options=options)
browser.get('https://google.com/')