我的测试大约有一半的时间。
@Test
public void thirdSwipe() {
onView(withId(R.id.pager)).perform(swipeLeft());
onView(withId(R.id.pager)).perform(swipeLeft());
onView(withId(R.id.pager)).perform(swipeLeft());
onView(allOf(withId(R.id.hint_english_text), withText("dog 0a"))).check(matches(isDisplayed()));
}
我失败了:
android.support.test.espresso.base.DefaultFailureHandler$AssertionFailedWithCauseError: 'is displayed on the screen to the user' doesn't match the selected view.
Expected: is displayed on the screen to the user
Got: "TextView{id=2131427358, res-name=hint_english_text, visibility=VISIBLE, width=624, height=62, 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=20.0, y=20.0, text=dog 0a, input-type=0, ime-target=false, has-links=false}"
因此,它看起来TextView
找到了"dog 0a"
,但它无法识别它。
我查看了其他问题,并且我用String
设置了文本,这只是我班上的几行:
private String englishText;
englishTextView.setText(englishText);
另外,我正在使用allOf()
。
任何帮助,将不胜感激。这个视图位于ViewPager
的视图中,所以我不确定测试是在ViewPager
是idyl之前发生的,但它确实说它找到了视图。
答案 0 :(得分:0)
这对我有用
onView(allOf(
withId(R.id.pagerimage),
ChildOf(withId(R.id.viewpager), 0)
)).check(matches(isDisplayed()))
.perform(swipeLeft());