1

I am using Vaadin Testbench to implement test imulations. I have to check whether the Chrome Browsers language is English or German and based on that I have to set values either in English or German to simulate.

How to detect Chrome browser language when running the Integration test class? Based on the language detected I will set the language in the Chrome Driver parameters.

Manushi
  • 597
  • 1
  • 7
  • 26

1 Answers1

0

Using Vaadin TestBench, you can retrieve the language via a JavaScript call like so

String language = (String) executeScript(
                "let language = window.navigator.userLanguage || window.navigator.language;"
                + "return language");

Note also that rather than retrieving the language, it might be useful to set it explicitly yourself like so

ChromeOptions options = new ChromeOptions();
options.addArguments("--lang=es");
ChromeDriver driver = new ChromeDriver(options);
Tarek Oraby
  • 1,199
  • 6
  • 11