android studio - Code generated by Record Espresso Test for recycler view throwing an exception -




i want match title of recycler view custom text so, used android studio built in tool "record espresso test", after adding assertion when try run test file throws exception. following code generated espresso record tool

 @test   public void mainactivitytest() {     viewinteraction textview = onview(             allof(withid(r.id.title_text_view), withtext("making way downtown, walking fast..."),                     childatposition(                             allof(withid(r.id.post_parent_layout),                                     childatposition(                                     withid(r.id.posts_recycler_view),                                             0)),2),isdisplayed()));     textview.check(matches(withtext("making way downtown, walking fast...")));  }  private static matcher<view> childatposition(         final matcher<view> parentmatcher, final int position) {      return new typesafematcher<view>() {         @override         public void describeto(description description) {             description.appendtext("child @ position " + position + " in parent ");             parentmatcher.describeto(description);         }          @override         public boolean matchessafely(view view) {             viewparent parent = view.getparent();             return parent instanceof viewgroup && parentmatcher.matches(parent)                     && view.equals(((viewgroup) parent).getchildat(position));         }     }; } 

************* exception ***********************

android.support.test.espresso.nomatchingviewexception: no views in hierarchy found matching: (with id: com.rajasaboor.redditclient:id/user_name_text_view , text: "king_o" , child @ position 3 in parent (with id: 2131558575 , child @ position 0 in parent id: 2131558533) , displayed on screen user)  view hierarchy: +>decorview{id=-1, visibility=visible, width=1440, height=2560, 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=3} | +->linearlayout{id=-1, visibility=visible, width=1440, height=2392, 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=2} | +-->viewstub{id=16909287, res-name=action_mode_bar_stub, visibility=gone, width=0, height=0, has-focus=false, has-focusable=false, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=true, is-selected=false, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0} | +-->framelayout{id=-1, visibility=visible, width=1440, height=2296, 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=96.0, child-count=1} | +--->fitwindowslinearlayout{id=2131558503, res-name=action_bar_root, visibility=visible, width=1440, height=2296, 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=2} | +---->viewstubcompat{id=2131558504, res-name=action_mode_bar_stub, visibility=gone, width=0, height=0, has-focus=false, has-focusable=false, has-window-focus=true, is-clickable=false, is-enabled=true, is-focused=false, is-focusable=false, is-layout-requested=true, is-selected=false, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0} | +---->contentframelayout{id=16908290, res-name=content, visibility=visible, width=1440, height=2296, 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} | +----->constraintlayout{id=2131558529, res-name=main_parent_layout, visibility=visible, width=1440, height=2296, 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=3} | +------>toolbar{id=2131558530, res-name=toolbar_include, visibility=visible, width=1440, height=224, has-focus=false, 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=3} | +------->progressbar{id=2131558582, res-name=menu_progress_bar, visibility=visible, width=224, height=224, has-focus=false, has-focusable=false, 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=992.0, y=0.0} | +------->appcompattextview{id=-1, visibility=visible, width=457, height=107, has-focus=false, has-focusable=false, 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=64.0, y=58.0, text=reddit client, input-type=0, ime-target=false, has-links=false} | +------->actionmenuview{id=-1, visibility=visible, width=224, height=224, has-focus=false, 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=1216.0, y=0.0, child-count=1} | +-------->actionmenuitemview{id=2131558585, res-name=refresh_post_list_menu, desc=refresh, visibility=visible, width=224, height=192, 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=16.0, text=, input-type=0, ime-target=false, has-links=false} | +------>appcompattextview{id=2131558531, res-name=no_offline_data_text_view, visibility=visible, width=774, height=97, has-focus=false, has-focusable=false, 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=333.0, y=1206.0, text=no offline data available, input-type=0, ime-target=false, has-links=false} | +------>swiperefreshlayout{id=2131558532, res-name=swipe_layout, visibility=visible, width=1440, height=2072, 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=224.0, child-count=2} | +------->circleimageview{id=-1, visibility=gone, width=160, height=160, has-focus=false, has-focusable=false, 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=640.0, y=-160.0} | +------->recyclerview{id=2131558533, res-name=posts_recycler_view, visibility=visible, width=1440, height=2072, 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=0.0, y=0.0, child-count=0} | +->view{id=16908336, res-name=navigationbarbackground, visibility=visible, width=1440, height=168, has-focus=false, has-focusable=false, 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=2392.0} | +->view{id=16908335, res-name=statusbarbackground, visibility=visible, width=1440, height=96, has-focus=false, has-focusable=false, 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} | @ dalvik.system.vmstack.getthreadstacktrace(native method) @ java.lang.thread.getstacktrace(thread.java:1566) @ android.support.test.espresso.base.defaultfailurehandler.getuserfriendlyerror(defaultfailurehandler.java:92) @ android.support.test.espresso.base.defaultfailurehandler.handle(defaultfailurehandler.java:56) @ android.support.test.espresso.viewinteraction.runsynchronouslyonuithread(viewinteraction.java:184) @ android.support.test.espresso.viewinteraction.check(viewinteraction.java:158) @ com.rajasaboor.redditclient.mainactivitytest.mainactivitytest(mainactivitytest.java:44) @ java.lang.reflect.method.invoke(native method) @ org.junit.runners.model.frameworkmethod$1.runreflectivecall(frameworkmethod.java:50) @ org.junit.internal.runners.model.reflectivecallable.run(reflectivecallable.java:12) @ org.junit.runners.model.frameworkmethod.invokeexplosively(frameworkmethod.java:47) @ org.junit.internal.runners.statements.invokemethod.evaluate(invokemethod.java:17) @ android.support.test.internal.statement.uithreadstatement.evaluate(uithreadstatement.java:55) @ android.support.test.rule.activitytestrule$activitystatement.evaluate(activitytestrule.java:270) @ org.junit.rules.runrules.evaluate(runrules.java:20) @ org.junit.runners.parentrunner.runleaf(parentrunner.java:325) @ org.junit.runners.blockjunit4classrunner.runchild(blockjunit4classrunner.java:78) @ org.junit.runners.blockjunit4classrunner.runchild(blockjunit4classrunner.java:57) @ org.junit.runners.parentrunner$3.run(parentrunner.java:290) @ org.junit.runners.parentrunner$1.schedule(parentrunner.java:71) @ org.junit.runners.parentrunner.runchildren(parentrunner.java:288) @ org.junit.runners.parentrunner.access$000(parentrunner.java:58) @ org.junit.runners.parentrunner$2.evaluate(parentrunner.java:268) @ org.junit.runners.parentrunner.run(parentrunner.java:363) @ org.junit.runners.suite.runchild(suite.java:128) @ org.junit.runners.suite.runchild(suite.java:27) @ org.junit.runners.parentrunner$3.run(parentrunner.java:290) @ org.junit.runners.parentrunner$1.schedule(parentrunner.java:71) @ org.junit.runners.parentrunner.runchildren(parentrunner.java:288) @ org.junit.runners.parentrunner.access$000(parentrunner.java:58) @ org.junit.runners.parentrunner$2.evaluate(parentrunner.java:268) @ org.junit.runners.parentrunner.run(parentrunner.java:363) @ org.junit.runner.junitcore.run(junitcore.java:137) @ org.junit.runner.junitcore.run(junitcore.java:115) @ android.support.test.internal.runner.testexecutor.execute(testexecutor.java:59) @ android.support.test.runner.androidjunitrunner.onstart(androidjunitrunner.java:262) @ android.app.instrumentation$instrumentationthread.run(instrumentation.java:1939) 





wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -