Screenshot on Android device

How does one take screenshots using appium ? I read on different forums that the screenTake function often fails … What I ended up doing was of writing a function do take android screenshots via adb

public void ScrShot(){

		//how to capture picture
		System.out.println("take screen shot");
		File scrFile = driver.getScreenshotAs(OutputType.FILE);
		String fileName = UUID.randomUUID().toString();
		File targetFile = new File("E:/Appium/logs" + fileName+".jpg");
	}catch(Exception e){
		System.out.println("Exception while adding a contact: "+e.getMessage());


I don’t have trouble writing the screen capture function … The bug in appium that the function doesn’t always gets called and often gets skipped

@AI You can probably try @Override your findElements() to include the screenshot() method you have created to be called every time you look for an element.
Btw what cases of failure have you faced? Could you please instantiate them.