In the previous article in this series, we introduced the Monkeyrunner, and mentioned that there are some limitations in the hypothesis that it is possible to write your own active script based on coordinates (click " read the text" at the end to open this article). This article will further describe how to write your own proactive script based on the ID of the control
Manipulating controls based on the ID of the control
Start from Android 2.3.3. Monkeyrunner added the Easymonkeydevice and by of the two classes. They are all in the Com.android.monkeyrunner.easy package, and with these two classes we are able to manipulate the control based on the ID of the control.
In the previous article in this series. We show the Sogou mobile browser after entering the Settings page, the absolute coordinates of the control under different resolutions are not the same.
Let's say we want to click on one of the controls, for example, to replace the skin, use the following method:
The Id/rl_preference_skin is the ID of the control to change the skin, so how do you know what the ID of each control is? Another tool that can be used with ADT Hierarchyviewer
To view the ID of a control using Hierarchyviewer
The executable file of Hierarchyviewer is called Hierarchyviewer.bat, and is under the same folder as Monkeyrunner.bat. This interface will appear after execution
The list of activity in progress, click on the Sogou mobile browser settings interface activity--, to resolve the layout of the entire interface, the process may be slightly slower.
The layout of the app is sometimes very complex. We don't need to find 1.1, we can click on the control we want to see in the lower right corner, and the control will be selected in the control tree on the left.
In the left-hand control tree, the basic information for the control is listed, for example, the control ID that we need.
Finally, it needs to be explained that manipulating the control based on the ID of the control requires the device to turn on Viewserver. Today most of the equipment is not open viewserver, assuming that the viewserver can not be found to open the device, use the simulator bar.
Use ADT's own tools to make Android self-motivated test (iii)