2016-06-13 58 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