TestProject Forum
Powered by leading experts in the test automation community

Selecting element that have no unique identifiers

hello @ran.tzur
Suppose i have four same elements A on one screen.
all four elements have same resource-ids,classname i.e no unique identifiers
can i select the element on the base of its instance without using tree(xpath)?
i want to select the element at first instance or second/third/fourth instance?
is it possible? if possible how can i do that?

Hello @ahmad
The best way to achieve it is by selecting the element you want within the locator strategy.
If you are using XPATH for example, you can use array notation.

For example:
Will select the second element.

HELLO @ran.tzur
in android the xpath for element using tree is like something like this

locator is not able to find the element as the tree structure is continuously changing and there are no unique identifiers
without approaching the developer how can i handle it ?

You will need to find some parent element which has a static value, maybe text or another attribute, and from there traverse to the element you are searching for.

You can use the Element Explorer to check for the element that can help you.


1 Like