Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
251 views
in Technique[技术] by (71.8m points)

android - PerformException:执行“单击”时出错(PerformException: Error performing 'single click')

I got a error when i run android espresso test:

(当我运行android espresso测试时出现错误:)

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

(com.google.android.apps.common.testing.ui.espresso.PerformException:对“ ID为:is <2131034173>”的视图执行“单击”时出错。)

My code is easy:

(我的代码很简单:)

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

But there is no error with this code:

(但是此代码没有错误:)

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

I can not find the cause why it happen.

(我找不到发生这种情况的原因。)

  ask by Winton Hou translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

which explains the error in detail.

(详细解释了错误。)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...