oscarxie / android-test-kit

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

Espresso fails to click on action bar icons or overflow menu options #70

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
On android 4.1.2 phone emulator, do onView(withId(id)).perform(click()) on an 
action bar icon, or open the overflow menu then 
onView(withText(id)).perform(click()) on a menu option.

What is the expected output? What do you see instead?
Sometimes it fails to click on that view. But sometimes it can click 
successfully.

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

Please provide any additional information below.

This happens more frequently on tablet, and this happens on both smartphone and 
tablet.

Original issue reported on code.google.com by K76...@gmail.com on 8 May 2014 at 1:33

GoogleCodeExporter commented 9 years ago
Here is the log for one of the problems. The menu was brought up and performed 
click on one of the item, but when I later use check to check whether the 
expected view in expected activity was shown, the view hierarchy indicates that 
it was still in the menu list.

01-10 20:41:48.608 V/ESP_TRACE( 1773): EventInjector:Injecting event for 
character (À€) with key code (82) downtime: (100255)

01-10 20:41:48.608 V/ESP_TRACE( 1773): UiControllerImpl: MessageQueue.next(): { 
what=10 when=-1ms arg1=3373 }, with target: 
android.view.ViewRootImpl.ViewRootHandler, callback: no callback.
01-10 20:41:48.638 V/ESP_TRACE( 1773): UiControllerImpl: MessageQueue.next(): { 
what=0 when=-3ms }, with target: android.view.Choreographer.FrameHandler, 
callback: android.view.Choreographer$FrameDisplayEventReceiver@b3b2eaa0
01-10 20:41:48.678 V/ESP_TRACE( 1773): UiControllerImpl: MessageQueue.next(): { 
what=6 when=-48ms arg1=1 arg2=1 }, with target: 
android.view.ViewRootImpl.ViewRootHandler, callback: no callback.

01-10 20:41:48.678 V/ESP_TRACE( 1773): UiControllerImpl: MessageQueue.next(): { 
what=3 when=-47ms }, with target: android.os.Handler, callback: no callback.

01-10 20:41:48.678 V/ESP_TRACE( 1773): Barrier detected or task avaliable for 
running shortly.

01-10 20:41:48.740 V/ESP_TRACE( 1773): UiControllerImpl: MessageQueue.next(): { 
what=1 when=-1ms obj=android.os.AsyncTask$AsyncTaskResult@b3cd4690 }, with 
target: android.os.AsyncTask.InternalHandler, callback: no callback.

01-10 20:41:48.740 V/ESP_TRACE( 1773): Barrier detected or task avaliable for 
running shortly.

01-10 20:41:48.740 V/ESP_TRACE( 1773): UiControllerImpl: MessageQueue.next(): { 
what=0 when=-82ms }, with target: android.view.Choreographer.FrameHandler, 
callback: android.view.Choreographer$FrameDisplayEventReceiver@b3b2eaa0

01-10 20:41:48.740 V/ESP_TRACE( 1773): Barrier detected or task avaliable for 
running shortly.

01-10 20:41:48.740 V/ESP_TRACE( 1773): UiControllerImpl: MessageQueue.next(): { 
what=5 when=-67ms arg1=480 arg2=117 
obj=android.view.ViewRootImpl$ResizedInfo@b3cd4720 }, with target: 
android.view.ViewRootImpl.ViewRootHandler, callback: no callback.

01-10 20:41:48.799 D/dalvikvm( 1773): GC_CONCURRENT freed 1503K, 11% free 
14822K/16583K, paused 17ms+2ms, total 116ms

01-10 20:41:48.799 V/ESP_TRACE( 1773): Barrier detected or task avaliable for 
running shortly.

01-10 20:41:48.799 V/ESP_TRACE( 1773): UiControllerImpl: MessageQueue.next(): { 
what=1 when=-57ms obj=android.widget.ProgressBar@b3b15cf8 }, with target: 
android.view.ViewRootImpl.ViewRootHandler, callback: no callback.

01-10 20:41:48.799 V/ESP_TRACE( 1773): Barrier detected or task avaliable for 
running shortly.

01-10 20:41:48.799 V/ESP_TRACE( 1773): UiControllerImpl: MessageQueue.next(): { 
what=1 when=-57ms obj=android.widget.ProgressBar@b3b15cf8 }, with target: 
android.view.ViewRootImpl.ViewRootHandler, callback: no callback.

01-10 20:41:48.799 V/ESP_TRACE( 1773): Barrier detected or task avaliable for 
running shortly.

