【问题标题】:How to change chrome browser language in selenium automation如何在 selenium 自动化中更改 chrome 浏览器语言
【发布时间】:2018-10-30 05:30:56
【问题描述】:

我想自动化 Web 应用程序的本地化功能。根据我的应用程序,当浏览器语言发生变化时,应用程序语言应该会根据浏览器语言自动变化。该怎么做?

【问题讨论】:

    标签: selenium selenium-webdriver localization selenium-chromedriver


    【解决方案1】:

    在启动驱动程序之前,请在 chrome 选项中设置语言代码,如下所示。

    System.setProperty("webdriver.chrome.driver","<PATH>/chromedriver.exe");
    ChromeOptions chromeoptions = new ChromeOptions();
    // for japanese language
    chromeoptions.addArguments("–lang= ja");
    ChromeDriver driver = new ChromeDriver(chromeoptions);
    driver.get("https://www.google.com");
    

    语言代码:https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes

    【讨论】:

    猜你喜欢
    • 2016-01-06
    • 1970-01-01
    • 2016-09-10
    • 1970-01-01
    • 2018-01-18
    • 1970-01-01
    • 2017-06-15
    • 2014-02-20
    • 2018-10-30
    相关资源
    最近更新 更多