Problem Statement: Your scripts execution takes a lot of time and you want to reduce this execution time.
How: Headless browser is a program with no UI but works as any other normal browser in the background.
Overall Benefits:
1. To improve the overall speed of script execution.
2. Opening multiple browsers on one single machine. Since there is no UI so less memory is used. can be used for load testing.
3. If you cant install a browser on a machine, a headless browser is the best option to choose.
4. Your machine is free for other tasks to do.
Options:
Few headless drivers are:
1. Chrome
2. HTMLUnit
3. Ghost
4. PhantomJS
5. Watir
6. Slimer
7. Trifle
How to do it with chrome:
Initialise your browser withthe following setup:
System.setProperty("webdriver.chrome.driver", "ChromeDriverPath");
ChromeOptions options = new ChromeOptions();
options.addArguments("headless");
WebDriver driver = new ChromeDriver(options);
And run your scripts
Notes: Google support headless browser with version 59 and above.
No comments:
Post a Comment