以下为使用UiAutomation打开settings的一个标本实例,来简单说明使用该工具的测试步骤
package com.uia.example.my;
//导入需要的内容
import android.os.RemoteException;
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;
public class LaunchSettings extends UiAutomatorTestCase {
public void testDemo() throws UiObjectNotFoundException, RemoteException {
System.out.println("My first time to use it") ;
// Simulate a short press on the HOME button. 模拟点击home键
getUiDevice().pressHome();
System.out.println("Step 1