You can create scripts for monitoring native applications on mobile devices by leveraging the API calls and HTTP requests from the mobile app.
Identify APIs and HTTP requests to monitor
Consult with the app developers to identify the API calls and HTTP requests that represent key user activities.
Review the Scripting best practices as you plan the tests for monitoring the key user activities. For example, create a separate test for each user activity so you can more easily identify the specific activity associated with any performance issues.
In the Dynatrace Recorder, use the File > New Script command to manually create scripts. See Using the New Script command for details.
Configure the script profile
Best Practice is to select a Mobile Device profile for monitoring your mobile application.
- Select Mobile Device.
- Click Select device to open the Device Manager.
- Expand the device brand and select the device from the list, then click OK to save the selection and close the Device Manager.
- Click the add button to the right of the Parameters field to add a row for each parameter.
- Type the Name and Default Value for the parameter in the fields.
- The parameters are saved automatically.
Add actions to the script
To add an action to the script timeline:
- Hover over the separator line until it becomes a plus sign .
- Click the plus sign to display the actions list.
- Click the action to add it to the timeline.
For more information, see Editing script actions.
You will typically use these actions to construct a mobile app script:
- HTTP action for the API call or HTTP request.
- Wait action, as needed, for the time needed to complete network activity before executing the next action.
- Validate action as needed to confirm that the user activity was performed successfully.
See the example script, below, for details of defining these actions in your script.
Organize the actions into logical steps with descriptive names. For example, create a new step for each HTTP request, as shown in the example script.
Test the script
Play back the script to make sure the tests you provision will run successfully.
When the script is complete, upload the script to the Dynatrace Portal.
This example script consists of two steps: It authenticates the user, and then displays a user-specific dashboard.
The parameters used in the actions are defined in the Parameters tab.
Each HTTP action is configured with the HTTP request.
Note the syntax of the POST statement in the first figure:
- The parameters are identified by the prefix
- Multiple statements can be combined, with a plus sign ( + ) between them.
The Wait actions ensure that network activity is completed before the next action is executed.
In the second step, the Validate action confirms that the dashboard is correctly loaded by checking that the Match Text appears in the page.