SetEnvironmentProperty to ChromeDriver programmatically
Asked Answered
S

2

3

I am running tests with SE2 and firefoxDriver in a headless enviroment(Xvfb). With FirefoxDriver I can set the DISPLAY environment property very easily:

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

How can I do the above with ChromeDriver?

UPDATE: Seems that this is not possible to do yet! There is a similar question with mine here where explains the situation: ChromeDriver Headless

Straighten answered 11/10, 2011 at 7:21 Comment(0)
M
9

looks like they've fixed this (at least for now)

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

Here's the revision in the code which adds this method: http://code.google.com/p/selenium/source/detail?r=15232

Mccaskill answered 22/2, 2012 at 21:7 Comment(0)
C
2

another non-programmatic approach, go to /etc/chromium/default (or /etc/chromium-browser/default or similar, depends on distribution) and set display there :

CHROMIUM_FLAGS="--display :99"
Compressibility answered 22/8, 2012 at 11:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.