01-10 20:41:48.799 V/ESP_TRACE( 1773): UiControllerImpl: MessageQueue.next(): { 
what=6 when=-55ms arg2=1 }, with target: 
android.view.ViewRootImpl.ViewRootHandler, callback: no callback.

01-10 20:41:48.799 V/ESP_TRACE( 1773): Barrier detected or task avaliable for 
running shortly.

01-10 20:41:48.799 V/ESP_TRACE( 1773): UiControllerImpl: MessageQueue.next(): { 
what=0 when=-55ms }, with target: android.view.Choreographer.FrameHandler, 
callback: android.view.Choreographer$FrameDisplayEventReceiver@b3b2eaa0

01-10 20:41:48.799 V/ESP_TRACE( 1773): Barrier detected or task avaliable for 
running shortly.

01-10 20:41:48.799 V/ESP_TRACE( 1773): UiControllerImpl: MessageQueue.next(): { 
what=0 when=-14ms }, with target: android.os.Handler, callback: 
android.widget.Toast$TN$2@b3cd0d38

01-10 20:41:48.799 V/ESP_TRACE( 1773): Barrier detected or task avaliable for 
running shortly.

01-10 20:41:48.799 V/ESP_TRACE( 1773): UiControllerImpl: MessageQueue.next(): { 
what=3 when=0 }, with target: android.view.ViewRootImpl.ViewRootHandler, 
callback: no callback.

01-10 20:41:48.799 I/ViewInteraction( 1773): Performing 'single click' action 
on view with string from resource id: <2131362320>[calMenu_edit] value: Edit

01-10 20:41:48.838 V/ESP_TRACE( 1773): UiControllerImpl: MessageQueue.next(): { 
what=2 when=-1ms arg1=1 
obj=android.graphics.drawable.AnimatedRotateDrawable@b3b8da18 }, with target: 
android.view.Choreographer.FrameHandler, callback: no callback.

01-10 20:41:48.849 V/ESP_TRACE( 1773): UiControllerImpl: MessageQueue.next(): { 
what=0 when=-30ms }, with target: android.view.Choreographer.FrameHandler, 
callback: android.view.Choreographer$FrameDisplayEventReceiver@b3b2eaa0

01-10 20:41:48.860 V/ESP_TRACE( 1773): UiControllerImpl: MessageQueue.next(): { 
what=4 when=-22ms }, with target: android.os.Handler, callback: no callback.

01-10 20:41:48.860 V/ESP_TRACE( 1773): UiControllerImpl: MessageQueue.next(): { 
what=0 when=-19ms }, with target: android.view.Choreographer.FrameHandler, 
callback: android.view.Choreographer$FrameDisplayEventReceiver@b3b2eaa0

01-10 20:41:48.869 V/ESP_TRACE( 1773): UiControllerImpl: MessageQueue.next(): { 
what=0 when=0 }, with target: android.os.Handler, callback: no callback.

01-10 20:41:48.869 V/ESP_TRACE( 1773): UiControllerImpl: MessageQueue.next(): { 
what=0 when=0 }, with target: android.os.Handler, callback: 
android.widget.Toast$TN$1@b3d8d598

01-10 20:41:48.909 V/ESP_TRACE( 1773): UiControllerImpl: MessageQueue.next(): { 
what=0 when=-41ms }, with target: android.view.Choreographer.FrameHandler, 
callback: android.view.Choreographer$FrameDisplayEventReceiver@b3b2eaa0

01-10 20:41:48.969 V/ESP_TRACE( 1773): UiControllerImpl: MessageQueue.next(): { 
what=0 when=-100ms }, with target: android.os.Handler, callback: no callback.

01-10 20:41:48.969 V/ESP_TRACE( 1773): Barrier detected or task avaliable for 
running shortly.

01-10 20:41:48.969 V/ESP_TRACE( 1773): UiControllerImpl: MessageQueue.next(): { 
what=2 when=-36ms arg1=1 
obj=android.graphics.drawable.AnimatedRotateDrawable@b3b8da18 }, with target: 
android.view.Choreographer.FrameHandler, callback: no callback.

01-10 20:41:48.978 V/ESP_TRACE( 1773): Barrier detected or task avaliable for 
running shortly.

01-10 20:41:48.978 V/ESP_TRACE( 1773): UiControllerImpl: MessageQueue.next(): { 
what=107 when=-40ms arg1=-1182164664 }, with target: 
android.webkit.WebViewClassic.PrivateHandler, callback: no callback.

01-10 20:41:48.998 V/ESP_TRACE( 1773): Barrier detected or task avaliable for 
running shortly.

