test下新建类
public class ButtonClickTest {private UiDevice device;@Beforepublic void setUp() {// 初始化 UiDevice 实例device = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());try {device.executeShellCommand("am start -n com.yy.test/.MainActivity"); //启动,包名,Activity名} catch (IOException e) {e.printStackTrace();}}@Testpublic void testButtonClick() throws UiObjectNotFoundException {UiObject user = device.findObject(new UiSelector().resourceId("com.yy.test:id/user"));user.clearTextField();user.setText("admin");UiObject pass = device.findObject(new UiSelector().resourceId("com.yy.test:id/pass"));pass.clearTextField();pass.setText("123456");UiObject button = device.findObject(new UiSelector().resourceId("com.yy.test:id/btnLogin"));button.click();} }