简体   繁体   English

如何使用Selenium WebDriver配置网页语言

[英]How to configure webpage language using selenium webdriver

I wanna set the web page language to international languages (eg: es ie spanish) , I tried below code : 我想将网页语言设置为国际语言(例如:es即西班牙文),我尝试了以下代码:

System.setProperty("webdriver.chrome.driver", "E://chromedriver.exe");
ChromeOptions options=new ChromeOptions();
options.addArguments("--lang=es");
ChromeDriver driver=new ChromeDriver(options);
driver.manage().window().maximize();
//driver.get("http://www.google.com");
driver.get("http://www.yahoo.com");
driver.close();

The above code is successfully translating only google. 上面的代码仅成功翻译了google。 Coming to other websites like yahoo, the page is remained in english and the chrome browser is translated in spanish. 进入诸如yahoo之类的其他网站,该页面仍为英文,而chrome浏览器则翻译为西班牙语。 I want to translate entire webpage as well. 我也想翻译整个网页。 Can anyone help me out please. 谁能帮帮我。

Thanks. 谢谢。

Try this. 尝试这个。 Maybe it would clear up things: How to change language on desired browser . 也许它可以解决一些问题: 如何在所需的浏览器上更改语言

Another useful tool is i18n-checker (to check is your language supported). 另一个有用的工具是i18n-checker (检查是否支持您的语言)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM