In this chapter, learn about Android app test step by step.
Test scenario
Test the freely available Dropbox mobile app. Our test contains the following steps:
- Start the Dropbox app on the Android device.
- Check if the Dropbox is empty.
- Create a new folder called MyDocuments.
- Create a screenshot of the Dropbox desktop with the folder in it.
- Delete the folder.
- Check if the Dropbox is empty.
- Close the app.
Preparations
Device settings
- Apply the required device settings to your Android device and install the Ranorex Service App.
Connect mobile device
- Connect your mobile device to your computer, preferably via USB, and add it as an endpoint in Ranorex Studio.
Instrument the app
- Download the Dropbox APK from the Dropbox website and instrument it.
Create a Dropbox account
- You need a free Dropbox account. Create one at www.dropbox.com.
Create a solution for mobile testing
-
Create a new solution for mobile testing using the RocketStart wizard.
-
Open the Endpoints pad.
-
Open the recording module Recording1.rxrec.
Ranorex Studio should now look as follows:
-
Empty action table in the recording module
-
Empty repository
-
Your device is in the Endpoints pad.
-
Ranorex Service App running on the mobile device, showing the Dropbox app as instrumented.
Create the test
-
Click RECORD.
-
The dialog for selecting the mobile device and instrumented app appears.
-
Select your Android device and app (the Dropbox app) and click Create.
Setup
Ranorex Studio now executes the following processes to set up mobile test building.
In Ranorex Studio
Ranorex Studio starts the selected app on your mobile device and adds the respective action in the action table.
-
The RUN button changes to reflect that it now runs the test on the current automation root, i.e. the active endpoint/mobile devices, not the computer.
-
An action that starts the app on the mobile device has been added to the action table.
On the mobile device
The instrumented app starts on the mobile device. In our case, this is the Dropbox mobile app.
Ranorex Spy
Ranorex Spy starts in live tracking mode for all UI elements of the instrumented mobile app.
-
Element browser in Spy shows all the UI elements of the instrumented app.
-
Live view of the instrumented app on the mobile device.
Build the recording module
Now we can start filling our recording module with actions.
You can do this using the two-step test-building procedure for mobile tests as explained in detail in Create a mobile test.
Validate that the Dropbox is empty
Step 1: Identify validation text
-
Ensure that the validation text Empty folder is visible on the mobile device.
-
Click Refresh in Spy.
-
Drag the UI element for Empty folder from Spy to the repository in Ranorex Studio.
Step 2: Define validation
-
Drag the new repository item to the last position in the action table.
-
In the context menu that opens, click Validation.
-
Define the Validation action: For Match-Name, select Text and for Match-Value, enter “Empty folder”.
Open the menu
Step 1: Identify UI element
-
Ensure that the button for opening the menu is visible on the mobile device.
-
Click Refresh in Spy.
-
Drag the UI element for the button from Spy to the repository in Ranorex Studio.
Step 2: Define action
-
Drag the new repository item to the last position in the action table.
-
In the context menu that opens, click Touch.
-
The Touch action needs no further definition and is complete.
Creating these first two actions illustrates the 2-step procedure, which remains the same for the following actions. Therefore, the following instructions don’t describe the procedure in quite as much detail.
Create a new folder
The option to create a new folder is located in the breadcrumb menu of the Dropbox app.
-
Add the UI element for the menu option New folder to your repository with Spy.
-
Create a Touch action with this repository item.
-
-
Touch action linked to the repository item for the menu option New folder.
-
Enter folder name and create folder
-
Add the UI elements for the Folder name text field and the Create button to your repository with Spy.
-
Create the following three actions with these repository items:
-
-
Touch action to place the cursor in the text field.
-
Set value action to enter the folder name.
-
Touch action tapping Create to create the folder.
-
If you want to test the functionality of the on-screen keyboard, you can also automate entering the name by a series of touch actions on the keys.
Validate folder
Now, validate that the folder exists. Use image-based validation for this purpose.
-
Add the folder image to your repository with Spy.
-
Create the following action with this repository item.
-
-
Validation action that uses image-based validation.
-
Image-based validation is explained in Ranorex Studio fundamentals > Validation > Image-based validation
Delete folder
Deleting the folder requires that we open a menu, tap the first Delete button, and then tap the second Delete button.
-
Add the three required UI elements to your repository with Spy.
-
Create the following actions with this repository item.
-
Opens the folder menu by tapping the respective symbol.
-
Taps the first Delete button.
-
Taps the second Delete button.
Validate that the folder has been deleted and close app
-
The repository items that we need already exist. Use them to create the following two actions.
-
Validates that the Dropbox home screen is empty (a simple copy of action #2).
-
Closes the app.
Completed recording module
If you followed our instructions, your completed recording should look like this:
You can now switch to the test suite view and run the test. However, in a real-life scenario, the test wouldn’t be quite finished here. The next step would be to modularize the recording and structure the test suite.
The concepts of modularizing and structuring apply to all recording modules and test suites, whether for desktop, web, or mobile tests.
Managing recording modules is explained in:
- Ranorex Studio fundamentals > Ranorex Studio Overview > Manage recording modules
Structuring a test suite is explained in:
- Ranorex Studio fundamentals > Ranorex Studio Overview > Test suite structure
A step-by-step example of building a full test suite is available in:
- Ranorex Studio fundamentals > Ranorex Studio Overview > Build a test