Encountered error in Take screenshot function | Selenium Forum
Suraj M B Posted on 18/06/2020

Hi Sir,

In takeScreenshot() function, FileUtils.copyFile(scrFile, new File(System.getProperty("user.dir")+"//Screenshots//"+screenshotFile)); line showing an error. i couldn't identify the reason for this issue. Please help me to solve this error.



Cannot make a static reference to the non-static method copyFile(File, File) from the type FileUtils


Support Team Replied on 19/06/2020

You have imported wrong FIleUtile it seems

Suraj M B Replied on 20/06/2020

Hi Sir, i have attached the screenshot of java imports in Base class. please have a look and help me to identify the wrong import

Akshay Replied on 23/06/2020

try this:

import org.apache.commons.io.FileUtils;

Support Team Replied on 23/06/2020

Add this in pom



and import this

import org.apache.commons.io.FileUtils;


Suraj M B Replied on 23/06/2020

Thank you sir, the issue is resolved after adding the dependencies in the pom xml.

Related Posts