Android   发布时间:2022-04-28  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了Android测试:等待视图层次结构的根目录具有窗口焦点大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
Android Ui测试中,我想在对话框中单击一个微调器项,但是会弹出以下错误
va.lang.RuntimeException: Waited for the root of the view hierarchy to have window focus and not be requesTing layout for over 10 seconds. If you specified a non default root matcher,it may be picking a root that never takes focus. Otherwise,something is serIoUsly 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,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}}
. All 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,decor-view-String=PopupViewContainer{id=-1,width=722,height=480,child-count=1}}
Root{application-window-token=android.view.ViewRootImpl$W@3c913e1,window-token=android.view.ViewRootImpl$W@3c913e1,layout-params-type=2,0)(wrapxwrap) gr=#11 sim=#20 ty=2 fl=#1800002 pfl=0x8 fmt=-3 wanim=0x1030462 surfaceInsets=Rect(0,0) mwfl=0x10},decor-view-String=DecorView{id=-1,width=1136,height=1058,child-count=1}}
Root{application-window-token=android.view.ViewRootImpl$W@2dac97c7,child-count=1}}
at android.support.test.espresso.base.RootViewPicker.get(RootViewPicker.java:99)
at android.support.test.espresso.ViewInteractionModule.provideRootView(ViewInteractionModule.java:69)
at android.support.test.espresso.ViewInteractionModule_ProvideRootViewFactory.get(ViewInteractionModule_ProvideRootViewFactory.java:23)
at android.support.test.espresso.ViewInteractionModule_ProvideRootViewFactory.get(ViewInteractionModule_ProvideRootViewFactory.java:9)
at android.support.test.espresso.base.ViewFinderImpl.getView(ViewFinderImpl.java:68)
at android.support.test.espresso.ViewInteraction$1.run(ViewInteraction.java:120)
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:739)
at android.os.Handler.dispatchmessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:145)
at android.app.ActivityThread.main(ActivityThread.java:6117)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194)

我试过了

onData(allOf(is(instanceOf(String.class)),containsString("A4"))).inRoot(isPlatformPopup()).perform(click());

onView(withText(containsString("A4"))).inRoot(isFocusable()).check(matches(isDisplayed()));

onView(withText(containsString("A4"))).inRoot(withDecorView(not(getActivity().getWindow().getDecorView()))).check(matches(isDisplayed()));

但它们都不起作用……
有人能告诉我如何获得ralavant root吗?

解决方法

当我在DialogFragment中使用Spinner时,我遇到了同样的错误.
这是唯一适合我的代码
onView(withText(containsString("A4"))).inRoot(isPlatformPopup()).check(matches(isDisplayed()));

大佬总结

以上是大佬教程为你收集整理的Android测试:等待视图层次结构的根目录具有窗口焦点全部内容,希望文章能够帮你解决Android测试:等待视图层次结构的根目录具有窗口焦点所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。