selenium change language browser chrome / firefox

后端 未结 4 1915
一个人的身影
一个人的身影 2021-02-09 13:05

I\'m trying to test my website with selenium but I don\'t manage to change the language of the browser. I tried with firefox, changing the profile also but it\'s not working.

4条回答
  •  悲&欢浪女
    2021-02-09 13:59

    FIREFOX JAVA

    Java code for changing the language to English:

    FirefoxProfile profile = new FirefoxProfile();
    profile.setPreference("intl.accept_languages", "en-GB");
    FirefoxOptions options = new FirefoxOptions();
    options.setProfile(profile);
    driver = new FirefoxDriver(options);
    

    CHROME JAVA

    Java code for changing the language to English:

    ChromeOptions options = new ChromeOptions();
    options.addArguments("lang=en-GB");
    driver = new ChromeDriver(options);
    

    FIREFOX PYTHON

    options = Options()
    profile = webdriver.FirefoxProfile()
    profile.set_preference('intl.accept_languages', 'en-GB')
    browser = webdriver.Firefox(options=options,firefox_profile=profile)
    

提交回复
热议问题