语法详解
获取控件案例
通过ID获取控件 onView(withId(R.id.et_username))通过文本内容获取控件 onView(withText("About"))使用案例
控件输入文本信息
perform(执行的具体操作)下面按案例中放的是键入文本cree1 * onView(withId(R.id.et_username)).perform(typeText("cree1"));控件点击事件
click()为点击操作 * onView(withId(R.id.button)).perform(click());打开菜单事件 * openActionBarOverflowOrOptionsMenu(getInstrumentation().getContext());
检查控件内的文本是否为ActionMode1 * onView(withId(R.id.status)).check(matches(withText("ActionMode1")));
针对控件右滑操作 * onView(withId(R.id.pager)).perform(swipeLeft());
检查控件是显示的 * onView(withId(R.id.error_text)).check(matches(isDisplayed()));