The alignment system and method and its automated testing method of browser page element
Technical field
The present invention relates to automatic test field, more particularly to a kind of alignment system of browser page element and method and
Its automated testing method.
Background technology
At present, it is required for using some testing tools in many automatic tests, such as to page elements content
Often using this automated test tool of Robot Framework in test, for this class testing of Robot Framework
Instrument is, it is necessary to input the positioning result to browser page element.Current way is manually to go in the source code of page front end to carry out
Search, capture out corresponding element positioning result in the source code of front end, and the element positioning result captured out is input to test work
In tool.This mode not only needs substantial amounts of human cost, and efficiency is low, and the accuracy for obtaining element positioning content is low,
The problem of easily causing test result inaccuracy.
The content of the invention
For problems of the prior art, the invention provides a kind of alignment system of browser page element and side
Method and its automated testing method, accurately the element of browser page can be accurately positioned, use Robot
Framework writes more quick and easy during test script, and effectively improves the efficiency for writing script.
The present invention adopts the following technical scheme that:
A kind of localization method of browser page element, the localization method include:
Location Request is produced according to the operation to page elements;
The front end source code of the page is parsed according to the Location Request, and obtains corresponding page in the front end source code
The positioning content of surface element;
The positioning content of acquisition is combined, and produces the positioning result of the page elements.
Preferably, include before the step of producing Location Request according to the operation to page elements:
Default one includes the definition vocabulary of multiple defined terms, and at least corresponding positioning of each defined terms please
Ask;
The front end source code of the page is parsed according to the Location Request, and obtains corresponding page in the front end source code
The step of positioning content of surface element, specifically includes:
The corresponding defined terms in the definition vocabulary is obtained according to the Location Request;
The front end source code is parsed according to the defined terms of acquisition, obtain in the front end source code with it is described fixed
Content corresponding to adopted word, and position content using the content of acquisition as the page elements.
Preferably, the step of page elements positioning content of acquisition being combined specifically includes:Will be according to described
The corresponding content that defined terms obtains from the front end source code is integrated.
Preferably, in methods described, the defined terms includes:Address and/or title and/or path and/or route text.
Preferably, the positioning content of acquisition is combined, and produces the step of the positioning result of the page elements
Also include after rapid:Show the positioning result of the page elements.
A kind of alignment system of browser page element, it is characterised in that the page elements applied to automatic test are determined
During position, the alignment system includes:
Task start module, produced according to the operation to page elements and send Location Request;
Main program module, it is connected with the task start module, the front end source code of the page is entered according to the Location Request
Row parsing, and obtain the positioning content of corresponding page elements in the front end source code;
Processing module, it is connected with the main program module, the positioning content of the page elements of acquisition is combined,
Produce the positioning result of the page elements.
Preferably, the alignment system also includes:
Memory module is defined, is stored with a definition vocabulary, the vocabulary that defines includes multiple defined terms, and each definition
Word at least corresponds to a Location Request;
The main program module includes:
Defined terms acquiring unit, corresponding defined terms in the definition vocabulary is obtained according to the Location Request;
Resolution unit, the front end source code is parsed according to the defined terms of acquisition, and obtain the front-end source
Content corresponding with the defined terms in code, and position content using the content of acquisition as element.
Preferably, the processing module will be obtained according to the defined terms from the front end source code corresponding to it is described fixed
Position content is integrated, and obtains the positioning result.
Preferably, the alignment system of the browser page element also includes:
Display module, it is connected with the processing module, shows the positioning result of the page elements.
A kind of automated testing method, the automated testing method include:
Above-mentioned positioning result is matched in testing tool according to the Location Request, the testing tool is according to
Positioning result carries out automatic test.
The beneficial effects of the invention are as follows:
The present invention is after the system is opened, as long as user operates to the page elements of browser, side will eject
One button small icon, a display box will be ejected by now clicking on this button small icon, be exactly that its element is determined in display box
Position result, this location mechanism play the role of very big, such as the most frequently used Robot at present for writing script in automatic test
Framework automated test frames, just need to position into row element when writing case, existing location mechanism is or not
Energy meet demand, the present invention is effective to solve some problems present in positioning at present, substantially increases testing efficiency.
Brief description of the drawings
Fig. 1 is a kind of structural representation of the alignment system of browser page element of the present invention;
Fig. 2 is the corresponding relation figure between Location Request and positioning content in main program module of the present invention;
Fig. 3 is the schematic diagram of the localization method of browser page element of the present invention.
Embodiment
It should be noted that in the case where not conflicting, following technical proposals, can be mutually combined between technical characteristic.
The embodiment of the present invention is further described below in conjunction with the accompanying drawings:
Embodiment one
As shown in figure 1, present embodiments providing a kind of method of browser page element positioning, the present embodiment is mainly applied
In in the process positioned to browser page element, when user is operated in browser page element, user afterwards
The prompting of an inquiry property can be obtained, i.e., to whether producing Location Request and confirming, if user confirms to produce Location Request,
Task start module produces Location Request, and the Location Request can be an instruction, and the content of instruction can be determined
The value of word defined in the request of position.Wherein, page elements can be the content of the displays such as word on browser page, picture, use
The operation that family is carried out can choose word and/or picture in browser etc., the browser page element in the present embodiment
Alignment system, it can include:Task start module, main program module, processing module.
First, task start module can produce according to the operation for the page elements that user selectes and send Location Request, should
Can be with scene:User selectes certain section of word of a browser page, and whether browser page ejection one sends again afterwards
The icon of Location Request, user can carry out clicking on to the icon to be confirmed to produce and send Location Request;Main program module, can be with
It is connected, the front end source code of the page is parsed according to Location Request, and obtain in the front end source code with task start module
The positioning content of corresponding page elements, the main resolving of task start module are:Have one before resolving is carried out
Define memory module and be pre-stored with a definition vocabulary, this definition vocabulary includes multiple defined terms, and each defined terms is at least right
Defined terms acquiring unit can obtain corresponding defined terms in this definition vocabulary according to Location Request after answering a Location Request,
The front end source code is parsed according to the defined terms of acquisition by resolution unit again, and obtain in the source code of front end with the definition
Content corresponding to word, and position content using the content of acquisition as element.Acquisition defined terms is eliminated in Fig. 2, and according to definition
Word determines the process of positioning content, as in 2 the columns of commend (Location Request) one input be Location Request instruction, and
The columns of Target (object content) one are the positioning content obtained by above-mentioned resolving, for example, the first row in Fig. 2,
Click both can be the instruction of Location Request, be positioned such that instruction can determine in above-mentioned definition vocabulary according to click
Defined terms corresponding to this instruction of click is link, and resolution unit solves according to the defined terms link of acquisition to front end source code
Analysis, it is summary to obtain positioning content.But the defined terms in the present embodiment is not limited to limit in table, can enter as the case may be
Row addition.
Processing module is connected with main program module, and the positioning content of the page elements of acquisition is combined, and produces the page
The positioning result of element.In a preferred embodiment of the invention, processing module is integrated content is positioned, and obtains positioning knot
Fruit.In the above embodiments, processing module can simply be enumerated obtained positioning content, as be integrated, if needing
Arrange the conversion such as restructuring to enumerate as combining.It will position after content handled in processing module, can both be positioned
As a result, positioning result can be shown by a display module, display module, be connected with processing module, can show page member
The positioning result of element.
Embodiment two
As shown in figure 3, based on above-mentioned system, a kind of localization method of browser page element is present embodiments provided,
The specific steps of the localization method include:First default one includes the definition vocabulary of multiple defined terms, and each defined terms is at least right
A Location Request is answered, i.e. Location Request has corresponding relation with a defined terms, and user can operate to page elements afterwards, root
Location Request can be produced according to the operation to page elements, it is preferred that can be asked whether before Location Request is produced by one
The process of request is produced, if user confirms, request can be produced.As shown in figure 3, positioning needed for user Quan Xuan or click
Page elements, start above-mentioned alignment system afterwards, icon occurs beside the page elements chosen, click on what side occurred
Icon, confirm to produce Location Request.
Browser backstage is responded to the front end source code of the page according to Location Request, parsed, and is obtained in the source code of front end
The positioning content of corresponding page elements, above-mentioned steps are specifically as follows according to corresponding fixed in Location Request acquisition definition vocabulary
Adopted word, the defined terms that this definition word can obtain according to parse to front end source code, obtain in the source code of front end with defined terms
Corresponding content, and position content using the content of acquisition as page elements.Wherein defined terms can include:Address (ID) and/
Or title (name) and/or path (xpath) and/or route text (linktext).But defined terms be not limited to it is above-mentioned enumerate,
It can be added or select as the case may be.
Afterwards, the positioning content of acquisition is combined inside browser, and produces the positioning of the page elements
As a result.Wherein combination can be that positioning content is carried out the operation such as rearranging.Preferably, will be according to defined terms from front end source code
The positioning content of middle acquisition carries out integration processing, and integration can simply be enumerated, it is not necessary to the step such as is ranked up.Afterwards will
Positioning result is fed back, and the positioning result of page elements is shown in text box.
Embodiment three
The automatic test that the present embodiment is carried out based on the system and method for above-described embodiment one and embodiment two, according to upper
The system and method stated can obtain positioning result, herein no longer to obtaining positioning result the step of repeat, determined
After the result of position, positioning result matching can be inputted into testing tool according to Location Request, in testing tool, a positioning
Request can correspond to a positioning result, and testing tool carries out automatic test further according to positioning result afterwards.
In summary, the present invention is after the system is opened, as long as user operates to the page elements of browser, side
A button small icon will be ejected, a display box will be ejected by now clicking on this button small icon, be exactly it in display box
Element positioning result, this location mechanism for write in automatic test script play the role of it is very big, such as at present it is most normal
Robot Framework automated test frames, just need to position into row element when writing case, existing localization machine
System is or is unable to meet demand, and the present invention is effective to solve some problems present in positioning at present, substantially increases survey
Try efficiency.
By explanation and accompanying drawing, the exemplary embodiments of the specific structure of embodiment are given, it is smart based on the present invention
God, it can also make other conversions.Although foregoing invention proposes existing preferred embodiment, however, these contents are not intended as
Limitation.
For a person skilled in the art, after reading described above, various changes and modifications undoubtedly will be evident.
Therefore, appended claims should regard whole variations and modifications of the true intention and scope that cover the present invention as.Weighing
Any and all scope and content of equal value, are all considered as still belonging to the intent and scope of the invention in the range of sharp claim.