Uiautomator测试分享(一)

本文介绍如何使用Android UI Automator进行UI测试,包括元素定位、点击操作、文本输入及异常处理等关键技术点。

if (new UiObject(new UiSelector().textContains("x")).exists())

 

new UiObject(new UiSelector().className("android.widget.EditText").instance(0)).setText("xxx")

 

new UiObject(new UiSelector().text("xxx")).click()

 

new UiObject(new UiSelector().resourceIdMatches(".+id/xxx")).getChild(new UiSelector().instance(0)).click()

 

new UiObject(new UiSelector().textStartsWith("xxx")).exists()

 

new UiObject(new UiSelector().resourceIdMatches(".+id/xx")).getText().replace("xx","xxx")

 

public String getPara(Bundle params){
   String para = null;
  if(params.getString("para")!=null){
   para=params.getString("para")+".txt";
  }
  return para;
 }

private Bundle params;

params=getParams();

 

StringWriter sw = new StringWriter();
  e.printStackTrace(new PrintWriter(sw, true));
        String str[] = sw.toString().split("\n");

str[0]

 

android create uitest-project -n Uiautomator -t 1 -p "E:\ECLIPSE_WORKSPACE\UIautomator"

ant build

adb push bin\Uiautomator.jar /data/local/tmp

adb shell uiautomator runtest Uiautomator.jar -c com.xxx.xxx

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值