This site is in read only mode. Please continue to browse, but replying, likes, and other actions are disabled for now.
3 / 3
Oct 2018

I want to click and hold the object then take a screen shot before releasing the object, is it possible in Appium ?.

  • created

    Jul '18
  • last reply

    Oct '18
  • 2

    replies

  • 654

    views

  • 3

    users

  • 1

    like

Yes, it is possible.

Appium version : 1.8.1
Java client : 6.1.0

public void longPressScreenshot(MobileElement element,String screenshotName){
new TouchAction<>(driver).longPress(longPressOptions()
.withElement(element(element))).waitAction(waitOptions(Duration.ofSeconds(3)))
.moveTo(ElementOption.element(element))
.perform().release();
captureScreenshot(screenshotName);
}

public void captureScreenshot(String screenshotName) {
File srcFile = ((TakesScreenshot) driver).getScreenshotAs(OutputType.FILE);
String filePath = System.getProperty(“user.dir”) + File.separator + “screenshots” + File.separator +screenshotName+".png";
try {
FileUtils.copyFile(srcFile, new File(filePath));
} catch (IOException e) {
e.printStackTrace();
}
}

com-video-to-gif

3 months later