Advanced search commands

Redirection

Up TO DATE

Sometimes some elements of the view can’t be directly found or clicked, for example the element I want to click as no usefull id, text, content-desc or class. In these cases you can use advanced search commands.

The key is to used the command of the group Find in GDSL documentation and used the path of the elements in the dump hierarchy of the view. Since the item you are looking for is not easy to find directly, you can find another element (parent or child) to access the item you are looking for. Every command of type Find put in memory the last element found, so another command which finish with ‘LastElementFound’ can be used, for example you can use the clickOnLastElementFoundcommand to click on the last element found.

 

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

 

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