Summary of the invention
The technical matters that the present invention mainly solves is to provide a kind of many browser compatibilitys method of testing and system, can reduce manual test workload, increase work efficiency.
For solving the problems of the technologies described above, the technical scheme that the present invention adopts is: provide a kind of many browser compatibilitys method of testing, comprises configuration operation browser and at least one test browser; In the process that described operating browser is tested, record the operation behavior that the web page element in described operating browser is tested, generating run instruction; To the synchronous described operational order of described test browser; On described test browser, simulate described operation behavior according to described operational order, and be recorded in the execution result information produced when described operation behavior simulated by described test browser; Judge whether described execution result information includes error message; If comprise error message, then carry out error handle according to described error message, to ensure that the simulation test on described synchronism detection browser all completes.
Wherein, described step of carrying out error handle according to described error message comprises: search the error code corresponding with described error message; If find described error code, then search the error handle model corresponding with described error code; If find described error handle model, then carry out error handle according to described error handle model.
Wherein, described error message comprises the mistake that UI interface causes; Described error handle model comprises switching anchored object, reorientates the web page element that operation behavior relates to, re-executes.
Wherein, described operational order comprises the tree bit code of web page element numbering, web page element coordinate figure and web page element, and wherein, described tree bit code is that in the webpage in browser, each web page element is mapped to the numbering in tree; Described switching anchored object, reorientate the web page element that operation behavior relates to comprise: locate the failure of described web page element according to described coordinate figure, then locate described web page element according to the tree bit code of its correspondence, or, locate the failure of described web page element according to described tree bit code, then locate described web page element according to the coordinate figure of its correspondence.
Wherein, the step of described configuration operation browser and at least one test browser comprises: on described operational test set, configure described operating browser, at least one test browser described at least one synchronism detection Equipments Setting, wherein, described operating browser is different browsers from described synchronism detection browser.
For solving the problems of the technologies described above, another technical solution used in the present invention is: provide a kind of many browser compatibilitys test macro, comprise operational test set and at least one synchronism detection equipment, described operational test set is configured with operating browser, and described synchronism detection Equipments Setting has synchronism detection browser; Described operational test set comprises record generation module and synchronization module; Described record generation module, in the process of testing described operating browser, records the operation behavior of testing the web page element in described operating browser, generating run instruction; Described synchronization module, for operational order described in synchronism detection device synchronization; Described synchronism detection equipment comprises receiver module, analog module, logging modle, judge module and error handling module; Described receiver module, for receiving described operational order; Described analog module, for simulating described operation behavior according to described operational order at described synchronism detection browser; Logging modle described in synchronism detection equipment, for simulating in the process of described operation behavior on described synchronism detection browser, is recorded in the execution result information produced when described operation behavior simulated by described synchronism detection browser; Described judge module, for judging whether described execution result information includes error message; Described error handling module, for determine at described judge module execution result information include error message time, carry out error handle according to described error message, to ensure that the simulation test on described synchronism detection browser all completes.
Wherein, described error handling module comprises: first searches unit, for searching the error code corresponding with described error message; Second searches unit, for described first search unit find described error code time, search the error handle model corresponding with described error code; Error handling unit, finds described error handle model for searching unit described second, then carries out error handle according to described error handle model.
Wherein, described error message comprises the mistake that UI interface causes; Described error handle model comprises switching anchored object, reorientates the web page element that operation behavior relates to, re-executes.
Wherein, described operational order comprises the tree bit code of web page element numbering, web page element coordinate figure and web page element, wherein, described tree bit code is that in webpage in a browser, each web page element is mapped to tree structure, and described web page element is in the numbering of the position of tree structure; Described switching anchored object, reorientate the web page element that operation behavior relates to comprise: locate the failure of described web page element according to described coordinate figure, then locate described web page element according to the tree bit code of its correspondence, or, locate the failure of described web page element according to described tree bit code, then locate described web page element according to the coordinate figure of its correspondence.
Wherein, described operating browser and described synchronism detection browser are dissimilar browser.
The invention has the beneficial effects as follows: the situation being different from prior art, the present invention is recorded in the operation behavior performed by operating browser, generating run instruction, operational order is synchronized to synchronism detection browser, thus this operational order is simulated on synchronism detection browser, realize the automatic test of browser compatibility, reduce manual test workload, increase work efficiency; In addition, in synchronism detection browser because of UI interface problem cause cannot locating web-pages element time, changeable anchored object, reorientate the web page element that operation behavior relates to, proceed to make the simulation test on synchronism detection browser, the simulation test avoided on synchronism detection browser is hung up and fault, thus ensures that simulation test is complete smoothly.
Embodiment
Below in conjunction with drawings and embodiments, the present invention is described in detail.
Refer to Fig. 1 and Fig. 2, many browser compatibilitys test macro comprises operational test set 21 and at least one synchronism detection equipment 22.Operational test set 21 is configured with operating browser, and operating browser is actual in operating browser, such as: tester manually tests on operating browser.Synchronism detection equipment 22 is configured with synchronism detection browser, wherein, operating browser and synchronism detection browser can be various browsers, to realize the compatibility test of many browsers; Or operating browser is identical type browser with test browser, but operational test set and the standby operating system of synchronism detection are dissimilar system, to realize cross-platform test; Or the operational test set operating system standby with synchronism detection is not identical, and operating browser and synchronism detection browser can be various browsers, carry out the compatibility of many browsers and cross-platform test simultaneously.
Operational test set 21 comprises record generation module 211 and synchronization module 212.Record generation module 211, in the process of testing operating browser, records the operation behavior of testing the web page element in operating browser, generating run instruction.Synchronization module 212, for synchronism detection equipment 22 synchronous operation instruction.Synchronism detection equipment 22 comprises receiver module 221, analog module 222, logging modle 223, judge module 224 and error handling module 225.Receiver module 221 receives operational order.Analog module 222 simulates described operation behavior according to operational order at described synchronism detection browser.Logging modle 223 is simulated in the process of operation behavior on synchronism detection browser, is recorded in the execution result information produced when synchronism detection browser simulating operation behavior.Judge module 224 judges whether execution result information includes error message.Operational order numbering, operating result and error message is carried in operation result information.Operating browser perform operational order with when testing the instruction of browser executable operations and being identical, if operating result is not identical, the execution result information that then executable operations instruction produces on synchronism detection browser includes error message, then detailed misregistration event and error reason in error message, if operating result is identical, then do not record any content in error description; Or, procedural mistake is there is when the enterprising line operate of synchronism detection browser, such as: program crashing, cannot locating web-pages element etc., illustrate that the execution result information that executable operations instruction produces on synchronized explorer includes error message, same, also misregistration event and error reason in detail in error message.
Error handling module 225 judge module 224 determine execution result information include error message time, carry out error handle according to error message, to ensure that the simulation test on synchronism detection browser all completes row.It should be noted that: analog module 222 is when simulating in the operation behavior performed by operating browser, if operating browser and test browser-incompatible, then web page element in the collapse of synchronism detection browser, synchronism detection browser is likely caused to locate the Problem-Errors such as inaccurate.When there is Problem-Error in synchronism detection browser, error handling module 225 carries out error handle, all operations behavior can be performed smoothly to make analog module 222, can effectively avoid when mistake appears in synchronism detection browser, synchronism detection browser is hung up and fault, and then causes test to stop.
The corresponding operational order of one operation behavior, an operational order corresponding an execution result information, wherein execution result information, as shown in table 1.
Table 1
By comparing the execution result information of different browsers, the compatibility issue that known different browsers exists.
In synchronism detection browser during simulated operation behavior, likely there is mistake in test browser, and then causes compatibility test to interrupt.In order to avoid test is interrupted, synchronism detection browser issuable mistake in test process is encoded in advance, generation error code; And pre-set error handle model.Between error handle model and error code, there is corresponding relation, then can obtain error code according to the error message comprised in execution result information, obtain error code transaction module according to error code, and then carry out error handle according to error handle model.Therefore, error handling module 225 comprises first and searches unit 2251, second and search unit 2252 and error handling unit 2253.First searches unit 2251 searches the error code corresponding with error message.First search unit 2251 do not find the error code corresponding with error code information time, then processing according to presetting transaction module, such as: restart system, restarting browser, recovering test environment etc.; Or, according to the learning algorithm study error handle preset, to constantly update error code.Second searches unit 2252 searches unit 2251 according to first and finds error code, searches the error handle model corresponding with error code.Second search unit 2252 do not find the error handle model corresponding with error code time, then also processing according to presetting transaction module, such as: restart system, restarting browser, recovering test environment etc.; Or, according to the learning algorithm study error handle preset.Error handling unit 2253 is searched according to second the error handle model that unit 2252 finds and is carried out error handle.What deserves to be explained is: error code and error handle model separately coupling, is in order to according to different error messages, mates one or more error handle model, add the dirigibility of system mistake process; In addition, also according to the learning algorithm preset, in conjunction with result, to the error handle model that error message coupling is more excellent, or more excellent error handle model can be generated, improves the error processing capacity of system.
A kind of mistake that can cause for U I interface in error message, specifically refers to that webpage shows its interface in different browsers not identical, and then causes the failure of locating web-pages element.Then the error handle model of its correspondence is for switching anchored object, reorientates the web page element that operation behavior relates to, re-executes.In this real formula mode, operational order comprises the tree bit code of web page element numbering, web page element coordinate figure and web page element, and wherein, tree bit code is that in webpage in a browser, each web page element is mapped to the numbering in tree; Switch anchored object, reorientate the web page element that operation behavior relates to comprise: according to the failure of coordinate figure locating web-pages element, then according to the tree bit code locating web-pages element of its correspondence, or, locate unsuccessfully, then according to the coordinate figure locating web-pages element of its correspondence according to tree bit code locating web-pages element.
Further, operational order also can comprise operation input apparatus and operation input content.。Web page element coordinate figure refers to by the positional value of the web page element operated, and it comprises X-axis coordinate and Y-axis coordinate.Operation input apparatus refers to that this operates the equipment used, such as: mouse or keyboard etc.Operation input content refers to the input that the web page element in browser is done, such as: mouse click, input through keyboard word etc.Output rusults refers to the input that the web page element in browser is done, the result produced.In the embodiment of the present invention, Output rusults is the mouse of reappearing user and the operation of keyboard input devices mainly.If use input through keyboard, then Output rusults is the content of input through keyboard; If use mouse click and produce redirect, then Output rusults is the network address after redirect; If use mouse click and eject forms, then Output rusults is the text contained in forms.After web page element tree bit code refers to and the web page element of current operation is mapped to tree structure, the numbering of the position of web page element in tree structure, wherein, each web page element can have a unique tree bit code, unique identification web page element is carried out with this code, as shown in Figure 3:
Wherein, the tree bit code of ground floor web page element html is 1; The tree bit code of second layer web page element buttom is 21, and the tree bit code of web page element menu is 22; The tree bit code of third layer web page element Inputbox is 31, and the tree bit code of web page element buttom is 32.In the present embodiment, locating web-pages element, can be positioned by coordinate figure and tree bit code, be position by coordinate figure under default situations.
In order to understand error handling procedures of the present invention better, following citing is described, wherein, table 2 is the mapping tables between error code and error message, table 3 is error code transaction module table, table 4 is the mapping tables between error code and error handle model, and table 5 is execution result information table.
Table 2
Table 3
Table 4
Such as: when layout errors occurs synchronism detection browser UI, click and buy button not in the coordinate axis of specifying, cause clicking unsuccessfully.Then in execution result information, misregistration information is as shown in table 5.
Table 5
First searches unit 2251 according to error message, and it is 1 that look-up table 4 obtains error code.Second searches unit 2252 according to error code 1, and question blank 5 and table 6 obtain error handle mode 7 and 5, are: switch objects location pattern, re-execute an instruction.Specifically, synchronism detection equipment 22 is executable operations instruction on test browser again, and this operational order is no longer with coordinate setting web page element, but with setting bit code locating web-pages element.Tester views execution result information, knows to click and buys the compatibility issue that button has UI interface on synchronism detection browser.While testing out browser and there is the compatibility error at UI interface, test macro carries out error handle automatically, test can not be caused to interrupt, can continue to perform next operational order to test, thus normally carrying out of ensure that many browser compatibilitys test, make to find out more compatibility issue in robotization compatibility test.
Conveniently management testing information, system also comprises server 23.Operational test set 21 passes through server 23 to synchronism detection equipment 22 synchronous operation instruction.Be specially: operational order, to server 23 transmit operation instruction, after server 23 receives operational order, is forwarded to synchronism detection equipment 22 by operational test set 21.The execution result information that executable operations produces on operating browser and the execution result information that executable operations produces on test browser are all back to server 23.Error handle part also can be performed by server 23.The error handle model found is sent to synchronism detection equipment 22 by server 23, carries out error handle by synchronism detection equipment 22.Therefore, also can not arrange judge module 224 and error handling module 225 in synchronism detection equipment 22, server 23 comprises judge module 224 and error handling module 225.
It should be noted that: in the present embodiment, operational test set 21 and synchronism detection are preferably computing machine for 22.Wherein, operational test set 21 is connected by network with synchronism detection equipment 22; Synchronism detection is multiple for the quantity of 22, and a synchronism detection arranges a browser on 22.In brief, present system can be a distributed system.In distributed test system of the present invention, multiple testing apparatus is adopted to test.With run compared with scheme that multiple browser carries out testing 1 testing apparatus: Each performs its own functions for each testing apparatus of the present invention, and take up room low, reusability is the highest.If run multiple browser in single testing apparatus, but it is large to take up room, and reusability is low.Between in each testing apparatus not alternately, communication is low with cooperation efficiency, needs extra increase tester to process.In effect, according to this distributed test system, only need 1 tester, test operation can be synchronized to other testing apparatus.Be completed, can automatically collect result and feed back.A testing apparatus is run the concurrent of the concurrent of multiple browser or multiple deploying virtual machine, and that is simulated operation aspect, can not produce the concurrent of true operation aspect.Such as send out 10 log on request to server, the value that possible server returns is all successful simultaneously, and this is simulated operation aspect.A testing apparatus and multiple stage testing apparatus can both be accomplished, but 10 Button Logins simultaneously can not clicked on a machine on 10 browsers, the speed that may perform script can be very fast, but also can only 1 each and every one go to click, and has a long way to go like this in efficiency with distributed deployment.
In embodiments of the present invention, the operation behavior of record performed by operating browser, generating run instruction, operational order is synchronized to test browser, thus this operational order is simulated on test browser, realize the automatic test of browser compatibility, reduce manual test workload, increase work efficiency; In addition, in synchronism detection browser because of UI interface problem cause cannot locating web-pages element time, changeable anchored object, reorientate the web page element that operation behavior relates to, proceed to make the simulation test on synchronism detection browser, the simulation test avoided on synchronism detection browser is hung up and fault, thus ensures that simulation test is complete smoothly.
Refer to Fig. 4, the method for many browser compatibility tests comprises:
Step S300: configuration operation browser and at least one synchronism detection browser.
Operating browser is actual in the browser operated.
Step S301: in the process of testing operating browser, records the operation behavior of testing the web page element in operating browser, generating run instruction.
Web page element refers in webpage can by the element operated, such as: knob, input frame etc.In order to improve test speed, preferably, operating browser starts in operational test set, and synchronism detection browser starts in synchronism detection equipment, and wherein, operating browser is dissimilar browser with test browser.Start-up operation browser in operational test set, starts synchronism detection browser, realizes distributed architecture in synchronism detection equipment, favourable raising test speed.What deserves to be explained is: the quantity of synchronism detection equipment can for multiple, such as 3,4 etc., a synchronism detection equipment start a synchronism detection browser.
Step S302: to synchronism detection browser synchronous operation instruction.
Synchronism detection browser is simulated the operation on operating browser, be equivalent to carry out actual test on synchronism detection browser, thus detect the compatibility of operating browser and synchronism detection browser, manually one by one each browser is tested without the need to tester.
Step S303: simulate operation behavior according to operational order on synchronism detection browser, and be recorded in the execution result information produced when synchronism detection browser simulating operation behavior.
The corresponding operational order of each operation behavior, the corresponding execution result information of an operational order can consult above-mentioned embodiment for the specific descriptions of execution result information, repeats no longer one by one herein.
Step S304: judge whether execution result information includes error message, if comprise error message, then enter step S305, otherwise do not process.
Error message refers to that test result is not identical with test result on synchronism detection browser on operating browser, and, synchronism detection browser carries out the mistake that simulated operation produces, comprise procedural mistake and system mistake, such as: the collapse of test browser, test browser are carried out dead Xun ring and be suspended.
Step S305: carry out error handle according to error message, to ensure that the simulation test on synchronism detection browser all completes.
When simulated operation makes a mistake on test browser, carry out error handle, avoid certain behavioral test to hang up at mistake place, ensure that whole test can complete smoothly.Tester by checking execution result information, can find the place of operating browser and synchronism detection browser-incompatible.
Concrete, the mistake that may occur for synchronism detection browser is encoded in advance, generation error code, and sets up error handle model, and as shown in Figure 5, then step S305 comprises again:
Step S3051: search the error code corresponding with error message, if the error code of finding, then enters step S3053, otherwise enters step S3052.
For mating between error message with error code, can be mated by keyword.
Step S3052: process according to predetermined error handle model.
Predetermined error handle model can attach most importance to starting system, restart browser etc., or be according to learning algorithm study error handle.
Step S3052:, search the error handle model corresponding with error code, if find described error handle model, then enter step S3053, otherwise return step S3052.
Step S3053: carry out error handle according to error handle model.
A kind of mistake that can cause for U I interface in error message, specifically refers to that webpage shows its interface in different browsers not identical, and then causes the failure of locating web-pages element.Then the error handle model of its correspondence is for switching anchored object, reorientates the web page element that operation behavior relates to, re-executes.In this real formula mode, operational order comprises the tree bit code of web page element numbering, web page element coordinate figure and web page element, and wherein, tree bit code is that in webpage in a browser, each web page element is mapped to the numbering in tree; Switch anchored object, reorientate the web page element that operation behavior relates to comprise: according to the failure of coordinate figure locating web-pages element, then according to the tree bit code locating web-pages element of its correspondence, or, locate unsuccessfully, then according to the coordinate figure locating web-pages element of its correspondence according to tree bit code locating web-pages element.Certainly, error message and error handle model also comprise other content, specifically can consult the description of above-mentioned embodiment, repeat no longer one by one herein.
In embodiments of the present invention, be recorded in the operation behavior on performed by operating browser, generating run instruction, operational order is synchronized to test browser, thus this operational order is simulated on test browser, realize the automatic test of browser compatibility, reduce manual test workload, increase work efficiency; In addition, in synchronism detection browser because of U I interface problem cause cannot locating web-pages element time, changeable anchored object, reorientate web page element, proceed to make the simulation test on synchronism detection browser, the simulation test avoided on synchronism detection browser is hung up and fault, thus ensures that simulation test is complete smoothly.
The foregoing is only embodiments of the present invention; not thereby the scope of the claims of the present invention is limited; every utilize instructions of the present invention and accompanying drawing content to do equivalent structure or equivalent flow process conversion; or be directly or indirectly used in other relevant technical fields, be all in like manner included in scope of patent protection of the present invention.