jxs1211 / android-test-kit

Automatically exported from code.google.com/p/android-test-kit
0 stars 0 forks source link

PerformException: Error performing 'single click' on view #44

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?

1. Create an Android application that uses Espresso as its test runner.
2. Place an EditText in the middle of an Activity
3. Place a Button below the EditText
4. Write a test which calls 
onView(withId(R.id.testEdit)).perform(typeText("Have a cup of Espresso."), 
closeSoftKeyboard()); from your test
5. Call onView(withId(R.id.button)).perform(click());

What is the expected output? 

- Test should pass

What do you see instead?

- The test fails/crashes as the "click" is not sent to the Button, but 
seemingly to the SystemUI.
- Crash log:
com.google.android.apps.common.testing.ui.espresso.PerformException: Error 
performing 'single click' on view 'with id: is <2131165246>'.
at 
com.google.android.apps.common.testing.ui.espresso.PerformException$Builder.buil
d(PerformException.java:67)
at 
com.google.android.apps.common.testing.ui.espresso.base.DefaultFailureHandler.ge
tUserFriendlyError(DefaultFailureHandler.java:57)
at 
com.google.android.apps.common.testing.ui.espresso.base.DefaultFailureHandler.ha
ndle(DefaultFailureHandler.java:40)
at 
com.google.android.apps.common.testing.ui.espresso.ViewInteraction.runSynchronou
slyOnUiThread(ViewInteraction.java:159)
at 
com.google.android.apps.common.testing.ui.espresso.ViewInteraction.doPerform(Vie
wInteraction.java:90)
at 
com.google.android.apps.common.testing.ui.espresso.ViewInteraction.perform(ViewI
nteraction.java:73)
at com.example.tests.FailingTest.testTypingAndPressBack(FailingTest.java:36)
at java.lang.reflect.Method.invokeNative(Native Method)
at 
android.test.InstrumentationTestCase.runMethod(InstrumentationTestCase.java:214)
at 
android.test.InstrumentationTestCase.runTest(InstrumentationTestCase.java:199)
at 
android.test.ActivityInstrumentationTestCase2.runTest(ActivityInstrumentationTes
tCase2.java:192)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:191)
at android.test.AndroidTestRunner.runTest(AndroidTestRunner.java:176)
at 
android.test.InstrumentationTestRunner.onStart(InstrumentationTestRunner.java:55
4)
at 
com.google.android.apps.common.testing.testrunner.GoogleInstrumentationTestRunne
r.onStart(GoogleInstrumentationTestRunner.java:167)
at 
android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1701)
Caused by: com.google.android.apps.common.testing.ui.espresso.PerformException: 
Error performing 'Send down montion event' on view 'unknown'.
at 
com.google.android.apps.common.testing.ui.espresso.PerformException$Builder.buil
d(PerformException.java:67)
at 
com.google.android.apps.common.testing.ui.espresso.action.MotionEvents.sendDown(
MotionEvents.java:90)
at 
com.google.android.apps.common.testing.ui.espresso.action.Tap$1.sendTap(Tap.java
:24)
at 
com.google.android.apps.common.testing.ui.espresso.action.GeneralClickAction.per
form(GeneralClickAction.java:82)
at 
com.google.android.apps.common.testing.ui.espresso.ViewInteraction$1.run(ViewInt
eraction.java:119)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
at java.lang.reflect.Method.invokeNative(Native Method)
at 
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)
Caused by: 
com.google.android.apps.common.testing.ui.espresso.InjectEventSecurityException:
 java.lang.SecurityException: Injecting to another application requires 
INJECT_EVENTS permission
at 
com.google.android.apps.common.testing.ui.espresso.base.InputManagerEventInjecti
onStrategy.injectMotionEvent(InputManagerEventInjectionStrategy.java:131)
at 
com.google.android.apps.common.testing.ui.espresso.base.EventInjector.injectMoti
onEvent(EventInjector.java:80)
at 
com.google.android.apps.common.testing.ui.espresso.base.UiControllerImpl$3.call(
UiControllerImpl.java:201)
at 
com.google.android.apps.common.testing.ui.espresso.base.UiControllerImpl$3.call(
UiControllerImpl.java:198)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
at 
java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at 
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:841)
Caused by: java.lang.SecurityException: Injecting to another application 
requires INJECT_EVENTS permission
at android.os.Parcel.readException(Parcel.java:1465)
at android.os.Parcel.readException(Parcel.java:1419)
at 
android.hardware.input.IInputManager$Stub$Proxy.injectInputEvent(IInputManager.j
ava:356)
at android.hardware.input.InputManager.injectInputEvent(InputManager.java:641)
at java.lang.reflect.Method.invokeNative(Native Method)
at 
com.google.android.apps.common.testing.ui.espresso.base.InputManagerEventInjecti
onStrategy.injectMotionEvent(InputManagerEventInjectionStrategy.java:122)
... 9 more

What version of the product are you using? On what operating system?

- Issues observed with Espresso 1.1

Please provide any additional information below.

- All animations disabled in AVD
- AVD Settings: Nexus 4, Google APIs Level 19, ARM, 1907 RAM, 64 VM, Use Host 
GPU, no hardware keyboard (screenshot attached)
- Attached animated gif of failure
- Attached sample code displaying the issue

Original issue reported on code.google.com by daniel.j...@jadedpixel.com on 14 Jan 2014 at 7:11

Attachments:

GoogleCodeExporter commented 9 years ago
Not an espresso bug.

