是否可以使用Selenium更改Firefox中的浏览器语言? [英] Is it possible change browser language in firefox using selenium?
本文介绍了是否可以使用Selenium更改Firefox中的浏览器语言?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在硒自动化中以给定的语言启动firefox浏览器.我可以那样做吗?如果是这样,请分享一些示例代码实现.
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.
谢谢.
推荐答案
在启动驱动程序之前,请在firefox配置文件首选项中设置语言代码,如下所示.
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");
对于语言代码: https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes
这篇关于是否可以使用Selenium更改Firefox中的浏览器语言?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文