Android,Espresso:找不到带有标签的ImageView" en"

时间:2017-03-02 13:50:13

标签: android android-espresso

我想找到带有标签的imageView文本" en"。

我的浓咖啡测试:

    @Test
public void testViewPagerSwipe() {
    onView(withId(R.id.containerLanguageEN)).perform(click());
    onView(withId(R.id.textViewNext)).perform(click());
    ImageView imageViewTour = (ImageView) mActivityRule.getActivity().findViewById(R.id.imageViewTour);
    String tag = (String) imageViewTour.getTag();
    if (BuildConfig.DEBUG)
        Log.d(TAG, "testViewPagerSwipe: tag = " + tag);
    onView(allOf(withId(R.id.imageViewTour), withTagValue(is((Object) endsWith("en"))))).check(matches(isDisplayed()));
}

此测试打印:

testViewPagerSwipe: tag = walkthrough_01_en

正如您所看到的,imageViewTour的标记是 walkthrough_01_en

但测试失败了:

     android.support.test.espresso.NoMatchingViewException:

No views in hierarchy found matching: (with id: com.myproject.android.dev:id/imageViewTour and with tag value: is <a string ending with "en">)

为什么?

0 个答案:

没有答案