Common cases that cause this:
- ANR/crash dialogs from other apps (can be handled on a device setup level. 
This is quite involved and is outside the scope of UI test execution)
- soft keyboard is showing (can be handled by adding closeSoftKeyboard action) 

You can confirm by observing the test during execution or taking a screenshot 
on failure.

Original comment by vale...@google.com on 14 Jan 2014 at 7:41

GoogleCodeExporter commented 9 years ago
I disagree. Would appreciate it you could look more closely at the bug 
description I provided or if you could try out the sample application attached.

For instance, 
1. closeSoftKeyboard() is being called
2. There are no other dialogs showing
3. Animations are disabled

The attached GIF shows what's happening.

I've had to work around this in my code by adding a sleep after the 
closeSoftKeyboard which seems to defeat the purpose of Espresso.

Original comment by daniel.j...@jadedpixel.com on 14 Jan 2014 at 7:51

GoogleCodeExporter commented 9 years ago
The same issue (with the same scenario) is reproducible for me as well? Why the 
bug is market as invalid?

Original comment by vitaliy....@gmail.com on 5 Feb 2014 at 2:59

GoogleCodeExporter commented 9 years ago
Having same issue. The soft keyboard is dismissed but the perform click still 
fails.

Original comment by a...@spoton.com on 7 Feb 2014 at 9:25

GoogleCodeExporter commented 9 years ago
I'm getting this issue as well, along with ensuring I'm using the 
closeSoftKeyboard() method.

And indeed, a wait before the click() fixes it for me, but negates the reason 
I'm using Espresso unfortunately.

Even more strange is the fact that a Thread.sleep(1) works.

Original comment by my.name....@gmail.com on 11 Feb 2014 at 7:24

GoogleCodeExporter commented 9 years ago
I can reproduce it as well... just could hack it like said with 
Thread.sleep(1000ms) !

Original comment by luserdr...@googlemail.com on 13 Feb 2014 at 11:48

GoogleCodeExporter commented 9 years ago
Confirmed. Same issue with my tests.

Original comment by desire2l...@gmail.com on 4 Mar 2014 at 7:05

GoogleCodeExporter commented 9 years ago
same here :(

Original comment by to.mikek...@gmail.com on 7 Mar 2014 at 9:54

GoogleCodeExporter commented 9 years ago
The same for me. But somehow it worked before. Now I always have this issue. 
Maybe it is related to SDK update?

Original comment by denys.ze...@gmail.com on 3 Apr 2014 at 12:02

GoogleCodeExporter commented 9 years ago
I noticed the problem for e-mail field

Original comment by denys.ze...@gmail.com on 3 Apr 2014 at 12:03

GoogleCodeExporter commented 9 years ago
Facing the same issue. Is there a patch or fix for it?

Original comment by adnan.ch...@tigerspike.com on 8 May 2014 at 7:12

GoogleCodeExporter commented 9 years ago
I didn't have to close the soft keyboard a few months ago when I initially 
wrote tests using Espresso. Also, using closeSoftKeyboard does not always work 
so the test is now flaky. Does anyone know what introduced this issue in the 
first place? This is definitely not an invalid issue.

Original comment by james.w...@gmail.com on 23 Jul 2014 at 9:14

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
I've worked around this issue by writing my own tiny keyboard that is 32dp 
tall. It seems to work much better than having the stock keyboard.

https://github.com/johnybot/TestingKeyboard

Original comment by johnatha...@hootsuite.com on 28 Jul 2014 at 9:34

GoogleCodeExporter commented 9 years ago
Have the same problem with espresso-contrib-1.1. In login test scenario after 
typeText() and call closeSoftKeyboard() without thread.sleep() it cause 
"PerformException: Error performing 'single click' on view". With 
thread.sleep() it works. Test on real device (lenovo A7600)

Original comment by v.averja...@crystals.ru on 16 Sep 2014 at 8:34

GoogleCodeExporter commented 9 years ago
I have that issue too on my Panasonic FZ-A1.

Heres how i solved it:
onView(withId(R.id.testEdit)).perform(typeText("Have a cup of Espresso."), 
closeSoftKeyboard());
Thread.sleep(1000);

dunno why it works with a sleep, but it works....

Original comment by ein...@googlemail.com on 22 Oct 2014 at 10:44

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
I can repro it as well. Please fix if you want people to use espresso. 

Original comment by ak...@intelius.com on 26 Dec 2014 at 6:54

GoogleCodeExporter commented 9 years ago
#18 Same issue here (New status)
https://code.google.com/p/android-test-kit/issues/detail?id=79

Original comment by ard...@gmail.com on 28 Dec 2014 at 7:06

GoogleCodeExporter commented 9 years ago
I am facing following issue , However the button is clicking during the test 
but the following error is showing-

com.proptiger.app.MyEspressoTest > testRegisterButton[GT-I9152 - 4.2.2] FAILED 
        android.support.test.espresso.PerformException: Error performing 'single click' on view 'with id: com.proptiger:id/register_country_spinner'.
        at android.support.test.espresso.PerformException$Builder.build(PerformException.java:83)

Please look into this issue.

Original comment by bhupendr...@proptiger.com on 19 May 2015 at 9:44

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Hey!

Had the same problem - and found a solution.

What I found is, that my perform(click()) is performed correctly, but (In my 
case) the JSON which should be returned after click, was incorrect and therefor 
made my test crash with error: Error performing 'single click' on view. 

It seems that this error message defines that there is a problem with something 
that happened during/after the click, not the click it self.

So check that logcat, thats how I found the solution to my problem.

Hope this helps :)

Original comment by kasperda...@gmail.com on 14 Aug 2015 at 6:53