在 Appium 中拖动时截取屏幕截图 [英] Take a screenshot during dragging in Appium

查看:46
本文介绍了在 Appium 中拖动时截取屏幕截图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Android 中,我需要在我的应用中拖动一个对象并在按住对象的同时截取屏幕截图.

In Android, I need to drag an object in my app and take a screenshot WHILE STILL HOLDING the object.

我知道有两种使用触摸动作的方法(我什至没有考虑诸如 swipe() 这样的高级方法,因为它们对我的触摸动作的控制要少得多):

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();

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();

我收到以下错误:

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.

有什么想法吗?

推荐答案

通过查看您的问题

new TouchAction(driver)
    .release()
    .perform();

发布时提供一些 x 和 y 位置来发布尝试可能会奏效

for release provide some x and y location to release have a try might work

这篇关于在 Appium 中拖动时截取屏幕截图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