在 UiAutomation 中长按 [英] Long press in UiAutomation

查看:28
本文介绍了在 UiAutomation 中长按的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在 moto X 设备 android 4.4 kitkat 中使用 eclipse 为 android 开发 Uiautomation.我正在做自动化以使用静态 IP 连接到 wifi 并使用 OPEN 安全性.要设置安全性,我需要长按 AP 名称,如何使用 Uiautomation 长按.我曾尝试使用 UiObject.longClick() 但它没有进行长按,并且 UiObject 的长按可设置为 FALSE.有没有其他方法可以做到这一点?

I am working on Uiautomation for android using eclipse in the moto X device android 4.4 kitkat.I am doing automation to connect to wifi with a static IP and using OPEN security. To set security I need to do long press on the AP name, how can I do long press with Uiautomation. I had tried with UiObject.longClick() but its not doing long press and that UiObject's long-clickable is set to FALSE. Is there any other way to do this?

推荐答案

使用 swipe(int startX, int startY, int endX, int endY, int steps) 在您希望的时间执行长按.最后一个参数steps决定了时间.对于 100 步,滑动大约需要 1/2 秒才能完成.步数越大,按压的持续时间越长.示例:

Use swipe(int startX, int startY, int endX, int endY, int steps) to perform a long click for the time you wish. The last parameter, steps, determines the time. For 100 steps, the swipe will take about 1/2 of a second to complete. The greater the value of steps, the longer the duration of the press. Example:

UiObject connect = new UiObject(new UiSelector().className("android.widget.LinearLayout").instance(6));
Rect rectButton = connect.getBounds();
UiDevice device = UiDevice.getInstance();
device.swipe(rectButton.centerX(), rectButton.centerY(), rectButton.centerX(), rectButton.centerY(), 200);

这里,connect 是我长按的 UiObject.

Here, connect is the UiObject which I am performing a long click on.

这篇关于在 UiAutomation 中长按的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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