Capture Screenshot in Selenium WebDriver using FileHandler Class

Are you wondering why FileUtils is not working to capture screenshot. Is your eclipse not showing any suggestion when you hover on FileUtils. Don’t worry. Its an update in Selenium. In the latest version of Selenium, FileHandler class is implemented to capture screenshot instead of FileUtils.

Here is a sample program to use FileHandler in a Selenium script to capture a screenshot.

Given a detailed explanation inside the program for your understanding.

We have to import package “” to work with FileHandler class

Here is a sample program.

Before Selenium 3.6.0, Apache Commons Library comes along with Selenium. But in Selenium new versions from Selenium 3.6.0 onwards, we have to download it separately to use it in our project.

You can download it from

If you are using Maven Project, here is the dependency of Apache Commons Library

If you have any queries, please comment below.

Sharing is caring.

Share on facebook
Share on twitter
Share on linkedin

Like This Post?

We have a lot more where that came from?

We only send really good stuff occasionally, promise.

Rajkumar SM

Leave a Comment

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

Share on facebook
Share on google
Share on twitter
Share on linkedin
Share on whatsapp

Recent Posts:

Scroll to Top
API Testing eBook