CN103678105A - Page code testing method and device - Google Patents

Page code testing method and device Download PDF

Info

Publication number
CN103678105A
CN103678105A CN201210345049.1A CN201210345049A CN103678105A CN 103678105 A CN103678105 A CN 103678105A CN 201210345049 A CN201210345049 A CN 201210345049A CN 103678105 A CN103678105 A CN 103678105A
Authority
CN
China
Prior art keywords
page
test
response data
background module
request
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN201210345049.1A
Other languages
Chinese (zh)
Other versions
CN103678105B (en
Inventor
乔健
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Baidu Netcom Science and Technology Co Ltd
Original Assignee
Beijing Baidu Netcom Science and Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Baidu Netcom Science and Technology Co Ltd filed Critical Beijing Baidu Netcom Science and Technology Co Ltd
Priority to CN201210345049.1A priority Critical patent/CN103678105B/en
Publication of CN103678105A publication Critical patent/CN103678105A/en
Application granted granted Critical
Publication of CN103678105B publication Critical patent/CN103678105B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Debugging And Monitoring (AREA)

Abstract

The invention provides a page code testing method and device. The page code testing method includes: S1, designing a test case containing designed or recorded backstage module response data, recorded page test operation and page area reference images; S2, replaying the recorded test operation, intercepting a request transmitted to a backstage module by a tested page and returning the designed or recorded backstage module response data to the tested page according to the request; S3, intercepting a test image of the page area and comparing the test image of the page area with the reference image of the page area to detect the test result. By the page code testing method, automatic test of web page codes is realized, and detection of the test result is automatic. Compared with the prior art, the page code testing method saves hardware resources and manual cost and improves test efficiency.

Description

A kind of method of testing of page code and device
[technical field]
The present invention relates to system testing technology, particularly a kind of method of testing of page code and device.
[background technology]
It is the necessary means that ensures web page code issue quality that the web page code of developing is tested.Existing method of testing all requires to build the background module that tested web page is corresponding conventionally, then on browser, manually carries out test operation, and carrys out verification test result by the bandwagon effect that human eye is directly observed web page.There are a plurality of deficiencies in such method of testing: builds background module and need to take separately server, expended hardware resource, and under development, when web page code is ready, background module is often not yet ready, and the test job of web page code can only wait for background module and carry out after ready again, delayed the job schedule of web page code tester; The inspection of the execution of test operation and webpage representation effect all needs manually to complete, and has increased cost of labor, meanwhile, the desk checking page represent effect time easily the problem existing is omitted.
[summary of the invention]
The invention provides a kind of method and apparatus of test of page code, can robotization be tested and validation test result by web page code.
Concrete technical scheme is as follows:
A method of testing for page code, the method comprises:
S1, structure test case, wherein, described test case comprises: the background module response data of constructing or recording, the page test operation of recording and page area benchmark image;
The page test operation of recording described in S2, playback, tackles the tested page to the request of background module transmission the background module response data of returning to described structure or recording to the tested page according to this request;
S3, intercept page domain test image, and by described page area test pattern and described page area benchmark image comparison test test result.
According to one preferred embodiment of the present invention, described background module response data is constructed in the following way:
Determine and the form of the described tested page to background module response data corresponding to the request of background module transmission, according to described form, generate the value of each parameter in response data.
According to one preferred embodiment of the present invention, described background module response data is recorded in the following way:
Tackle the tested page and send to the request of background module, record after this request, this request is sent to background module;
The response data that interception background module returns, preserves this response data and described request and forms corresponding relation, and described response data is returned to the tested page.
According to one preferred embodiment of the present invention, recording of described page test operation, is specially:
Be recorded in the page test operation of carrying out on controlled browser;
The page test operation of recording described in playback in described step S2, is specially: the page test operation of recording described in playback on described controlled browser.
According to one preferred embodiment of the present invention, described page area benchmark image obtains in the following way:
On described controlled browser, execute after page test operation, the image of the page area of intercepting appointment, wherein, the page area of described appointment is: according to the region of the page elements location of choosing; Or, the region of directly being chosen by mouse drag;
Intercept page domain test image in described step S3, specifically comprises: after the background module response data of returning to described structure to the tested page or recording, intercept the page area image of described appointment as page area test pattern on the tested page.
According to one preferred embodiment of the present invention, in described step S3 by page area test pattern and page area benchmark image comparison test test result, specifically comprise: the similarity of calculating described page area test pattern and described page benchmark image, if similarity surpasses predefined threshold value, think to test and pass through; Otherwise, think to test and do not pass through.
A proving installation for page code, this device comprises:
Tectonic element, for constructing test case, wherein, described test case comprises: the background module response data of constructing or recording, the page test operation of recording and page area benchmark image;
The test cell that comprises test operation playback subelement and the second sectional drawing subelement;
Described test operation playback subelement, for the page test operation of recording described in playback, tackles the tested page to the request of background module transmission the background module response data of returning to described structure or recording to the tested page according to this request;
Described the second sectional drawing subelement, for intercept page domain test image, and by described page area test pattern and described page area benchmark image comparison test test result.
According to one preferred embodiment of the present invention, described tectonic element comprises response data subelement, and described response data subelement is for constructing in the following way described background module response data:
Determine and the form of the described tested page to background module response data corresponding to the request of background module transmission, according to described form, generate the value of each parameter in response data.
According to one preferred embodiment of the present invention, described tectonic element comprises response data subelement, and described response data subelement is for recording in the following way described background module response data:
Tackle the tested page and send to the request of background module, record after this request, this request is sent to background module;
The response data that interception background module returns, preserves this response data and described request and forms corresponding relation, and described response data is returned to the tested page.
According to one preferred embodiment of the present invention, described tectonic element comprises that test operation records subelement, and described test operation is recorded subelement for recording in the following way described page test operation:
Be recorded in the page test operation of carrying out on controlled browser;
The page test operation that described test operation playback subelement is recorded described in playback in the following way:
The page test operation of recording described in playback on described controlled browser.
According to one preferred embodiment of the present invention, described tectonic element comprises the first sectional drawing subelement, and described the first sectional drawing subelement is used for intercept page region benchmark image in the following way:
On described controlled browser, execute after page test operation, the image of the page area of intercepting appointment, wherein, the page area of described appointment is: according to the region of the page elements location of choosing; Or, the region of directly being chosen by mouse drag;
Described the second sectional drawing subelement is intercept page domain test image in the following way:
Described test operation playback subelement to the tested page, return to described structure or the background module response data recorded after, on the tested page, intercept the page area image of described appointment as page area test pattern.
According to one preferred embodiment of the present invention, described the second sectional drawing subelement is in the following way by page area test pattern and page area benchmark image comparison test test result:
Calculate the similarity of described page area test pattern and described page benchmark image, if similarity surpasses predefined threshold value, think to test and pass through; Otherwise, think to test and do not pass through.
As can be seen from the above technical solutions, the present invention is by constructing the test case of a page test operation that comprises background module response data, records and page area benchmark image, when test, playback test operation, to web page, return to response data, and sectional drawing contrast verification test result, with this, realized the automatic test to web page code.Method of testing provided by the invention and device, make to have saved hardware resource and cost of labor when test, significantly promoted testing efficiency simultaneously.
[accompanying drawing explanation]
The method of testing process flow diagram of the page code that Fig. 1 provides for the embodiment of the present invention one;
The response data building method process flow diagram that Fig. 2 provides for the embodiment of the present invention one;
The page test operation of recording and page area benchmark image preparation method process flow diagram that Fig. 3 provides for the embodiment of the present invention one;
The test case preparation method process flow diagram that Fig. 4 provides for the embodiment of the present invention one;
The method flow diagram that utilizes test case to test page code that Fig. 5 provides for the embodiment of the present invention one;
The proving installation schematic diagram of the page code that Fig. 6 provides for the embodiment of the present invention two.
[embodiment]
In order to make the object, technical solutions and advantages of the present invention clearer, below in conjunction with the drawings and specific embodiments, describe the present invention.
Embodiment mono-
The method of testing process flow diagram of the page code that Fig. 1 provides for the embodiment of the present invention one, as shown in Figure 1, the method can comprise:
S101, structure test case, wherein, described test case comprises: the background module response data of constructing or recording, the page test operation of recording and page area benchmark image.
In order to realize the test automation of web page code, need the test case of can robotization repeatedly carrying out.The present invention utilizes just response data by constructing or record background module, records page test operation, intercept page region benchmark image form one can automated execution test case, and realize the test automation of web page code with this.
Below the acquisition pattern of the background module response data of constructing or recording is described.
If background module is not yet ready, need to construct the response data of background module, as shown in Figure 2, this process can realize by following step S111-S112:
The form of S111, definite background module response data corresponding with page request.
Can carry out by a management platform form of the unified management response data corresponding with request, on this platform, for the web page of each type, may be sent to the request of background module, the form of recording the type of this request and the response data of correspondence, this form comprises: the span of the structure of response data and quantity, type, title and each parameter of the parameter in response data etc.Afterwards, just can determine the form that sends to response data corresponding to the request of background module with each web page from this management platform.
S112, according to the form of the described background module response data corresponding with page request, generate background module response data.
After having determined the form of the background module response data corresponding with page request, can be sent to according to this form generation and web page the response data corresponding to request of background module.First generate the value of each parameter in response data, the invention provides following two kinds of optimal ways and generate parameter value: the random value that generates each parameter in the span of each parameter; Or, according to testing the value that need to set each parameter.Afterwards, according to the structure of response data, generated parameter is formed to a complete response data.
In step S 111, adopt management platform manage and ask after the form of corresponding response data, can be by this platform the structure according to response data, generate at random the value of each parameter in response data, with this, complete the robotization structure of response data.If when follow-up test, need to simulate some extreme abnormal conditions, can as required, by tester, be set the value of each parameter in response data.
Above-mentioned is in the not yet ready situation of background module, the mode of tectonic response data.If background module is ready, response data that can direct recording background module, this process can be, but not limited to adopt following method to realize:
Interception web page is sent to the request of background module, record this request, then this request is sent to background module, afterwards, after the response data of returning of background module and the request of recording are before formed to corresponding relation, preserve, then this response data is back to web page.For the ease of preserving the corresponding relation between response data and request, when line item is gone forward side by side in the request that is sent to background module at interception web page, can carry out following operation: the url that records this request, this request is sent to background module, and the response data of afterwards background module being returned is preserved after forming corresponding relation with the url recording; The field of extracting this request of sign, generates unique character string according to this field, and this request is sent to background module, and the response data of afterwards background module being returned is preserved after forming corresponding relation with the character string generating.
By said process, can record and obtain the request that background module sends according to web page and return to corresponding response data.
The above-mentioned acquisition pattern for structure in test case or the background module response data recorded, is described the acquisition pattern of the page test operation of recording in test case and page area benchmark image below.
For follow-up can automatic test, need to record the test operation on the page, to carry out playback when testing, need intercept page region benchmark image with the result of checking follow-up test simultaneously, as shown in Figure 3, this process can realize by following step S121-S123:
S121, a controlled browser of configuration, have this controlled browser to record, the function of playback, location and sectional drawing.
The present invention realizes the recording of page test operation by a controlled browser with recording function is set, and this controlled browser can have by being written in browser the plug-in unit of corresponding function to be realized.For example, can load by the Extension mechanism of Firefox a plug-in unit with recording function, in recording plug-in unit, this defines sequence of operations, these operations need to cover all operations were that user may carry out on web page, after enabling this plug-in unit, any operation of on controlled browser, web page being carried out all can trigger this and record plug-in unit, record plug-in unit and obtain performed operation, record the action type of this operational correspondence, operated element finger URL and operating parameter etc., and be kept in specified file.
In order to complete follow-up sectional drawing and test operation, controlled browser also needs to be written into the function that playback plug-in unit, location plug-in unit and sectional drawing plug-in unit are realized corresponding playback, location and sectional drawing.
Playback plug-in unit can be from preserve the file of test operation read operation type, operated element finger URL and operating parameter, afterwards the operated element of need is carried out to respective operations.
Location plug-in unit and sectional drawing plug-in unit complete the function to page area location sectional drawing jointly.The invention provides following two kinds of optimal ways page area positioned to sectional drawing:
1, according to element finger URL, position sectional drawing, after test operation finishes, appointment needs the element of sectional drawing, location plug-in unit can obtain the path expression of the Xpath(element that is selected element), Xpath by element can locate the position of those elements in the page, the element that sectional drawing plug-in unit is selected those carries out sectional drawing, and institute's truncated picture is saved in specified file as page area benchmark image.
2, according to coordinate, position sectional drawing, after test operation finishes, mouse drag is chosen the region that needs sectional drawing, location plug-in unit can obtain this region with respect to horizontal ordinate x and the ordinate y in the page upper left corner, and the height h in this region and width w, to take horizontal ordinate x and ordinate y be starting point to sectional drawing plug-in unit afterwards, and the h of take carries out sectional drawing as height, w as width to this region, and institute's truncated picture is saved in specified file as page area benchmark image.
S122, be recorded in the page test operation carrying out on described controlled browser.
Enable and record plug-in unit, on controlled browser, web page is carried out to test operation, described in step S121, record plug-in unit and can record and preserve performed page test operation.
The image of the page area of S123, intercepting appointment is as page area benchmark image.
Web page is being executed after test operation, tester specifies the region that need to carry out sectional drawing, described in step S121, can specify and need the element of sectional drawing or directly choose the region that needs sectional drawing, behind plug-in unit location, location, sectional drawing plug-in unit carries out sectional drawing, using truncated picture preservation and as page area benchmark image.
By describing method in above-mentioned steps S101, can form the test case that comprises background module response data, the page operation of recording and page area benchmark sectional drawing, this test case can realize the follow-up automatic test work to web page code.
It should be noted that, in actual applications, there will be a part of background module ready, and the not yet ready situation of another part background module, in addition, when background module is ready, records the process of response data and can carry out with step 121 to the process of recording page test operation intercept page region benchmark image that step S123 describes simultaneously.So, as shown in Figure 4, the method for describing in above-mentioned steps S101, S131-S134 realizes in the steps below:
The response data of S131, the not yet ready background module of structure.
For not yet ready background module, need the response data of those background modules of structure, this process can adopt with step S111 and complete to the identical method described in step S112.
S132, be recorded in the page test operation carrying out on described controlled browser.
Controlled browser can adopt method described in step S121 to configure.Enable the plug-in unit of recording being loaded in controlled browser, web page is tested to required operation, record plug-in unit and can record and preserve performed page test operation.
S133, the interception page are sent to the request of background module, if ask corresponding response data with existence in the data of having constructed with this, return to this response data so to the page; Otherwise, this request is sent to corresponding background module, the response data that background module is returned and this request form after corresponding relation preservation, to the page, return to this response data.
When web page is operated, whether web page can send a request to background module, tackles this request, search to exist with this and ask corresponding response data in the response data of step S131 structure, if exist, directly the response data finding be back to web page; If do not exist, illustrate that the background module that this request need call is ready, therefore in step S131, do not construct the response data of this background module, now need this request to be sent to background module, the response data that background module is returned and this request are preserved after forming corresponding relation, afterwards response data is back to web page, this process with before described in to record the response data of background module identical, do not repeat them here.
The image of the page area of S134, intercepting appointment is as page area benchmark image.
After completing the test operation of web page, appointment need to be carried out the region of sectional drawing, and behind plug-in unit location, location, sectional drawing plug-in unit carries out sectional drawing to this region, using truncated picture preservation and as page area benchmark image.The implementation method of this step can be identical with method described in step S123.
Referring to returning Fig. 1, after subsequent steps S101, there is step S102 in continuation.
S102, utilize described test case to test and verification test result tested page code.
This step is test process, after having constructed the page test operation that comprises background module response data, record and this three's of page area benchmark image test case, can utilize this test case to complete the automatic test of tested page code verification test result.As shown in Figure 5, this process can realize by following step S141-S143:
S141, the page test operation that playback is recorded in controlled browser.
Controlled browser can adopt method described in step S121 to configure.Enable playback plug-in unit, in web page replay procedure S122, record the page test operation that plug-in unit is recorded, playback plug-in unit is read operation type, operated element finger URL and operating parameter etc. from the file of preservation test operation, and these information are converted to accordingly and operate on web page and carry out.
When to web page playback test operation, web page can send request to background module, tackles this request, searches with this and ask corresponding response data and return to web page from the response data of test case.If the response data of test case comprises the response data of structure and the response data of recording, can first search the corresponding response data whether existing in constructed response data with this request, if exist, to web page, return to this response data; Otherwise, in the corresponding relation of preserving when recording background module response data, search with this and ask corresponding response data, if corresponding relation is the url that asks or the character string that generates according to identification request field, preserve, so correspondingly with the url of this request or the character string that generates according to this request field of sign, in corresponding relation, search with this and ask corresponding response data.
The page area test pattern of S142, intercepting appointment.
After the test operation of playback is finished, page area is carried out to sectional drawing.In this step, need the page area of sectional drawing identical with the page area of appointment in step S123, in step S123, location plug-in unit has been known the positional information of the page area that needs sectional drawing, so in this step, location plug-in unit can directly be located the position of this page area, and sectional drawing plug-in unit carries out sectional drawing to this page area afterwards.
Specified page area image and page area benchmark image validation test result that S143, contrast intercept.
The page area test pattern that step S142 is intercepted and the page area benchmark image in test case contrast, and according to two images, whether there are differences to judge test result.The contrast of image can be, but not limited to adopt following method:
According to predefined cell size, the cell that is same quantity by page area test pattern and the cutting in an identical manner of page area benchmark image, choose successively page area test pattern and cell identical in page area benchmark image, afterwards, adopt dot matrix diff algorithm to calculate the similarity of image in two selected cells, if calculate the similarity of gained, be not less than predefined threshold value, think that the image of these two cells is identical, test is passed through; Otherwise, think that the image of these two cells there are differences, test is not passed through.Utilize said method, can take cell as unit, judge whether page area test pattern and page area benchmark image there are differences.After finding the cell there are differences, can this cell be shown with high brightness set-up function automatically, to point out more intuitively tester there are differences.If the size of page area test pattern and page area benchmark image is less, can directly with dot matrix diff algorithm, calculates both similarities, and need not be cell by image cutting.
The above-mentioned description of carrying out for the page code method of testing that the embodiment of the present invention one is provided, by said method, can realize the actual automatic test that represents effect to web page code in a certain region (as html code, css code, Javascript code etc.).Below by bis-pairs of devices provided by the invention of embodiment, be described, this device has been used for flow process described in the embodiment of the present invention one.
Embodiment bis-,
The proving installation schematic diagram of the page code that Fig. 6 provides for the embodiment of the present invention two, as shown in Figure 6, this device comprises: tectonic element 10, test cell 20, wherein, tectonic element 10 further comprises: response data subelement 11, test operation are recorded subelement 12 and the first sectional drawing subelement 13, and test cell 20 further comprises: test operation playback subelement 21 and the second sectional drawing subelement 22.
Tectonic element 10, for constructing test case, wherein, described test case comprises: the background module response data of constructing or recording, the page test operation of recording and page area benchmark image.
Tectonic element 10 further comprises: response data subelement 11, test operation are recorded subelement 12 and the first sectional drawing subelement 13.
Response data subelement 11 is for structure or record background module response data.
For not yet ready background module, response data subelement 11 can be carried out the response data that those background modules are constructed in following operation:
Determine the form of the background module response data corresponding with page request, according to the form of the described background module response data corresponding with page request, generate background module response data afterwards.
Response data subelement 11 can carry out by a management platform form of the unified management response data corresponding with request, on this platform, for the web page of each type, may be sent to the request of background module, the form of recording the type of this request and the response data of correspondence, this form comprises: the span of the structure of response data and quantity, type, title and each parameter of the parameter in response data etc.Afterwards, just can determine the form that sends to response data corresponding to the request of background module with each web page from this management platform.After having determined the form of the background module response data corresponding with page request, can be sent to according to this form generation and web page the response data corresponding to request of background module.First generate the value of each parameter in response data, the invention provides following two kinds of optimal ways and generate parameter value: the random value that generates each parameter in the span of each parameter; Or, according to testing the value that need to set each parameter.Afterwards, according to the structure of response data, generated parameter is formed to a complete response data.
For ready background module, response data subelement 11 can be carried out the response data that those background modules are recorded in following operation:
Interception web page is sent to the request of background module, record this request, then this request is sent to background module, afterwards, after the response data of returning of background module and the request of recording are before formed to corresponding relation, preserve, then this response data is back to web page.For the ease of preserving the corresponding relation between response data and request, when line item is gone forward side by side in the request that is sent to background module at interception web page, can carry out following operation: the url that records this request, this request is sent to background module, and the response data of afterwards background module being returned is preserved after forming corresponding relation with the url recording; The field of extracting this request of sign, generates unique character string according to this field, and this request is sent to background module, and the response data of afterwards background module being returned is preserved after forming corresponding relation with the character string generating.
Test operation is recorded subelement 12 for recording page test operation, and this process can realize by carrying out following operation:
In controlled browser, be written into the plug-in unit of recording with recording function, enable this and record plug-in unit, obtain the operation of on controlled browser, web page being carried out, record the action type of this operational correspondence, operated element finger URL and operating parameter etc., and be kept in specified file.
The first sectional drawing subelement 13 is for intercept page region benchmark image, and this process can realize by carrying out following operation:
In controlled browser, be written into the location plug-in unit with positioning function and the sectional drawing plug-in unit with sectional drawing function, at test operation, recording subelement 12 completes after recording of page test operation, enable location plug-in unit, locate and need the position of the region of sectional drawing in the page, enable afterwards sectional drawing plug-in unit, sectional drawing is carried out in located region and using as page area benchmark image.The first sectional drawing subelement 13 can be carried out by following two kinds of modes the operation of location sectional drawing:
1, according to element finger URL, position sectional drawing, after test operation finishes, appointment needs the element of sectional drawing, enable location plug-in unit and obtain the Xpath that is selected element, Xpath by element can locate the position of those elements in the page, enable the element that sectional drawing plug-in unit is selected those and carry out sectional drawing, and institute's truncated picture is saved in specified file as page area benchmark image.
2, according to coordinate, position sectional drawing, after test operation finishes, mouse drag is chosen the region that needs sectional drawing, enable location plug-in unit and obtain this region with respect to horizontal ordinate x and the ordinate y in the page upper left corner, and the height h in this region and width w, enabling afterwards sectional drawing plug-in unit, to take horizontal ordinate x and ordinate y be starting point, and the h of take carries out sectional drawing as height, w as width to this region, and institute's truncated picture is saved in specified file as page area benchmark image.
Test cell 20, for the page test operation of recording described in playback, tackles the tested page to the request of background module transmission the background module response data of returning to described structure or recording to the tested page according to this request; Also for intercept page domain test image, and by described page area test pattern and described page area benchmark image comparison test test result.
Test cell 20 further comprises: test operation playback subelement 21 and the second sectional drawing subelement 22.
The page test operation of test operation playback subelement 21 for recording described in playback, tackles the tested page to the request of background module transmission the background module response data of returning to described structure or recording to the tested page according to this request.
Test operation playback subelement 21 is written into the playback plug-in unit with playback function in controlled browser, from specific file, action type, operated element finger URL and the operating parameter etc. that subelement 12 records are recorded in read test operation afterwards, these information are converted to corresponding operation and enable playback plug-in unit, on controlled browser, web page is carried out to this operation.
When web page can send request to background module, this request of test operation playback subelement 21 interceptions, searches with this and asks corresponding response data and return to web page the response data of constructing or recording from response data subelement 11.Test operation playback subelement 21 is first searched the corresponding response data whether existing in the response data that response data subelement 11 constructs with this request, if exist, to web page, returns to this response data; Otherwise, in the corresponding relation of preserving when response data subelement 11 is recorded background module response data, search with this and ask corresponding response data, if corresponding relation is the url that asks or the character string that generates according to identification request field, preserve, so correspondingly with the url of this request or the character string that generates according to this request field of sign, in corresponding relation, search with this and ask corresponding response data.
The second sectional drawing subelement 22 is for intercept page domain test image, and by described page area test pattern and described page area benchmark image comparison test test result.
After the test operation of test operation playback subelement 21 playback is finished, the second sectional drawing subelement 22 is enabled location plug-in unit and the sectional drawing plug-in unit that the first sectional drawing subelement 13 is written in controlled browser sectional drawing is carried out in specified page region, using sectional drawing gained image as page area test pattern, and the page area benchmark image that this image and the first sectional drawing subelement 13 intercept is contrasted with verification test result.The contrast of image can be, but not limited to adopt following method:
According to predefined cell size, the cell that is same quantity by page area test pattern and the cutting in an identical manner of page area benchmark image, choose successively page area test pattern and cell identical in page area benchmark image, afterwards, adopt dot matrix diff algorithm to calculate the similarity of image in two selected cells, if calculate the similarity of gained, be not less than predefined threshold value, think that the image of these two cells is identical, test is passed through; Otherwise, think that the image of these two cells there are differences, test is not passed through.Utilize said method, can take cell as unit, judge whether page area test pattern and page area benchmark image there are differences.After finding the cell there are differences, can this cell be shown with high brightness set-up function automatically, to point out more intuitively tester there are differences.If the size of page area test pattern and page area benchmark image is less, can directly with dot matrix diff algorithm, calculates both similarities, and need not be cell by image cutting.
The foregoing is only preferred embodiment of the present invention, in order to limit the present invention, within the spirit and principles in the present invention not all, any modification of making, be equal to replacement, improvement etc., within all should being included in the scope of protection of the invention.

Claims (12)

1. a method of testing for page code, is characterized in that, the method comprises:
S1, structure test case, wherein, described test case comprises: the background module response data of constructing or recording, the page test operation of recording and page area benchmark image;
The page test operation of recording described in S2, playback, tackles the tested page to the request of background module transmission the background module response data of returning to described structure or recording to the tested page according to this request;
S3, intercept page domain test image, and by described page area test pattern and described page area benchmark image comparison test test result.
2. method according to claim 1, is characterized in that, described background module response data is constructed in the following way:
Determine and the form of the described tested page to background module response data corresponding to the request of background module transmission, according to described form, generate the value of each parameter in response data.
3. method according to claim 1, is characterized in that, described background module response data is recorded in the following way:
Tackle the tested page and send to the request of background module, record after this request, this request is sent to background module;
The response data that interception background module returns, preserves this response data and described request and forms corresponding relation, and described response data is returned to the tested page.
4. method according to claim 1, is characterized in that, recording of described page test operation, is specially:
Be recorded in the page test operation of carrying out on controlled browser;
The page test operation of recording described in playback in described step S2, is specially: the page test operation of recording described in playback on described controlled browser.
5. method according to claim 4, is characterized in that, described page area benchmark image obtains in the following way:
On described controlled browser, execute after page test operation, the image of the page area of intercepting appointment, wherein, the page area of described appointment is: according to the region of the page elements location of choosing; Or, the region of directly being chosen by mouse drag;
Intercept page domain test image in described step S3, specifically comprises: after the background module response data of returning to described structure to the tested page or recording, intercept the page area image of described appointment as page area test pattern on the tested page.
6. method according to claim 1, it is characterized in that, in described step S3 by page area test pattern and page area benchmark image comparison test test result, specifically comprise: the similarity of calculating described page area test pattern and described page benchmark image, if similarity surpasses predefined threshold value, think to test and pass through; Otherwise, think to test and do not pass through.
7. a proving installation for page code, is characterized in that, this device comprises:
Tectonic element, for constructing test case, wherein, described test case comprises: the background module response data of constructing or recording, the page test operation of recording and page area benchmark image;
The test cell that comprises test operation playback subelement and the second sectional drawing subelement;
Described test operation playback subelement, for the page test operation of recording described in playback, tackles the tested page to the request of background module transmission the background module response data of returning to described structure or recording to the tested page according to this request;
Described the second sectional drawing subelement, for intercept page domain test image, and by described page area test pattern and described page area benchmark image comparison test test result.
8. device according to claim 7, is characterized in that, described tectonic element comprises response data subelement, and described response data subelement is for constructing in the following way described background module response data:
Determine and the form of the described tested page to background module response data corresponding to the request of background module transmission, according to described form, generate the value of each parameter in response data.
9. device according to claim 7, is characterized in that, described tectonic element comprises response data subelement, and described response data subelement is for recording in the following way described background module response data:
Tackle the tested page and send to the request of background module, record after this request, this request is sent to background module;
The response data that interception background module returns, preserves this response data and described request and forms corresponding relation, and described response data is returned to the tested page.
10. device according to claim 7, is characterized in that, described tectonic element comprises that test operation records subelement, and described test operation is recorded subelement for recording in the following way described page test operation:
Be recorded in the page test operation of carrying out on controlled browser;
The page test operation that described test operation playback subelement is recorded described in playback in the following way:
The page test operation of recording described in playback on described controlled browser.
11. devices according to claim 10, is characterized in that, described tectonic element comprises the first sectional drawing subelement, and described the first sectional drawing subelement is used for intercept page region benchmark image in the following way:
On described controlled browser, execute after page test operation, the image of the page area of intercepting appointment, wherein, the page area of described appointment is: according to the region of the page elements location of choosing; Or, the region of directly being chosen by mouse drag;
Described the second sectional drawing subelement is intercept page domain test image in the following way:
Described test operation playback subelement to the tested page, return to described structure or the background module response data recorded after, on the tested page, intercept the page area image of described appointment as page area test pattern.
12. devices according to claim 7, described the second sectional drawing subelement is in the following way by page area test pattern and page area benchmark image comparison test test result:
Calculate the similarity of described page area test pattern and described page benchmark image, if similarity surpasses predefined threshold value, think to test and pass through; Otherwise, think to test and do not pass through.
CN201210345049.1A 2012-09-17 2012-09-17 A kind of test method and device of page code Active CN103678105B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201210345049.1A CN103678105B (en) 2012-09-17 2012-09-17 A kind of test method and device of page code

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201210345049.1A CN103678105B (en) 2012-09-17 2012-09-17 A kind of test method and device of page code

Publications (2)

Publication Number Publication Date
CN103678105A true CN103678105A (en) 2014-03-26
CN103678105B CN103678105B (en) 2018-11-09

Family

ID=50315745

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201210345049.1A Active CN103678105B (en) 2012-09-17 2012-09-17 A kind of test method and device of page code

Country Status (1)

Country Link
CN (1) CN103678105B (en)

Cited By (25)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104636255A (en) * 2015-02-14 2015-05-20 广州华多网络科技有限公司 Method and device for testing webpage application display effect
CN104978270A (en) * 2015-07-03 2015-10-14 上海触乐信息科技有限公司 Automatic software testing method and apparatus
CN105068918A (en) * 2015-06-03 2015-11-18 中国人民财产保险股份有限公司 Page test method and device
CN105095083A (en) * 2015-08-24 2015-11-25 上海斐讯数据通信技术有限公司 Mobile phone interface screenshot test method and device used in Android system
CN105260301A (en) * 2015-09-24 2016-01-20 努比亚技术有限公司 Visual effect comparison test device of user interfaces and realization method of visual effect comparison test device of user interfaces
CN105515883A (en) * 2014-09-22 2016-04-20 阿里巴巴集团控股有限公司 Test method and system
CN105630669A (en) * 2014-11-20 2016-06-01 埃森哲环球服务有限公司 Automated testing of web-based applications
CN105653460A (en) * 2016-02-29 2016-06-08 东南大学 Method and system for recording and playback of man-machine interface testing actions of touch screen product
CN105930265A (en) * 2016-04-11 2016-09-07 武汉卡比特信息有限公司 Image recognition based software test method
CN106326091A (en) * 2015-06-24 2017-01-11 深圳市腾讯计算机系统有限公司 Browser webpage compatibility detection method and system
CN106802864A (en) * 2016-12-30 2017-06-06 中国银联股份有限公司 A kind of method of testing and device based on financial sector
CN107040574A (en) * 2016-11-17 2017-08-11 阿里巴巴集团控股有限公司 A kind of sectional drawing, data processing method and equipment
CN107239404A (en) * 2017-07-27 2017-10-10 广州云测信息技术有限公司 A kind of positioning problems method and apparatus
CN108255726A (en) * 2018-01-18 2018-07-06 北京网信云服信息科技有限公司 A kind of application program page adaptation test method and device
CN109086203A (en) * 2018-07-20 2018-12-25 百度在线网络技术(北京)有限公司 The detection method and device of the page
CN109784369A (en) * 2018-12-14 2019-05-21 深圳壹账通智能科技有限公司 H5 page test method and device, electronic equipment, storage medium
CN110008117A (en) * 2019-03-12 2019-07-12 深圳壹账通智能科技有限公司 Page test method, device, computer equipment and storage medium
CN110580224A (en) * 2019-09-20 2019-12-17 中国银行股份有限公司 System testing method, device and equipment
CN110704772A (en) * 2018-06-22 2020-01-17 北京京东尚科信息技术有限公司 Page abnormity monitoring method, system, device, electronic equipment and computer readable medium
CN110737599A (en) * 2019-10-18 2020-01-31 付彪 Front-end automatic regression testing system and method based on picture comparison technology
CN111522749A (en) * 2020-04-26 2020-08-11 北京三快在线科技有限公司 Page testing method and device, readable storage medium and electronic equipment
CN112100075A (en) * 2020-09-24 2020-12-18 腾讯科技(深圳)有限公司 User interface playback method, device, equipment and storage medium
CN112256984A (en) * 2020-10-22 2021-01-22 上海悦易网络信息技术有限公司 Method and device for acquiring interface background screenshot corresponding to webpage
CN113342627A (en) * 2021-05-31 2021-09-03 深圳前海微众银行股份有限公司 Application service monitoring method and monitoring system of terminal
CN113722203A (en) * 2020-05-26 2021-11-30 京东数字科技控股有限公司 Program testing method and device, electronic device and computer readable storage medium

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101242621A (en) * 2008-01-21 2008-08-13 中兴通讯股份有限公司 An automatic testing method and system based on interface
US20090217303A1 (en) * 2008-02-27 2009-08-27 Accenture Global Services Gmbh Test script transformation analyzer with change guide engine
CN101882105A (en) * 2010-06-01 2010-11-10 华南理工大学 Method for testing response time of Web page under concurrent environment
CN102419732A (en) * 2011-12-27 2012-04-18 Tcl集团股份有限公司 Android-platform-based automated testing method and testing tool

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101242621A (en) * 2008-01-21 2008-08-13 中兴通讯股份有限公司 An automatic testing method and system based on interface
US20090217303A1 (en) * 2008-02-27 2009-08-27 Accenture Global Services Gmbh Test script transformation analyzer with change guide engine
CN101882105A (en) * 2010-06-01 2010-11-10 华南理工大学 Method for testing response time of Web page under concurrent environment
CN102419732A (en) * 2011-12-27 2012-04-18 Tcl集团股份有限公司 Android-platform-based automated testing method and testing tool

Cited By (30)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105515883A (en) * 2014-09-22 2016-04-20 阿里巴巴集团控股有限公司 Test method and system
CN105630669A (en) * 2014-11-20 2016-06-01 埃森哲环球服务有限公司 Automated testing of web-based applications
CN104636255A (en) * 2015-02-14 2015-05-20 广州华多网络科技有限公司 Method and device for testing webpage application display effect
CN105068918A (en) * 2015-06-03 2015-11-18 中国人民财产保险股份有限公司 Page test method and device
CN106326091B (en) * 2015-06-24 2020-12-11 深圳市腾讯计算机系统有限公司 Method and system for detecting browser webpage compatibility
CN106326091A (en) * 2015-06-24 2017-01-11 深圳市腾讯计算机系统有限公司 Browser webpage compatibility detection method and system
CN104978270A (en) * 2015-07-03 2015-10-14 上海触乐信息科技有限公司 Automatic software testing method and apparatus
CN105095083A (en) * 2015-08-24 2015-11-25 上海斐讯数据通信技术有限公司 Mobile phone interface screenshot test method and device used in Android system
CN105260301A (en) * 2015-09-24 2016-01-20 努比亚技术有限公司 Visual effect comparison test device of user interfaces and realization method of visual effect comparison test device of user interfaces
CN105653460A (en) * 2016-02-29 2016-06-08 东南大学 Method and system for recording and playback of man-machine interface testing actions of touch screen product
CN105930265A (en) * 2016-04-11 2016-09-07 武汉卡比特信息有限公司 Image recognition based software test method
CN107040574A (en) * 2016-11-17 2017-08-11 阿里巴巴集团控股有限公司 A kind of sectional drawing, data processing method and equipment
CN107040574B (en) * 2016-11-17 2020-03-27 阿里巴巴集团控股有限公司 Screenshot and data processing method and device
CN106802864A (en) * 2016-12-30 2017-06-06 中国银联股份有限公司 A kind of method of testing and device based on financial sector
CN107239404A (en) * 2017-07-27 2017-10-10 广州云测信息技术有限公司 A kind of positioning problems method and apparatus
CN108255726A (en) * 2018-01-18 2018-07-06 北京网信云服信息科技有限公司 A kind of application program page adaptation test method and device
CN110704772A (en) * 2018-06-22 2020-01-17 北京京东尚科信息技术有限公司 Page abnormity monitoring method, system, device, electronic equipment and computer readable medium
CN109086203A (en) * 2018-07-20 2018-12-25 百度在线网络技术(北京)有限公司 The detection method and device of the page
CN109784369A (en) * 2018-12-14 2019-05-21 深圳壹账通智能科技有限公司 H5 page test method and device, electronic equipment, storage medium
CN110008117A (en) * 2019-03-12 2019-07-12 深圳壹账通智能科技有限公司 Page test method, device, computer equipment and storage medium
CN110580224A (en) * 2019-09-20 2019-12-17 中国银行股份有限公司 System testing method, device and equipment
CN110737599A (en) * 2019-10-18 2020-01-31 付彪 Front-end automatic regression testing system and method based on picture comparison technology
CN111522749A (en) * 2020-04-26 2020-08-11 北京三快在线科技有限公司 Page testing method and device, readable storage medium and electronic equipment
CN111522749B (en) * 2020-04-26 2023-04-11 北京三快在线科技有限公司 Page testing method and device, readable storage medium and electronic equipment
CN113722203A (en) * 2020-05-26 2021-11-30 京东数字科技控股有限公司 Program testing method and device, electronic device and computer readable storage medium
CN112100075A (en) * 2020-09-24 2020-12-18 腾讯科技(深圳)有限公司 User interface playback method, device, equipment and storage medium
CN112100075B (en) * 2020-09-24 2024-03-15 腾讯科技(深圳)有限公司 User interface playback method, device, equipment and storage medium
CN112256984A (en) * 2020-10-22 2021-01-22 上海悦易网络信息技术有限公司 Method and device for acquiring interface background screenshot corresponding to webpage
CN112256984B (en) * 2020-10-22 2022-09-30 上海万物新生环保科技集团有限公司 Method and device for acquiring interface background screenshot corresponding to webpage
CN113342627A (en) * 2021-05-31 2021-09-03 深圳前海微众银行股份有限公司 Application service monitoring method and monitoring system of terminal

Also Published As

Publication number Publication date
CN103678105B (en) 2018-11-09

Similar Documents

Publication Publication Date Title
CN103678105A (en) Page code testing method and device
CN108683562B (en) Anomaly detection positioning method and device, computer equipment and storage medium
CN106844217B (en) Method and device for embedding point of applied control and readable storage medium
CN105765528B (en) Method, system and medium with the application execution path trace that configurable origin defines
CN103246602B (en) Code coverage determines method and system, code coverage detection method and system
CN109408375B (en) Method and device for generating interface document
CN103425572A (en) Code analyzing method and system
CN105022694B (en) Method for generating test case and system for mobile terminal test
CN108459850B (en) Method, device and system for generating test script
CN107085549B (en) Method and device for generating fault information
CN108009080B (en) Code scanning tool evaluation method and device
CN103577310A (en) Method and device for recording software debugging logs
KR101796369B1 (en) Apparatus, method and system of reverse engineering collaboration for software analsis
CN103729294A (en) Method and device for testing performance script of application software
CN112650688A (en) Automated regression testing method, associated device and computer program product
CN105279092A (en) Software testing method and apparatus
Selay et al. Adaptive random testing for image comparison in regression web testing
KR20140046121A (en) System and method for testing application
KR101228902B1 (en) Cloud Computing-Based System for Supporting Analysis of Malicious Code
CN106201859A (en) A kind of regression testing method and system
CN110380936A (en) Test method and device
CN113220597A (en) Test method, test device, electronic apparatus, and storage medium
CN101510172B (en) Test system and method
CN116719736A (en) Test case generation method and device for testing software interface
US10169216B2 (en) Simulating sensors

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
EXSB Decision made by sipo to initiate substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant