selenium change language browser chrome / firefox

后端 未结 4 1911
一个人的身影
一个人的身影 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:45

    I have this java code please modify it in python

    Using Firefox Browser :

    FirefoxProfile profile = new FirefoxProfile();
    //setting the locale french : ‘fr’
    profile.setPreference(“intl.accept_languages”,”fr”);
    driver = new FirefoxDriver(profile);
    driver.get(“http://google.co.in);
    

    Using Chrome Browser :

    System.setProperty(“webdriver.chrome.driver”,”D:/DollarArchive/chromedriver.exe”);
    ChromeOptions options = new ChromeOptions();
    options.addArguments(“–lang= sl”);
    ChromeDriver driver = new ChromeDriver(options);
    driver.get(“http://google.co.in);
    

    In python set something like below

    For firefox

    driver.set_preference(“intl.accept_languages”,”fr”)
    

    For Chrome

    options.add_argument(“–lang= sl”)
    

    Hope it will help you :)

提交回复
热议问题