selenium change language browser chrome / firefox
I have this java code please modify it in python
Using Firefox Browser :
FirefoxProfile profile = new FirefoxProfile();
//setting the locale french : ‘fr’
profile.setPreference(“intl.accept_languages”,”fr”);
driver = new FirefoxDriver(profile);
driver.get(“http://google.co.in);
Using Chrome Browser :
System.setProperty(“webdriver.chrome.driver”,”D:/DollarArchive/chromedriver.exe”);
ChromeOptions options = new ChromeOptions();
options.addArguments(“–lang= sl”);
ChromeDriver driver = new ChromeDriver(options);
driver.get(“http://google.co.in);
In python set something like below
For firefox
driver.set_preference(“intl.accept_languages”,”fr”)
For Chrome
options.add_argument(“–lang= sl”)
Hope it will help you :)
The answer is already available in one of the very recent post:
Change language on Firefox with Selenium Python
Here is the code:
def get_webdriver(attempts=3, timeout=60, locale='en-us'):
firefox_profile = webdriver.FirefoxProfile()
firefox_profile.set_preference("intl.accept_languages", locale)
firefox_profile.update_preferences()
desired_capabilities = getattr(
DesiredCapabilities, "FIREFOX").copy()
hub_url = urljoin('http://hub:4444', '/wd/hub')
driver = webdriver.Remote(
command_executor=hub_url, desired_capabilities=desired_capabilities,
browser_profile=firefox_profile)
return driver