Use ADT's own tools to make Android self-motivated test (iii)

Source: Internet
Author: User

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.