- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试使用 IdlingResource 编写一个 Espresso 测试来检查视频播放。
我的项目托管 here
这是测试:
@RunWith(AndroidJUnit4.class)
public class RecipeFetchTest {
@Rule
public ActivityTestRule<RecipeActivity> mActivityTestRule = new ActivityTestRule<>(RecipeActivity.class);
private IdlingResource mIdlingResource;
@Before
public void registerIdlingResource() {
mIdlingResource = mActivityTestRule.getActivity().getIdlingResource();
Espresso.registerIdlingResources(mIdlingResource);
}
@Test
public void checkRecipeNameRecipeActivity() {
onView(ViewMatchers.withId(R.id.rv_recipes)).perform(RecyclerViewActions.scrollToPosition(1));
onView(withText("Brownies")).check(matches(isDisplayed()));
}
@Test
public void checkPlayerViewIsVisibleRecipeDetailActivity1() {
onView(ViewMatchers.withId(R.id.rv_recipes)).perform(RecyclerViewActions.actionOnItemAtPosition(0,click()));
onView(ViewMatchers.withId(R.id.rv_steps)).perform(RecyclerViewActions.actionOnItemAtPosition(0,click()));
withContentDescription("playerVideo"))).check(matches(isDisplayed()));
onView(withId(R.id.playerView)).check(matches(isDisplayed()));
}
@After
public void unregisterIdlingResource() {
if (mIdlingResource != null) {
Espresso.unregisterIdlingResources(mIdlingResource);
}
}
}
我得到测试失败并出现此错误:
android.support.test.espresso.AmbiguousViewMatcherException: '(with id:
gautamhans.xyz.bakeaid:id/playerView and is displayed on the screen to the
user)' matches multiple views in the hierarchy.
Problem views are marked with '****MATCHES****' below.
+--------->SimpleExoPlayerView{id=2131558584, res-name=playerView,
visibility=VISIBLE, width=871, height=399, has-focus=false, has-
focusable=true, 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=0.0, y=0.0, child-count=3} ****MATCHES****
+---------->PlaybackControlView{id=2131558584, res-name=playerView,
visibility=VISIBLE, width=871, height=399, has-focus=false, has-
focusable=true, 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=0.0, y=0.0, child-count=1} ****MATCHES****
根据测试,我有两个具有相同 res-id 的 View ,即“playerView”。
一个是SimpleExoPlayerView另一个是PlaybackControlView
我记得定义了 SimpleExoPlayerView 但没有定义 PlaybackControlView 。
因此,我们将不胜感激。
最佳答案
我也遇到了同样的问题。
我认为 SimpleExoPlayer 会自动生成一个 PlaybackControlView。我不知道我们是否可以避免这一代,但我找到了解决方法。
看这一行:
onView(allOf(instanceOf(SimpleExoPlayerView.class), withId(R.id.playerView))).check(matches(isDisplayed()));
我只是添加了一个 Matcher 以确保检查 SimpleExoPlayer 对象,然后检查它是否正确显示。
关于android - AmbiguousViewMatcherException Espresso ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45611942/
我正在尝试使用 IdlingResource 编写一个 Espresso 测试来检查视频播放。 我的项目托管 here 这是测试: @RunWith(AndroidJUnit4.class) publ
我正在尝试编写一个 Android Espresso 测试来检查视频是否播放。单击播放按钮后,我正在检查 SimpleExoPlayerView 的关联播放器是否正在播放。问题是层次结构中还有一个 P
我有一个包含 RecyclerView 的 Fragment。但是因为我在这个 Fragment 中有很多元素,所以我想向上滑动列表以查看并检查这个 Fragment 中的所有元素。 早些时候这个方法
我正在尝试做的测试:进行购买,记下标题,然后返回主页 Activity ,然后按“home_image”,这是一个图像按钮。 我的问题是无法导航 home_image。我按下它,我得到了一个伪造的重复
我正在尝试使用 onData 运行 espresso 测试,对于其中只有一个 AdapterView 的 View ,一切正常。但是,当屏幕显示其中嵌套了多个适配器 View 的 View 时,我得到
当我尝试在测试下运行时,我得到了 AmbiguousViewMatcherException,我怎样才能从多个 View 中获得预期的 View 。 onData(hasToString(starts
拥有包含一些图像的 gridView。 gridView 的单元格来自相同的预定义布局,具有相同的 id 和 desc。 R.id.item_image == 2131493330 onView(wi
我是一名优秀的程序员,十分优秀!