Java 如何使用Selenium ChromeDriver翻译网页语言
当我运行脚本时,网页以土耳其语打开。我想转换为英语,尝试了下面使用chrome选项的代码,但它正在将浏览器语言设置为英语而不是网页语言。请帮助Java 如何使用Selenium ChromeDriver翻译网页语言,java,selenium,automated-tests,Java,Selenium,Automated Tests,当我运行脚本时,网页以土耳其语打开。我想转换为英语,尝试了下面使用chrome选项的代码,但它正在将浏览器语言设置为英语而不是网页语言。请帮助 static DesiredCapabilities setChromeCapabilities() { Map<String, Object> prefs = new HashMap<String, Object>(); prefs.put("profile.default_content_set
static DesiredCapabilities setChromeCapabilities()
{
Map<String, Object> prefs = new HashMap<String, Object>();
prefs.put("profile.default_content_settings.popups", 1);
prefs.put("download.default_directory", "C:\\dev\\tmpReport");
ChromeOptions options = new ChromeOptions();
options.setExperimentalOption("prefs", prefs);
options.addArguments("chrome.switches","--disable-extensions");
options.addArguments("--start-maximized");
options.addArguments("--lang=en"); **//tried adding this line of code**
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
capabilities.setCapability(ChromeOptions.CAPABILITY,options);
return capabilities;
}
static desireedcapabilities setchromecabilities()
{
Map prefs=新的HashMap();
prefs.put(“profile.default\u content\u settings.popups”,1);
prefs.put(“下载.默认目录”,“C:\\dev\\tmpReport”);
ChromeOptions选项=新的ChromeOptions();
选项。设置实验选项(“prefs”,prefs);
options.addArguments(“chrome.switches”,“--禁用扩展”);
options.addArguments(“--start maximized”);
options.addArguments(“--lang=en”);**//尝试添加这行代码**
DesiredCapabilities=DesiredCapabilities.chrome();
能力。设置能力(色度选项。能力,选项);
返回能力;
}