Mobile Testing using Android

Purpose

Rapise lets you record and play automated tests against native applications on a variety of mobile devices using either Apple iOS or Android. Rapise gives you the flexibility to test your applications on either real or simulated devices.

This tutorial is a simple example of using Rapise to record and playback a simple test against a sample Android application running on the Android Emulator on your local PC. It does not require any physical mobile devices and only uses the PC that you have already installed Rapise on. (There is other documentation that describes the full range of mobile testing options).

Setting up Environment

The first thing you need to do is install Appium and Android Studio.

Launch Android Virtual Device (AVD) Manager from the menu:

android virtual device menu windows android virtual device manager windows

Use the Create Virtual Device... button to create a Virtual Device. Learn more about how to create and manage virtual devices.

You can then start the device and then connect to it using Rapise.

Configure the Mobile Profile

To begin the actual mobile testing, create a new test, using the File > New Test option in Rapise. Make sure you choose the mobile methodology option Mobile: Mobile Support:

create new test dialog mobile selected

Once you have entered the name for the new test you will be asked to choose the mobile profile. Rapise ships with several default profiles, for now select the one that is closer to the device you want to test (we recommend the Android App Simulator generic profile):

mobile choose profile android generic

When you click the OK button, Rapise will ask you to choose the Scripting Language:

clip0121

Please choose the Rapise Visual Language (RVL). Rapise will then create a new mobile test with the Android App Simulator profile selected.

clip0122

Now you need to modify the profile so that it correctly matches the type of device you are testing and also so that it correctly points to the Appium server that you are using to host the mobile devices. Click ... button in the top right corner of Rapise window

open mobile profile button

to bring up the Mobile Settings dialog box:

mobile settings dialog android tutorial

In the mobile profile screen, make sure you change the following:

Once you have entered in the information and saved the profile, make sure that Appium is running on the PC and then click the Test Url button to verify the connection with Appium:

mobile_settings_dialog_android_success

Using the Mobile Spy

The Mobile Spy will let you view an application running on the mobile device, take a snapshot of its screen and then interactively inspect the objects in the application being tested. This is a useful first step to make sure that Rapise recognizes the application and has access to the objects in the user interface.

If you do not see Mobile Spy button mobile spy button on the toolbar then choose Mobile Spy from the main menu: Tools > Spy > Mobile. Click Mobile Spy button, Mobile Spy will be displayed in Discovery Mode. Now click the Get Snapshot button to display the application specified in the mobile profile on the screen:

spy_dialog_mobile_android

In the example above, we are displaying the sample Android application that is available in AUTAndroid Repository.

If you click on one of objects in the user interface, it will be highlighted in Red and the tree hierarchy on the left will expand to show the properties of that object:

spy_dialog_mobile_android_2

If you want to view the contents of the Spy as a text file, just click Spy > Page Source menu and you will see the contents of the Spy properties window as a text file.

If you want to perform an action on the application (e.g. click on the selected item) use toolbar buttons.

mobile spy event buttons

Now click on Tap and Rapise will send a tap event to the application, switching the application to the next page:

spy_dialog_mobile_android_5

Assuming that you can see your application in the Spy and that the objects can be inspected (similar to that shown above) you can now begin the process of testing your mobile application. Click on Spy > Disconnect menu to end your Spy session and close the Rapise Spy dialog. You will now be returned back to your test script.

Recording and Playing a Test

With the new Rapise mobile test script open, click on the Record button on the toolbar and that will display the recording activity dialog:

recording activity dialog_mobile

Now click on the Spy button and the Rapise Spy will be displayed in Recording Mode:

spy_dialog_mobile_android_3

We now want to record a click on one of the menu options, simply click on the Login button on the screenshot you see in Mobile Spy:

spy_dialog_mobile_android_3

Now click the Tap button to move the sample app to the next screen; Rapise will automatically reload the page in the Mobile Spy to get the updated screen:

spy_dialog_mobile_android_4

Now highlight user name field, put text into the edit field on the toolbar and press Send Keys button. Do the same for password field and record tap action on the Login and Home (back arrow) buttons. You will see the events in the recording activity dialog:

recording activity dialog_mobile_android

Now click on the Finish button and you will be taken back to the test script with the Android objects listed and actions displayed on the RVL sheet:

clip0123

Now to playback the test simply click Play in the Rapise toolbar and the test will play back in the Android Emulator. This is the report of the test being executed.

report_mobile_android

Sample Application and Tests

You can find the Android sample tests and sample Application in AUTAndroid Repository.

See Also