Search methods
1 - Introduction
Sometimes, some elements of the view can’t be directly found or clicked because they have no useful id, text, description or class.
You can find another element (parent or child) to access the item you are looking for by the path of the elements in the dump hierarchy of the view.
Every command of type Find put in memory the last element found. Another command which finish with LastElementFound
can be used, for example you can use the clickOnLastElementFound
command to click on the last element found.
2 - List search commands
3 - Use case
Use case 1 : Click on the second element with the same text
I want to click on the second button with the text “Découvrez”
findByText,Découvrez,2
clickOnLastElementFound
Use case 2 : Navigate to the elements of the view to find the good object
Here in the site sncf-connect, we want to directly set text on the Edit Text to fill the departure.
As we can see in the image, the field has no text, content-desc and the resource-id may be shuffle. The field has eventually a class but we decide for the example to navigate on the view to find the interesting element.
# Let's find the 'Départ' libelle
findByText,Départ
# go to the first parent
findParentLastElementFound
# go to the second parent
findParentLastElementFound
# then go to the 2th element (index 1) of the parent to find the EditText
findChildByIndexLastElementFound,1
# set the text directly
setTextLastElementFound,Paris