2016-06-13 55 views
1

我希望你能帮助我。 Selenium与Docker无关。 我能够从我的网格访问Web服务器,打开谷歌和做Selenium Teststeps是没有问题的。Selenium Grid with Docker设置语言为Firefox

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

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

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

预先感谢您对我付出的帮助:)

回答

2

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

非常感谢你:) – Simon