Unlock instant, AI-driven research and patent intelligence for your innovation.

A method and device for acquiring a control

A technology for obtaining controls and controls, applied in the computer field, can solve the problems of reduced automation coverage, inability to automate functions or scenes, and inability to obtain encapsulated control sub-controls, and achieve the effect of improving automation coverage.

Active Publication Date: 2017-03-15
TENCENT TECH (SHENZHEN) CO LTD
View PDF3 Cites 0 Cited by
  • Summary
  • Abstract
  • Description
  • Claims
  • Application Information

AI Technical Summary

Problems solved by technology

In the existing Android automation test, the Android system generally obtains the specific control of the current interface by calling the FindViewById() function, but the FindViewById() function is only for the non-encapsulated control (ie, the basic control) of the Android system; for the packaged control, Calling the FindViewById() function cannot obtain the sub-controls in the encapsulated control of the current interface, so it cannot trigger related operations on the sub-controls to realize automated testing, and can only terminate Android automated testing
[0004] In the process of realizing the present invention, the inventor finds that there are at least the following problems in the prior art: in the existing Android automation test, the FindViewById () function called by the Android system can only obtain the non-encapsulated control (i.e. the basic control) of the current interface, and cannot Get the sub-controls in the encapsulation control of the current interface, so that some functions or scenarios in the Android automation test cannot be automated, and the automation coverage rate is reduced

Method used

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
View more

Image

Smart Image Click on the blue labels to locate them in the text.
Viewing Examples
Smart Image
  • A method and device for acquiring a control
  • A method and device for acquiring a control
  • A method and device for acquiring a control

Examples

Experimental program
Comparison scheme
Effect test

Embodiment 1

[0027] refer to figure 2 , figure 2 It is a flowchart of a method embodiment for obtaining a control provided in Embodiment 1 of the present invention; this embodiment is applied in an Android automated test, and the method for obtaining a control includes:

[0028] S101: According to the Java reflection mechanism, dynamically obtain the first basic control and the first encapsulated control of the current interface.

[0029] S102: Recursively traverse the second basic control in the first packaged control, and use the first basic control and the second basic control as a third basic control.

[0030] S103: Obtain visible controls of the current interface according to the third basic control.

[0031] S104: Find and acquire a basic control conforming to predetermined attribute information from the visible controls of the current interface.

[0032] In the Android automation test in this embodiment, all the basic controls of the current interface are obtained by recursivel...

Embodiment 2

[0034] refer to image 3 , image 3 It is a flow chart of a method embodiment for obtaining a control provided in Embodiment 2 of the present invention; this embodiment is applied in an Android automated test, and the method for obtaining a control includes:

[0035] S201: According to the Java reflection mechanism, dynamically acquire the first basic control and the first encapsulated control of the current interface.

[0036] The method of dynamically obtaining information and dynamically calling objects is called the java reflection mechanism; the Java reflection mechanism mainly provides the following functions: judging the class to which any object belongs at runtime; constructing an object of any class at runtime; judging any class at runtime The member variables and methods of the class; call the method of any object at runtime; generate dynamic proxy.

[0037] In the Android system, when the application program is running, the application program's response to the us...

Embodiment 3

[0071] refer to Figure 5 , Figure 5 It is a schematic structural diagram of an embodiment of an apparatus for acquiring controls provided in Embodiment 3 of the present invention; the apparatus for acquiring controls includes:

[0072] The dynamic acquisition module 301 is configured to dynamically acquire the first basic control and the first packaged control of the current interface according to the Java reflection mechanism.

[0073] The third basic control obtaining module 302 is configured to recursively traverse the second basic control in the first packaged control, and use the first basic control and the second basic control as a third basic control.

[0074] The visible control acquiring module 303 is configured to acquire the visible controls of the current interface according to the third basic control.

[0075] Obtaining module 304: configured to search for and obtain basic controls conforming to predetermined attribute information among the visible controls of...

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
Login to View More

PUM

No PUM Login to View More

Abstract

The invention discloses a method and a device for obtaining a control and belongs to the technical field of computers. The method for obtaining the control includes the steps: according to a java reflex mechanism, obtaining a first basic control and a first sealing control which are on a current interface in a dynamic mode; traversing a second basic control in the first sealing control in a recursion mode, and enabling the first basic control and the second basic control to be used as a third basic control; according to the third basic control, obtaining a visual control of the current interface; and looking up and obtaining a basic control which satisfies predetermined attribute information in the visual control of the current interface. The method and the device for obtaining the control can fully achieve android automatic testing and enable automation coverage rate to be improved.

Description

technical field [0001] The invention relates to the field of computer technology, in particular to a method and device for acquiring controls in Android automated testing. Background technique [0002] With the widespread use of the Android system in the field of mobile phones, Android automated testing for mobile phones is becoming more and more important. At present, most of the Android automation tests are control-based automation tests. By obtaining the specific controls of the current interface, and then triggering related operations on the controls to simulate human operations, the automation effect is achieved. [0003] The controls in the Android system are all inherited from the base class View, and the controls include basic controls and encapsulation controls; the encapsulation control includes multiple sub-controls, and the encapsulation control is a control that encapsulates multiple sub-controls together, such as figure 1 As shown, each of the sub-controls can...

Claims

the structure of the environmentally friendly knitted fabric provided by the present invention; figure 2 Flow chart of the yarn wrapping machine for environmentally friendly knitted fabrics and storage devices; image 3 Is the parameter map of the yarn covering machine
Login to View More

Application Information

Patent Timeline
no application Login to View More
Patent Type & Authority Patents(China)
IPC IPC(8): G06F11/36
Inventor 丁如敏
Owner TENCENT TECH (SHENZHEN) CO LTD