How to change chrome browser language in selenium automation

限于喜欢 提交于 2019-12-19 04:03:14

问题


I want to automate localization functions of a web application. According to my application when the browser language changes, application language should change automatically according to the browser language. How to do that?


回答1:


Set the language code in chrome options before launching the the driver as shown below.

System.setProperty("webdriver.chrome.driver","<PATH>/chromedriver.exe");
ChromeOptions chromeoptions = new ChromeOptions();
// for japanese language
chromeoptions.addArguments("–lang= ja");
ChromeDriver driver = new ChromeDriver(chromeoptions);
driver.get("https://www.google.com");

For language codes : https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes



来源:https://stackoverflow.com/questions/50433931/how-to-change-chrome-browser-language-in-selenium-automation

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