Encountered error in Take screenshot function | Selenium Forum
S
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.

 

error:-

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

 


A
Ashish Thakur Replied on 19/06/2020

You have imported wrong FIleUtile it seems


S
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


A
Akshay Replied on 23/06/2020

try this:

import org.apache.commons.io.FileUtils;


A
Ashish Thakur Replied on 23/06/2020

Add this in pom

<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
<version>2.6</version>
</dependency>

 

and import this

import org.apache.commons.io.FileUtils;

 


S
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