gpt4 book ai didi

android - 使用 onView(withId(...)) 时使用 Espresso 单击操作栏中的菜单项

转载 作者:塔克拉玛干 更新时间:2023-11-02 18:59:45 26 4
gpt4 key购买 nike

我正在使用 Espresso 进行测试,首先我打开操作栏:

openActionBarOverflowOrOptionsMenu(getInstrumentation().getTargetContext());

到目前为止一切正常,但我想点击一个选项菜单:

onView(withId(R.id.action_menu)).perform(click());

菜单布局 xml 有一个 id 为“action_menu”的选项。

我得到一个错误:

android.support.test.espresso.NoMatchingViewException: No views in hierarchy found matching: with id: ***.********.******.android.debug:id/action_menu
If the target view is not part of the view hierarchy, you may need to use Espresso.onData to load it from one of the following AdapterViews:android.support.v7.widget.ListPopupWindow$DropDownListView{43fd3f58 VFED.VC. .F...... 24,24-612,168}

我通过使用以下方法来完成此步骤:

onView(withText(R.string.action_report)).perform(click());

我想知道这个 id 出了什么问题。

有什么想法吗?

最佳答案

表示菜单的 View 似乎不知道id,只知道一个item的文本。我是 Espresso 的新手,因此无法提供更多详细信息,但这篇文章与您的问题有关: Espresso NoMatchingViewException when using withId matcher

关于android - 使用 onView(withId(...)) 时使用 Espresso 单击操作栏中的菜单项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35650194/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com