是否可以使用selenium在Firefox中更改浏览器语言?

pra*_*n p 5 selenium selenium-firefoxdriver selenium-webdriver

我想在selenium自动化中以给定语言启动firefox浏览器.我能这样做吗?如果是这样,请分享一些示例代码实现.

提前致谢.

Vij*_*jah 7

在启动驱动程序之前,在fire fox配置文件首选项中设置语言代码,如下所示.

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

语言代码:https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes

  • 请参阅此/sf/ask/3530375201/以进行chrome浏览器更改 (3认同)