Selenium Chrome Headless Mode Overview


Introduction

Selenium Chrome Headless Mode execution is not a new terminology. Nowadays, it is being used widely for automation testing and web data scraping. Selenium Chrome Headless mode is a great value add when you have GUI less test beds for automation script execution.

PhantomJs used to be a very popular tool before Chrome headless implementation. However, present scenario Chrome is the ideal choice for headless execution. There are two reasons - one is Chrome's execution is much faster than PhantomJs and the next reason is Chrome is developed using Blink engine & PhantomJS uses old web-kit engine. In this blog, article, you will learn how to run Selenium scripts in Chrome headless mode and how it mimics user actions.

What is Blink?

Blink is a browser engine and it is developed as part of the Chromium project. All modern browsers these days are being developed using Blink browser engine. Headless Chrome uses the latest version of Blink. The popularity of blink is such that Microsoft has went to an extend of even discarding its own browser engine and started using Blink. Firefox uses Gecko engine and Safari uses Webkit. All other browsers are using Blink. Any browser which uses webkit engine lags a bit behind in terms of performance and stability.

PhantomJS Development is discontinued

PhantomJS was single handedly developed by a developer by named Vitaly Slobodin. After Chrome headless is being launched PhantomJS has become obsolete. Because Chrome headless is much faster than PhatomJS. As we all know that Webkit is older engine compared to Blink. Chrome Headless uses Blink and PhantomJS used Webkit. It has been officially announced that PhantomJS development is discontinued.

Code Example

from selenium import webdriver

options = webdriver.ChromeOptions()
options.add_argument("--headless")

driver = webdriver.Chrome(chrome_options=options)

Does Chrome headless mimic real user?

Chrome headless mode does not mimic real user. However, you can use it for test data creation scripts, prerequisite and web data scraping. Based on your automation testing requirements, you can decide which mode is suitable for your objective.

Conclusion

We, as a test automation services company, use Selenium Chrome headless mode for various turn key projects. Whereas, the objectives are different for different projects. For instance: In one of the projects, we use headless mode to trigger JavaScripts events and verify them on Analytics platform. It can also be used for a different perspective altogether. We hope you have relished reading this blog article.


Leave a Reply

Your email address will not be published. Required fields are marked *