有没有办法使用 Espresso 测试小吃栏是否显示正确的文本?
我有一个简单的调用来创建一个小吃栏
Snackbar.make(mView, "My text", Snackbar.LENGTH_LONG).show();
我尝试过这个但没有运气
onView(withText("My text")).inRoot(withDecorView(not(is(mActivityRule.getActivity().getWindow().getDecorView())))).check(matches(isDisplayed()));
这对我有用,请尝试。
onView(allOf(withId(android.support.design.R.id.snackbar_text), withText("My text")))
.check(matches(isDisplayed()));
如果您使用AndroidX,请使用以下内容:
onView(withId(com.google.android.material.R.id.snackbar_text))
.check(matches(withText(R.string.whatever_is_your_text)))
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)