01-10 20:41:48.998 V/ESP_TRACE( 1773): UiControllerImpl: MessageQueue.next(): { 
what=129 when=-60ms arg2=2 }, with target: 
android.webkit.WebViewClassic.PrivateHandler, callback: no callback.

01-10 20:41:48.998 V/ESP_TRACE( 1773): Barrier detected or task avaliable for 
running shortly.

01-10 20:41:48.998 V/ESP_TRACE( 1773): UiControllerImpl: MessageQueue.next(): { 
what=129 when=-61ms arg1=1 arg2=2 }, with target: 
android.webkit.WebViewClassic.PrivateHandler, callback: no callback.

01-10 20:41:48.998 V/ESP_TRACE( 1773): Barrier detected or task avaliable for 
running shortly.

01-10 20:41:48.998 V/ESP_TRACE( 1773): UiControllerImpl: MessageQueue.next(): { 
what=129 when=-61ms }, with target: 
android.webkit.WebViewClassic.PrivateHandler, callback: no callback.

01-10 20:41:48.998 V/ESP_TRACE( 1773): Barrier detected or task avaliable for 
running shortly.

01-10 20:41:48.998 V/ESP_TRACE( 1773): UiControllerImpl: MessageQueue.next(): { 
what=100 when=-59ms }, with target: android.webkit.CallbackProxy, callback: no 
callback.

01-10 20:41:48.998 V/ESP_TRACE( 1773): Barrier detected or task avaliable for 
running shortly.

01-10 20:41:48.998 V/ESP_TRACE( 1773): UiControllerImpl: MessageQueue.next(): { 
what=106 when=-58ms }, with target: android.webkit.CallbackProxy, callback: no 
callback.

01-10 20:41:48.998 V/ESP_TRACE( 1773): Barrier detected or task avaliable for 
running shortly.

01-10 20:41:48.998 V/ESP_TRACE( 1773): UiControllerImpl: MessageQueue.next(): { 
what=0 when=-58ms }, with target: android.webkit.WebViewClassic.PrivateHandler, 
callback: android.webkit.ViewManager$2@b39928c8

01-10 20:41:48.998 V/ESP_TRACE( 1773): Barrier detected or task avaliable for 
running shortly.

01-10 20:41:48.998 V/ESP_TRACE( 1773): UiControllerImpl: MessageQueue.next(): { 
what=0 when=-33ms }, with target: android.view.Choreographer.FrameHandler, 
callback: android.view.Choreographer$FrameDisplayEventReceiver@b3b2eaa0

01-10 20:41:49.028 V/ESP_TRACE( 1773): Barrier detected or task avaliable for 
running shortly.

01-10 20:41:49.028 V/ESP_TRACE( 1773): UiControllerImpl: MessageQueue.next(): { 
what=5 when=-51ms arg1=158 arg2=77 
obj=android.view.ViewRootImpl$ResizedInfo@b3a2d980 }, with target: 
android.view.ViewRootImpl.ViewRootHandler, callback: no callback.

01-10 20:41:49.039 V/ESP_TRACE( 1773): Barrier detected or task avaliable for 
running shortly.

01-10 20:41:49.039 V/ESP_TRACE( 1773): UiControllerImpl: MessageQueue.next(): { 
what=0 when=-47ms }, with target: android.view.Choreographer.FrameHandler, 
callback: android.view.Choreographer$FrameDisplayEventReceiver@b3b2eaa0

01-10 20:41:49.039 V/ESP_TRACE( 1773): Barrier detected or task avaliable for 
running shortly.

01-10 20:41:49.039 V/ESP_TRACE( 1773): UiControllerImpl: MessageQueue.next(): { 
what=0 when=-33ms }, with target: android.view.ViewRootImpl.ViewRootHandler, 
callback: android.view.View$CheckForTap@b3983d08

01-10 20:41:49.039 V/ESP_TRACE( 1773): Barrier detected or task avaliable for 
running shortly.

01-10 20:41:49.039 V/ESP_TRACE( 1773): UiControllerImpl: MessageQueue.next(): { 
what=106 when=-16ms }, with target: android.webkit.CallbackProxy, callback: no 
callback.

01-10 20:41:49.039 V/ESP_TRACE( 1773): Barrier detected or task avaliable for 
running shortly.

01-10 20:41:49.039 V/ESP_TRACE( 1773): UiControllerImpl: MessageQueue.next(): { 
what=129 when=-17ms arg2=2 }, with target: 
android.webkit.WebViewClassic.PrivateHandler, callback: no callback.

01-10 20:41:49.039 V/ESP_TRACE( 1773): Barrier detected or task avaliable for 
running shortly.

