Headless mode is a very useful way to run Firefox for automated testing with Selenium WebDriver. In headless mode, Firefox runs as normal only you don't see the UI components. This makes Firefox faster and tests run more efficiently, especially in the CI (Continuous Integration) environment.
We can run Selenium tests in headless mode by configuring the FirefoxOptions class, as shown in the following code snippet:
@BeforeMethodpublic void setup() { System.setProperty("webdriver.gecko.driver", "./src/test/resources/drivers/geckodriver 2"); FirefoxOptions firefoxOptions = new FirefoxOptions(); firefoxOptions.setHeadless(true); driver = new FirefoxDriver(firefoxOptions); driver.get("http://demo-store.seleniumacademy.com/" ...