【问题标题】:How to DoubleTap using Android UI Automator如何使用 Android UI Automator 双击
【发布时间】:2014-03-27 11:46:35
【问题描述】:

我正在尝试使用 Android UI Automator 工具双击视图,但没有 API 可以双击。有没有其他方法可以使用 ui automator 双击。

提前致谢。

【问题讨论】:

  • 你想双击什么?哪个元素?
  • 嗨 Smriti,感谢您的评论。我想双击图像视图,但没有来自 ui automator 的直接 api。但最后我得到了解决方案。我使用 Configurator(developer.android.com/tools/help/uiautomator/Configurator.html) api 配置了事件之间的延迟
  • UiObject selectImage = new UiObject(new UiSelector().className("android.widget.RelativeLayout").index(3));配置器 cc = Configurator.getInstance(); cc.setActionAcknowledgementTimeout(40); selectImage.click(); selectImage.click();
  • @SatyaAttili 建议使用 setActionAcknowledgmentTimeout(40) 的方法对我有用。
  • 添加setActionAcknowledgmentTimeout(40) 似乎也有助于融合除UiObject.click() 之外的其他操作组合。例如,我需要在涉及UiObject.click() 后跟UiObject.swipeDown(30) 的地图上自动执行放大操作(也可以缩小UiObject.click() 后跟UiObject.swipeUp(30)。如果不添加setActionAcknowledgmentTimeout(40),它就无法工作。

标签: android android-uiautomator


【解决方案1】:
Gesture interaction with the device
Click on the screen

d.click(x, y)
Double click

d.double_click(x, y)
d.double_click(x, y, 0.1) # default duration between two click is 0.1s
Long click on the screen

d.long_click(x, y)
d.long_click(x, y, 0.5) # long click 0.5s (default)
Swipe

d.swipe(sx, sy, ex, ey)
d.swipe(sx, sy, ex, ey, 0.5) # swipe for 0.5s(default)

d.drag(sx, sy, ex, ey)
d.drag(sx, sy, ex, ey, 0.5) # swipe for 0.5s(default)
Swipe points

# swipe from point(x0, y0) to point(x1, y1) then to point(x2, y2)
# time will speed 0.2s bwtween two points
d.swipe_points([(x0, y0), (x1, y1), (x2, y2)], 0.2))

【讨论】:

    【解决方案2】:

    我是这样做的:

    img.click();
    Thread.sleep(50);
    img.click();
    

    【讨论】:

      猜你喜欢
      • 2019-04-09
      • 2013-05-06
      • 2013-09-15
      • 2018-03-03
      • 1970-01-01
      • 2020-09-22
      • 1970-01-01
      • 2011-01-14
      • 2015-11-09
      相关资源
      最近更新 更多