Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible change browser language in firefox using selenium?

I want to launch firefox browser in a given language in selenium automation. Can I do that? If so, please share some sample code implementation.

Thanks in advance.

like image 217
pravin p Avatar asked Mar 07 '23 04:03

pravin p


1 Answers

Set the language code in fire fox profile preference before launch the the driver as shown below.

FirefoxProfile ffprofile = new FirefoxProfile();
//For japenese language
ffprofile.setPreference("intl.accept_languages","ja");
driver = new FirefoxDriver(ffprofile);
driver.get("https://www.google.com");

For language codes : https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes

like image 110
Vijendran Selvarajah Avatar answered May 02 '23 08:05

Vijendran Selvarajah