收藏 分享(赏)

android自动化测试uiautomator-uicollection.pptx

上传人:天天快乐 文档编号:571703 上传时间:2018-04-12 格式:PPTX 页数:12 大小:1.27MB
下载 相关 举报
android自动化测试uiautomator-uicollection.pptx_第1页
第1页 / 共12页
android自动化测试uiautomator-uicollection.pptx_第2页
第2页 / 共12页
android自动化测试uiautomator-uicollection.pptx_第3页
第3页 / 共12页
android自动化测试uiautomator-uicollection.pptx_第4页
第4页 / 共12页
android自动化测试uiautomator-uicollection.pptx_第5页
第5页 / 共12页
点击查看更多>>
资源描述

1、UiCollection2013年 10月 16日UiCollection继承 UiObject用于枚举一个容器的用户界面 (ui)元素计数的目的, 或安装子元素的文本 或 描述条件 获取子 元素对象。Public MethodsUiObject getChildByDescription(UiSelector childPattern, String text)通 过 包含的条件 寻 找符合条件的子元素UiObject getChildByInstance(UiSelector childPattern, int instance)通 过 包含的条件 寻 找符合条件的子元素UiObject

2、getChildByText(UiSelector childPattern, String text)通 过 包含的条件 寻 找符合条件的子元素int getChildCount(UiSelector childPattern)递归计 算符合条件的子元素数量public UiObject getChildByDescription (UiSelector childPattern, String text)在 uiselector选择器的选择条件中从子 ui元素中搜索,递归寻找所有符合条件的子集。再次用文件条件从前面搜索子集定位到想要的元素参数:childPattern UiSelector

3、从子元素中的选择条件text 从搜索出的元素中再次用文本条件搜索元素返回值UiObject 返回一个 uiobject对象抛出异常UiObjectNotFoundException 1public UiObject getChildByInstance (UiSelector childPattern, int instance)在在 uiselector选择器的选择条件中从子选择器的选择条件中从子 UI元素中搜索,递归选择所有符合条件的子集。元素中搜索,递归选择所有符合条件的子集。再次用实例从前面搜索子集定位到想要的元素再次用实例从前面搜索子集定位到想要的元素参数参数childPattern

4、 从子集搜索的条件从子集搜索的条件instance 再次从搜索的子集中用实例搜索定位想要的元素再次从搜索的子集中用实例搜索定位想要的元素返回值返回值UiObject 返回一个返回一个 uiobject对象对象抛出异常抛出异常UiObjectNotFoundException 2public UiObject getChildByText (UiSelector childPattern, String text)在 uiselector选择器的选择条件中从子 ui元素中搜索,递归寻找所有符合条件的子集。再次用文件条件从前面搜索子集定位到想要的元素参数:childPattern UiSelect

5、or从子元素中的选择条件text 从搜索出的元素中再次用文本条件搜索元素返回值UiObject 返回一个 uiobject对象抛出异常UiObjectNotFoundException 3public int getChildCount (UiSelector childPattern)按照 uiselector递归查找所有符合条件的子子孙孙集合的的数量参数childPattern 选择条件返回值符合条件的子子孙孙集合数量4例子 1:判断界面不再变化思路:对于 95%以上的大部分界面,界面的变化会跟谁着元素的变化1.通过判断子元素数量,与特定元素数量不再变化;2.获取文件元素, 5个对象进行判

6、断,文本不在变化;/* 需求:对比两个下标数量相同的字符串数组是否相等* param a* param b* return*/public boolean compareStringArray(String a,String b)boolean compare=true;for(int i=0;ia.length;i+)if(!(ai.equals(bi)compare=false;return compare;/* 需求:获取界面元素类的个数与 5个 textview的字符串,返回一个字符串数组,用于判断界面是否变化* 使用:请在需要判断的位置插入此函数,对比两次范围的数组是否相等,判断界面

7、是否变化* return* throws UiObjectNotFoundException*/public String isUiChange() throws UiObjectNotFoundException UiCollection framCollection = new UiCollection(new UiSelector().className(“android.widget.FrameLayout“);int count=0;String ts=“a“,“a“,“a“,“a“,“a“; if (framCollection.exists() int textcount = f

8、ramCollection.getChildCount(new UiSelector().className(“android.widget.TextView“);int linearcount = framCollection.getChildCount(new UiSelector().className(“android.widget.LinearLayout“);int viewcount = framCollection.getChildCount(new UiSelector().className(“android.view.View“);count = textcount + linearcount + viewcount;for (int j = 0; j 5; j+) UiObject textObject = new UiObject(new UiSelector().className(“android.widget.TextView“).instance(j);if (textObject.exists() tsj = textObject.getText(); else break;String change=String.valueOf(count),ts0,ts1,ts2,ts3,ts4;return change;

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 经济财会 > 经济学

本站链接:文库   一言   我酷   合作


客服QQ:2549714901微博号:道客多多官方知乎号:道客多多

经营许可证编号: 粤ICP备2021046453号世界地图

道客多多©版权所有2020-2025营业执照举报