Skip to content

Headless Chrome

Headless Chrome refers to running the Google Chrome browser in a headless environment, which operates without a visible graphical user interface (GUI) or "browser window."^[600-developer__automatic__chromeDriver.md]

Usage and Configuration

To enable this mode, specific arguments must be passed when initializing the browser driver. The primary argument required is --headless^[600-developer__automatic__chromeDriver.md]. It is also standard practice to include the --disable-gpu argument when configuring headless operations^[600-developer__automatic__chromeDriver.md].

Implementation Example

The following Java code snippet demonstrates how to configure a [[Selenium]] ChromeDriver to run in headless mode. The ChromeOptions class is used to add the necessary arguments before the driver object is initialized^[600-developer__automatic__chromeDriver.md].

String chromeDriverPath = userDir + "/src/main/resources/[ChromeDriver](<./chromedriver.md>).exe";
System.setProperty("webdriver.chrome.driver", chromeDriverPath);

ChromeOptions options = new ChromeOptions();
options.addArguments("--lang=es");
options.addArguments("--headless");
options.addArguments("--disable-gpu");
driver = new [ChromeDriver](<./chromedriver.md>)(options);

Sources

^[600-developer__automatic__chromeDriver.md]