2011-10-11 70 views
3

我正在使用SE2和firefoxDriver在無頭環境 環境(Xvfb)中運行測試。隨着FirefoxDriver我可以設置顯示環境屬性很容易 :以編程方式將環境屬性設置爲ChromeDriver

 FirefoxBinary firefox = new FirefoxBinary(); 
    firefox.setEnvironmentProperty("DISPLAY",":"+DISPLAY); 
    FirefoxProfile firefoxProfile = new ProfilesIni().getProfile(Config.webDriverFirefoxProfile); 
    this.webDriver = new FirefoxDriver(firefox,firefoxProfile); 

我如何能做到以上ChromeDriver?

更新:似乎這是不可能做到!有與我在這裏過類似的問題,其中介紹了情況:ChromeDriver Headless

回答

8

看起來他們已經解決了這個問題(至少目前如此)

service = new ChromeDriverService.Builder() 
     .usingChromeDriverExecutable(new File("/path/to/chromedriver")) 
     .usingAnyFreePort() 
     .withEnvironment(ImmutableMap.of("DISPLAY",":20")) 
     .build(); 

這裏的代碼這增加了該方法的修訂: http://code.google.com/p/selenium/source/detail?r=15232

1

另一非編程方法,轉到的/ etc /鉻/默認(或的/ etc /鉻的瀏覽器/默認或類似,依賴於分佈),並有設置顯示:

CHROMIUM_FLAGS="--display :99" 
相關問題