带有Docker的Selenium Grid设置Firefox的语言

我希望你能帮助我。 Selenium与Docker一起正在运行。 我能够从我的网格访问Web服务器,打开谷歌和做seleniumtesting步骤是没有问题的。

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

@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"); 

不幸的是,我还没有开发这个应用程序,我只testing它。 我已经打开了一个错误,我无法使用语言环境en访问该网站。 我需要使用locale de访问此页面。 如何在Selenium或Docker中使用德语区域设置来访问该站点? 随着Webdriver我会知道如何改变,但不是在selenium网格,我是selenium新网格。

非常感谢您的帮助:)

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

注意: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);