PerformException:执行“单击"时出错 [英] PerformException: Error performing 'single click'

查看:67
本文介绍了PerformException:执行“单击"时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

运行android espresso测试时出现错误:

I got a error when i run android espresso test:

com.google.android.apps.common.testing.ui.espresso.PerformException:在"id为:"的视图上执行单击"错误是< 2131034173>".

com.google.android.apps.common.testing.ui.espresso.PerformException: Error performing 'single click' on view 'with id: is <2131034173>'.

我的代码很简单:

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

但是此代码没有错误:

onView(withId(R.id.btn)).check(matches(isDisplayed()));

我找不到原因.

推荐答案

诀窍是读取错误的完整堆栈跟踪.在中间,有一些重要的信息,例如:

The trick is to read the full stack-trace of the error. In the middle, there is some crucial piece of information like this:

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}"

详细解释错误.

这篇关于PerformException:执行“单击"时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