Multiple approaches to locate to a particular position of an element in Espresso when having multiple same ID

Save

In Espresso when we have to locate to a particular position of an element and there are multiple element of having same id then we can do it by the following approaches :-

  1. Through Custom index we can locate to an element by the index of that element.
  2. In Recycler view when we want to locate an element where the element not having unique id.

 

  1. Through Custom index  we can locate to an element by the index value of that element.

In this we have to create a custom index :-

And like this we have to use it :-

Here the “button_id” is the id where we want to perfom a click action and “0” is the index position of that element.

   2.  In Recycler view when we want to locate an element where the element not having unique id.

Then we using this class in code like this:-

here “my_recycler_view” is the id of recycler view and “0” is the position where we want to click that button and 
button-id” is the id of the button on which we have to perform the click.

Here is the class “MyViewAction“:-

By using this technique you can easily locate to your location When there are multiple same id buttons.

I hope this will help you when you face “multiple match” problem in Espresso.

 

 

 

 

 

. . .

Leave a Comment

Your email address will not be published. Required fields are marked*


Be the first to comment.

css.php

Webkul is a truly trusted and supported IT Company to develop business ideas for e-commerce. They provide professional support after deploying the solution to production and be responsible to act for fixing the reported issues or system errors. We highly encourage to deal with Webkul for business development.

Hussein Zawia

Hussein Zawia

Co-founder, 24Dokan

Talk to Sales

Global

Live Chat
Start a Project


    Message Sent!

    If you have more details or questions, you can reply to the received confirmation email.

    Back to Home