Headless Chrome in GIRD- Not Working | Selenium Forum
Vinay Krishna Posted on 08/08/2020

Hello Sir,

I am trying the execute the test cases in headless mode to reduce the overaltime execution time. I tested the new changes locally and all works fine but when try to run in GRID even though i mention as headless it starts with chrome., any idea why tis is happening ?


public WebDriver launchHeadLessChrome()
if (REMOTE_URL != null && !REMOTE_URL.equals("")) {
DesiredCapabilities capabilities = DesiredCapabilities.chrome();
capabilities.setCapability("headless", true);
//capabilities.setCapability("disable-gpu", true);
try {
return new RemoteWebDriver(new URL(System.getProperty("RemoteUrl")), capabilities);

catch (MalformedURLException e) {

return null;

Parametrs passed for local execution :

<!-- 1 - Firefox; 2 - Internet Explorer; 3 - Chrome; 4- HeadLess -->
<prop key="selenium.browser">4</prop>
<prop key="TargetEnvironment">P</prop>


No Remote URL.


With Maven execution : With below goal

clean install -DTargetEnvironment=P -Dtest=PassportComboTestCase -Dselenium.browser=4 -DRemoteUrl=http://XXXXXX:4444/wd/hub -DRunArguments=All


But with this goal it starts with physical browser.


Can you pls help me with this.




Ashish Replied on 09/08/2020

You have to use options class to run Selenium in headless mode. Please check this:


ChromeOptions options = new ChromeOptions();
WebDriver driver = new ChromeDriver(options);
System.out.println("Title: " + driver.getTitle());
File scrFile = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(scrFile, new File("d://headless.jpg"));



Vinay Krishna Replied on 09/08/2020

How do i use Options class in GRID execution ? Grid we suppose to use RemoteWebDriver and that uses Capabilities rt ?


So i did write in this way

DesiredCapabilities capabilities = DesiredCapabilities.chrome();
capabilities.setCapability("headless", true);

Ashish Replied on 15/08/2020

You can also try


ChromeOptions options = new ChromeOptions();
    driver = new RemoteWebDriver(new URL("http://localhost:4444/wd/hub"), options);

Also refer https://github.com/SeleniumHQ/selenium/issues/6019

Related Posts