automated tests - Android testing: Waited for the root of the view hierarchy to have window focus -


in android ui testing, want click on spinner item in dialog, pop error:

va.lang.runtimeexception: waited root of view hierarchy have window focus , not requesting layout on 10 seconds. if specified non default root matcher, may picking root never takes focus. otherwise, wrong. selected root: root{application-window-token=android.view.viewrootimpl$w@2dac97c7, window-token=android.view.viewrootimpl$w@2dac97c7, has-window-focus=false, layout-params-type=1, layout-params-string=wm.layoutparams{(0,0)(fillxfill) sim=#10 ty=1 fl=#81810100 pfl=0x8 wanim=0x1030461 surfaceinsets=rect(0, 0 - 0, 0) mwfl=0x0}, decor-view-string=multiphonedecorview{id=-1, visibility=visible, width=1600, height=2560, has-focus=true, has-focusable=true, has-window-focus=false, 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}} . roots: root{application-window-token=android.view.viewrootimpl$w@3c913e1, window-token=android.view.viewrootimpl$w@21b23506, has-window-focus=true, layout-params-type=1002, layout-params-string=wm.layoutparams{(310,600)(722x480) gr=#10000033 sim=#1 ty=1002 fl=#1860200 fmt=-3 wanim=0x10302db surfaceinsets=rect(0, 0 - 0, 0) mwfl=0x0}, decor-view-string=popupviewcontainer{id=-1, visibility=visible, width=722, height=480, 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}} root{application-window-token=android.view.viewrootimpl$w@3c913e1, window-token=android.view.viewrootimpl$w@3c913e1, has-window-focus=false, layout-params-type=2, layout-params-string=wm.layoutparams{(0,0)(wrapxwrap) gr=#11 sim=#20 ty=2 fl=#1800002 pfl=0x8 fmt=-3 wanim=0x1030462 surfaceinsets=rect(0, 0 - 0, 0) mwfl=0x10}, decor-view-string=decorview{id=-1, visibility=visible, width=1136, height=1058, has-focus=true, has-focusable=true, has-window-focus=false, 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}} root{application-window-token=android.view.viewrootimpl$w@2dac97c7, window-token=android.view.viewrootimpl$w@2dac97c7, has-window-focus=false, layout-params-type=1, layout-params-string=wm.layoutparams{(0,0)(fillxfill) sim=#10 ty=1 fl=#81810100 pfl=0x8 wanim=0x1030461 surfaceinsets=rect(0, 0 - 0, 0) mwfl=0x0}, decor-view-string=multiphonedecorview{id=-1, visibility=visible, width=1600, height=2560, has-focus=true, has-focusable=true, has-window-focus=false, 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}} @ android.support.test.espresso.base.rootviewpicker.get(rootviewpicker.java:99) @ android.support.test.espresso.viewinteractionmodule.providerootview(viewinteractionmodule.java:69) @ android.support.test.espresso.viewinteractionmodule_providerootviewfactory.get(viewinteractionmodule_providerootviewfactory.java:23) @ android.support.test.espresso.viewinteractionmodule_providerootviewfactory.get(viewinteractionmodule_providerootviewfactory.java:9) @ android.support.test.espresso.base.viewfinderimpl.getview(viewfinderimpl.java:68) @ android.support.test.espresso.viewinteraction$1.run(viewinteraction.java:120) @ java.util.concurrent.executors$runnableadapter.call(executors.java:422) @ java.util.concurrent.futuretask.run(futuretask.java:237) @ android.os.handler.handlecallback(handler.java:739) @ android.os.handler.dispatchmessage(handler.java:95) @ android.os.looper.loop(looper.java:145) @ android.app.activitythread.main(activitythread.java:6117) @ java.lang.reflect.method.invoke(native method) @ java.lang.reflect.method.invoke(method.java:372) @ com.android.internal.os.zygoteinit$methodandargscaller.run(zygoteinit.java:1399) @ com.android.internal.os.zygoteinit.main(zygoteinit.java:1194) 

i have tried

ondata(allof(is(instanceof(string.class)),containsstring("a4"))).inroot(isplatformpopup()).perform(click()); 

and

onview(withtext(containsstring("a4"))).inroot(isfocusable()).check(matches(isdisplayed())); 

and

onview(withtext(containsstring("a4"))).inroot(withdecorview(not(getactivity().getwindow().getdecorview()))).check(matches(isdisplayed())); 

but none of them works... can tell me how ralavant root please?

i had same error, when used spinner inside dialogfragment. code working me:

onview(withtext(containsstring("a4"))).inroot(isplatformpopup()).check(matches(isdisplayed())); 

Comments

Popular posts from this blog

javascript - Thinglink image not visible until browser resize -

firebird - Error "invalid transaction handle (expecting explicit transaction start)" executing script from Delphi -

mongodb - How to keep track of users making Stripe Payments -