为 Firefox 设置 Docker 语言的 Selenium Grid

Selenium Grid with Docker set Language for Firefox

希望你能帮助我。 Selenium 是 运行 无头的 Docker。 我可以从我的网格访问 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");

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

非常感谢您的帮助:)

为此,您需要创建一个 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);