If an Element appears more than once on the screen, you can differ between its instances by index - with "0" referring to the Highest and Left-most, and as it goes Down and Right - the number grows.
Best practice: As Index differ between visible elements on the screen, it can change according to resolution or page state. It is recommended not to rely on Index to identify elements.
Good approach for element identification is to keep index value = 0 all time while finding a unique identifier for the element.
For the following image Arrow which appears on the IMDB application there are 4 visible instances. To differ between them using Image recognition we will use the element from the repository with the Index as shown on the reflection.
To click the Arrow next to the ‘Your Ratings’ label we will use Index = 1.
Index for xpath identification is similar in nature except it is not zero based
Example:
In the below screenshot, there are 4 buttons on the page having same parent name.
In order to identify the first button, we will use index 1.
xpath=//*[@class='UIRoundedRectButton'][1]