You can do this by adding chrome command line switches "--lang".
Basically, all you need to do is launch ChromeDriver using the ChromeOption argument --lang=es . See the API for details.
The following is a working C # code example for running Chrome in Spanish using Selenium.
ChromeOptions options = new ChromeOptions(); options.AddArguments("--lang=es"); ChromeDriver driver = new ChromeDriver(options);
Java code should be approximately the same (untested). Remember that the locale here is in the language of the form [-country], where the language is the 2-letter code from ISO-639.
public WebDriver getDriver(String locale){ System.setProperty("webdriver.chrome.driver", "driver/chromedriver.exe"); ChromeOptions options = new ChromeOptions(); options.addArguments("--lang=" + locale); return new ChromeDriver(options); } public void initializeSelenium() throws Exception{ driver = getDriver("es");
source share