2016-09-12 6 views
5

के लिए एंड्रॉयड 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{[email protected], [email protected], 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}} 
. All Roots: 
Root{[email protected], [email protected], 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{[email protected], [email protected], 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{[email protected], [email protected], 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}} 
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())); 

और

0,123,516 की कोशिश की है
onView(withText(containsString("A4"))).inRoot(withDecorView(not(getActivity().getWindow().getDecorView()))).check(matches(isDisplayed())); 

लेकिन उनमें से कोई भी काम नहीं करता है ... क्या कोई मुझे बता सकता है कि रालवंत रूट कैसे प्राप्त करें?

उत्तर

1

मैं एक ही त्रुटि थी, जब मैं एक DialogFragment अंदर एक स्पिनर का इस्तेमाल किया। यह केवल कोड है कि मेरे लिए काम कर रहा था है:

onView(withText(containsString("A4"))).inRoot(isPlatformPopup()).check(matches(isDisplayed())); 
+0

यह हल मेरी समस्या है जब एक 'AlertDialog' अंदर एक स्पिनर के प्रयोग से। –

1

शायद ज़रुरत पड़े अगर यह (ठीक उसी लॉग के साथ) किसी की ट्रैविस निर्माण होता है। this की जांच करें।

वही समस्या ठीक थी, और द्वारा हल किया गया था जो निम्न लक्ष्य संस्करण (1 9) के साथ एवीडी बना रहा था।

मैं क्या कोशिश की है और काम नहीं किया:

  • यूआई परीक्षण करने के लिए एक unlockScreen()@Before विधि जोड़ना।

  • adb shell input keyevent 82 & जोड़ना/निकालना।

  • अलग emulator आदेश विकल्पों -no-skin या -no-audio या -no-window निकाला जा रहा है। अब मैं -no-window वहाँ जो ठीक है।

अंत में,

echo no | android create avd --force -n test -t android-24 --abi armeabi-v7a 

से बदल रहा है

echo no | android create avd --force -n test -t android-19 --abi armeabi-v7a 

को पूरी तरह से इस मुद्दे को हल।

0

सिर्फ travis.yml में निर्माण उपकरणों को अद्यतन:

  • इस फाइल .travis.yml में: आप .travis.yml में इस before_install: - echo yes | android update sdk --all --filter build-tools-26.0.1 --no-ui --force
  • इस wel के रूप में
  • होना चाहिए:
script: echo no | android create avd --force -n test -t android-22 
--abi armeabi-v7a emulator -avd test -no-audio -no-window & 
android-wait-for-emulator 
adb shell settings put global window_animation_scale 0 & 
adb shell settings put global transition_animation_scale 0 & 
adb shell settings put global animator_duration_scale 0 & 
adb shell input keyevent 82 & 
संबंधित मुद्दे