- 1、本文档共12页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
android自动化测试UIautomatorUiCollection概要1
UiCollection 2013年10月16日;UiCollection继承UiObject;Public Methods;public UiObject getChildByDescription (UiSelector childPattern, String text)
在uiselector选择器的选择条件中从子ui元素中搜索,递归寻找所有符合条件的子集。
再次用文件条件从前面搜索子集定位到想要的元素
参数:
childPattern UiSelector从子元素中的选择条件
text 从搜索出的元素中再次用文本条件搜索元素
返回值
UiObject 返回一个uiobject对象
抛出异常
UiObjectNotFoundException ;public UiObject getChildByInstance (UiSelector childPattern, int instance)
在uiselector选择器的选择条件中从子UI元素中搜索,递归选择所有符合条件的子集。
再次用实例从前面搜索子集定位到想要的元素
参数
childPattern 从子集搜索的条件
instance 再次从搜索的子集中用实例搜索定位想要的元素
返回值
UiObject 返回一个uiobject对象
抛出异常
UiObjectNotFoundException ;public UiObject getChildByText (UiSelector childPattern, String text)
在uiselector选择器的选择条件中从子ui元素中搜索,递归寻找所有符合条件的子集。
再次用文件条件从前面搜索子集定位到想要的元素
参数:
childPattern UiSelector从子元素中的选择条件
text 从搜索出的元素中再次用文本条件搜索元素
返回值
UiObject 返回一个uiobject对象
抛出异常
UiObjectNotFoundException;public int getChildCount (UiSelector childPattern)
按照uiselector递归查找所有符合条件的子子孙孙集合的的数量
参数
childPattern 选择条件
返回值
符合条件的子子孙孙集合数量;例子1:判断界面不再变化;/**
* 需求:对比两个下标数量相同的字符串数组是否相等
* @param a
* @param b
* @return
*/
public boolean compareStringArray(String[] a,String[] b){
boolean compare=true;
for(int i=0;ia.length;i++){
if(!(a[i].equals(b[i]))){
compare=false;
}
}
return compare;
}
;/**
* 需求:获取界面元素类的个数与5个textview的字符串,返回一个字符串数组,用于判断界面是否变化
* 使用:请在需要判断的位置插入此函数,对比两次范围的数组是否相等,判断界面是否变化
* @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 = framCollection.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;
文档评论(0)