I am not allowed to use FileUtils in the program and error is shown when doing so. Even no suggestion is showing to import this pre-defined Class. I tried to search the solution but what I found was to import the class. But in my case even suggestion is not showing to import any class. Hovering on the "FileUtils" shows the suggestion to create FileUtils class/interface. Below is my code:
package captureScreenshot;
import java.io.File;
import java.io.IOException;
import org.apache.commons.io.FileUtils; //Getting Error at this line
import org.openqa.selenium.By;
import org.openqa.selenium.OutputType;
import org.openqa.selenium.TakesScreenshot;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.Test;
import com.google.common.io.Files;
public class FacebookScreenshot {
@Test
public void captureScreenshot() throws IOException
{
WebDriver driver = new FirefoxDriver();
driver.manage().window().maximize();
driver.get("https://www.facebook.com");
driver.findElement(By.xpath("//input[@name='firstname']")).sendKeys("Anil Kumar");
TakesScreenshot ts = (TakesScreenshot) driver;
File source = ts.getScreenshotAs(OutputType.FILE);
FileUtils.copyfile(source,new File("./Screenshots/facebook.png")); //Getting error at this line
driver.quit();
}
}