Hi,
I am trying to take a screenshot during a failure. The file is saved but i cannot open it.
When I try to open the file I get a message of: The file “clickOnFirstRow.png” could not be opened because it is empty.
I am using mac os.
I have set the capability:
capabilities.setCapability(MobileCapabilityType.TAKES_SCREENSHOT,"true");
This is my code:
public static void captureScreenshot(AppiumDriver driver, String screenshotName){
try {
TakesScreenshot ts=driver;
File source = ts.getScreenshotAs(OutputType.FILE);
File target = new File("/Users/shay/Desktop/" +screenshotName+".png");
FileUtils.copyFile(source,target);
System.out.println("Screenshot was taken");
} catch (IOException e) {
Log.report("Exception while taking the screenshot");
}
}
Any idea what am I doing wrong?
Thanks