0

I want to be able to test with different languages. How can I do that with chromedriver ?

1

You can do this by adding Chrome's command line switches "--lang".

You start ChromeDriver with an ChromeOption argument, e.g. --lang=es

C# code for how to start Chrome in Spanish using Selenium:

ChromeOptions options = new ChromeOptions();
options.AddArguments("--lang=es");
ChromeDriver driver = new ChromeDriver(options);

Java:

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"); // two letters to represent the locale, or two letters + country
}
| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.