I am having some problems setting the language of my chrome-browser to english when running Tests in my CI/CD-Pipeline. I use Selenium and TestNG for testing. Everytime I run my tests locally it works perfectly fine but when the Pipeline executes the tests, it always ends up failing the asserted value. This seems to be because the pipeline changes the browsers language to english instead of german.
I already tried the following code snippets to change the browsers language but none of them worked:
WebDriverManager.chromedriver().setup();
ChromeOptions options = new ChromeOptions();
options.setHeadless(headless); //headless is true
options.setExperimentalOption("prefs", Collections.singletonMap("intl.accept_languages", "de-DE"));
and
options.addArguments("--lang=de-DE")
and
options.addArguments("lang=de-DE")
and
options.addArguments("lang=de")
I tried literally every solution I found online. I think the problem might be the headless mode but I couldn't figure out how to solve it.