Search code examples
javaseleniumwebdriverappium

how to take screen shot of android app when testcase fails on real device


I am trying to get screenshot on android/iPhone device with following code:

File temp = ((TakesScreenshot (AndroidDriver) driver).getScreenshotAs(OutputType.FILE);
FileUtils.copyFile(temp, new File("D:\\my1.png"));

I am getting error unable to handle screenshot in Appium version 1.4.8. Please help me to resolve this issue with my native android app.


Solution

  • Please try with following code File temp=((TakesScreenshot)driver).getScreenshotAs(OutputType.FILE); FileUtils.copyFile(temp, new File("D:\\my1.png"));