In Android, I need to drag an object in my app and take a screenshot WHILE STILL HOLDING the object.
I know that there are two ways of using touch actions (I'm not even considering the higher-level methods such as swipe()
as they give me much less control over my touch actions):
new TouchAction(driver).press(element).moveTo(x,y).release().perform();
and
driver.performTouchAction(new TouchAction(driver).press(element).moveTo(x,y).release());
When I try to divide my touch action into two parts, and inserting a screenshot capture in between as in the code below:
new TouchAction(driver)
.press(x,y)
.moveTo(newX,newY)
.perform();
takeScreenshot(); // My own implementation for readability
new TouchAction(driver)
.release()
.perform();
I get the following error:
org.openqa.selenium.WebDriverException: ERROR running Appium command: Cannot read property 'x' of null
Command duration or timeout: 14 milliseconds
The program fails during the second touch action, i.e., the screenshot is being successfully taken, but I have no way of releasing the object after grabbing it in this manner.
Any ideas?