简体   繁体   English

有没有办法在 Android 上使用 Appium 执行双击?

[英]Is there a way to perform a double tap using Appium on Android?

I've tried every combination of TouchActions and chaining I can think of to perform a double tap on Android using the Appium integration test framework.我已经尝试过使用 Appium 集成测试框架在 Android 上执行双击的 TouchActions 和链接的所有组合。 I'm only able to record a single tap.我只能记录一个水龙头。 Here's the (Java) code I would expect to work:这是我希望工作的(Java)代码:

new TouchAction(driver).tap(x, y).tap(0, 0).perform();

Does anyone have a working Android code sample to share?有没有人可以分享一个有效的 Android 代码示例?

For reference, in iOS, the following (Python) code does seem to produce a double tap:作为参考,在 iOS 中,以下(Python)代码似乎确实产生了双击:

wd = webdriver.Remote('http://127.0.0.1:4723/wd/hub', desired_caps)
...
wd.tap([(215, 315)])
wd.tap([(215, 315)])
time.sleep(1)

Try:尝试:

action = TouchAction(self.driver)
action.tap(element=None, x=100, y=600, count=2).perform()

or with element and without x, y coordinates或带元素但不带 x, y 坐标

(You have to import: "from appium.webdriver.common.touch_action import TouchAction") (你必须导入:“from appium.webdriver.common.touch_action import TouchAction”)

使用 x,y 坐标在 Appium java 中双击:

new TouchAction(driver).press(PointOption.point(328, 185)).release().perform().press(PointOption.point(338, 185)).release().perform();

try this appium geastures Automating Mobile Gestures With UiAutomator2试试这个 appium 手势 使用 UiAutomator2 自动化移动手势

MobileElement button = driver.findElement(By.id("Button")); MobileElement button = driver.findElement(By.id("Button"));

((JavascriptExecutor) driver).executeScript("mobile: doubleClickGesture", ImmutableMap.of("elementId",((MobileElement)button).getId())); ((JavascriptExecutor) driver).executeScript("mobile: doubleClickGesture", ImmutableMap.of("elementId",((MobileElement)button).getId()));

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM