(回帖有奖)基于Android AndroidJUnit框架的espresso测试,如今卡在[AppleScript] 纯文本查看 复制代码 @Test
public void changeText_sameActivity() {
// Type text and then press the button.
onView(withId(R.id.editTextUserInput))
.perform(typeText(STRING_TO_BE_TYPED), closeSoftKeyboard());
onView(withId(R.id.changeTextBt)).perform(click());
// Check that the text was changed.
onView(withId(R.id.textToBeChanged)).check(matches(withText(STRING_TO_BE_TYPED)));
}
执行到onView(withId(R.id.textToBeChanged)).check(matches(withText(STRING_TO_BE_TYPED)));会报错,如下:
[AppleScript] 纯文本查看 复制代码 Caused by: junit.framework.AssertionFailedError: 'with text: is "Espresso"' doesn't match the selected view.
Expected: with text: is "Espresso"
Got: "TextView{id=2131165184, res-name=textToBeChanged, visibility=VISIBLE, width=0, height=59, has-focus=false, has-focusable=false, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=false, is-selected=false, root-is-layout-requested=false, has-input-connection=false, x=360.0, y=96.0, text=, input-type=0, ime-target=false, has-links=false}"
如果有大神整过,提供点学习帮助。
|