Ways to perform headless browser Testing with chrome


What is headless Testing

Headless Testing means running a browser UI test without the head aka. no browser UI. It is extremely helpful when we don’t really care about the UI, but would like to execute out Automation tests as fast as possible and not involving any “draw” operations onto the screen that consumes it own time and memory.


Ways to execute headless browser Testing
1.        
If Chrome version is 59 we can use ChromeOption class as suggested below
ChromeOptions options = new ChromeOptions();
//Adding "headless" argument to options
options.addArguments("headless");
driver = new ChromeDriver(options);


if Chrome version is less than 59 we can use HtmlUnitDriver which allows us to select version of browser that you would like to run your tests on. You can select the browser version like this.





How to enable javascript support in Headless driver.


Post a Comment