A kind of user interface automated testing method and system
Technical field
The present invention relates to using field tests, more particularly to a kind of user interface automated testing method and system.
Background technology
User interface (User Interface, abbreviation UI) test generally comprises layout test, content test (including word
And picture), Fabric Hand Test, the content such as components testing.For test objects such as layout, content style, fonts, generally using static
Mode is tested, and such as point of use inspection table combines the mode of manual observation and obtains test result.And in user interface
For space, because it has the characteristic of man-machine interaction, can provide a user with such as interface redirect, on-off control, word it is defeated
The interaction sexual function such as enter, need to test UI using dynamical fashion.
The existing dynamic test for UI generally needs tester to write test case, to measurand, test mode,
The contents such as expected resultss are bound, and then perform the test case by test terminal and complete to test UI.Write test case
Generally quite time-consuming, tester generally requires to be taken a significant amount of time and test case is programmed and is changed, in practical application
Excessively labor intensive cost.
It is a kind of UI automatic test approach simple to operation to record and play back (Record and Replay).But it is logical
Crossing the mode recorded and play back carries out UI automatically test has drawback:
First, the test script " nonsense " of recording is more.Mouse is for example moved, original final purpose is moved to A points, but
In recording process, all recorded where mouse being passed through, cause the redundant code of a lot " useless ".
Second, the script of recording is inefficient.Due to midway a lot " nonsense ", and be to play back the operation of people in the form of
It is circulated test;The efficiency of the manual operation of people is certainly not fast enough, so inefficient.
3rd, the script of recording does not possess versatility.It is typically only capable to be used on a computer, because in different computers
The coordinate system of its reference is different.Cause accurately find the object to be operated when playback.
The of paramount importance something of UI automatic tests is exactly the control object for obtaining being operated, such as one
Textbox, button etc..Object first must can be obtained, can operation object.This records test script in fact
Sole purpose, is accurately obtained and records pair key for liking automatic test.
At present, many automated test tools, when test script is recorded, are to click on the input actions such as mouse by record
Screen coordinate and the region control information come realize record function, and in this, as playback when obtain object key
Condition.The information that this recording mode is gathered isolates relatively, and in a kind of uncorrelated mode in record data.Once coordinate
Change, it is easy to occur can not find the situation of object.
The content of the invention
For the problems referred to above that prior art is present, the present invention proposes a kind of user interface automated testing method.
The present invention is adopted the following technical scheme that:
A kind of user interface automated testing method, it includes:
Step one, obtains the recording process of test script;
Step 2, according to the test script replayed section of test operation is performed;
Wherein, the test script includes the sequence of the input action by the time order and function journal for occurring, the record
Input action sequence described in process record processed, the replayed section is performed in the test script according to time order and function order and 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 according to the type of action of the input action needs what is implemented
Operational motion, the replayed section determines that the enforcement of the operational motion is right according to the operation object information of the input action
As.
Preferably, the operation object information also includes coordinate weighted value, control path weight value value.
Preferably, whether the objective for implementation that the operation object information also includes representing 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 it is standard control that the control type information represents the objective for implementation of the operational motion, the coordinate
Weighted value is less than the control path weight value value;When the control type information represents that the objective for implementation of the operational motion is non-
During standard control, the coordinate weighted value is more than the control path weight value value;The replayed section, in the coordinate weighted value
During more 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 mark weighted value is less than the control path weight value value, determine that the enforcement of the operational motion is right according to the control routing information
As.
Preferably, the operation object information also 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 display parameters and the display parameters of the recording process of the replayed section
Higher, then the value of the matching threshold is bigger;The replayed section, when the matching threshold is more than 50%, can be according to institute
State the objective for implementation that coordinate information determines the operational motion.
Present invention also offers a kind of user interface automatization test system, it is characterised in that:Including for being tested
The recording module of script and the playback module for performing test operation according to the test script;The test script include by
The sequence of the input action of the sequencing record of generation, the recording module records the input action sequence, the playback
Module performs the input action sequence recorded in the test script according to time order and function order;Wherein, the input action bag
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 of the operational motion that needs are implemented implements single according to the type of action of the input action
Unit, the playback module includes determining the objective for implementation of the operational motion according to the operation object information of the input action
Objective for implementation determining unit.
Preferably, the operation object information also includes coordinate weighted value, control path weight value value.
Preferably, whether the objective for implementation that the operation object information also includes representing the operational motion is standard control
The control type information of part.
Preferably, the recording module includes weighted value determining unit, the weighted value determining 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 represents the behaviour
When the objective for implementation for making action is standard control, the coordinate weighted value is less than the control path weight value value;When the control
Type information represent the operational motion objective for implementation be non-standard control when, the coordinate weighted value be more than the control road
Footpath weighted value;The playback module, when the coordinate weighted value is more than the control path weight value value, believes 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 also includes matching threshold;The playback module also includes that matching threshold is true
Order unit, the matching threshold determining unit by the display parameters of the playback module and it is described record module display parameters ratio
Compared with, when the display parameters of the replayed section it is higher with the matching degree of the display parameters of the recording process, then the matching threshold
The value of value is bigger;The playback module, when the matching threshold is more than 50%, can be according to the coordinate information determines
The objective for implementation of operational motion.
The present invention is adapted to respectively from the integrity of recorded information and the mode of introducing weight in more flexible mode
The recording of test script under occasion is planted, and improves the success rate of test script playback.
Description of the drawings
The user interface automatization test system schematic diagram of the embodiment of the present invention of accompanying drawing 1.
The user interface automated testing method flow chart of the embodiment of the present invention of accompanying drawing 2.
Specific embodiment
Specific examples below is only explanation of the invention, and it is not limitation of the present invention, art technology
Personnel can make as needed the modification without creative contribution after this specification is read to the present embodiment, but as long as
All protected by Patent Law in scope of the presently claimed invention.Although showing the exemplary enforcement of the disclosure in accompanying drawing
Example, but of course it is to be understood that may be realized in various forms the disclosure and should not be limited by embodiments set forth here.Phase
Instead, there is provided these embodiments are able to be best understood from the disclosure and can be by the complete reception and registration of the scope of the present disclosure
To those skilled in the art.
Embodiment one
A kind of user interface automatization test system, formulates in actual applications for recording, storing, playing back tester
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 Interface for formulating testing scheme.Tester can be connected to the operation such as mobile phone or computer terminal
Test system, tested application is run in operation terminal and the testing scheme of formulation is performed.Test system tool in the present embodiment
Body includes display module, records module, playback module and memory module.Wherein:
(1) display module
The interfaces windows of tested application are shown, and receives the operational motion implemented for the control object in interfaces windows.
In practical application, display module can operate terminal for mobile phone or computer etc., be test for applying in the operation such as mobile phone or computer
Run in terminal and show.Tester can possess in mobile phone etc. and use in the operation terminal of touch screen the direct trigger point of finger
The operational motion such as hit, it is also possible to triggering is clicked by mouse on the non-tactile equipment such as computer and the operational motion such as clicks on, or also
The movement of keyboard or the directionkeys/navigation key control operation focus (such as highlighted choice box) on remote control can be passed through, and
The operational motions such as triggering click.The concrete form of the operational motions such as tester's triggering click is by the operation for operating terminal to be supported
According to decision, automatization test system only receives as electronic signals the operation execution that operation terminal sends to type.
(2) module is recorded
For obtaining test script.The interfaces windows that sequencing record according to the time passes through display module display output
In, for the input action that the control object in interfaces windows is implemented.Jing records the input action sequence work that module record is obtained
Deposit in a storage module for test script.
Wherein, input action includes type of action information and operation object information.Type of action information is used for labeled test
Operational motion that personnel implement in the interfaces windows of display module display output (such as it is long by operation, it is short by operation, click on behaviour
Work, slide, single-point touch, multi-point touch etc.).Operation object information includes control type information, coordinate information, control road
Footpath information, coordinate weighted value, control path weight value value and matching threshold.Coordinate information is used for labeled test personnel in display module
Generation position of the operational motion implemented in the interfaces windows of display output in interfaces windows.Control routing information is used for labelling
The path of the control that the operational motion that tester implements in the interfaces windows of display module display output is implemented.Control class
The objective for implementation that type information is used to represent operational motion is standard control or user-defined non-standard control.
Tester produces corresponding operational motion event after the operational motions such as triggering click in operation terminal, and
The operational motion event can be successively delivered on the window object control of system bottom.For example, if tester passes through touch-control
Screen triggering click event, then produce touch events;If tester triggers click event by mouse, click things are produced
Part.In system bottom, click event can trigger corresponding function call, the click thing obtained comprising system in the function call
The relevant parameter of part, including the coordinate parameters clicked on and event type (such as it is long by operation, it is short by operation, clicking operation, slip
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 the corresponding event type of the click as the type of action information of the operational motion.
The screen size of different operation terminals there may be difference, and the same window object control is in different operation terminals
The coordinate position of upper display may be different.If test terminal is directly using the coordinate parameters obtained in operation terminal, then have
Other window object controls may be navigated to up.Additionally, same client (such as mobile phone visitor applied on different terminals
Family end and computer client), its 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 whole desktop control
A node elements in part tree structure, are can be identified with complete path completely, there is this detailed path
Description, can accurately go to position and obtain this control object.
The operation that recording module in the present embodiment is gathered in the recording process for UI automatic test scripts is right
Image information mainly has:It is respectively control routing information and coordinate information.By increasing control routing information, in most cases may be used
Accurately to navigate to control.But also can some special circumstances, such as:There are the feelings that self-defined control can not be correctly validated
Condition.Now, coordinate information can be introduced into by the setting of weight, can flexibly improve the availability for recording script.
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 to different levels window in multiple window object controls carry out continuity point
Hit, obtain a click path.For this kind of situation, recording module needs to obtain the corresponding type of action of each clicking operation respectively
The operation object information of the window object control that information and the clicking operation are implemented, and will be all by the sequencing clicked on
Operational motion merges into an operational motion sequence, in being written to test script.
The matching threshold of operation object information needs tester before recording process system to be configured or adopted
With the default value of system.Control path weight value value and control coordinate weighted value can be pre-set by tester, or by this
The special configuration module of system pre-enters configuration, then or by the weighted value determining unit of recording module, recording module
It is dynamically determined according to control type in recording process.Weighted value determining unit is to the method that is dynamically determined of weighted value:
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 determining unit determines the operation
The control path weight value value of object is more than coordinate weighted value, and more than matching threshold.If the window object space is nonstandard
Quasi- control, then weighted value determining unit determine the operation object control path weight value value be less than coordinate weighted value.Meanwhile, coordinate
Weighted value is more than matching threshold.
(3) memory module
Memory module is used for the input action sequence that module record is recorded in storage.In the present embodiment, advanced elder generation can be adopted
The store storehouse for going 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 and operation object information of the operational motion and is put in the store storehouse and stores.
(4) playback module
For performing the playback module of test operation according to the test script.Playback module reads and is stored in memory module
In operational motion sequence.And test case is generated according to the sequencing for occurring, to perform the operational motion sequence.Need
Bright, when test example is generated, playback module needs to generate test case code according to the language environment of test terminal,
To ensure that the test case code can smoothly be understood and be implemented in test terminal.For example, for the survey for performing JAVA test cases
Examination terminal, playback module is needed the window pair of the operational motion of type of action information institute labelling and operation object information institute labelling
As control is converted to JAVA sentences, and for the test terminal of LUA test cases is performed, then playback module is needed type of action
The operational motion of information institute labelling and the window object control of operation object information institute labelling are converted to LUA sentences.The process is complete
Performed automatically by playback module entirely, invalid tester's intervention, thereby simplify test case writes complexity.
Playback module also includes matching threshold determining unit.Matching threshold determining unit compares playback module and records module
Display parameters (including resolution, viewing area size etc.), and matching threshold (scope 0~1) is determined according to comparative result.It is aobvious
Show that project consistent in parameter is more, the value of matching threshold is bigger, the display matching degree for representing playback module and recording module is got over
It is high.For example, if the display parameters of playback module and recording module are completely the same, matching threshold is 1, represents their height
Match somebody with somebody.If the display parameters of playback module and recording module are entirely different, matching threshold is 0.
Replayed section determines the objective for implementation of operational motion according to the operation object information, in the coordinate weighted value
During more 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 mark weighted value is less than the control path weight value value, determine that the enforcement of the operational motion is right according to the control routing information
As.And if when the matching threshold of coordinate weighted value is more than 50%, it is also possible to the operational motion is determined according to the coordinate information
Objective for implementation.As a example by following table:
Playback module it is determined that operation object 1 objective for implementation when, can directly be searched 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 window object control of operation position in the window is determining window object control.
Playback module it is determined that operation object 2 objective for implementation when, can directly be searched according to the control routing information
The corresponding window object control in the path.And matching threshold is 0.8, this can also determine according to the coordinate information needs behaviour
The window object control of work position in the window is determining window object control.
Playback module it is determined that operation object 3 objective for implementation when, can only directly be searched according to the control routing information
The corresponding window object control in the path.Because its matching threshold is 0.1, represents playback module and record the display ginseng of module
Number is mismatched, it is impossible to which being determined according to coordinate information needs the window object control of operation.
Playback module it is determined that operation object 4 objective for implementation when, the road can only directly be searched according to the coordinate information
The corresponding window object control in footpath.
Based on the method for testing of the automatization test system of the present embodiment, including for obtaining the recording process of test script
With for according to test script perform test operation replayed section.
(1) recording process
The application widget interface of test, interfaces windows of the tester in tested application are needed by display module display output
In window object control is operated.The sequencing that module occurs according to each operational motion is recorded, each operation is obtained dynamic
The type of action information and operation object information of work.And the sequencing according to their generations is stored in a storage module.
(2) replayed section
Storage test script in a storage module is read by display module.Understand according to sequencing and be stored in test foot
Operational motion sequence in this.Determined according to operational motion type need to perform operational motion (such as it is long by operation, it is short by behaviour
Work, clicking operation, slide, single-point touch, multi-point touch etc.).Operation object of the display module according to the operational motion
Information determines the objective for implementation of the operational motion.After obtaining operational motion and objective for implementation, display module just can be according to test
Environmental language generates and runs corresponding test case.
The present invention proposes a kind of method that optimization UI automatic test scripts are recorded, from the integrity of recorded information and
The mode of weight is introduced, script under various occasions is adapted in more flexible mode and is recorded, lift the success rate of playback.