01-10 20:41:49.039 V/ESP_TRACE( 1773): UiControllerImpl: MessageQueue.next(): { 
what=129 when=-18ms arg1=1 arg2=2 }, with target: 
android.webkit.WebViewClassic.PrivateHandler, callback: no callback.

01-10 20:41:49.039 V/ESP_TRACE( 1773): Barrier detected or task avaliable for 
running shortly.

01-10 20:41:49.039 V/ESP_TRACE( 1773): UiControllerImpl: MessageQueue.next(): { 
what=129 when=-17ms }, with target: 
android.webkit.WebViewClassic.PrivateHandler, callback: no callback.

01-10 20:41:49.039 V/ESP_TRACE( 1773): Barrier detected or task avaliable for 
running shortly.

01-10 20:41:49.039 V/ESP_TRACE( 1773): UiControllerImpl: MessageQueue.next(): { 
what=131 when=-19ms }, with target: 
android.webkit.WebViewClassic.PrivateHandler, callback: no callback.

01-10 20:41:49.039 V/ESP_TRACE( 1773): Barrier detected or task avaliable for 
running shortly.

01-10 20:41:49.039 V/ESP_TRACE( 1773): UiControllerImpl: MessageQueue.next(): { 
what=125 when=-6ms }, with target: android.webkit.CallbackProxy, callback: no 
callback.

01-10 20:41:49.039 V/ESP_TRACE( 1773): Barrier detected or task avaliable for 
running shortly.

