Espressο:单击微调器项后,视图层次结构仅包含微调器 PopupViewContainer
Espressο: After clicking on a spinner item, view hierarchy contains only the spinner PopupViewContainer
我有一个带有各种选项的 Spinner。单击任何选项后,片段将加载到 activity 中的 FrameLayout 中。
使用 Espresso,我 select 正在 select 并单击 Spinner 项,没有任何错误,但之后视图层次结构仅包含 Spinner PopupViewContainer 并且我不能 select 我的 activity 中的任何视图。
我的测试代码如下:
onView(withId(R.id.pager)).perform(swipeLeft()).perform(swipeLeft());
onView(withId(R.id.fgs_cbx_scan_type)).perform(click());
onData(hasToString(startsWith(GreenScanType.ARRIVAL.getName()))).inAdapterView(withId(R.id.fgs_cbx_scan_type)).perform(click());
//So far so good with no errors. Then the following call fails
//because the view hierarchy does not contain the hierarchy
//of the activity anymore but just the popup of the spinner.
onView(withId(R.id.fgs_cbx_scan_type)).check(matches(withText(containsString(GreenScanType.ARRIVAL.getName()))));
我是否遗漏了什么或做错了什么?
最后我也不得不打电话给
onView(withText(GreenScanType.ARRIVAL.getName())).perform(click());
在onData
之后
我有一个带有各种选项的 Spinner。单击任何选项后,片段将加载到 activity 中的 FrameLayout 中。 使用 Espresso,我 select 正在 select 并单击 Spinner 项,没有任何错误,但之后视图层次结构仅包含 Spinner PopupViewContainer 并且我不能 select 我的 activity 中的任何视图。
我的测试代码如下:
onView(withId(R.id.pager)).perform(swipeLeft()).perform(swipeLeft());
onView(withId(R.id.fgs_cbx_scan_type)).perform(click());
onData(hasToString(startsWith(GreenScanType.ARRIVAL.getName()))).inAdapterView(withId(R.id.fgs_cbx_scan_type)).perform(click());
//So far so good with no errors. Then the following call fails
//because the view hierarchy does not contain the hierarchy
//of the activity anymore but just the popup of the spinner.
onView(withId(R.id.fgs_cbx_scan_type)).check(matches(withText(containsString(GreenScanType.ARRIVAL.getName()))));
我是否遗漏了什么或做错了什么?
最后我也不得不打电话给
onView(withText(GreenScanType.ARRIVAL.getName())).perform(click());
在onData