android UiAutomator长按实现控制按住控件时间的方法
来源:互联网 发布:shell脚本编程教程 编辑:程序博客网 时间:2024/06/07 21:24
本人在使用UiAutomator做测试的时候,遇到一些控件需要长按一会儿,比如录音功能,需要按住几秒,官方api不太好用,所以自己写了一个长按的方法。分享如下,供大家参考。
public void longclickUiObectByResourceId(String id) throws UiObjectNotFoundException {int x = getUiObjectByResourceId(id).getBounds().centerX();int y = getUiObjectByResourceId(id).getBounds().centerY();UiDevice.getInstance().swipe(x, y, x, y, 300);//最后一个参数单位是5ms}public void longclickUiObectByText(String text) throws UiObjectNotFoundException {int x = getUiObjectByText(text).getBounds().centerX();int y = getUiObjectByText(text).getBounds().centerY();UiDevice.getInstance().swipe(x, y, x, y, 300);//最后一个参数单位是5ms}
也可以通过参数控制长按时间。这里就不写了。
阅读全文
0 0
- android UiAutomator长按实现控制按住控件时间的方法
- Anroid的uiautomator实现控件长按的效果
- UIAutomator定位Android控件的方法实践和建议
- UIAutomator定位Android控件的方法(渐进篇)
- android 实现按住说话功能
- 【Android】长按连续触发事件的实现方法
- 【Android】长按连续触发事件的实现方法
- android UiAutomator控制多台手机同时运行用例的方法
- android uiautomator 一个截屏并且以当前时间命名图片名的方法
- android uiautomator自定义方法输出yyyy-MM-dd HH:mm:ss的时间
- UIAutomator定位Android控件的方法实践和建议(Appium姊妹篇)
- UIAutomator定位Android控件的方法实践和建议(Appium姊妹篇)
- UIAutomator定位Android控件的方法实践和建议(Appium姊妹篇)
- UIAutomator定位Android控件的方法实践和建议(Appium姊妹篇)
- android UiAutomator获取当前页面某类控件个数的方法
- Android UiAutomator: 中文字符的输入方法
- android uiautomator计算时间差的方法
- Uiautomator中longClick方法时间长度无法调节的解决办法
- 使用Ajax和Jquery配合数据库实现下拉框的二级联动
- spark 运行内存异常及参数调整
- SpringBoot快速入门,简单样例
- 获取ContentProvider来获取手机所有的联系人及联系人信息
- gradle linux 绝对路径
- android UiAutomator长按实现控制按住控件时间的方法
- HDU 3714 Error Curves(三分)
- Spring ContextLoaderListener与DispatcherServlet所加载的applicationContext的区别
- php-china.org 的开源项目安装
- 《利用Python进行数据分析》学习笔记ch03(4)
- C++实现双链表基本接口
- OpenAirInterface USRP安装时You do not have write permissions at the install location问题解决方案
- 通过JPA来自动创建Model类与数据中表对应
- hdu 4506 快速幂