user interface - Espresso: Clicking on Recycler view with unknown position -


i have have list if recycler views in different positions in screen. below enter image description here

  • i want click on specific recycler view based on variable text 'job#' inside it.
  • but cannot perform same not know exact position should click.
  • the position of recycler view keeps changing. tried below code clicks on static position '6'

    recyclerview = onview( allof(withid(r.id.recycler_view), isdisplayed())); recyclerview.perform(actiononitematposition(6, click()));

i want know proper position dynamically.

clicking position in instrumentation tests, in opinion, bad practice leads non-deterministic tests. applicable both recyclerview , adapterview.

so in order not rely on position need itemview matcher recyclerview action.

itemview matcher view matcher matches itemview of viewholder. in case need match linearlayout holds highlighted relativelayout, can represented hasdescendant(withtext("job 109"))

the end solution in case should like:

onview(allof(withid(r.id.recycler_view),isdisplayed())).perform(recyclerview actions.actiononitem(hasdescendant(withtext("job 109")), click()));


Comments

Popular posts from this blog

unity3d - Rotate an object to face an opposite direction -

angular - Is it possible to get native element for formControl? -

javascript - Why jQuery Select box change event is now working? -