- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我正在使用 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/
我正在使用 Junit4 和 Espresso 进行测试。我在 espresso 测试中遇到了一个奇怪的问题——当我调用 onView 时,有时一切都会按预期执行,但有时我的测试会卡住,60 秒后我会
我正在测试我为 android 编写的代码,我使用的是 JUnit4 和 android.support.test.espresso.Espresso.*。如果我在之前调用的 android 对象(如
我一整天都在使用 Espresso 设置 Junit4 仪器测试,但似乎无法完成最后一步。无论我做什么,它都不会识别 onView() 方法。我已经尝试了多个 SDK/support-lib 版本,但
我正在使用 Espresso 进行测试,首先我打开操作栏: openActionBarOverflowOrOptionsMenu(getInstrumentation().getTargetConte
有什么区别 1.ViewInteraction v = onView(allOf(withId(R.id.login_card_view), isDisplayed())) 和 2.v.check(匹
我是一名优秀的程序员,十分优秀!