Android 自动化测试经验 - UiScrollable
2013-01-24 09:17
281 查看
UiScrollable is a
UiScrollable是一个UiCollection(这东西还没搞懂),我们可以使用它,在可滑动的页面(水平滑动或上下滑动都可以)上查找我们想要的控件(item)。
例1:下面的这个scrollClickObject方法就是使用UiScrollable,来自动选择我们想要点击的那个控件。
首先定义一个UiScrollable对象,识别这个对象的唯一条件就是,屏幕上有可滑动的控件。(这里有一个问题,就是如果屏幕上同时存在2个可滑动的控件,就会报错了)
然后我们判断这个可滑动对象是否存在
存在,则使用getChildByText方法,获取我们想要点击的那个控件,然后点击它
不存在,则说明页面不可滑动,也就是所有控件均已显示在界面上。那我们就可以直接使用UiObject获取控件并操作它。
例2:
UiCollectionand provides support for searching for items in a scrollable user interface (UI) elements. This class can be used with horizontally or vertically scrollable controls.
UiScrollable是一个UiCollection(这东西还没搞懂),我们可以使用它,在可滑动的页面(水平滑动或上下滑动都可以)上查找我们想要的控件(item)。
例1:下面的这个scrollClickObject方法就是使用UiScrollable,来自动选择我们想要点击的那个控件。
public void scrollClickObject(String targetClassName,String targetName) throws UiObjectNotFoundException { UiScrollable collectionObject = new UiScrollable(new UiSelector().scrollable(true)); if(collectionObject.exists()) { UiObject scrollableObject = collectionObject.getChildByText(new UiSelector().className(targetClassName), targetName); scrollableObject.clickAndWaitForNewWindow(); } else { UiObject targetObject = new UiObject(new UiSelector().className(targetClassName).text(targetName)); targetObject.clickAndWaitForNewWindow(); } }
首先定义一个UiScrollable对象,识别这个对象的唯一条件就是,屏幕上有可滑动的控件。(这里有一个问题,就是如果屏幕上同时存在2个可滑动的控件,就会报错了)
然后我们判断这个可滑动对象是否存在
存在,则使用getChildByText方法,获取我们想要点击的那个控件,然后点击它
不存在,则说明页面不可滑动,也就是所有控件均已显示在界面上。那我们就可以直接使用UiObject获取控件并操作它。
例2:
相关文章推荐
- Android 自动化测试经验分享 深入UiScrollable
- Android 自动化测试经验 - UiScrollable
- android自动化测试工具【UiAutomator】——UiScrollable
- Android 自动化测试经验 - UiObejct.getFromParent()
- Android 自动化测试经验分享 UiObejct.getFromParent()的使用方法
- Android 自动化测试经验 - UiObejct.getFromParent()
- 使用Python进行Android自动化测试
- Android自动化测试工具调研
- Android自动化测试框架开发(二)Monkey、MonkeyRunner介绍和分析
- Android 程序员必须掌握的三种自动化测试方法
- (jenkins)hudson平台搭建android项目持续化集成以及基于NativeDriver的自动化测试环境
- 自动化测试推广经验分析总结
- 工作碎片记录-android自动化测试
- Android自动化测试框架开发(三)Instrumentation测试框架
- 转载:The Test Automation Experience Paradox(自动化测试经验悖论)
- 实现android自动化测试部署与运行Shell脚本分享
- android--自动化测试工具
- Android_自动化测试工具_Calabash-android调研
- 使用 flow.ci 实现 Android 自动化测试与持续集成
- Android 下的自动化测试方法