2016-08-12 7 views
8

मेरे पास एक गतिविधि है जहां कुछ संवाद खुला है। इस संवाद पर एक स्पिनर है। मैं इस स्पिनर में किसी विशिष्ट मान का चयन करना चाहते हैं, लेकिन मैं निम्नलिखित अपवाद:डायलॉग में स्पिनर का चयन करते समय एंड्रॉइड एस्प्रेसो में रनटाइम अपवाद

java.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=#3 ty=1 fl=#1810100 wanim=0x10303e5 needsMenuKey=2}, decor-view-string=DecorView{id=-1, visibility=VISIBLE, width=1280, height=752, 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{(91,111)(509x113) gr=#10000033 sim=#1 ty=1002 fl=#1860200 fmt=-3 wanim=0x10302e3 surfaceInsets=Rect(0, 0 - 0, 0) (manual)}, decor-view-string=PopupDecorView{id=-1, visibility=VISIBLE, width=509, height=113, 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=#3 ty=2 fl=#1800002 fmt=-3 wanim=0x10303e6 needsMenuKey=2}, decor-view-string=DecorView{id=-1, visibility=VISIBLE, width=616, height=490, 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=#3 ty=1 fl=#1810100 wanim=0x10303e5 needsMenuKey=2}, decor-view-string=DecorView{id=-1, visibility=VISIBLE, width=1280, height=752, 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) ..... 

मेरे कोड:

protected void selectSpinnerValue(int id, String value) { 
    onView(withId(id)).perform(click()); 
    onData(allOf(is(instanceOf(String.class)), is(value))).perform(click()); 
} 

अपवाद लाइन onData (allof ....)

पर होता है

संवाद में देखने के लिए मैं एस्प्रेसो को कैसे बता सकता हूं?

+0

isPlatformPopup() का उपयोग कर की कोशिश करें, यह विंडो स्पिनर में प्रदान की गई है से मेल खाएगी – jeprubio

+0

धन्यवाद, मैं कैसे इस का उपयोग करते हैं।? ऑनडाटा (isPlatformPopup (allOf (है (exampleOf (String.class)))) काम नहीं कर रहा है – Peter

+1

मैं अब अपने मोबाइल से लिख रहा हूं, मुझे लगता है कि ऑनडाटा ठीक था और एस्प्रेसो ऑनव्यू कोड और कुछ निष्पादित करते समय अपवाद फेंक रहा है जैसे: onView (withId (id))। inRoot (isPlattormPopup())। प्रदर्शन करें (क्लिक करें)); कार्य करना चाहिए। इसे आज़माएं, मैंने पहले इस अपवाद को देखा था। – jeprubio

उत्तर

4

इस प्रयास करें:

onData(allOf(is(instanceOf(String.class)), is(value))) 
    .inRoot(isPlatformPopup()).perform(click()); 
6

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

onView(withText(value)).inRoot(isPlatformPopup()).perform(click()); 
+0

वाह, बहुत बहुत धन्यवाद! वह वास्तव में मेरी समस्या थी –

संबंधित मुद्दे