Home > Enterprise >  How can i set browser language in Selenide using Java?
How can i set browser language in Selenide using Java?

Time:02-18

Hello guys please how can i do it?When i run not headless mode browser is in english and everything works fine, but when i run headless mode language is changed to my native language.

I am using this for headless mode.

   Configuration.headless = true;

CodePudding user response:

Selenide Configuration class contains

public static MutableCapabilities browserCapabilities which used within the driver startup if provided.

For Chrome:

ChromeOptions options = new ChromeOptions()
    .setHeadless(true)
    .addArguments("--lang=en_US");
Configuration.browserCapabilities = options;

But note --lang argument might be ignored on Linux.

For Firefox:

FirefoxProfile profile = new FirefoxProfile();
profile.setPreference("intl.accept_languages", "en-US");
FirefoxOptions options = new FirefoxOptions()
    .setHeadless(true);
    .setProfile(profile);
Configuration.browserCapabilities = options;
  • Related