A kind of user interface automated testing method and system
Technical field
The present invention relates to using testing field more particularly to a kind of user interface automated testing method and system.
Background technique
User interface (User Interface, abbreviation UI) test generally comprises layout test, content test (including text
And picture), Fabric Hand Test, the contents such as components testing.For test objects such as layout, content style, fonts, static state is generallyd use
Mode is tested, such as the mode of point of use inspection table combination artificial observation obtains test result.And in user interface
For space, due to its characteristic with human-computer interaction, can provide a user such as interface jump, switch control, text it is defeated
The interaction sexual function such as enter, needs to test UI using dynamical fashion.
The existing dynamic test for UI usually requires tester and writes test case, to measurand, test mode,
The contents such as expected results are bound, and are then executed the test case by test terminal and are completed to test UI.Write test case
Usually quite time-consuming, tester, which generally requires to take a significant amount of time, to be programmed and modifies to test case, in practical application
Excessively labor intensive cost.
Recording and playback (Record and Replay) is a kind of UI automatic test approach simple to operation.But it is logical
The mode for crossing recording and playback carries out UI and tests that there are drawbacks automatically:
First, the test script " nonsense " of recording is more.Such as mouse is moved, original final purpose is moved to A point, still
In recording process, the place that mouse can be passed through all be recorded, and lead to the redundant code of very much " useless ".
Second, the script of recording is inefficient.It since midway is very much " nonsense ", and is in the form of the operation for playing back people
Carry out loop test;The efficiency of the manual operation of people is certainly not fast enough, so inefficient.
The script of third, recording does not have versatility.It is typically only capable to use on a computer, because in different computers
Its coordinate system referred to is different.Cause accurately find the object to be operated when playback.
The mostly important something of UI automatic test is exactly to obtain the control object to be operated, such as one
Textbox, button etc..Object can must be first obtained, it can operation object.This is exactly to record test script in fact
Sole purpose, being accurately obtained and recording object is the key that automatic test.
Currently, many automated test tools are to click the input actions such as mouse by record when recording test script
Screen coordinate and the information of the region control realize the function of recording, and in this, as playback when obtains the key of object
Condition.This recording mode information collected is relatively isolated, and in record data in a manner of a kind of onrelevant.Once coordinate
It changes, it is easy to the case where can not find object occur.
Summary of the invention
In view of the above-mentioned problems existing in the prior art, the invention proposes a kind of user interface automated testing methods.
The present invention adopts the following technical scheme that:
A kind of user interface automated testing method comprising:
Step 1 obtains the recording process of test script;
Step 2 executes the replayed section of test operation according to the test script;
Wherein, the test script includes the sequence of the input action recorded by the chronological order of generation, the record
Input action sequence described in process record processed, the replayed section are executed in the test script according to chronological order and are recorded
Input action sequence;The input action includes type of action information and operation object information;The operation object packet
Coordinate information and control routing information are included, the replayed section determines what needs were implemented according to the type of action of the input action
Operational motion, the replayed section determine the implementation pair of the operational motion according to the operation object information of the input action
As.
Preferably, the operation object information further includes coordinate weighted value, control path weight value value.
Preferably, the operation object information further includes indicating whether the objective for implementation of the operational motion is standard control
The control type information of part.
Preferably, the recording process determines the coordinate weighted value and the control according to the control type information
Path weight value value;When the control type information indicates that the objective for implementation of the operational motion is standard control, the coordinate
Weighted value is less than the control path weight value value;When the control type information indicates that the objective for implementation of the operational motion is non-
When standard control, the coordinate weighted value is greater than the control path weight value value;The replayed section, in the coordinate weighted value
When greater than the control path weight value value, the objective for implementation of the operational motion is determined according to the coordinate information, in the seat
When marking weighted value less than the control path weight value value, the implementation pair of the operational motion is determined according to the control routing information
As.
Preferably, the operation object information further includes matching threshold;The replayed section is by its display parameters and records
The display parameters of process processed compare, when the matching degree of the display parameters of the display parameters and recording process of the replayed section
Higher, then the value of the matching threshold is bigger;The replayed section can be according to institute when the matching threshold is greater than 50%
State the objective for implementation that coordinate information determines the operational motion.
The present invention also provides a kind of user interface automatization test systems, it is characterised in that: including for being tested
The recording module of script and for according to the test script execute test operation playback module;The test script includes pressing
The sequence of the input action of the sequencing record of generation, the recording module record the input action sequence, the playback
Module executes the input action sequence recorded in the test script according to chronological order;Wherein, the input action packet
Include type of action information and operation object information;The operation object information includes coordinate information and control routing information, described
Playback module includes determining that the operational motion for needing the operational motion implemented implements list according to the type of action of the input action
Member, the playback module include the objective for implementation that the operational motion is determined according to the operation object information of the input action
Objective for implementation determination unit.
Preferably, the operation object information further includes coordinate weighted value, control path weight value value.
Preferably, the operation object information further includes indicating whether the objective for implementation of the operational motion is standard control
The control type information of part.
Preferably, the recording module includes weighted value determination unit, the weighted value determination unit is according to the control
Part type information determines the coordinate weighted value and the control path weight value value;When the control type information indicates the behaviour
When the objective for implementation that work acts is standard control, the coordinate weighted value is less than the control path weight value value;When the control
When type information indicates that the objective for implementation of the operational motion is non-standard control, the coordinate weighted value is greater than the control road
Diameter weighted value;The playback module is believed when the coordinate weighted value is greater than the control path weight value value according to the coordinate
Breath determines the objective for implementation of the operational motion, when the coordinate weighted value is less than the control path weight value value, according to institute
State the objective for implementation that control routing information determines the operational motion.
Preferably, the operation object information further includes matching threshold;The playback module further includes that matching threshold is true
Order member, the matching threshold determination unit by the display parameters of the playback module and it is described record module display parameters ratio
Compared with, when the matching degree of the display parameters and the display parameters of the recording process of the replayed section is higher, then the matching threshold
The value of value is bigger;The playback module can be according to coordinate information determination when the matching threshold is greater than 50%
The objective for implementation of operational motion.
The present invention is from the integrality of recorded information and introduces the mode of weight, is adapted in a manner of more flexible each
The recording of test script under kind occasion, and improve the success rate of test script playback.
Detailed description of the invention
The user interface automatization test system schematic diagram of 1 embodiment of the present invention of attached drawing.
The user interface automated testing method flow chart of 2 embodiment of the present invention of attached drawing.
Specific embodiment
Following specific embodiments are only explanation of the invention, are not limitation of the present invention, art technology
Personnel can according to need the modification that not creative contribution is made to the present embodiment after reading this specification, but as long as
All by the protection of Patent Law in scope of the presently claimed invention.Although showing the exemplary implementation of the disclosure in attached drawing
Example, however of course it is to be understood that may be realized in various forms the disclosure and should not be limited by the embodiments set forth herein.Phase
Instead, these embodiments are provided to facilitate a more thoroughly understanding of the present invention and can completely convey the scope of the present disclosure
To those skilled in the art.
Embodiment one
A kind of user interface automatization test system, in practical applications for recording, storing, playing back tester's formulation
Test case.User interface automatization test system in the present embodiment can be by customer terminal webpage or Web page towards survey
Examination personnel provide the man-machine interactive interface for formulating testing scheme.The operating terminals such as mobile phone or computer can be connected to by tester
Test macro runs the tested testing scheme applied and execute formulation in operating terminal.Test macro tool in the present embodiment
Body includes display module, records module, playback module and memory module.Wherein:
(1) display module
The interfaces windows of the tested application of display, and receive the operational motion implemented for the control object in interfaces windows.
In practical application, display module can be the operating terminals such as mobile phone or computer, and tested applying is operated in mobile phone or computer etc.
It runs and shows in terminal.Tester can use the direct trigger point of finger in the operating terminal that mobile phone etc. has touch screen
Equal operational motions are hit, the operational motions such as triggering click can also be clicked by mouse in the non-tactile equipment such as computer, or also
Can by the movement of the directionkeys on keyboard or remote controler/navigation key control operation focus (such as highlighted choice box), and
The operational motions such as triggering click.Tester triggers the operation that the concrete form of the operational motions such as click is supported by operating terminal
Type only receives the operation that operating terminal is sent as electronic signals and executes according to decision, automatization test system.
(2) module is recorded
For obtaining test script.The interfaces windows for passing through display module display output according to the sequencing record of time
In, for the input action of the control object implementation in interfaces windows.The input action sequence that module record obtains is recorded to make
In a storage module for test script storage.
Wherein, input action includes type of action information and operation object information.Type of action information is used for labeled test
Personnel display module display output interfaces windows in implement operational motion (such as long press operation, short-press operation, click behaviour
Work, slide, single-point touch, multi-point touch etc.).Operation object information includes control type information, coordinate information, control road
Diameter information, coordinate weighted value, control path weight value value and matching threshold.Coordinate information is for labeled test personnel in display module
Show generation position of the operational motion implemented in the interfaces windows of output in interfaces windows.Control routing information is for marking
The path for the control that the operational motion that tester implements in the interfaces windows of display module display output is implemented.Control class
Type information is used to indicate that the objective for implementation of operational motion to be standard control or the customized non-standard control of user.
Tester generates corresponding operation action event after the operational motions such as triggering click in operating terminal, and
The operational motion event can be successively transmitted on the window object control of system bottom.For example, if tester passes through touch-control
Screen triggering click event, then generate touch event;If tester triggers click event by mouse, click thing is generated
Part.In system bottom, click event can trigger corresponding function call, the click thing obtained in the function call comprising system
The relevant parameter of part, coordinate parameters and event type (such as the operation of long press operation, short-press, clicking operation, sliding including click
Operation, single-point touch, multi-point touch etc.).Display module is dynamic as the operation in the coordinate parameters that system bottom obtains the click
The coordinate information of work obtains type of action information of the corresponding event type of the click as the operational motion.
There may be differences for the screen size of different operating terminals, and the same window object control is in different operating terminals
The coordinate position of upper display may be different.If test terminal directly uses the coordinate parameters obtained in operating terminal, have
Other window object controls may be navigated to up.In addition, same application on different terminals client (such as mobile phone visitor
Family end and computer client), interface layout generally also can be variant, and the size of window object control, position may be mutual
Difference, when directly determining window object control using the coordinate information in operation object information, it is possible to can not find or look for
To the window object control of mistake.And the control that the operational motion occurred in interfaces windows is implemented substantially is entire desktop control
A node elements in part tree structure, can be identified completely with complete path, there is this detailed path
Description, can accurately go to position and obtain this control object.
Recording module operation pair collected in the recording process for UI automatic test script in the present embodiment
Image information mainly has: being control routing information and coordinate information respectively.By increasing control routing information, in most cases may be used
Accurately to navigate to control.But also can some special circumstances, such as: the feelings that self-defined control cannot be correctly validated occur
Condition.At this point, coordinate information can be introduced by the setting of weight, the availability for recording script can be flexibly improved.
In the present embodiment, by setting coordinate weighted value and control path weight value value and matching threshold, introducing one kind can
The threshold value matching process of flexible configuration.Tester can carry out continuity point to multiple window object controls in different levels window
It hits, obtains a click path.For such situation, records module and need to obtain the corresponding type of action of each clicking operation respectively
The operation object information for the window object control that information and the clicking operation are implemented, and will own by the sequencing of click
Operational motion merges into an operational motion sequence, is written in test script.
The matching threshold of operation object information needs tester that system is configured or adopted before recording process
With the default value of system.Control path weight value value and control coordinate weighted value can be preset by tester, or by this
The special configuration module of system pre-enters configuration, then by recording module weighted value determination unit, recording module
It is dynamically determined in recording process according to control type.Weighted value determination unit is dynamically determined method to weighted value are as follows:
The control type information of the operation object is obtained, to judge that the window object control that the operation object is implemented is mark
Quasi- control also criteria of right and wrong control.If the window object control is standard control, weighted value determination unit determines the operation
The control path weight value value of object is greater than coordinate weighted value, and is greater than matching threshold.If the window object space is nonstandard
Quasi- control, then weighted value determination unit determines that the control path weight value value of the operation object is less than coordinate weighted value.Meanwhile coordinate
Weighted value is greater than matching threshold.
(3) memory module
Memory module is used to store the input action sequence for recording module record.In the present embodiment, advanced elder generation can be used
Store storehouse out.Tester often implements an operational motion in the interfaces windows of display module display output, records mould
Block just obtains the type of action information of the operational motion and operation object information is put into the store storehouse and stores.
(4) playback module
For executing the playback module of test operation according to the test script.Playback module reading is stored in memory module
In operational motion sequence.And test case is generated according to the sequencing of generation, to execute the operational motion sequence.It needs
Bright, when generating test example, playback module needs to generate test case code according to the language environment of test terminal,
It can smoothly be interpreted with guarantee test terminal and implement the test case code.For example, for the survey for executing JAVA test case
Terminal is tried, playback module is needed the operational motion that type of action information is marked and the window pair that operation object information is marked
As control is converted to JAVA sentence, and the test terminal for executing LUA test case, then playback module is needed type of action
The window object control that the operational motion and operation object information that information is marked are marked is converted to LUA sentence.The process is complete
It is executed automatically by playback module entirely, invalid tester's intervention, thereby simplify test case writes complexity.
Playback module further includes matching threshold determination unit.Matching threshold determination unit compares playback module and records module
Display parameters (including resolution ratio, display area size etc.), and matching threshold (range 0~1) is determined according to comparison result.It is aobvious
Show that consistent project is more in parameter, the value of matching threshold is bigger, indicates that playback module and the display matching degree of recording module are got over
It is high.For example, matching threshold 1 indicates their height if the display parameters of playback module and recording module are completely the same
Match.If playback module and the display parameters for recording module are entirely different, matching threshold 0.
Replayed section determines the objective for implementation of operational motion according to the operation object information, in the coordinate weighted value
When greater than the control path weight value value, the objective for implementation of the operational motion is determined according to the coordinate information, in the seat
When marking weighted value less than the control path weight value value, the implementation pair of the operational motion is determined according to the control routing information
As.And if can also determine the operational motion according to the coordinate information when coordinate weighted value matching threshold is greater than 50%
Objective for implementation.For following table:
Playback module can directly be searched when determining the objective for implementation of operation object 1 according to the control routing information
The corresponding window object control in the path.And matching threshold is 0.9, therefore can also determine needs according to the coordinate information
The position of the window object control of operation in the window, to determine window object control.
Playback module can directly be searched when determining the objective for implementation of operation object 2 according to the control routing information
The corresponding window object control in the path.And matching threshold is 0.8, this can also need to grasp according to coordinate information determination
The position of the window object control of work in the window, to determine window object control.
Playback module can only directly be searched when determining the objective for implementation of operation object 3 according to the control routing information
The corresponding window object control in the path.Because of matching threshold 0.1, indicates playback module and record the display ginseng of module
Number mismatches, and cannot determine the window object control for needing to operate according to coordinate information.
Playback module can only directly search the road according to the coordinate information when determining the objective for implementation of operation object 4
The corresponding window object control of diameter.
The test method of automatization test system based on the present embodiment, including the recording process for obtaining test script
With the replayed section for executing test operation according to test script.
(1) recording process
Show that output needs application widget interface to be tested, interfaces windows of the tester in tested application by display module
In window object control is operated.The sequencing that module occurs according to each operational motion is recorded, it is dynamic to obtain each operation
The type of action information and operation object information of work.And it is stored in a storage module according to the sequencing that they occur.
(2) replayed section
The test script of storage in a storage module is read by display module.Test foot is stored according to sequencing interpretation
Operational motion sequence in this.According to operational motion type determine need to be implemented operational motion (such as long press operation, short-press behaviour
Work, clicking operation, slide, single-point touch, multi-point touch etc.).Display module is according to the operation object of the operational motion
Information determines the objective for implementation of the operational motion.After obtaining operational motion and objective for implementation, display module can be according to test
Environmental language generates and runs corresponding test case.
The invention proposes a kind of method that optimization UI automatic test script is recorded, from the integrality of recorded information and
The mode for introducing weight is adapted to script under various occasions in a manner of more flexible and recorded, promotes the success rate of playback.