01-10 20:41:49.039 V/ESP_TRACE( 1773): UiControllerImpl: MessageQueue.next(): { 
what=121 when=-7ms obj=notes://// }, with target: android.webkit.CallbackProxy, 
callback: no callback.

01-10 20:41:49.039 V/Unknown Source( 1773): WebViewAnnotator:annotate(WebView) 
- start

01-10 20:41:49.039 V/ESP_TRACE( 1773): Barrier detected or task avaliable for 
running shortly.

01-10 20:41:49.039 V/ESP_TRACE( 1773): UiControllerImpl: MessageQueue.next(): { 
what=125 when=-7ms }, with target: android.webkit.CallbackProxy, callback: no 
callback.

01-10 20:41:49.039 V/ESP_TRACE( 1773): Barrier detected or task avaliable for 
running shortly.

01-10 20:41:49.059 V/ESP_TRACE( 1773): UiControllerImpl: MessageQueue.next(): { 
what=0 when=-32ms }, with target: android.view.Choreographer.FrameHandler, 
callback: android.view.Choreographer$FrameDisplayEventReceiver@b3b2eaa0

01-10 20:41:49.068 V/ESP_TRACE( 1773): Barrier detected or task avaliable for 
running shortly.

01-10 20:41:49.068 V/ESP_TRACE( 1773): UiControllerImpl: MessageQueue.next(): { 
what=0 when=-2ms }, with target: android.view.ViewRootImpl.ViewRootHandler, 
callback: android.webkit.ZoomManager$PostScale@b3c9cf58

01-10 20:41:49.068 V/ESP_TRACE( 1773): UiControllerImpl: MessageQueue.next(): { 
what=4 when=0 }, with target: android.os.Handler, callback: no callback.

01-10 20:41:49.068 V/ESP_TRACE( 1773): UiControllerImpl: MessageQueue.next(): { 
what=0 when=0 }, with target: android.app.ActivityThread.H, callback: 
android.app.LoadedApk$ReceiverDispatcher$Args@b3ad59a8

01-10 20:41:49.098 V/ESP_TRACE( 1773): UiControllerImpl: MessageQueue.next(): { 
what=2 when=-12ms arg1=1 
obj=android.graphics.drawable.AnimatedRotateDrawable@b3b8da18 }, with target: 
android.view.Choreographer.FrameHandler, callback: no callback.

01-10 20:41:49.098 V/ESP_TRACE( 1773): UiControllerImpl: MessageQueue.next(): { 
what=105 when=0 obj=android.webkit.WebViewCore$DrawData@b389e368 }, with 
target: android.webkit.WebViewClassic.PrivateHandler, callback: no callback.

01-10 20:41:49.109 V/ESP_TRACE( 1773): UiControllerImpl: MessageQueue.next(): { 
what=0 when=-10ms }, with target: android.view.Choreographer.FrameHandler, 
callback: android.view.Choreographer$FrameDisplayEventReceiver@b3b2eaa0

01-10 20:41:49.118 V/ESP_TRACE( 1773): UiControllerImpl: MessageQueue.next(): { 
what=123 when=-16ms }, with target: android.webkit.CallbackProxy, callback: no 
callback.

01-10 20:41:49.118 V/ESP_TRACE( 1773): UiControllerImpl: MessageQueue.next(): { 
what=0 when=-16ms }, with target: android.webkit.WebViewClassic.PrivateHandler, 
callback: android.webkit.ViewManager$3@b3ca03f0

01-10 20:41:49.118 V/ESP_TRACE( 1773): UiControllerImpl: MessageQueue.next(): { 
what=0 when=-12ms }, with target: android.view.ViewRootImpl.ViewRootHandler, 
callback: android.webkit.ZoomManager$PostScale@b3a54b40

01-10 20:41:49.118 V/ESP_TRACE( 1773): UiControllerImpl: MessageQueue.next(): { 
what=105 when=0 obj=android.webkit.WebViewCore$DrawData@b3b8f310 }, with 
target: android.webkit.WebViewClassic.PrivateHandler, callback: no callback.

01-10 20:41:49.118 V/ESP_TRACE( 1773): UiControllerImpl: MessageQueue.next(): { 
what=0 when=-13ms }, with target: android.view.Choreographer.FrameHandler, 
callback: android.view.Choreographer$FrameDisplayEventReceiver@b3b2eaa0

01-10 20:41:49.139 V/ESP_TRACE( 1773): UiControllerImpl: MessageQueue.next(): { 
what=0 when=-1ms }, with target: android.os.Handler, callback: no callback.

01-10 20:41:49.139 E/ViewAssertions( 1773): 'is displayed on the screen to the 
user' check could not be performed because view 'is displayed on the screen to 
the user' was not found.

01-10 20:43:43.650 E/cucumber-android( 1773): 
com.google.android.apps.common.testing.ui.espresso.NoMatchingViewException: No 
views in hierarchy found matching: with id: is <2131165564>

01-10 20:43:43.650 E/cucumber-android( 1773): 

01-10 20:43:43.650 E/cucumber-android( 1773): View Hierarchy:

01-10 20:43:43.650 E/cucumber-android( 1773): +>DecorView{id=-1, 
visibility=VISIBLE, width=480, height=117, has-focus=true, has-focusable=true, 
has-window-focus=true, is-clickable=false, 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=0.0, y=0.0, 
child-count=1} 

01-10 20:43:43.650 E/cucumber-android( 1773): |

01-10 20:43:43.650 E/cucumber-android( 1773): +->IconMenuView{id=16908939, 
res-name=icon_menu, visibility=VISIBLE, width=474, height=99, has-focus=true, 
has-focusable=true, has-window-focus=true, is-clickable=false, is-enabled=true, 
is-focused=true, is-focusable=true, is-layout-requested=false, 
is-selected=false, root-is-layout-requested=false, has-input-connection=false, 
x=3.0, y=18.0, child-count=3} 

01-10 20:43:43.650 E/cucumber-android( 1773): |

01-10 20:43:43.650 E/cucumber-android( 1773): +-->IconMenuItemView{id=16908310, 
res-name=title, visibility=VISIBLE, width=157, height=99, 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=0.0, y=0.0, text=Set Alarm, input-type=0, ime-target=false} 

01-10 20:43:43.650 E/cucumber-android( 1773): |

01-10 20:43:43.650 E/cucumber-android( 1773): +-->IconMenuItemView{id=16908310, 
res-name=title, visibility=VISIBLE, width=157, height=99, 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=158.0, y=0.0, text=Edit, input-type=0, ime-target=false} 

01-10 20:43:43.650 E/cucumber-android( 1773): |

01-10 20:43:43.650 E/cucumber-android( 1773): +-->IconMenuItemView{id=16908310, 
res-name=title, visibility=VISIBLE, width=158, height=99, 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=316.0, 

Original comment by K76...@gmail.com on 8 May 2014 at 1:33

GoogleCodeExporter commented 9 years ago
I have produced similar behavior on Nexus 7. Though it seems to be an issue 
common to devices with enabled animations. I have shut them off following guide 
on Espresso home page. As result I had my tasts passed.

https://code.google.com/p/android-test-kit/wiki/Espresso#Setup_your_test_environ
ment

Original comment by tom.kop...@gmail.com on 12 Sep 2014 at 7:09

GoogleCodeExporter commented 9 years ago
As mentioned above, this is likely due to animations being turned on. This is 
currently an unsupported for Espresso.

Original comment by vale...@google.com on 19 Nov 2014 at 9:36

GoogleCodeExporter commented 9 years ago
You can not disable animations here: 
https://code.google.com/p/android-test-kit/wiki/DisablingAnimations

Original comment by jaredsburrows@gmail.com on 4 Aug 2015 at 4:15