GUI based on MSAA under the windows platform tests driving methodOne, technical field
The present invention relates to the GUI test driving method under a kind of windows platform, used GUI operative technique especially, realized the gui program test drive system of a robotization based on MSAA.
Two, background technology
Along with the computer system man-machine interface is more and more graphical, the application of GUI (graphical user interface) becomes more and more widely.But exploitation GUI interactive program great challenge is the problem of how the GUI interface being tested.The GUI test request test driver of robotization can possess certain judgement, can judge the operation that selection should be carried out according to the current environment situation.
Traditional gui program is tested, or carries out actual operation by employing a large amount of test mans, or uses some elementary GUI operation tools, produces inlet flow blindly.Traditional test driving method or expend a large amount of human resources, otherwise anti-jamming capacity is very poor, and one has disturbance will cause entering incorrect state, still needing finally to cause the distribution personnel on duty.
An outstanding automatic GUI test Solution should be able to have the certain reaction ability for performance and the incident of GUI, can judge according to current state, produces corresponding input then.This scheme should require manual intervention as few as possible.
Three, summary of the invention
Technical matters to be solved by this invention provides a kind of GUI test drive system with sight reaction capacity, and it can reduce the manual intervention in the test process of the software with GUI, finishes test case automatically.
GUI test drive system based on MSAA of the present invention, it comprises test script interpreter, environment sensing device and actuator.Script interpreter is used for the test case script that interpreting user is write, and the perceptron that controls environment identification current environment and control action actuator produce input.The step that this program is carried out is as follows:
A) read test drives script: this is written as concrete test script to abstract test case by the tester according to concrete linguistic norm.Script interpreter reads script file in internal memory;
B) carry out environment sensing according to test script: script interpreter is sought satisfactory operating point by the perception requirement of appointment in the environment sensing device execution script;
C) carry out specific action:, produce corresponding action by script interpreter control action actuator if find to meet the operating point of demand.
At above-mentioned steps b) in, the MSAA interface that the environment sensing device uses Windows to provide, and, when finding the window that satisfies condition, return window handle to script according to the IAccessible interface of the object in the conditional search current environment of appointment in the script.
In step c), actuator is set in input focus on the specific window object, and the API that calls Windows then produces mouse or keyboard input.
When writing test script, can use following statement at least:
Statement 1 environment of observation
Find topwnd " title " |
Childwnd " name " " role " " class " |
Anywnd " name " " role " " class " |
Topwnd represents the window of top layer, application program of ordinary representation.As long as header parameter; Childwnd is illustrated under the current window environment, searches the IAccessible of qualified subwindow, three parameters; Anywnd so begin to search the IAccessible interface of subwindow from desktop, three parameters because whom bad definite parent window is
Statement 2 actions
Do kbinput " character string " |
(click|rclick|dbclick)?x?y
Wherein kbinput represents to produce the keyboard input, and " character string " is the string that will import.Following click represents to produce the left mouse button single-click operation, rclick represents to produce the right mouse button single-click operation, dbclick represents to produce the left mouse button double click operation, and last x y represents that this coordinate of coordinate of clicking operation is based on the upper left corner that a find orders the window that finds.The present invention carries out flow process by script interpreter control, obtains qualified environment position by the environment sensing device, produces corresponding input by actuator.Can carry out the operation of robotization to the program in the system of being loaded into by the test script of writing as required.
The present invention compared with prior art, its remarkable advantage is: program for operated object have identification and judgement.So in the process of test, just need manual intervention seldom, improved labour productivity greatly.
Four, description of drawings
Fig. 1 has shown system architecture of the present invention.
Fig. 2-1,2-2,2-3 have shown three groundwork flow processs respectively.
Five, embodiment
1, running environment:
(1) PC of operation Windows system, they are as the platform of program run.
(2) this program is installed and tests drive system on the PC device as GUI.
(3) tested software is loaded on this platform.
(4) the auxiliary test script of writing of the Inspect32 of installation Microsoft.
(5) write test script for test process.
System architecture as shown in Figure 1, it comprises script interpreter, environment sensing device, actuator, described script interpreter is explained the test script program of being write by test procedure person, interface object in running environment by the environment for use perceptron, when the object that satisfies condition occurs, the input that script interpreter again can the usage operation actuator produces keyboard or mouse.
2, scene:
Fig. 2-1 has shown the workflow of the script interpreter of native system.The test that interpretive routine at first reads in appointment drives script, begins to explain sentence by sentence script then.If current statement is the script sentence (promptly seek qualified window object, and return the handle of window object) of a perception environment, carry out corresponding judgment with regard to the transfer environment perceptron so.If one is carried out imperative statement (following usually after a series of environment sensing statements), that is carried out corresponding script with regard to the invoke script actuator and produces input action.
On the PC of mounted Windows and native system, load the application program that to test.Then, be the programming test script.Then the input boldface type partly moves under control desk
C: PCompiler script file name
Then, the script interpretive routine can be carried out test script, seeks qualified window object, produces corresponding operation then.
The flow process of seeking qualified window object is shown in Fig. 2-2.The window system of Windows is to be that root tissue becomes tree structure with the desktop.Seeking qualified window object is to begin search from desktop, obtain the IAccessible interface of current window, obtain the name (IAccessible::get_accName) of window by the method for this IAccessible interface, role (IAccessible::get_accRole), class information such as (WindowFromAccessibleObject and GetObjectClass), the information conforms Rule of judgment, then return the handle of current window, otherwise all the subwindow () IAccessible::get_accChild and the IEnumVARIANT interface of recursive search current window) judge, up to finding window or the exhaustive intact all windows that will look for.
The flow process of carrying out corresponding operating is shown in Fig. 2-3.What judge at first that this statement will carry out is keyboard input or mouse input.If the keyboard input is read input of character string, one by one described all key-press event of input of character string.If mouse input, read the type (left button is clicked, right-click, double-click) of mouse input, import corresponding mouse event then.
3, technical description:
(1)MSAA:
Microsoft Active Accessibility technology has been used in the identification of window elements.This technology exposes unified com interface by the window writing routine below windows platform.Make the programmer can discern and operate standard interface element on the Windows by this interface.
Here window has three important attribute: Name, Class, Role.Name represents the name of window, and Class represents the class name that window is registered in system, and Role represents that the developer gives the role of window.The parent window information that these three attributes and window have been arranged just can uniquely be determined a window.
(2) windows messaging mechanism
On produce action, use the message mechanism of Windows, under the desktop environment of Windows, produce keyboard or mouse input.This process is the API SendInput realization by Windows.