Capturing Screenshot in Headless Mode

Capturing Screenshot in Headless Mode
In this blog, we are going to learn how we can capture screenshot while executing our test in a chrome headless browser.

Before Moving further in this blog I would highly recommend you to refer this blog to understand how to execute automation script in Headless mode.

To capture screenshot in the headless mode approach would be similar that we normally use to capture a screenshot. We can use Third party Utility like aShot or Shutterbug that we have already discussed in other blogs.

In this blog for the purpose of learning, we will be using the TakeScreenshot interface to Capture Screenshot.

Below is the Code Snippet for capturing the screenshot of google homepage in headless mode and storing it in a particular location.

Result of execution is:



My Name is Ankur Jain and I am currently working as Automation Test Architect.I am ISTQB Certified Test Manager,Certified UI Path RPA Developer as well as Certified Scrum Master with total 12 years of working experience with lot of big banking clients around the globe.I love to Design Automation Testing Frameworks with Selenium,Appium,Protractor,Cucumber,Rest-Assured, Katalon Studio and currently exploring lot in Dev-OPS as well. I am currently staying in Mumbai, Maharashtra. Please Connect with me through Contact Us page of this website.

Previous Post
Next Post
June 14, 2019 at 12:23 AM

Hi Ankur,
Hope you doing well.

I am working as Associate Software Engineer.
I am trying to take screenshot of full page but sticky header in the website creating problem.
How can I correct it.?
Please help me out.


June 15, 2019 at 8:22 PM

Hi Vaibhav Please share the screenshot of page and the issue you are getting .i will look and based on that i can suggest some solution.My email id