I am currently working on Selenium WebDriver, Java and the TestNG framework.
The code I had written in Java.
If my Java code is in Boolean, how I can take a screenshot?
Example:
public boolean test() throws Exception {
// Some implementation
}
I tried this step, but it is showing an error:
WebDriver driver = new FirefoxDriver();
driver.get("http://www.google.com/");
File scrFile = ((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE);
// Now you can do whatever you need to do with it, for example copy somewhere
FileUtils.copyFile(scrFile, new File("c:\\tmp\\screenshot.png"));
The error is showing in this line for the copyFile as The method copyFile(File, File) is undefined for the type FileUtils
:
FileUtils.copyFile(scrFile, new File("c:\\tmp\\screenshot.png"));