Sample Test in Appium

Price: INR 8,999.00
Price: INR 14,999.00
Was: INR 16,999.00

Let’s see, How can you create Sample test in Appium. In the previous tutorial, You have seen How can you locate the Multiple Elements in Appium.


In this tutorial, we will see how can we manage the Complex elements. Sometimes we need to find the elements within elements.

We will see the example of Whats App. You will see, how can you manage the Elements within the other elements.


Let’s see our First Appium Test Case.

Test Case  – Open WhatsApp and print the name of all your chat contacts.


To implement the script, you need to open UI Automator and capture the screen shot of WhatsApp home page.

Now you will see, All chat container have the same ID (com.whatsapp:id/contact_row_container) & container don’t have any value in the attribute ‘Text‘.


You can find this in below-attached image.

Appium Test

Now the question is how can we get the Text of our chats.


For this, we need to find the element present within this element i.e inner element within outer element.

We have inner elements in Whats app, You can see in the Attached image.

Appium Sample Test


You can see, this inner element has the value for attribute ‘text’. Now let’s implement the test with this element.

Id & class of each and every row is same for all records.

record -id – com.whatsapp:id/conversations_row_contact_name

class – android.widget.TextView


Now let’s implement the script, which print each and every chat contact name also open the chat and close it.

The above code will open the WhatsApp and print the Name of your chat contacts and click on each and then come back to the Home screen.


To come back on home screen, you need to press back button on your device. We can do this with the help of AndroidKeyCode class in Appium. So to press the Back key in Android the command would be like –

((AndroidDriver) driver).pressKeyCode(AndroidKeyCode.BACK);


This script will work for only visible chat contacts i.e the chat contacts which are not visible without scroll the screen will not be print and clicked by this script.

Please copy the code and Run on your local machine.

0 Comment

Leave a Reply