【问题标题】:Selenium Grid with Docker set Language for FirefoxSelenium Grid 与 Docker 为 Firefox 设置语言
【发布时间】:2016-10-13 13:59:44
【问题描述】:

我希望你能帮助我。 Selenium 在 Docker 中无头运行。 我可以从我的 Grid 访问 Web 服务器,打开 google 并执行 Selenium Teststeps 没问题。

现在我想用特定的语言环境测试我的应用程序。

    @Before
    public void setUp() throws Exception {
            selenium = new DefaultSelenium("localhost",4444,"*firefox","http://wildfly:8080");
            selenium.start();
    }
    @Test
    public void testSeleniumSupplier() throws Exception {
            selenium.open("/");
            selenium.click("link=Lieferant");

很遗憾我还没有开发这个应用程序,我只是在测试它。我已经打开了一个错误,我无法使用语言环境访问该站点。我需要使用语言环境访问此页面。如何在 Selenium 或 Docker 中设置它以访问具有德语语言环境的站点? 使用 Webdriver 我会知道如何更改,但不是在 Selenium Grid 中,我是 Selenium Grid 的新手。

非常感谢您的帮助:)

【问题讨论】:

    标签: selenium docker selenium-grid selenium-grid2


    【解决方案1】:

    为此,您需要创建一个 FirefoxProfile。在此配置文件中,您可以设置您的偏好。

    注意:不推荐使用 DefaultSelenium,因此您不想使用它。

    FirefoxProfile profile = new FirefoxProfile();
    profile.setPreference("intl.accept_languages", "de");
    
    // Start the driver with the new profile
    DesiredCapabilities dc = DesiredCapabilities.firefox();
    dc.setCapability(FirefoxDriver.PROFILE, profile);
    WebDriver driver = new RemoteWebDriver(
                                    new URL("http://localhost:4444/wd/hub"), 
                                    dc);
    

    【讨论】:

      猜你喜欢
      • 2021-12-27
      • 2019-02-17
      • 2018-04-11
      • 2013-09-09
      • 2016-01-31
      • 1970-01-01
      • 2016-01-06
      • 1970-01-01
      • 2020-01-29
      相关资源
      最近更新 更多