当我运行 android espresso 测试时出现错误:
com.google.android.apps.common.testing.ui.espresso.PerformException:在视图“id:为 ”上执行“单击”时出错。
我的代码很简单:
onView(withId(R.id.btn)).perform(click());
但这段代码没有错误:
onView(withId(R.id.btn)).check(matches(isDisplayed()));
我找不到发生这种情况的原因。
诀窍是读取错误的完整堆栈跟踪。中间有一些关键信息,如下所示:
Caused by: java.lang.RuntimeException: Action will not be performed because the target view does not match one or more of the following constraints:
at least 90 percent of the view's area is displayed to the user.
Target view: "ImageView{id=2131492903, res-name=button_hamburger, desc=opens the side drawer, visibility=VISIBLE, width=64, height=64, has-focus=false, has-focusable=false, has-window-focus=true, is-clickable=true, 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=6.0, y=6.0}"
这详细解释了错误。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)