-1

Help me please. My windows is not english, but my chrome language is english. The problem is when i automate tests and selenium browser window is open, the language of my selenium window matches to my windows language but not to my chrome language.

For example: when selenium chrome window is shown and machine types values to the field with suggestion drop down menu. The listed items in the dropdown displayed in my windows language not english. How can i resolve this proble? Thanks!

Frebush
  • 1
  • 4

1 Answers1

0

ChromeOptions Provide a way to set the language preferences

Here is an example code in java:-

ChromeOptions opt = new ChromeOptions();
      //set language to Spanish
      opt.addArguments("−−lang=es");
      // configure options parameter to Chrome driver
      WebDriver driver = new ChromeDriver(opt);
      driver.manage().timeouts().implicitlyWait(8, TimeUnit.SECONDS);
      driver.get("https://www.google.com/ ");
Kumar Rishabh
  • 292
  • 1
  • 9
  • Hi, thank you for help. I set up it into my code but it does not work. This is my code. Did i something wrong? – Frebush Jan 03 '23 at 19:24
  • private static final ChromeOptions chromeOptions; static { initProperties(); chromeOptions = new ChromeOptions(); chromeOptions.addArguments("−−lang=en-us"); String options = properties.getProperty(PROP_CHROME_OPTIONS); if (options != null) { for (String argument : options.split(";")) { chromeOptions.addArguments(argument); } } WebDriverManager.chromedriver().setup(); } – Frebush Jan 03 '23 at 19:26
  • static Properties getProperties() { return properties; } static boolean isServerRun() { return System.getenv("CI_RUN") != null; } static WebDriver createDriver() { WebDriver driver = new ChromeDriver(chromeOptions); driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(10)); return driver; } – Frebush Jan 03 '23 at 19:26
  • can you try "−−lang=en-US" instead – Kumar Rishabh Jan 07 '23 at 18:12
  • Also, https://stackoverflow.com/questions/18645205/set-chromes-language-using-selenium-chromedriver says that there is a desiredCapabilities too which you can set. See if it helps. – Kumar Rishabh Jan 07 '23 at 18:16
  • 1
    --accept-lang=en-US. This helped me – Frebush Jan 21 '23 at 15:11