Uiautomator测试分享(一)

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

你可能感兴趣的:(Uiautomator测试分享(一))