"if" and "while" commands

Command “if”

When you want to test your application or your website, it sometimes happens that the actions to be performed are not exactly the same at each measurement iteration. You can use the "if" command to execute GDSL commands only if a condition exists or does not exist

For example

We want to configure “airbnb” cookies options.

If the popup “Votre vie privée” is displayed, we click on button “Préférences de cookies”

Then we scroll and select cookie “sécurité” and “ cookie “ Airbnb”

Then we click on button “Enregistrer”

 

 

You can do this with this GDSL :

if,exists,text,Votre vie privée clickByText,Préférences de cookies waitUntilText,Votre confidentialité swipeDownward clickByText,Sécurité clickByText,Airbnb clickByText,Enregistrer fi

 

Here are all the "if" commands you can use

# exists text if,exists,text,Votre vie privée # not exists text if,notExists,text,Votre vie privée # exists id if,exists,id,0_183215-toggle-cookie # not exists id if,notExists,id,0_183215-toggle-cookie

 

You could use measureStart and measureStop inside or outside the if/if but be careful to stop all started measurements.

Command “while”

You can use a while command to repeat some actions

For example

We want to delete all sms from the conversation. For this, as long as there is a message, we long click on it and we click on delete it.

You can do this with this GDSL :

while,exists,id,com.google.android.apps.messaging:id/message_text_and_info do longClickById,com.google.android.apps.messaging:id/message_text_and_info waitUntilByIdBeforeClick,com.google.android.apps.messaging:id/action_delete_message waitUntilGoneId,com.google.android.apps.messaging:id/action_delete_message done

Here are all the "while" commands you can use

 

The while loop runs 20 laps maximum. At the end of the 20 laps, if the while condition is not find, an error is launched