以编程方式将SetEnvironmentProperty设置为ChromeDriver

Ari*_*e82 3 google-chrome webdriver xvfb selenium-webdriver

我在无头环境(Xvfb)中运行SE2和firefoxDriver测试.使用FirefoxDriver,我可以非常轻松地设置DISPLAY环境属性​​:

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

如何使用ChromeDriver完成上述操作?

更新:似乎这还不可能!我这里有一个类似的问题可以解释这种情况:ChromeDriver Headless

小智 8

看起来他们已经解决了这个问题(至少目前为止)

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

以下是添加此方法的代码中的修订:http: //code.google.com/p/selenium/source/detail?r = 15232