问题
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