Two Great Web Drivers to Use With Selenium

Headless Browser in HtmlUnit Driver
HtmlUnit Driver is getting famous because of its lightweight and fast features. It is also known as a headless browser driver. It does not provide any GUI while executing programs.
Some Examples of Headless Drivers Are:

HtmlUnit
PhantomJS
ZombieJS
Watir-webdriver
Ghost

Advantages of HtmlUnit Driver

Lack of GUI, which is why it takes less time and memory to run.
Works fast compared to Google Chrome, Firefox or Safari.
It supports Java and JavaScript.
Easy to use and understand

Disadvantages of HtmlUnit Driver

Difficult to perform user interface testing.
Exhaustive testing is impossible using this driver.

Code Snippet
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.htmlunit.HtmlUnitDriver;

public class Test {

public static void main(String[] args) throws InterruptedException
{
WebDriver driver = new HtmlUnitDriver();
driver.get(“http://softwaretestingbooks.com/");
System.out.println(driver.getTitle());
driver.quit();
}
}
Also, check:

Link: https://dzone.com/articles/headless-browser-htmlunit-driver?utm_medium=feed&utm_source=feedpress.me&utm_campaign=Feed%3A+dzone%2Fwebdev