Hello @Nishant, follow these steps to use HTML Unit driver as a headless driver with Selenium:
1. In Eclipse, copy the following code along with standard selenium library files:
package headlessDriver;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.htmlunit.HtmlUnitDriver;
public class HtmlDriver {
 public static void main(String[] args) {
  WebDriver driver = new HtmlUnitDriver();
        driver.get("http://www.google.com");
        WebElement element = driver.findElement(By.name("q"));  
        element.sendKeys("Edureka");
        element.submit();   
        System.out.println("Page title is: " + driver.getTitle());  
        driver.quit();
}
}
2. Run the code. You will see that no browser is launched and the result is shown in Console:
