|
网上找的一个简单例子
package com;
import com.android.uiautomator.core.UiObject;
import com.android.uiautomator.core.UiObjectNotFoundException;
import com.android.uiautomator.core.UiScrollable;
import com.android.uiautomator.core.UiSelector;
import com.android.uiautomator.testrunner.UiAutomatorTestCase;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
public class Runner extends UiAutomatorTestCase {
public void testDemo() throws UiObjectNotFoundException {
getUiDevice().pressHome();
UiObject settingApp = new UiObject(new UiSelector().text("Settings"));
settingApp.click();
try {
Thread.sleep(3000);
} catch (InterruptedException e1) {
e1.printStackTrace();
}
UiScrollable settingItems = new UiScrollable( new UiSelector().scrollable(true));
UiObject languageAndInputItem = settingItems.getChildByText(
new UiSelector().text("Language & input"), "Language & input", true);
languageAndInputItem.clickAndWaitForNewWindow();
}
}
例子来原:http://blog.csdn.net/g19920917/article/details/16131565 测试用机子为MT15I(android 4.1.2) 而我的project.properties 里为target=android-22,不知道是不是这个原因,有没有人遇到我这情况
|
|