我不认为这是一个重复的问题。我正在编写一个简单的Espresso测试,其中一部分涉及点击snackbar中的“确定”按钮。
Espresso.onView(allOf(withId(android.support.design.R.id.snackbar_text), withText(R.string.permission_snackbar)))
.check(matches(isDisplayed()));
Espresso.onView(withText("Ok")).perform(click());
出现了以下错误:
android.support.test.espresso.PerformException: 在“文本为“Ok”的视图”上执行“单击”操作时出错。原因是:java.lang.RuntimeException:由于目标视图未满足以下一个或多个约束条件,因此不会执行操作:至少90%的视图区域对用户可见。目标视图:“AppCompatButton {id = 2131558552,res-name = snackbar_action,visibility = VISIBLE,width = 264,height = 144,has-focus = false,has-focusable = true,has-window-focus = true,is-clickable = true,is-enabled = true,is-focused = false,is-focusable = true,is-layout-requested = false,is-selected = false,root-is-layout-requested = false,has-input-connection = false,x = 684.0,y = 53.0,text = Ok,input-type = 0,ime-target = false,has-links = false}”
有什么想法吗?