Android EspressoTest match navigationDrawer item with position -


i want open navigation drawer , click specific position item code below.

private void clickmenu(int position) {     onview(withid(r.id.drawer_layout))             .perform(actionopendrawer());      ondata(is(instanceof(navdraweritem.class)))             .inadapterview(withid(r.id.navigation_list))             .atposition(position).perform(viewactions.click()); } 

current shows no matches.

android.support.test.espresso.nomatchingviewexception: no views in hierarchy found matching: id: com.trumpia.android.loyaltea.debug:id/navigation_list if target view not part of view hierarchy, may need use espresso.ondata load 1 of following adapterviews:android.widget.listview{3bb66aad vfed.vc. .f...... 0,0-720,1533 #7f0f008c app:id/navigation_drawer} - android.widget.listview{22585c25 gfed.vc. ......i. 0,0-0,0 #102000a android:id/list} 

or other error below

caused by: java.lang.runtimeexception: action not performed because target view not match 1 or more of following constraints: (is assignable class: class android.widget.adapterview , displayed on screen user) target view: "listview{id=2131689612, res-name=navigation_drawer, visibility=invisible, width=720, height=1533, has-focus=false, has-focusable=false, 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=-720.0, y=0.0, child-count=5}" 

it seems there inconsistent between each running. because drawer not opened? how can guarantee drawer opened?

if comment .inadapterview line then, matches 2 item below.

+--------->listview{id=16908298, res-name=list, visibility=gone, width=0, height=0, has-focus=false, has-focusable=false, has-window-focus=true, is-clickable=true, is-enabled=true, is-focused=false, is-focusable=true, is-layout-requested=true, is-selected=false, root-is-layout-requested=false, has-input-connection=false, x=0.0, y=0.0, child-count=0} ****matches**** ... +------>listview{id=2131689612, res-name=navigation_drawer, visibility=visible, width=720, height=1533, has-focus=true, has-focusable=true, has-window-focus=true, is-clickable=true, 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=-1.0, y=0.0, child-count=5} ****matches**** 

is there way match navigation drawer item item position? can match text item order matter in case.

well, changed adapterview's resource name r.id.navigation_drawer r.id.navigation_list. , update espresso core 2.2 2.0, works well.

private void clickmenu(int position) {     onview(withid(r.id.drawer_layout))             .perform(actionopendrawer());       ondata(is(instanceof(navdraweritem.class)))              .inadapterview(withid(r.id.navigation_drawer))             .atposition(position).perform(viewactions.click()); } 

navigationdrawerfragment replaced r.id.navigation_drawer fragment mainactivity. , navigationdrawerfragment has r.id.navigation_list listview.


Comments

Popular posts from this blog

python - Healpy: From Data to Healpix map -

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -