Is it possible change browser language in firefox using selenium?

丶灬走出姿态 提交于 2019-12-10 14:24:10

问题


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.


回答1:


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



来源:https://stackoverflow.com/questions/50442811/is-it-possible-change-browser-language-in-firefox-using-selenium

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!