CN104424087A - Web page element positioning method, apparatus and system - Google Patents

Web page element positioning method, apparatus and system Download PDF

Info

Publication number
CN104424087A
CN104424087A CN201310367470.7A CN201310367470A CN104424087A CN 104424087 A CN104424087 A CN 104424087A CN 201310367470 A CN201310367470 A CN 201310367470A CN 104424087 A CN104424087 A CN 104424087A
Authority
CN
China
Prior art keywords
web page
information
parent
attribute
next time
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
CN201310367470.7A
Other languages
Chinese (zh)
Other versions
CN104424087B (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.)
Alibaba Singapore Holdings Pte Ltd
Original Assignee
Alibaba Group Holding 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 Alibaba Group Holding Ltd filed Critical Alibaba Group Holding Ltd
Priority to CN201310367470.7A priority Critical patent/CN104424087B/en
Publication of CN104424087A publication Critical patent/CN104424087A/en
Application granted granted Critical
Publication of CN104424087B publication Critical patent/CN104424087B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Landscapes

  • Train Traffic Observation, Control, And Security (AREA)
  • Management, Administration, Business Operations System, And Electronic Commerce (AREA)

Abstract

The invention provides a web page element positioning method, apparatus and system. The method includes the steps of obtaining at least two positioning information of one or more web page elements of a web page to be tested, determining the optimal positioning information in the at least two positioning information, and using other positioning information for updating the optimal positioning information when the optimal positioning information cannot be used for positioning the web page elements and at least one other positioning information capable of being used for positioning the web page elements. The web page element positioning method, apparatus and system is used for quickly positioning the web page elements, improves the execution efficiency of the positioning of the web page elements, can automatically repair the positioning information of the web page elements, ensures the self-adaptability of the positioning information of the web page elements to the maximum extent and effectively reduces the maintenance cost of the positioning information of the web page elements.

Description

A method for web page element location, Apparatus and system
Technical field
The application relates to Internet technical field, particularly relates to the method for a kind of web page element location, a kind of device of web page element location, and, a kind of system of web page element location.
Background technology
In software development process, software test is indispensable.Software test utilizes testing tool to carry out test operation according to certain testing scheme and flow process, thus reaches and find to hide the defect in software, reduces the cost of software development and maintenance, promotes the object that software quality promotes.The cost of software test accounts for 30% ~ 50% of whole software development process, and along with improving constantly of software function complexity, corresponding automatization testing technique is also in development and progress.
In various types of automatic test, test closest to user's request is the automatic test of the user interface (UI) relevant to user interactions, write the UI automatic test script of web page, inevitably run into web page elemental recognition problem, in the maintenance process of script, because web page attribute of an element value changes the script failure caused, also in frequent generation, become a key factor of location script failure cause.Positioning action for web page element is not only embodied in the operating process of Business Stream, also can be embodied in other side, as the Content inspection of web page text element, web page attribute of an element check, web page attribute of an element value as variable uses, complicated web page element, inspection of web page element as sub-in <table> etc.Because the automatic test of UI is closest to user's request, the maintenance cost of the locating information data of web page element has also become indispensable cost in UI automatized script maintenance process.
The locator meams of current web page element is all carry out based on the mode of static state, and namely once employ the locator meams of certain type, the locating information of its reality will be determined, automatically can not check, repair locating information.Such as, in the automatic test script writing phase of UI, can uniquely can identify that the information of this web page element is recorded by searching out on web page, as the locating information of this web page element, it is the content needing major maintenance in UI automatic test script in follow-up test, if change appears in this single locating information, just must carry out manual type and correct, guarantee UI automatic test script successful execution.The approach of location web page element is also often unique, if such as use id attribute to locate web page element, once id attribute changes, then needs manually to correct, so just can not effectively and position web page element simply.
Therefore, one of problem that those skilled in the art are in the urgent need to address is, the method of a kind of web page element location is proposed, Apparatus and system, in order to quick position web page element, improve the execution efficiency of location web page element, and the automatic reparation of web page element locating information can be carried out, ensure the adaptivity of web page element locating information to greatest extent, effectively reduce the maintenance cost of web page element locating information.
Summary of the invention
Technical problems to be solved in this application are to provide the method for a kind of web page element location, in order to quick position web page element, improve the execution efficiency of location web page element, and the automatic reparation of web page element locating information can be carried out, ensure the adaptivity of web page element locating information to greatest extent, effectively reduce the maintenance cost of web page element locating information.
Accordingly, present invention also provides the device of a kind of web page element location, and a kind of system of web page element location, in order to ensure said method application in practice.
In order to solve the problem, this application discloses the method for a kind of web page element location, comprising:
Obtain at least two locating information of one or more web page element in web page to be measured;
Oplimal Location information is determined in described at least two locating information;
When the described oplimal Location information of employing can not navigate to described web page element, and, when existence at least one can navigate to other locating information of described web page element, adopt oplimal Location information described in other positioning information update described.
Preferably, described method also comprises:
Described oplimal Location information is adopted to carry out the location of described web page element.
Preferably, the locating information of described web page element comprises three, is specially:
The first locating information formed by the combinations of attributes of described web page element itself;
By second locating information that parent attribute of an element combines and the relative position of described web page element in his father's dvielement is formed of described web page element;
And, the 3rd locating information formed by the XPATH path of described web page element.
Preferably, in described acquisition web page to be measured, the step of at least two locating information of one or more web page element comprises:
Sub-step S1, for the one or more web page elements in web page to be measured, obtains the attribute information of its correspondence respectively;
Sub-step S2, judges whether that existence uniquely can navigate to corresponding web page attribute of an element information; If so, then sub-step S3 is performed; If not, then sub-step S4 is performed;
Sub-step S3, records the combinations of attributes that described attribute information forms described web page element itself;
Sub-step S4, obtains the parent attribute of an element information of current page element;
Sub-step S5, judges whether that existence uniquely can navigate to described parent attribute of an element information; If so, sub-step S6 is performed; If not, then described parent element is returned sub-step S4 as current page element;
Sub-step S6, records the parent attribute of an element combination that described parent attribute of an element information forms described web page element, and, obtain the relative position of described web page element in his father's dvielement;
Sub-step S7, for the one or more web page elements in web page to be measured, adopts XPATH path orientation engine to generate the XPATH path of described web page element respectively.
Preferably, described sub-step S2 comprises further:
When secondary traversal step, adopt and work as secondary attribute information combination, travel through the web page element set of web page to be measured, obtain the gathering when secondary and work as sub-quantity of the web page element navigated to;
Traversal step next time, adopts attribute information combination next time, to described obtain when time traversal step travel through when time set, obtain set next time and the quantity next time of the web page element navigated to; Wherein, attribute information combination next time includes when the information in time attribute information combination and newly-increased attribute information;
Determining step, described in judgement, whether quantity is less than or equal to and works as sub-quantity next time, and whether described quantity is next time 1; If so, then run succeeded determination step; If not, then attribute information switch process is performed;
Success determination step, by the described combination of attribute information next time, is judged to uniquely to navigate to corresponding web page attribute of an element information;
Combinations of attributes switch process, using the combination of described attribute information next time as when time attribute information combination, set is next time as when time to gather, and quantity is as working as sub-quantity next time, traversal step next time described in re-executing.
Preferably, before sub-step S2, also comprise:
Sub-step S11, from one or more attribute informations of described web page element, filtering out property value is empty attribute information.
Preferably, described sub-step S5 comprises further:
Parent is when time traversal step, and time parent attribute of an element information combination is worked as in employing, travels through the parent element set of the web page element of web page to be measured, obtains the gathering when secondary and work as sub-quantity of the parent element of the web page element navigated to;
Parent is traversal step next time, adopt parent attribute of an element information combination next time, traveling through when time set of the parent element obtained when time traversal step described parent, obtains set next time and the quantity next time of the parent element of the web page element navigated to; Wherein, parent attribute of an element information combination includes when the information in time parent attribute of an element information combination and a newly-increased parent attribute of an element information next time;
Parent determining step, described in judgement, whether quantity is less than or equal to and works as sub-quantity next time, and whether described quantity is next time 1; If so, parent success determination step is then performed; If not, then parent attribute information switch process is performed;
Parent success determination step, by the described attribute of an element of parent next time information combination, is judged to be the parent attribute of an element information that uniquely can navigate to corresponding web page element;
Parent combinations of attributes switch process, using the described attribute of an element of parent next time information combination as working as time parent attribute of an element information combination, set is next time gathered as when secondary, and quantity is as working as sub-quantity next time, re-executes parent traversal step next time.
Preferably, describedly in the locating information of at least two web page elements, determine that the step of oplimal Location information comprises:
Statistics adopts described first locating information to be the first processing time to the described web page to be measured time of carrying out spent by web page element location;
Statistics adopts described second locating information to be the second processing time to the described web page to be measured time of carrying out spent by web page element location;
Statistics adopts described 3rd locating information to be the 3rd processing time to the described web page to be measured time of carrying out spent by web page element location;
By described first processing time, the second processing time and the 3rd processing time carry out backward sequence, extract the most front locating information corresponding to processing time of sequence as oplimal Location information.
Preferably, when described oplimal Location information is the first locating information, the step that described employing oplimal Location information carries out the location of web page element comprises:
Location is when time traversal step, and employing, when time attribute information combination, travels through the web page element set of web page to be measured, obtains working as time set and working as sub-quantity of the web page element navigated to;
Locate traversal step next time, adopt attribute information combination next time, what obtain when time traversal step described location travels through when time set, obtains set next time and the quantity next time of the web page element navigated to; Wherein, attribute information combination next time includes when the information in time attribute information combination and newly-increased attribute information;
Location determination step, described in judgement, whether quantity is less than or equal to and works as sub-quantity next time, and whether described quantity is next time 1; If so, the successful determination step in location is then performed; If not, then positioning properties Combination conversion step is performed;
Locate successful determination step, judge to adopt described oplimal Location Information locating to described web page element;
Positioning properties Combination conversion step, the described combination of attribute information next time combined as when secondary attribute information, set is next time gathered as when secondary, and quantity is as working as sub-quantity next time, re-executes and locates traversal step next time.
Preferably, when described oplimal Location information is the second locating information, the step that described employing oplimal Location information carries out the location of web page element comprises:
Parent location is when time traversal step, and time parent attribute of an element information combination is worked as in employing, travels through the parent element set of the web page element of web page to be measured, obtains the gathering when secondary and work as sub-quantity of the parent element of the web page element navigated to;
Parent locates traversal step next time, adopt parent attribute of an element information combination next time, traveling through when time set of the parent element obtained when time traversal step described parent location, obtains set next time and the quantity next time of the parent element of the web page element navigated to; Wherein, the combination of attribute information next time of parent element includes the information in time attribute information combines and a newly-increased parent attribute of an element information of parent element;
Parent location determination step, described in judgement, whether quantity is less than or equal to and works as sub-quantity next time, and whether described quantity is next time 1; If so, then perform parent and locate successful determination step; If not, then parent positioning properties information switch process is performed;
Parent locates successful determination step, by the described attribute of an element of parent next time information combination, is judged to be the parent attribute of an element information that uniquely can navigate to corresponding web page element, and goes to Relatively orientation step;
Parent positioning properties Combination conversion step, using the described attribute of an element of parent next time information combination as working as time parent attribute of an element information combination, set is next time gathered as when secondary, and quantity is as working as sub-quantity next time, re-executes described parent and locates traversal step next time;
Relatively orientation step, according to the Relatively orientation of described web page element within the scope of his father's dvielement to described web page element, then judge to adopt described oplimal Location Information locating to described web page element.
Preferably, described in other positioning information update of described employing, the step of oplimal Location information comprises:
Adopt other locating information described as described oplimal Location information;
Or,
Other locating information described is adopted to repair described oplimal Location information.
Disclosed herein as well is the device of a kind of web page element location, comprising:
Locating information acquisition module, for obtaining the locating information of one or more web page element at least two in web page to be measured;
Oplimal Location information chooses module, for determining oplimal Location information in described at least two locating information;
Oplimal Location information updating module, for described web page element can not be navigated to when the described oplimal Location information of employing, further, when existence at least one can navigate to other locating information of described web page element, oplimal Location information described in other positioning information update described is adopted.
Preferably, described device also comprises:
Web page element locating module, for the location adopting described oplimal Location information to carry out described web page element.
Preferably, the locating information of described web page element comprises three, is specially:
The first locating information formed by the combinations of attributes of described web page element itself;
By second locating information that parent attribute of an element combines and the relative position of described web page element in his father's dvielement is formed of described web page element;
And, the 3rd locating information formed by the XPATH path of described web page element.
Preferably, described locating information acquisition module comprises:
Attribute information obtains submodule, for for the one or more web page elements in web page to be measured, obtains the attribute information of its correspondence respectively;
Location determination submodule, for judging whether that existence uniquely can navigate to corresponding web page attribute of an element information; If so, attribute information record sub module is then called; If not, then call parent element and obtain submodule;
Attribute information record sub module, forms the combinations of attributes of described web page element itself for recording described attribute information;
Parent element obtains submodule, for obtaining the parent attribute of an element information of current page element;
Parent location determination submodule, for judging whether that existence uniquely can navigate to described parent attribute of an element information; If so, parent attribute information record sub module is called; If not, then using described parent element as current page element, and call return parent element obtain submodule;
Parent attribute information record sub module, forms the parent attribute of an element combination of described web page element for recording described parent attribute of an element information, and, obtain the relative position of described web page element in his father's dvielement;
Coordinates measurement submodule, for for the one or more web page elements in web page to be measured, adopts XPATH path orientation engine to generate the XPATH path of described web page element respectively.
Preferably, described location determination submodule comprises:
When secondary Traversal Unit, working as secondary attribute information combination for adopting, traveling through the web page element set of web page to be measured, obtain the gathering when secondary and work as sub-quantity of the web page element navigated to;
Traversal Unit next time, for adopting attribute information combination next time, to described obtain when time Traversal Unit travel through when time set, obtain set next time and the quantity next time of the web page element navigated to; Wherein, attribute information combination next time includes when the information in time attribute information combination and newly-increased attribute information;
Judging unit, for described in judging next time quantity whether be less than or equal to and work as sub-quantity, and whether described quantity is next time 1; If so, then identifying unit is called successfully; If not, then attribute information converting unit is called;
Success identifying unit, for by the described combination of attribute information next time, is judged to uniquely to navigate to corresponding web page attribute of an element information;
Combinations of attributes converting unit, for the described combination of attribute information next time being combined as when secondary attribute information, set is next time gathered as when secondary, and quantity is as working as sub-quantity next time, re-executes traversal step next time.
Preferably, described device also comprises:
Attribute information filters submodule, and in the one or more attribute informations from described web page element, filtering out property value is empty attribute information.
Preferably, described parent location determination submodule comprises:
Parent, when time Traversal Unit, is worked as time parent attribute of an element information combination for employing, is traveled through the parent element set of the web page element of web page to be measured, obtains the gathering when secondary and work as sub-quantity of the parent element of the web page element navigated to;
Parent is Traversal Unit next time, for adopting parent attribute of an element information combination next time, traveling through when time set of the parent element obtained when time Traversal Unit described parent, obtains set next time and the quantity next time of the parent element of the web page element navigated to; Wherein, parent attribute of an element information combination includes when the information in time parent attribute of an element information combination and a newly-increased parent attribute of an element information next time;
Parent judging unit, for described in judging next time quantity whether be less than or equal to and work as sub-quantity, and whether described quantity is next time 1; If so, parent success identifying unit is then called; If not, then parent attribute information converting unit is called;
Parent success identifying unit, for by the described attribute of an element of parent next time information combination, is judged to be the parent attribute of an element information that uniquely can navigate to corresponding web page element;
Parent combinations of attributes converting unit, for using the described attribute of an element of parent next time information combination as when time parent attribute of an element information combination, set is next time gathered as when secondary, and quantity is as working as sub-quantity next time, re invocation parent Traversal Unit next time.
Preferably, described oplimal Location information is chosen module and is comprised:
First statistics submodule was the first processing time for adding up described first locating information of employing to the described web page to be measured time of carrying out spent by web page element location;
Second statistics submodule was the second processing time for adding up described second locating information of employing to the described web page to be measured time of carrying out spent by web page element location;
3rd statistics submodule was the 3rd processing time for adding up described 3rd locating information of employing to the described web page to be measured time of carrying out spent by web page element location;
Submodule is chosen in sequence, and for by described first processing time, the second processing time and the 3rd processing time carry out backward sequence, extracts the most front locating information corresponding to processing time that sorts as oplimal Location information.
Preferably, described web page element locating module comprises:
Location, when time traversal submodule, for employing when time attribute information combination, travels through the web page element set of web page to be measured, obtains working as time set and working as sub-quantity of the web page element navigated to;
Location travels through submodule next time, for adopting attribute information combination next time, to described obtain when time traversal submodule travel through when time set, obtain the set next time of web page element that navigates to and quantity next time; Wherein, attribute information combination next time includes when the information in time attribute information combination and newly-increased attribute information;
Location determination submodule, for described in judging next time quantity whether be less than or equal to and work as sub-quantity, and whether described quantity is next time 1; If so, the successful decision sub-module in location is then performed; If not, then positioning properties Combination conversion submodule is performed;
Locating successful decision sub-module, adopting described oplimal Location Information locating to described web page element for judging;
Positioning properties Combination conversion submodule, for the described combination of attribute information next time being combined as when secondary attribute information, set is next time gathered as when secondary, and quantity is as working as sub-quantity next time, and re invocation travels through submodule next time.
Preferably, described web page element locating module comprises:
Parent is located when time traversal submodule, works as time parent attribute of an element information combination, travel through the parent element set of the web page element of web page to be measured for employing, obtains the gathering when secondary and work as sub-quantity of the parent element of the web page element navigated to;
Parent location travels through submodule next time, for adopting parent attribute of an element information combination next time, to described parent location traveling through when time set when the parent element that time traversal submodule obtains, obtain set next time and the quantity next time of the parent element of the web page element navigated to; Wherein, the combination of attribute information next time of parent element includes the information in time attribute information combines and a newly-increased parent attribute of an element information of parent element;
Parent location determination submodule, for described in judging next time quantity whether be less than or equal to and work as sub-quantity, and whether described quantity is next time 1; If so, then call parent and locate successful decision sub-module; If not, then parent positioning properties informoter module is called;
Parent locates successful decision sub-module, for by the described attribute of an element of parent next time information combination, is judged to be the parent attribute of an element information that uniquely can navigate to corresponding web page element, and goes to Relatively orientation submodule;
Parent positioning properties Combination conversion submodule, for the work as time attribute information of the described attribute of an element of parent next time information combination as parent element is combined, set is next time gathered as when secondary, and quantity is as working as sub-quantity next time, re-executes parent and calls submodule next time;
Relatively orientation submodule, for according to the Relatively orientation of described web page element within the scope of his father's dvielement to described web page element time, then judge to adopt described oplimal Location Information locating to described web page element.
Preferably, described oplimal Location information updating module comprises:
Oplimal Location information replacement module, for adopting other locating information described as described oplimal Location information;
Oplimal Location information repairs module, repairs described oplimal Location information for adopting other locating information described.
Disclosed herein as well is the system of a kind of web page element location, comprising:
Information extracting device, for obtaining at least two locating information of one or more web page element in web page to be measured, and determines oplimal Location information in described at least two locating information;
Engine of positioning device, carries out the location of web page element at least two locating information described in adopting;
Feedback assembly, for described web page element can not be navigated in the described oplimal Location information of employing, further, when existence at least one can navigate to other locating information of described web page element, oplimal Location information described in other positioning information update described is adopted.
Compared with prior art, the application comprises following advantage:
The application achieves web page element locating information and once creates, and by obtaining the locating information of at least two web page elements of web page to be measured, solves the problem that locating information is single.The application can determine oplimal Location information from the locating information of at least two the web page elements obtained, and determines thus can directly select oplimal Location information when performing the location of web page element, improves execution efficiency during location.In addition, the application can also when adopting oplimal Location information can not navigate to web page element, other locating information that still can navigate to web page element can be adopted to upgrade oplimal Location information, like this on automatic test script is safeguarded, the maintenance cost of web page element locating information can be avoided, minimizing is located because of web page element the script unsuccessfully caused and is performed failure, realize the automatic reparation of locating information, ensure the adaptive ability of web page element locating information to greatest extent.
The application, when performing the location of web page element, achieves the multipath location of web page element, solves the problem that location approach is single, realize the diversification of locating information.When the locating information location web page element failure of current use, other locating information can be selected to position web page element, ensure the execution efficiency of location with this, and increase substantially the stability of response efficiency and the test script execution performed at script.
The application ensures efficiency optimization in the web page element implementation of location by the priority of locating approach, for the locating information of at least two the web page elements obtained, time spent when the locating information of adding up different positions web page element, backward sequence is carried out according to the time expended, by the locating information of sequence corresponding to the most front time expended, expend time in the shortest locating information as oplimal Location information when namely carrying out web page element location, because the time adopting oplimal Location Information locating web page element to expend is short, therefore can quick position web page element, improve the execution efficiency of location web page element.
Accompanying drawing explanation
Fig. 1 is the flow chart of steps of the embodiment of the method 1 of a kind of web page element location of the application;
Fig. 2 is the schematic diagram of a kind of web page element (element) various dimensions locating information of the application;
Fig. 3 is a kind of web page element various dimensions locating information processing flow chart of the application;
Fig. 4 is the processing flow chart of a kind of web page attribute of an element information of the application;
Fig. 5 is a kind of web page attribute of an element information decision flow figure of the application;
Fig. 6 is the processing flow chart of the parent attribute of an element information of a kind of web page element of the application;
Fig. 7 is the parent attribute of an element information decision flow figure of a kind of web page element of the application;
Fig. 8 is the flow chart of steps of the embodiment of the method 2 of a kind of web page element location of the application;
Fig. 9 is the structured flowchart of the device embodiment of a kind of web page element location of the application;
Figure 10 is the overall construction drawing of a kind of web page element positioning information system of the application.
Embodiment
For enabling above-mentioned purpose, the feature and advantage of the application more become apparent, below in conjunction with the drawings and specific embodiments, the application is described in further detail.
One of core idea of the embodiment of the present application is, by recording the various dimensions locating information of the band priority of web page to be measured, determine the locating information that priority is the highest, and automatically oplimal Location information is repaired, for the locating information that priority is the highest provides accuracy guarantee, ensure the adaptivity of web page element locating information thus on the whole to greatest extent, reduce the maintenance cost of web page element locating information to greatest extent.
With reference to Fig. 1, show the flow chart of steps of the embodiment of the method 1 of a kind of web page element location of the application, described method specifically can comprise the steps:
Step 101, obtains at least two locating information of one or more web page element in web page to be measured;
As a kind of example of the embodiment of the present application embody rule, can with reference to the schematic diagram of a kind of web page element (element) various dimensions locating information of the application shown in Fig. 2, the locating information of the web page element in described step 101 can comprise three, is specifically as follows:
R1: the first locating information formed by the combinations of attributes of described web page element itself;
R2: by second locating information that parent attribute of an element combines and the relative position of described web page element in his father's dvielement is formed of described web page element;
R3: the 3rd locating information formed by the XPATH path of described web page element.
With reference to the various dimensions locating information processing flow chart of a kind of web page element of the application shown in figure 3, in a preferred embodiment of the present application, described step 101 can comprise following sub-step:
Sub-step S1, for the one or more web page elements in web page to be measured, obtains the attribute information of its correspondence respectively;
Such as, include 30 controls (control is the one in web page element) in web page to be measured, attribute information corresponding to certain web page element " tagName " can be obtained: " INPUT ", " name ": " user ", " type ": " text ", " value ": " ".
Preferably, described attribute information can comprise the property value of Property Name and correspondence, before judging whether that existence uniquely can navigate to the sub-step of corresponding web page attribute of an element information, namely before sub-step S2, can also comprise:
Sub-step S11, from the attribute information that described web page element is corresponding, filtering out property value is empty attribute information.
Suppose to there is following several Property Name: tagName, nodeName, src, title, and the property value of correspondence is:
"tagName":"A"
"nodeName":"B"
"src":"/xxx/yy.html"
"title":""
Because property value is that empty Property Name is not contributed for the location of web page element, therefore be that empty attribute information can filter out for property value, such as, " title ": " ", because its property value is " ", is a null value, therefore is filtered out.
Sub-step S2, judges whether that existence uniquely can navigate to corresponding web page attribute of an element information; If so, then sub-step S3 is performed; If not, then sub-step S4 is performed;
Sub-step S3, records the combinations of attributes that described attribute information forms described web page element itself;
Such as, suppose the attribute information " tagName " that certain web page element is corresponding: " INPUT ", " name ": " user ", " type ": " text ", uniquely can navigate to corresponding web page attribute of an element information, then record above-mentioned attribute information, form combinations of attributes { " tagName ": " INPUT ", " name ": " user ", " type ": " text " of described web page element itself,, as the first locating information R1.
Sub-step S4, obtains the parent attribute of an element information of current page element;
Sub-step S5, judges whether that existence uniquely can navigate to described parent attribute of an element information; If so, sub-step S6 is performed; If not, then described parent element is returned sub-step S4 as current page element;
Sub-step S6, records the parent attribute of an element combination that described parent attribute of an element information forms described web page element, and, obtain the relative position of described web page element in his father's dvielement;
In the embodiment of the present application, the step obtaining the parent attribute of an element combination of web page element is identical with the step that acquisition web page element property combines.
Suppose that the parent attribute of an element obtaining web page element is combined as { " tagName ": " form ", " index ": " 1 " }, if web page element comes first of his father's dvielement, so can record relative position information for " index ": " 1 ", the combination of above-mentioned parent attribute of an element and relative position information record are formed { parent:{ " tagName ": " form " " index ": " 1 " } " tagName ": " INPUT ", " index ": " 1 " }, as the second locating information R2
In addition, if the parent element of described web page element uniquely cannot be navigated to, using described parent element as current page element, the parent element of described current page element can also be obtained, re-execute the sub-step S4 obtaining corresponding parent attribute of an element information.
Sub-step S7, for the one or more web page elements in web page to be measured, adopts XPATH path orientation engine to generate the XPATH path of described web page element respectively.
In practice, do not limit the execution sequence of sub-step S7, such as, sub-step S7 can execution sub-step S1 before, or, after completing all sub-steps, or also can perform with other sub-steps, the embodiment of the present application does not limit this simultaneously.
For web page element, XPATH path orientation engine can also be adopted respectively to generate the XPATH path of described web page element, such as/html/body/form/input [@name=" user "], as the 3rd locating information R3.
As a kind of example of the embodiment of the present application embody rule, following sub-step can be adopted further to judge whether, and existence uniquely can navigate to corresponding web page attribute of an element information, i.e. described sub-step S2, can with reference to the application shown in Fig. 4 a kind of processing flow chart of web page attribute of an element information, concrete sub-step is as follows:
As secondary traversal step S21: adopt and work as secondary attribute information combination, travel through the web page element set of web page to be measured, obtain the gathering when secondary and work as sub-quantity of the web page element navigated to;
Traversal step S22 next time: adopt attribute information combination next time, to described obtain when time traversal step travel through when time set, obtain set next time and the quantity next time of the web page element navigated to; Wherein, attribute information combination next time includes when the information in time attribute information combination and newly-increased attribute information;
Determining step S23, described in judgement, whether quantity is less than or equal to and works as sub-quantity next time, and whether described quantity is next time 1; If so, then run succeeded determination step S24; If not, then attribute information switch process S25 is performed;
Success determination step S24, by the described combination of attribute information next time, is judged to uniquely to navigate to corresponding web page attribute of an element information;
Combinations of attributes switch process S25, the described combination of attribute information next time combined as when secondary attribute information, set is next time gathered as when secondary, and quantity is as working as sub-quantity next time, re-executes traversal step S22 next time.
In embodiments of the present invention, suppose to there is web page attribute of an element information " tagName ": " INPUT ", " name ": " user ", " type ": " text ", " value ": " 1 ", " the web page element set of web page to be measured is traveled through according to as time attribute information combination tagName ": " INPUT, obtain the gathering when secondary and work as sub-quantity 5 of the web page element navigated to, adopt tagName ": " INPUT of attribute information combination next time ", " name ": " user " traversal is when time set, obtain set and next time quantity 4 next time, because quantity 4 is less than when sub-quantity 5 next time, therefore the described combination of attribute information is next time combined as when time attribute information, to gather next time gather as when secondary, quantity 4 is as working as sub-quantity 4 next time, re-execute traversal step next time, so, attribute information combination is next time then tagName ": " INPUT ", " name ": " user ", " type ": " text ", tagName ": " INPUT of attribute information combination next time described in employing ", " name ": " user ", " type ": " text " traversal is when time set, obtain the set next time of web page element that navigates to and quantity 1 next time.Because quantity 1 is less than when sub-quantity 4 next time, and quantity is 1 next time, then will next time attribute information combination tagName ": " INPUT "; " name ": " user ", " type ": " text ", is judged to uniquely to navigate to corresponding web page attribute of an element information.
If when upper once quantity is 1, also there is other attribute information, so can also continue to increase the web page element set that other attribute informations continue traversal web page to be measured, and using the quantity next time obtained still be 1 attribute information adopt as locating information, form the combinations of attributes of web page element itself, as the first locating information R1, improve the accuracy of the web page element locating information of acquisition with this.
It should be noted that, only in upper once quantity with when sub-quantity is equal and when equaling 1, now could correctly navigate to web page element; If only have first time obtain when sub-quantity be 1, when the quantity of the web page element that what other repeatedly calculated navigate to is all 0, represent that web page to be measured only has a web page element to be worth identical on the attribute information of the attribute information combination of first time employing with the web page element that will look for, therefore matching degree is not high, do not meet the condition of searching web page element; If what first time obtained works as sub-quantity is 0, then locate the failure of web page element, represent that this web page location to be measured is less than the web page element that will look for; If what first time obtained works as sub-quantity be greater than 1, but the follow-up quantity repeatedly calculated does not exist for 1 situation yet, then represent and now locate the failure of web page element, in order to saving resource, the operation of the acquisition first locating information R1 to web page element can be stopped.
Below adopt a kind of preferred exemplary to judging whether in the application that there is the step that uniquely can navigate to corresponding web page attribute of an element information is described, with reference to a kind of web page attribute of an element information decision flow figure of the application shown in Fig. 5, concrete steps are as follows:
Sub-step SS21, adopts the web page element set of the first attribute information combination traversal web page to be measured, obtains the first set and the first quantity of the web page element navigated to; Wherein, described first attribute information combination comprises the first attribute information;
In specific implementation, attribute information can comprise the property value of Property Name and correspondence, first Property Name of described first attribute information can for the Property Name of specifying, as a kind of example, described Property Name of specifying can meet the Property Name of the non-null value that HTML agreement specifies, as tagName and nodeName etc., certainly, the specified attribute title adopting other also can, the application is not restricted this.
Sub-step SS22, adopts the second attribute information combination traversal first to gather, obtains the second set and the second quantity;
Wherein, described second attribute information combination comprises described first attribute information, and, the second attribute information;
Sub-step SS23, judges whether described first quantity is more than or equal to the second quantity, if so, then performs sub-step SS24, if not, then performs sub-step SS26;
Sub-step SS24, judges whether described second quantity is 1; If so, then perform sub-step S210, if not, then perform sub-step SS25;
Sub-step SS25, adopt the 3rd attribute information combination traversal second to gather, the quantity obtaining the current web page element navigated to is the 3rd quantity;
Wherein, described 3rd attribute information comprises described first attribute information, the second attribute information, and, the 3rd attribute information;
Sub-step SS26, adopt the 3rd attribute information combination traversal first to gather, the quantity obtaining the current web page element navigated to is the 3rd quantity; Go to sub-step SS27;
Sub-step SS27, judges whether to there is other attribute information, if so, then performs sub-step SS28, otherwise, perform sub-step SS29;
Sub-step SS28, using described 3rd attribute information combination as the first attribute information combination, and, after other attribute information combines as the second attribute information described in newly-increased one in described 3rd attribute information combination, return described sub-step SS22;
Sub-step SS29 is 1 in described 3rd quantity, and when the second quantity is more than or equal to the 3rd quantity, by described 3rd attribute information combination, is judged to uniquely to navigate to corresponding web page attribute of an element information; Otherwise be judged to uniquely to navigate to corresponding web page element;
Sub-step SS210, by described second attribute information combination, is judged to uniquely to navigate to corresponding web page attribute of an element information.
Suppose to there is web page attribute of an element information " tagName ": " INPUT ", " name ": " user ", " type ": " text ", " value ": " 1 ", " the web page element set of web page to be measured is traveled through according to the first attribute information combination tagName ": " INPUT, obtain the first set and the first quantity 5, adopt the second attribute information combination tagName ": " INPUT ", " name ": " user " traversal first set, obtain the second set and the second quantity 4, because the first quantity 5 is greater than the second quantity 4, therefore continue employing the 3rd attribute information tagName ": " INPUT ", " name ": " user ", " type ": " text " traversal second set.If other attribute information " value " of web page element: " 1 ", then by described 3rd attribute information combination tagName ": " INPUT ", " name ": " user ", " type ": " text " combines as the first attribute information, and, in described 3rd attribute information combination, newly-increased other attribute information forms the second new attribute information combination tagName ": " INPUT ", " name ": " user ", " type ": " text ", " value ": " 1 ", by that analogy, until the 3rd quantity is 1, and the second quantity is when being more than or equal to the 3rd quantity, by described 3rd attribute information combination, be judged to uniquely to navigate to corresponding web page attribute of an element information, such as, if the 3rd attribute information combination tagName ": " INPUT ", " name ": " user ", " type ": the quantity that " text " navigates to web page element is the 3rd quantity 1, then can judge the 3rd attribute information combination tagName ": " INPUT ", " name ": " user ", " type ": " text " uniquely can navigate to corresponding web page attribute of an element information.
Certainly, also may employing second attribute information combination tagName ": " INPUT "; " name ": " user " traversal first set; the quantity obtaining the current web page element navigated to is the second quantity 1; so now also can judge the second attribute information combination tagName ": " INPUT ", " name ": " user " uniquely can navigate to corresponding web page attribute of an element information.
In order to make those skilled in the art understand the embodiment of the present application further, the example that below employing one is concrete illustrates that the embodiment of the present application obtains the process of the first locating information R1.
Suppose to there is web page attribute of an element information " tagName ": " INPUT ", " name ": " user ", " type ": " text ", " value ": " 1 ", above-mentioned attribute information is adopted to travel through web page to be measured, and obtain the quantity of the web page element navigated to, specifically can locate web page number of elements table with reference to attribute information as shown in table 1 below:
As can be seen from Table 1, the attribute information obtaining web page element assignment combines " tagName " as when time attribute information: " INPUT ", adopt when time attribute information combination " tagName ": " INPUT " travels through the web page element set of whole web page to be measured, obtain the quantity 5 navigating to web page element, increase the quantity that attribute information also obtains the web page element navigated to one by one afterwards, when the quantity navigating to web page element obtained is 1, obtain corresponding attribute information and form combinations of attributes, as the first locating information R1.Be easy to find out, in employing " tagName ": " INPUT "+" name ": " user "+" type ": " text "+" value ": the quantity of the web page element that " 1 " navigates to is 1, then above-mentioned attribute information can be carried out record, obtain the combinations of attributes { " tagName ": " INPUT " of of web page itself, " name ": " user ", " type ": " text ", " value ": " 1 " }, as the first locating information R1.
As a kind of example of the embodiment of the present application embody rule, following sub-step can be adopted further to judge whether to there is the parent attribute of an element information that uniquely can navigate to corresponding web page element, i.e. described sub-step S5, can with reference to the application shown in Fig. 5 a kind of processing flow chart of parent attribute of an element information of web page element, concrete steps are as follows:
Parent is as time traversal step S31, and time parent attribute of an element information combination is worked as in employing, travels through the parent element set of the web page element of web page to be measured, obtains the gathering when secondary and work as sub-quantity of the parent element of the web page element navigated to;
Parent is traversal step S32 next time, adopt parent attribute of an element information combination next time, traveling through when time set of the parent element obtained when time traversal step described parent, obtains set next time and the quantity next time of the parent element of the web page element navigated to; Wherein, the combination of attribute information next time of parent element includes the information in time attribute information combines and a newly-increased parent attribute of an element information of parent element;
Parent determining step S33, described in judgement, whether quantity is less than or equal to and works as sub-quantity next time, and whether described quantity is next time 1; If so, parent success determination step S34 is then performed; If not, then parent attribute information switch process S35 is performed;
Parent success determination step S34, by the described attribute of an element of parent next time information combination, is judged to be the parent attribute of an element information that uniquely can navigate to corresponding web page element;
Parent combinations of attributes switch process S35, using the described attribute of an element of parent next time information combination as working as time parent attribute of an element information combination, set is next time gathered as when secondary, and quantity is as working as sub-quantity next time, re-executes parent traversal step S32 next time.
In the embodiment of the present application, suppose the parent attribute of an element information " tagName " that there is web page element: " form ", " index ": " 1 ", according to working as secondary parent attribute of an element information combination " tagName ": " form " travels through the parent element set of the web page element of web page to be measured, obtain the gathering when secondary and work as sub-quantity 3 of parent element; Adopt parent attribute of an element information combination " tagName " next time: " form ", " index ": " 1 " traversal parent element when time set, obtain set next time and the quantity 1 next time of the parent element of the web page element navigated to.Quantity next time 1 due to parent element be less than parent element when sub-quantity 3, and, the quantity next time of parent element is 1, therefore the attribute information next time of described parent element can be combined " tagName ": " form ", " index ": " 1 " is judged to be the parent attribute of an element information that uniquely can navigate to corresponding web page element.
Below adopt a kind of preferred exemplary to judging whether in the application that there is the step that uniquely can navigate to the parent attribute of an element information of corresponding web page element is described, with reference to the parent attribute of an element information decision flow figure of a kind of web page element of the application shown in Fig. 6, concrete steps are as follows:
Sub-step SS31, adopts the web page element set of the 4th attribute information combination traversal web page to be measured, obtains the 3rd set and the 4th quantity;
Wherein, described 4th attribute information combination comprises the 4th attribute information;
Sub-step SS32, adopts the 5th attribute information combination traversal the 3rd to gather, obtains the 4th set and the 5th quantity;
Wherein, described 5th attribute information combination comprises described 4th attribute information, and, the 5th attribute information;
Sub-step SS33, judges whether described 4th quantity is more than or equal to the 5th quantity, if so, then performs sub-step SS34, if not, then performs sub-step SS36;
Sub-step SS34, judges whether described 5th quantity is 1; If so, then perform sub-step S310, if not, then perform sub-step SS35;
Sub-step SS35, adopt the 6th attribute information combination traversal the 4th to gather, the quantity obtaining the current web page element navigated to is the 6th quantity;
Wherein, described 6th attribute information comprises described 4th attribute information, the 5th attribute information, and, the 6th attribute information;
Sub-step SS36, adopt the 6th attribute information combination traversal the 3rd to gather, the quantity obtaining the current web page element navigated to is the 6th quantity; Go to sub-step S37;
Sub-step SS37, judges whether to there is other parent attribute of an element information, if so, then performs sub-step SS38, otherwise, perform sub-step SS39;
Sub-step SS38, using described 6th attribute information combination as the 4th attribute information combination, further, after the property value of other parent attribute of an element title and correspondence combines as the 5th attribute information described in newly-increased one in described 6th attribute information combination, described sub-step SS32 is returned;
Sub-step SS39 is 1 in described 6th quantity, and when the 5th quantity is more than or equal to the 6th quantity, by described 6th attribute information combination, is judged to uniquely to navigate to corresponding parent attribute of an element information; Otherwise be judged to uniquely to navigate to corresponding parent element;
Sub-step SS310, by described 5th attribute information combination, is judged to uniquely to navigate to corresponding parent attribute of an element information.
Suppose the parent attribute of an element information " tagName " that there is web page element: " form ", " index ": " 1 ", according to the 4th attribute information combination " tagName ": " form " travels through the web page element set of web page to be measured, obtain the 3rd set and the 4th quantity 3, adopt the 5th attribute information combination " tagName ": " form ", " index ": " 1 " traversal the 3rd set, obtain the 4th set and the 5th quantity be 1, because the 4th quantity 3 is greater than the 5th quantity 1, then adopt the 6th attribute information combination traversal the 4th to gather, obtain the 6th quantity.Judge whether to there is other parent attribute of an element information, if there is other attribute information of parent element, then described 6th attribute information combination is combined as the 4th attribute information, and, in described 5th attribute information, newly-increased other parent attribute of an element information of combination combines as the 5th attribute information, by that analogy, be 1 in described 6th quantity, and the 5th quantity is when being more than or equal to the 6th quantity, by described 6th attribute information combination, be judged to navigate to corresponding parent attribute of an element information; Otherwise be judged to navigate to corresponding parent attribute of an element information.In this example, because the 5th quantity obtained is 1, then can judge the 5th attribute information combination tagName ": " form ", " index ": " 1 " uniquely can navigate to corresponding web page attribute of an element information.
In specific implementation, it is 1 that the attribute information of multiple attribute information may be adopted to combine the quantity that could obtain the web page element navigated to, or, adopt the quantity having the combination of the attribute information of multiple parent attribute of an element information could obtain the parent element of the web page element navigated to be 1; The quantity only having the combination of the attribute information of two attribute informations can obtain the web page element navigated to may be adopted to be 1, or, the quantity only having the combination of the attribute information of two parent attribute of an element information can obtain the parent element of the web page element navigated to may be adopted to be 1, depending on the situation of web page element set in concrete web page to be measured, the embodiment of the present application is not restricted this.
It should be noted that, above-mentioned three kinds of locating information R1, R2, the generating mode of R3 just exemplarily, in specific implementation, can adopt the generating mode of other locating information according to actual conditions, the form of such as web page to be measured generates the locating information of web page element, and the embodiment of the present application is not limited this.
Step 102, determines oplimal Location information in described at least two locating information;
In a preferred embodiment of the present application, described step 102 can comprise following sub-step:
Sub-step S102-1, statistics adopts described first locating information to be the first processing time to the described web page to be measured time of carrying out spent by web page element location;
Sub-step S102-2, statistics adopts described second locating information to be the second processing time to the described web page to be measured time of carrying out spent by web page element location;
Sub-step S102-3, statistics adopts described 3rd locating information to be the 3rd processing time to the described web page to be measured time of carrying out spent by web page element location;
Sub-step S102-4, by described first processing time, the second processing time and the 3rd processing time carry out backward sequence, extract the most front locating information corresponding to processing time of sequence as oplimal Location information.
If get locating information through information extracting device have R1, R2, R3 tri-kinds, so in the web page element set of web page to be measured, carry out the time spent when web page element is located by adding up respectively, and carry out row's priority according to the processing time spent by three kinds of locating information, such as can carry out backward queuing according to the length of time, will sort in the most front locating information as oplimal Location information.Such as, if the processing time of the 3rd locating information R3 is the shortest, then using the 3rd locating information R3 as oplimal Location information.
Certainly, the determination for oplimal Location information is exemplarily, such as, also can directly select certain locating information as oplimal Location information, when implementing the embodiment of the present application, can adopt mode determination oplimal Location information according to actual conditions, the embodiment of the present application is not limited this.
Step 103, when the described oplimal Location information of employing can not navigate to described web page element, and, when existence at least one can navigate to other locating information of described web page element, adopt oplimal Location information described in other positioning information update described.
As a preferred embodiment of the present application, described step 103 can comprise following sub-step:
Sub-step S103-1, adopts other locating information described as described oplimal Location information;
If web page to be measured changes, oplimal Location information can not navigate to web page element, and other so can be selected can to navigate to the locating information of web page element, replaces original oplimal Location information.Such as, when oplimal Location information R3 can not navigate to web page element, the first locating information R1 can be selected as oplimal Location information, the oplimal Location information R1 redefined is updated in various dimensions positioning information system.
As another preferred embodiment of the present application, described step 103 can comprise following sub-step:
Sub-step S102-2, adopts other locating information described to repair described oplimal Location information.
If oplimal Location information can not navigate to web page element, and at least one other locating information still can navigate to web page element, so can from still navigating to web page element locating information, extract related position information to repair oplimal Location information, make oplimal Location information still can continue to position web page element, such as, when oplimal Location information R3 can not navigate to web page element, if the first locating information R1 still can navigate to web page element, relevant locating information can be extracted from the first locating information R1, be updated in oplimal Location information R3, complete the reparation to oplimal Location information R3, finally, the oplimal Location information R3 redefined is updated in various dimensions positioning information system by feedback assembly.
With reference to Fig. 8, show the flow chart of steps of the embodiment of the method 2 of a kind of web page element location of the application, described method specifically can comprise the steps:
Step 201, obtains the locating information of one or more web page element at least two in web page to be measured;
Step 202, determines oplimal Location information in the locating information of described at least two web page elements;
Step 203, when the described oplimal Location information of employing can not navigate to described web page element, and, when existence at least one can navigate to other locating information of described web page element, adopt oplimal Location information described in other positioning information update described;
Step 204, adopts described oplimal Location information to carry out the location of web page element.
In a preferred embodiment of the present application, when described oplimal Location information is the first locating information R1, described step 204 can comprise following sub-step:
Location is as time traversal step S41, and employing, when time attribute information combination, travels through the web page element set of web page to be measured, obtains working as time set and working as sub-quantity of the web page element navigated to;
Locate traversal step S42 next time, adopt attribute information combination next time, what obtain when time traversal step described location travels through when time set, obtains set next time and the quantity next time of the web page element navigated to; Wherein, attribute information combination next time includes when the information in time attribute information combination and newly-increased attribute information;
Location determination step S43, described in judgement, whether quantity is less than or equal to and works as sub-quantity next time, and whether described quantity is next time 1; If so, the successful determination step S44 in location is then performed; If not, then positioning properties Combination conversion step S45 is performed;
Locate successful determination step S44, judge to adopt described oplimal Location Information locating to described web page element;
Positioning properties Combination conversion step S45, the described combination of attribute information next time combined as when secondary attribute information, set is next time gathered as when secondary, and quantity is as working as sub-quantity next time, re-executes traversal step next time.
In the embodiment of the present application, when oplimal Location information is the first locating information R1, corresponding attribute information can be read from the combinations of attributes of web page element itself, superpose the attribute information of reading one by one and gradation travels through the web page element set of web page to be measured, when the quantity of the web page element navigated to until current is 1, uniquely navigate to this web page element.
Such as, suppose that combinations of attributes is for just like properties title: (tagName name type value) (allowing the property value of some attribute information for empty), adopt the first locating information R1 to carry out the process of web page element location as shown in table 2 below:
Can learn according to table 2, add the location that attribute information carries out web page element one by one, when the quantity of the web page element navigated to is 1, navigated to described web page element.
First the attribute information " tagName " of specifying is extracted in dependency combination: " INPUT " combines as when time attribute information, suppose to adopt when time attribute information combination, the web page element set traveling through web page to be measured obtains the gathering when secondary and work as sub-quantity 5 of the web page element navigated to, adopt " tagName ": " INPUT "+" name ": " user " of attribute information combination next time, to traveling through when secondary set of obtaining when time traversal step, obtain the set next time of web page element that navigates to and quantity 3 next time, because quantity 3 is less than when sub-quantity 5 next time, then the described combination of attribute information is next time combined as when time attribute information, set is next time gathered as when secondary, quantity 3 is as working as sub-quantity 3 next time, re-execute and locate traversal step next time, so, attribute information is combined as " tagName " next time: " INPUT "+" name ": " user "+" type ": " text ", by that analogy, until adopt combinations of attributes " tagName ": " INPUT "+" name ": " user "+" type ": " text "+" value ": time " 1 ", the quantity navigating to web page element is 1, navigate to described web page element.
Below adopt a kind of preferred exemplary to be described the step adopting described oplimal Location information to carry out the location of web page element in the application, with reference to the process flow diagram of a kind of web page element location of the application shown in Fig. 9, concrete steps are as follows:
Sub-step SS41, adopts the web page element set of the first attribute information combination traversal web page to be measured, obtains the first set and the first quantity;
Wherein, described first attribute information comprises the first attribute information;
Sub-step SS42, adopts the second attribute information combination traversal first to gather, obtains the second set and the second quantity;
Wherein, described second attribute information combination comprises described first attribute information, and, the second attribute information;
Sub-step SS43, judges whether described first quantity is more than or equal to the second quantity, if so, then performs sub-step SS44; If not, then sub-step SS46 is performed;
Sub-step SS44, judges whether described second quantity is 1; If so, then perform sub-step SS411, if not, then perform sub-step SS45;
Sub-step SS45, adopt the 3rd attribute information combination traversal second to gather, the quantity obtaining the current web page element navigated to is the 3rd quantity;
Wherein, described 3rd attribute information comprises described first attribute information, the second attribute information, and, the 3rd attribute information;
Sub-step SS46, adopt the 3rd attribute information combination traversal first to gather, the quantity obtaining the current web page element navigated to is the 3rd quantity;
Sub-step SS47, judge whether described second quantity is 1, and described first quantity is more than or equal to the second quantity, if so, then performs sub-step SS48; If not, then sub-step SS49 is performed;
Sub-step SS48, judges to adopt described oplimal Location Information locating to described web page element;
Sub-step S49, judges whether to there is other attribute information, if so, then performs sub-step S49, otherwise, perform sub-step SS410;
Sub-step SS410, using described 3rd attribute information combination as the first attribute information combination, and, after other attribute information combines as the second attribute information described in newly-increased one in described 3rd attribute information combination, return described sub-step SS42;
Sub-step SS411, judges to adopt oplimal Location information can not navigate to described web page element.
With reference to table 2, first the attribute information " tagName " of specifying is extracted in dependency combination: " INPUT " combines as the first attribute information, suppose employing first attribute information combination " tagName ": the first quantity that " INPUT " correspondence navigates to web page element is 5 and obtains the first set, adopt the second attribute information combination " tagName ": " INPUT "+" name ": time " user ", second attribute information combination traversal first is gathered the second quantity that correspondence navigates to web page element and is 3 and obtains the second set, because the first quantity 5 is greater than the second quantity 3, therefore the 3rd attribute information combination traversal second is adopted to gather, the 3rd quantity navigating to web page element is 2, now also no-fix web page element success, then using the 3rd attribute information combination " tagName ": " INPUT "+" name ": " user " combines as the first attribute information, and form new the second combinations of attributes " tagName " at the 3rd attribute information combination other attribute information newly-increased: " INPUT "+" name ": " user "+" type ": " text ", by that analogy, until when the quantity navigating to web page element is 1, navigate to described web page element.In this example owing to adopting combinations of attributes " tagName ": " INPUT "+" name ": " user "+" type ": " text "+" value ": " 1 ", the quantity navigating to web page element is 1, therefore can judge to adopt combinations of attributes " tagName ": " INPUT "+" name ": " user "+" type ": " text "+" value ": " 1 " navigates to described web page element.
When described oplimal Location information is the second locating information R2, described step 204 can comprise following sub-step:
Parent location is as time traversal step S51, and time parent attribute of an element information combination is worked as in employing, travels through the parent element set of the web page element of web page to be measured, obtains the gathering when secondary and work as sub-quantity of the parent element of the web page element navigated to;
Parent locates traversal step S52 next time, adopt parent attribute of an element information combination next time, what obtain when time traversal step described parent location travels through when time set, obtains set next time and the quantity next time of the parent element of the web page element navigated to; Wherein, the combination of attribute information next time of parent element includes the information in time attribute information combines and a newly-increased parent attribute of an element information of parent element;
Parent location determination step S53, described in judgement, whether quantity is less than or equal to and works as sub-quantity next time, and whether described quantity is next time 1; If so, then perform parent and locate successful determination step S54; If not, then parent positioning properties information switch process S55 is performed;
Parent locates successful determination step S54, by the described attribute of an element of parent next time information combination, is judged to be the parent attribute of an element information that uniquely can navigate to corresponding web page element, and goes to Relatively orientation step;
Parent positioning properties Combination conversion step S55, using the described attribute of an element of parent next time information combination as working as time parent attribute of an element information combination, set is next time gathered as when secondary, and quantity is as working as sub-quantity next time, re-executes parent and locates traversal step S52 next time;
Relatively orientation step S56, according to the Relatively orientation of described web page element within the scope of his father's dvielement to described web page element, then judge to adopt described oplimal Location Information locating to described web page element.
Particularly, because the position fixing process of the parent element of web page element is identical with the position fixing process of web page element, so do not repeat.The whole position fixing process of the second locating information R2 can divide 2 blocks: first piece, according to the locating information of the parent element of web page element, navigates to this parent element.Second piece, the locating information based on parent element navigates to the parent element of web page element, finds the relative position of web page element in parent elemental range in the scope of parent element, navigates to shown web page element.
Below adopt a kind of preferred exemplary to judging whether in the application that there is the step that uniquely can navigate to corresponding web page attribute of an element information is described, with reference to the positioning flow figure of the parent element of a kind of web page element of the application shown in Figure 10, concrete steps are as follows:
Sub-step SS51, adopts the web page element set of the 4th attribute information combination traversal web page to be measured, obtains the 3rd set and the 4th quantity;
Wherein, described 4th attribute information combination comprises the 4th attribute information;
Sub-step SS52, adopt the 5th attribute information combination traversal the 3rd to gather, the quantity obtaining the current parent element navigated to is the 5th quantity;
Wherein, described 5th attribute information combination comprises described 4th attribute information, and, the 5th attribute information;
Sub-step SS53, judges whether described 4th quantity is more than or equal to the 5th quantity, if so, performs sub-step SS54, if not, then performs sub-step SS55;
Sub-step SS54, judges whether described 5th quantity is 1; If so, then perform sub-step SS511, if not, then perform sub-step SS56;
Sub-step SS55 adopts the 6th attribute information combination traversal the 4th to gather, and the quantity obtaining the current web page element navigated to is the 6th quantity;
Wherein, described 6th attribute information combination comprises described 4th attribute information, the 5th attribute information, and, the 6th attribute information;
Sub-step SS56, adopt the 6th attribute information combination traversal the 3rd to gather, the quantity obtaining the current web page element navigated to is the 6th quantity;
Sub-step SS57, judges whether the 6th quantity is 1, and described 5th quantity is more than or equal to the 6th quantity, if so, then performs sub-step SS511, if not, then performs sub-step SS59;
Sub-step S58, judges to adopt described 6th attribute information navigate to the parent element of corresponding web page element and perform sub-step SS512;
Sub-step SS59, judges whether to exist parent attribute of an element information described in other, if so, then performs sub-step SS510, otherwise, perform sub-step SS511;
Sub-step SS510, using described 6th attribute information combination as the 4th attribute information combination, further, in described 6th attribute information combination the property value of a newly-increased parent attribute of an element title described in other and correspondence as the 5th attribute information combination after, return described sub-step SS52;
Sub-step SS511, judges to adopt oplimal Location information can not navigate to web page element;
Sub-step SS512, if according to the Relatively orientation of described web page element within the scope of his father's dvielement to described web page element, then judges to adopt described oplimal Location Information locating to described web page element; Otherwise judge to adopt oplimal Location information can not navigate to web page element.
When described oplimal Location information is the 3rd locating information R3, described step 204 can comprise following sub-step:
Sub-step S61, adopts described XPATH path orientation to described web page element.
In the embodiment of the present application, when oplimal Location information is the 3rd locating information R3, to adopt XPATH language can navigate to web page element according to XPATH path searching at web page to be measured.
Suppose the 3rd locating information R3=html/body/form/input [@name=" user "], enter to search the daughter element body of html at web page to be measured according to the 3rd locating information R3, daughter element form in body, in the daughter element user input frame input in form, user's name name is " user " web page element.
It should be noted that, for embodiment of the method, in order to simple description, therefore it is all expressed as a series of combination of actions, but those skilled in the art should know, the application is not by the restriction of described sequence of movement, because according to the application, some step can adopt other orders or carry out simultaneously.Secondly, those skilled in the art also should know, the embodiment described in instructions all belongs to preferred embodiment, and involved action might not be that the application is necessary.
With reference to Fig. 9, show the structured flowchart of the device embodiment of a kind of web page element location of the application, specifically can comprise with lower module:
Locating information acquisition module 301, for obtaining the locating information of one or more web page element at least two in web page to be measured;
In a preferred embodiment of the present application, the locating information of described web page element can comprise three, is specially:
The first locating information formed by the combinations of attributes of described web page element itself;
By second locating information that parent attribute of an element combines and the relative position of described web page element in his father's dvielement is formed of described web page element;
And, the 3rd locating information formed by the XPATH path of described web page element.
In a preferred embodiment of the present application, described locating information acquisition module 301 can comprise:
Attribute information obtains submodule, for for the one or more web page elements in web page to be measured, obtains one or more attribute informations of its correspondence respectively;
Location determination submodule, for judging whether that existence uniquely can navigate to corresponding web page attribute of an element information; If so, the first attribute information record sub module is then called; If not, then call parent element and obtain submodule;
Attribute information record sub module, forms the combinations of attributes of described web page element itself for recording described attribute information;
Parent element obtains submodule, for obtaining the parent attribute of an element information of current page element;
Parent location determination submodule, for judging whether that existence uniquely can navigate to described parent attribute of an element information; If so, parent attribute information record sub module is called; If not, then using described parent element as current page element, and call return parent element obtain submodule;
Parent attribute information record sub module, forms the parent attribute of an element combination of described web page element for recording described parent attribute of an element information, and, obtain the relative position of described web page element in his father's dvielement;
Coordinates measurement submodule, for for the one or more web page elements in web page to be measured, adopts XPATH path orientation engine to generate the XPATH path of described web page element respectively.
In a preferred embodiment of the present application, described location determination submodule can comprise:
When secondary Traversal Unit, working as secondary attribute information combination for adopting, traveling through the web page element set of web page to be measured, obtain the gathering when secondary and work as sub-quantity of the web page element navigated to;
Traversal Unit next time, for adopting attribute information combination next time, to described obtain when time Traversal Unit travel through when time set, obtain set next time and the quantity next time of the web page element navigated to; Wherein, attribute information combination next time includes when the information in time attribute information combination and newly-increased attribute information;
Judging unit, for described in judging next time quantity whether be less than or equal to and work as sub-quantity, and whether described quantity is next time 1; If so, then identifying unit is called successfully; If not, then attribute information converting unit is called;
Success identifying unit, for by the described combination of attribute information next time, is judged to uniquely to navigate to corresponding web page attribute of an element information;
Combinations of attributes converting unit, for the described combination of attribute information next time being combined as when secondary attribute information, set is next time gathered as when secondary, and quantity is as working as sub-quantity next time, re-executes traversal step next time.
In a preferred embodiment of the present application, described location determination submodule can also comprise:
Attribute information filters submodule, for from described web page attribute of an element information, filters out the attribute information that property value is sky.
In a preferred embodiment of the present application, described parent location determination submodule can comprise:
Parent, when time Traversal Unit, is worked as time parent attribute of an element information combination for employing, is traveled through the parent element set of the web page element of web page to be measured, obtains the gathering when secondary and work as sub-quantity of the parent element of the web page element navigated to;
Parent is Traversal Unit next time, for adopting parent attribute of an element information combination next time, traveling through when time set of the parent element obtained when time Traversal Unit described parent, obtains set next time and the quantity next time of the parent element of the web page element navigated to; Wherein, parent attribute of an element information combination includes when the information in time parent attribute of an element information combination and a newly-increased parent attribute of an element information next time;
Parent judging unit, for described in judging next time quantity whether be less than or equal to and work as sub-quantity, and whether described quantity is next time 1; If so, parent success identifying unit is then called; If not, then parent attribute information converting unit is called;
Parent success identifying unit, for by the described attribute of an element of parent next time information combination, is judged to be the parent attribute of an element information that uniquely can navigate to corresponding web page element;
Parent combinations of attributes converting unit, for using the described attribute of an element of parent next time information combination as when time parent attribute of an element information combination, set is next time gathered as when secondary, and quantity is as working as sub-quantity next time, re invocation parent Traversal Unit next time.
Oplimal Location information chooses module 302, for determining oplimal Location information in the locating information of described at least two web page elements;
In a preferred embodiment of the present application, described oplimal Location information is chosen module 302 and can be comprised:
First statistics submodule was the first processing time for adding up described first locating information of employing to the described web page to be measured time of carrying out spent by web page element location;
Second statistics submodule was the second processing time for adding up described second locating information of employing to the described web page to be measured time of carrying out spent by web page element location;
3rd statistics submodule was the 3rd processing time for adding up described 3rd locating information of employing to the described web page to be measured time of carrying out spent by web page element location;
Submodule is chosen in sequence, and for by described first processing time, the second processing time and the 3rd processing time carry out backward sequence, extracts the most front locating information corresponding to processing time that sorts as oplimal Location information.
Oplimal Location information updating module 303, for described web page element can not be navigated to when the described oplimal Location information of employing, further, when existence at least one can navigate to other locating information of described web page element, oplimal Location information described in other positioning information update described is adopted.
In a preferred embodiment of the present application, described oplimal Location information updating module 303 can comprise:
Oplimal Location information replacement module, for adopting other locating information described as described oplimal Location information;
Oplimal Location information repairs module, repairs described oplimal Location information for adopting other locating information described.
In a preferred embodiment of the present application, described device can also comprise:
Web page element locating module, carries out the location of web page element for adopting described oplimal Location information.
In a preferred embodiment of the present application, described web page element locating module can comprise:
Location, when time traversal submodule, for employing when time attribute information combination, travels through the web page element set of web page to be measured, obtains working as time set and working as sub-quantity of the web page element navigated to;
Location travels through submodule next time, for adopting attribute information combination next time, to described obtain when time traversal submodule travel through when time set, obtain the set next time of web page element that navigates to and quantity next time; Wherein, attribute information combination next time includes when the information in time attribute information combination and newly-increased attribute information;
Location determination submodule, for described in judging next time quantity whether be less than or equal to and work as sub-quantity, and whether described quantity is next time 1; If so, the successful decision sub-module in location is then performed; If not, then positioning properties Combination conversion submodule is performed;
Locating successful decision sub-module, adopting described oplimal Location Information locating to described web page element for judging;
Positioning properties Combination conversion submodule, for the described combination of attribute information next time being combined as when secondary attribute information, set is next time gathered as when secondary, and quantity is as working as sub-quantity next time, and re invocation travels through submodule next time.
In a preferred embodiment of the present application, described web page element locating module can comprise:
Parent is located when time traversal submodule, works as time parent attribute of an element information combination, travel through the parent element set of the web page element of web page to be measured for employing, obtains the gathering when secondary and work as sub-quantity of the parent element of the web page element navigated to;
Parent location travels through submodule next time, for adopting parent attribute of an element information combination next time, to described parent location traveling through when time set when the parent element that time traversal submodule obtains, obtain set next time and the quantity next time of the parent element of the web page element navigated to; Wherein, the combination of attribute information next time of parent element includes the information in time attribute information combines and a newly-increased parent attribute of an element information of parent element;
Parent location determination submodule, for described in judging next time quantity whether be less than or equal to and work as sub-quantity, and whether described quantity is next time 1; If so, then call parent and locate successful decision sub-module; If not, then parent positioning properties informoter module is called;
Parent locates successful decision sub-module, for by the described attribute of an element of parent next time information combination, is judged to be the parent attribute of an element information that uniquely can navigate to corresponding web page element, and goes to Relatively orientation submodule;
Parent positioning properties Combination conversion submodule, for the work as time attribute information of the described attribute of an element of parent next time information combination as parent element is combined, set is next time gathered as when secondary, and quantity is as working as sub-quantity next time, re-executes parent and calls submodule next time;
Relatively orientation submodule, for according to the Relatively orientation of described web page element within the scope of his father's dvielement to described web page element time, then judge to adopt described oplimal Location Information locating to described web page element.
For device embodiment, due to itself and embodiment of the method basic simlarity, so description is fairly simple, relevant part illustrates see the part of embodiment of the method.
With reference to Figure 10, show the structured flowchart of the system embodiment of a kind of web page element location of the application, specifically can comprise with lower module:
Information extracting device 401, for obtaining at least two locating information of one or more web page element in web page to be measured, and determines oplimal Location information in described at least two locating information;
Engine of positioning device 402, carries out the location of web page element at least two locating information described in adopting;
Feedback assembly 403, for described web page element can not be navigated to when the described oplimal Location information of employing, further, when existence at least one can navigate to other locating information of described web page element, oplimal Location information described in other positioning information update described is adopted.
Described web page element positioning system can realize the function of each web page element in web page to be measured being carried out to various dimensions location, described web page element positioning system specifically can comprise the information extracting device 401 for performing step1, for performing the engine of positioning device 402 of step2, and, for performing the feedback assembly 403 of step3.
Page1 in Fig. 8 is the dom(Document ObjectModel of dynamic web page to be tested, DOM Document Object Model) tree, the locating information (i.e. the locating information of at least two web page elements of web page to be measured) of the web page element various dimensions of web page to be measured can be obtained through information extracting device 401, after the layout structure of page1 or the web page attribute of an element information of page1 or other factors change and become page2, web page element after engine of positioning device 402 adopts the locating information of described web page element various dimensions still can navigate to change, the positioning information update various dimensions locating information of web page element after the change navigated to can be adopted through feedback assembly 403, the locating information of web page element after change is repaired.
Below Step1-Step3 is illustrated further:
Step1:
Many locating information of the web page to be measured that information extracting device 401 obtains, the locating information of described acquisition can be three, specifically can comprise: the first locating information R1 formed by the combinations of attributes of described web page element itself; By the second locating information R2 that parent attribute of an element combines and the relative position of described web page element in his father's dvielement is formed of described web page element; The 3rd locating information R3 formed by the XPATH path of described web page element.
Information extracting device 401 can once create multiple locating information, therefore can realize the double shield of attribute location (R1+R2) and coordinate setting (R3).
Step2:
The locating information that engine of positioning device 402 obtains for information extracting device 401 carries out playback, carries out web page element location, check whether locating information can also navigate to web page element to the Page2 after web page layout to be measured changes.Particularly, engine of positioning device 402 is used can to comprise following flow process:
1, choosing the highest locating information of priority and position process, such as, can be the 3rd locating information R3;
2, use the engine of positioning that the first locating information R1 is corresponding, successively reading attributes, judge respectively, until the web page element navigated to only has one;
3, use the engine of positioning that the second locating information R2 is corresponding, to the execution R1 engine location parent element of the parent element of web page element, then by the relative position sequence index location of web page element in father's element;
4, use the XPATH engine of positioning that the 3rd locating information R3 is corresponding, standard x PATH syntax parsing engine positions.
Step3:
Feedback assembly 403 is repaired the locating information that information extracting device 401 obtains by engine of positioning device 402 execution result of playback.First can judge whether the priority of information extracting device 401 is still constant in engine of positioning, if constant, oplimal Location information is still effective, need not repair, if changed, need the locating information of repairing web page element, again this locating information is got by information extracting device 401, and feed back to web page element positioning system and upgrade, the web page element changed is positioned to the self-regeneration process of information.
For system embodiment, due to itself and embodiment of the method basic simlarity, so description is fairly simple, relevant part illustrates see the part of embodiment of the method.
Each embodiment in this instructions all adopts the mode of going forward one by one to describe, and what each embodiment stressed is the difference with other embodiments, between each embodiment identical similar part mutually see.
Those skilled in the art should understand, the embodiment of the application can be provided as method, device or computer program.Therefore, the application can adopt the form of complete hardware embodiment, completely software implementation or the embodiment in conjunction with software and hardware aspect.And the application can adopt in one or more form wherein including the upper computer program implemented of computer-usable storage medium (including but not limited to magnetic disk memory, CD-ROM, optical memory etc.) of computer usable program code.
The application describes with reference to according to the process flow diagram of the method for the embodiment of the present application, equipment (system) and computer program and/or block scheme.Should understand can by the combination of the flow process in each flow process in computer program instructions realization flow figure and/or block scheme and/or square frame and process flow diagram and/or block scheme and/or square frame.These computer program instructions can being provided to the processor of multi-purpose computer, special purpose computer, Embedded Processor or other programmable data processing device to produce a machine, making the instruction performed by the processor of computing machine or other programmable data processing device produce device for realizing the function of specifying in process flow diagram flow process or multiple flow process and/or block scheme square frame or multiple square frame.
These computer program instructions also can be stored in can in the computer-readable memory that works in a specific way of vectoring computer or other programmable data processing device, the instruction making to be stored in this computer-readable memory produces the manufacture comprising command device, and this command device realizes the function of specifying in process flow diagram flow process or multiple flow process and/or block scheme square frame or multiple square frame.
These computer program instructions also can be loaded in computing machine or other programmable data processing device, make on computing machine or other programmable devices, to perform sequence of operations step to produce computer implemented process, thus the instruction performed on computing machine or other programmable devices is provided for the step realizing the function of specifying in process flow diagram flow process or multiple flow process and/or block scheme square frame or multiple square frame.
Although described the preferred embodiment of the application, those skilled in the art once obtain the basic creative concept of cicada, then can make other change and amendment to these embodiments.So claims are intended to be interpreted as comprising preferred embodiment and falling into all changes and the amendment of the application's scope.
Finally, also it should be noted that, in this article, the such as relational terms of first and second grades and so on is only used for an entity or operation to separate with another entity or operational zone, and not necessarily requires or imply the relation that there is any this reality between these entities or operation or sequentially.And, term " comprises ", " comprising " or its any other variant are intended to contain comprising of nonexcludability, thus make to comprise the process of a series of key element, method, article or equipment and not only comprise those key elements, but also comprise other key elements clearly do not listed, or also comprise by the intrinsic key element of this process, method, article or equipment.When not more restrictions, the key element limited by statement " comprising ... ", and be not precluded within process, method, article or the equipment comprising described key element and also there is other identical element.
Above to the method for a kind of web page element location that the application provides, Apparatus and system, be described in detail, apply specific case herein to set forth the principle of the application and embodiment, the explanation of above embodiment is just for helping method and the core concept thereof of understanding the application; Meanwhile, for one of ordinary skill in the art, according to the thought of the application, all will change in specific embodiments and applications, in sum, this description should not be construed as the restriction to the application.

Claims (23)

1. a method for web page element location, is characterized in that, comprising:
Obtain at least two locating information of one or more web page element in web page to be measured;
Oplimal Location information is determined in described at least two locating information;
When the described oplimal Location information of employing can not navigate to described web page element, and, when existence at least one can navigate to other locating information of described web page element, adopt oplimal Location information described in other positioning information update described.
2. method according to claim 1, is characterized in that, also comprises:
Described oplimal Location information is adopted to carry out the location of described web page element.
3. method according to claim 1 and 2, is characterized in that, the locating information of described web page element comprises three, is specially:
The first locating information formed by the combinations of attributes of described web page element itself;
By second locating information that parent attribute of an element combines and the relative position of described web page element in his father's dvielement is formed of described web page element;
And, the 3rd locating information formed by the XPATH path of described web page element.
4. method according to claim 3, is characterized in that, in described acquisition web page to be measured, the step of at least two locating information of one or more web page element comprises:
Sub-step S1, for the one or more web page elements in web page to be measured, obtains the attribute information of its correspondence respectively;
Sub-step S2, judges whether that existence uniquely can navigate to corresponding web page attribute of an element information; If so, then sub-step S3 is performed; If not, then sub-step S4 is performed;
Sub-step S3, records the combinations of attributes that described attribute information forms described web page element itself;
Sub-step S4, obtains the parent attribute of an element information of current page element;
Sub-step S5, judges whether that existence uniquely can navigate to described parent attribute of an element information; If so, sub-step S6 is performed; If not, then described parent element is returned sub-step S4 as current page element;
Sub-step S6, records the parent attribute of an element combination that described parent attribute of an element information forms described web page element, and, obtain the relative position of described web page element in his father's dvielement;
Sub-step S7, for the one or more web page elements in web page to be measured, adopts XPATH path orientation engine to generate the XPATH path of described web page element respectively.
5. method according to claim 4, is characterized in that, described sub-step S2 comprises further:
When secondary traversal step, adopt and work as secondary attribute information combination, travel through the web page element set of web page to be measured, obtain the gathering when secondary and work as sub-quantity of the web page element navigated to;
Traversal step next time, adopts attribute information combination next time, to described obtain when time traversal step travel through when time set, obtain set next time and the quantity next time of the web page element navigated to; Wherein, attribute information combination next time includes when the information in time attribute information combination and newly-increased attribute information;
Determining step, described in judgement, whether quantity is less than or equal to and works as sub-quantity next time, and whether described quantity is next time 1; If so, then run succeeded determination step; If not, then attribute information switch process is performed;
Success determination step, by the described combination of attribute information next time, is judged to uniquely to navigate to corresponding web page attribute of an element information;
Combinations of attributes switch process, using the combination of described attribute information next time as when time attribute information combination, set is next time as when time to gather, and quantity is as working as sub-quantity next time, traversal step next time described in re-executing.
6. method according to claim 4, is characterized in that, before sub-step S2, also comprises:
Sub-step S11, from one or more attribute informations of described web page element, filtering out property value is empty attribute information.
7. method according to claim 4, is characterized in that, described sub-step S5 comprises further:
Parent is when time traversal step, and time parent attribute of an element information combination is worked as in employing, travels through the parent element set of the web page element of web page to be measured, obtains the gathering when secondary and work as sub-quantity of the parent element of the web page element navigated to;
Parent is traversal step next time, adopt parent attribute of an element information combination next time, traveling through when time set of the parent element obtained when time traversal step described parent, obtains set next time and the quantity next time of the parent element of the web page element navigated to; Wherein, parent attribute of an element information combination includes when the information in time parent attribute of an element information combination and a newly-increased parent attribute of an element information next time;
Parent determining step, described in judgement, whether quantity is less than or equal to and works as sub-quantity next time, and whether described quantity is next time 1; If so, parent success determination step is then performed; If not, then parent attribute information switch process is performed;
Parent success determination step, by the described attribute of an element of parent next time information combination, is judged to be the parent attribute of an element information that uniquely can navigate to corresponding web page element;
Parent combinations of attributes switch process, using the described attribute of an element of parent next time information combination as working as time parent attribute of an element information combination, set is next time gathered as when secondary, and quantity is as working as sub-quantity next time, re-executes parent traversal step next time.
8. method according to claim 3, is characterized in that, describedly in the locating information of at least two web page elements, determines that the step of oplimal Location information comprises:
Statistics adopts described first locating information to be the first processing time to the described web page to be measured time of carrying out spent by web page element location;
Statistics adopts described second locating information to be the second processing time to the described web page to be measured time of carrying out spent by web page element location;
Statistics adopts described 3rd locating information to be the 3rd processing time to the described web page to be measured time of carrying out spent by web page element location;
By described first processing time, the second processing time and the 3rd processing time carry out backward sequence, extract the most front locating information corresponding to processing time of sequence as oplimal Location information.
9. the method according to claim 4 or 5, is characterized in that, when described oplimal Location information is the first locating information, the step that described employing oplimal Location information carries out the location of web page element comprises:
Location is when time traversal step, and employing, when time attribute information combination, travels through the web page element set of web page to be measured, obtains working as time set and working as sub-quantity of the web page element navigated to;
Locate traversal step next time, adopt attribute information combination next time, what obtain when time traversal step described location travels through when time set, obtains set next time and the quantity next time of the web page element navigated to; Wherein, attribute information combination next time includes when the information in time attribute information combination and newly-increased attribute information;
Location determination step, described in judgement, whether quantity is less than or equal to and works as sub-quantity next time, and whether described quantity is next time 1; If so, the successful determination step in location is then performed; If not, then positioning properties Combination conversion step is performed;
Locate successful determination step, judge to adopt described oplimal Location Information locating to described web page element;
Positioning properties Combination conversion step, the described combination of attribute information next time combined as when secondary attribute information, set is next time gathered as when secondary, and quantity is as working as sub-quantity next time, re-executes and locates traversal step next time.
10. the method according to claim 4 or 7, is characterized in that, when described oplimal Location information is the second locating information, the step that described employing oplimal Location information carries out the location of web page element comprises:
Parent location is when time traversal step, and time parent attribute of an element information combination is worked as in employing, travels through the parent element set of the web page element of web page to be measured, obtains the gathering when secondary and work as sub-quantity of the parent element of the web page element navigated to;
Parent locates traversal step next time, adopt parent attribute of an element information combination next time, traveling through when time set of the parent element obtained when time traversal step described parent location, obtains set next time and the quantity next time of the parent element of the web page element navigated to; Wherein, the combination of attribute information next time of parent element includes the information in time attribute information combines and a newly-increased parent attribute of an element information of parent element;
Parent location determination step, described in judgement, whether quantity is less than or equal to and works as sub-quantity next time, and whether described quantity is next time 1; If so, then perform parent and locate successful determination step; If not, then parent positioning properties information switch process is performed;
Parent locates successful determination step, by the described attribute of an element of parent next time information combination, is judged to be the parent attribute of an element information that uniquely can navigate to corresponding web page element, and goes to Relatively orientation step;
Parent positioning properties Combination conversion step, using the described attribute of an element of parent next time information combination as working as time parent attribute of an element information combination, set is next time gathered as when secondary, and quantity is as working as sub-quantity next time, re-executes described parent and locates traversal step next time;
Relatively orientation step, according to the Relatively orientation of described web page element within the scope of his father's dvielement to described web page element, then judge to adopt described oplimal Location Information locating to described web page element.
11. methods according to claim 1, is characterized in that, described in other positioning information update of described employing, the step of oplimal Location information comprises:
Adopt other locating information described as described oplimal Location information;
Or,
Other locating information described is adopted to repair described oplimal Location information.
The device of 12. 1 kinds of web page element location, is characterized in that, comprising:
Locating information acquisition module, for obtaining the locating information of one or more web page element at least two in web page to be measured;
Oplimal Location information chooses module, for determining oplimal Location information in described at least two locating information;
Oplimal Location information updating module, for described web page element can not be navigated to when the described oplimal Location information of employing, further, when existence at least one can navigate to other locating information of described web page element, oplimal Location information described in other positioning information update described is adopted.
13. devices according to claim 12, is characterized in that, also comprise:
Web page element locating module, for the location adopting described oplimal Location information to carry out described web page element.
14. devices according to claim 12 or 13, it is characterized in that, the locating information of described web page element comprises three, is specially:
The first locating information formed by the combinations of attributes of described web page element itself;
By second locating information that parent attribute of an element combines and the relative position of described web page element in his father's dvielement is formed of described web page element;
And, the 3rd locating information formed by the XPATH path of described web page element.
15. devices according to claim 14, is characterized in that, described locating information acquisition module comprises:
Attribute information obtains submodule, for for the one or more web page elements in web page to be measured, obtains the attribute information of its correspondence respectively;
Location determination submodule, for judging whether that existence uniquely can navigate to corresponding web page attribute of an element information; If so, attribute information record sub module is then called; If not, then call parent element and obtain submodule;
Attribute information record sub module, forms the combinations of attributes of described web page element itself for recording described attribute information;
Parent element obtains submodule, for obtaining the parent attribute of an element information of current page element;
Parent location determination submodule, for judging whether that existence uniquely can navigate to described parent attribute of an element information; If so, parent attribute information record sub module is called; If not, then using described parent element as current page element, and call return parent element obtain submodule;
Parent attribute information record sub module, forms the parent attribute of an element combination of described web page element for recording described parent attribute of an element information, and, obtain the relative position of described web page element in his father's dvielement;
Coordinates measurement submodule, for for the one or more web page elements in web page to be measured, adopts XPATH path orientation engine to generate the XPATH path of described web page element respectively.
16. devices according to claim 15, is characterized in that, described location determination submodule comprises:
When secondary Traversal Unit, working as secondary attribute information combination for adopting, traveling through the web page element set of web page to be measured, obtain the gathering when secondary and work as sub-quantity of the web page element navigated to;
Traversal Unit next time, for adopting attribute information combination next time, to described obtain when time Traversal Unit travel through when time set, obtain set next time and the quantity next time of the web page element navigated to; Wherein, attribute information combination next time includes when the information in time attribute information combination and newly-increased attribute information;
Judging unit, for described in judging next time quantity whether be less than or equal to and work as sub-quantity, and whether described quantity is next time 1; If so, then identifying unit is called successfully; If not, then attribute information converting unit is called;
Success identifying unit, for by the described combination of attribute information next time, is judged to uniquely to navigate to corresponding web page attribute of an element information;
Combinations of attributes converting unit, for the described combination of attribute information next time being combined as when secondary attribute information, set is next time gathered as when secondary, and quantity is as working as sub-quantity next time, re-executes traversal step next time.
17. devices according to claim 15, is characterized in that, also comprise:
Attribute information filters submodule, and in the one or more attribute informations from described web page element, filtering out property value is empty attribute information.
18. devices according to claim 15, is characterized in that, described parent location determination submodule comprises:
Parent, when time Traversal Unit, is worked as time parent attribute of an element information combination for employing, is traveled through the parent element set of the web page element of web page to be measured, obtains the gathering when secondary and work as sub-quantity of the parent element of the web page element navigated to;
Parent is Traversal Unit next time, for adopting parent attribute of an element information combination next time, traveling through when time set of the parent element obtained when time Traversal Unit described parent, obtains set next time and the quantity next time of the parent element of the web page element navigated to; Wherein, parent attribute of an element information combination includes when the information in time parent attribute of an element information combination and a newly-increased parent attribute of an element information next time;
Parent judging unit, for described in judging next time quantity whether be less than or equal to and work as sub-quantity, and whether described quantity is next time 1; If so, parent success identifying unit is then called; If not, then parent attribute information converting unit is called;
Parent success identifying unit, for by the described attribute of an element of parent next time information combination, is judged to be the parent attribute of an element information that uniquely can navigate to corresponding web page element;
Parent combinations of attributes converting unit, for using the described attribute of an element of parent next time information combination as when time parent attribute of an element information combination, set is next time gathered as when secondary, and quantity is as working as sub-quantity next time, re invocation parent Traversal Unit next time.
19. devices according to claim 14, is characterized in that, described oplimal Location information is chosen module and comprised:
First statistics submodule was the first processing time for adding up described first locating information of employing to the described web page to be measured time of carrying out spent by web page element location;
Second statistics submodule was the second processing time for adding up described second locating information of employing to the described web page to be measured time of carrying out spent by web page element location;
3rd statistics submodule was the 3rd processing time for adding up described 3rd locating information of employing to the described web page to be measured time of carrying out spent by web page element location;
Submodule is chosen in sequence, and for by described first processing time, the second processing time and the 3rd processing time carry out backward sequence, extracts the most front locating information corresponding to processing time that sorts as oplimal Location information.
20. devices according to claim 15 or 16, it is characterized in that, described web page element locating module comprises:
Location, when time traversal submodule, for employing when time attribute information combination, travels through the web page element set of web page to be measured, obtains working as time set and working as sub-quantity of the web page element navigated to;
Location travels through submodule next time, for adopting attribute information combination next time, to described obtain when time traversal submodule travel through when time set, obtain the set next time of web page element that navigates to and quantity next time; Wherein, attribute information combination next time includes when the information in time attribute information combination and newly-increased attribute information;
Location determination submodule, for described in judging next time quantity whether be less than or equal to and work as sub-quantity, and whether described quantity is next time 1; If so, the successful decision sub-module in location is then performed; If not, then positioning properties Combination conversion submodule is performed;
Locating successful decision sub-module, adopting described oplimal Location Information locating to described web page element for judging;
Positioning properties Combination conversion submodule, for the described combination of attribute information next time being combined as when secondary attribute information, set is next time gathered as when secondary, and quantity is as working as sub-quantity next time, and re invocation travels through submodule next time.
21. devices according to claim 15 or 18, it is characterized in that, described web page element locating module comprises:
Parent is located when time traversal submodule, works as time parent attribute of an element information combination, travel through the parent element set of the web page element of web page to be measured for employing, obtains the gathering when secondary and work as sub-quantity of the parent element of the web page element navigated to;
Parent location travels through submodule next time, for adopting parent attribute of an element information combination next time, to described parent location traveling through when time set when the parent element that time traversal submodule obtains, obtain set next time and the quantity next time of the parent element of the web page element navigated to; Wherein, the combination of attribute information next time of parent element includes the information in time attribute information combines and a newly-increased parent attribute of an element information of parent element;
Parent location determination submodule, for described in judging next time quantity whether be less than or equal to and work as sub-quantity, and whether described quantity is next time 1; If so, then call parent and locate successful decision sub-module; If not, then parent positioning properties informoter module is called;
Parent locates successful decision sub-module, for by the described attribute of an element of parent next time information combination, is judged to be the parent attribute of an element information that uniquely can navigate to corresponding web page element, and goes to Relatively orientation submodule;
Parent positioning properties Combination conversion submodule, for the work as time attribute information of the described attribute of an element of parent next time information combination as parent element is combined, set is next time gathered as when secondary, and quantity is as working as sub-quantity next time, re-executes parent and calls submodule next time;
Relatively orientation submodule, for according to the Relatively orientation of described web page element within the scope of his father's dvielement to described web page element time, then judge to adopt described oplimal Location Information locating to described web page element.
22. devices according to claim 12, is characterized in that, described oplimal Location information updating module comprises:
Oplimal Location information replacement module, for adopting other locating information described as described oplimal Location information;
Oplimal Location information repairs module, repairs described oplimal Location information for adopting other locating information described.
The system of 23. 1 kinds of web page element location, is characterized in that, comprising:
Information extracting device, for obtaining at least two locating information of one or more web page element in web page to be measured, and determines oplimal Location information in described at least two locating information;
Engine of positioning device, carries out the location of web page element at least two locating information described in adopting;
Feedback assembly, for described web page element can not be navigated in the described oplimal Location information of employing, further, when existence at least one can navigate to other locating information of described web page element, oplimal Location information described in other positioning information update described is adopted.
CN201310367470.7A 2013-08-21 2013-08-21 A kind of method of Web page surface element positioning, apparatus and system Active CN104424087B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201310367470.7A CN104424087B (en) 2013-08-21 2013-08-21 A kind of method of Web page surface element positioning, apparatus and system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201310367470.7A CN104424087B (en) 2013-08-21 2013-08-21 A kind of method of Web page surface element positioning, apparatus and system

Publications (2)

Publication Number Publication Date
CN104424087A true CN104424087A (en) 2015-03-18
CN104424087B CN104424087B (en) 2017-07-28

Family

ID=52973133

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201310367470.7A Active CN104424087B (en) 2013-08-21 2013-08-21 A kind of method of Web page surface element positioning, apparatus and system

Country Status (1)

Country Link
CN (1) CN104424087B (en)

Cited By (16)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105279089A (en) * 2015-10-30 2016-01-27 中国人民财产保险股份有限公司 Method and device for obtaining page element
CN105528297A (en) * 2016-01-29 2016-04-27 广州酷狗计算机科技有限公司 Method and device for testing web page
CN105743736A (en) * 2016-01-27 2016-07-06 武汉联影医疗科技有限公司 Automated testing method and system
CN106776301A (en) * 2016-12-01 2017-05-31 广州酷狗计算机科技有限公司 Daughter element method of testing and device
CN106991045A (en) * 2017-03-24 2017-07-28 广州酷狗计算机科技有限公司 Page method of calibration and device
CN107451052A (en) * 2017-07-11 2017-12-08 广州慧睿思通信息科技有限公司 One kind is based on Web system positioning webpage element test method
CN107861779A (en) * 2017-09-20 2018-03-30 东软集团股份有限公司 Page object localization method and device, storage medium, electronic equipment
CN107908639A (en) * 2017-09-26 2018-04-13 东软集团股份有限公司 Page object lookup method and device, storage medium, electronic equipment
CN108845925A (en) * 2018-03-30 2018-11-20 新华三技术有限公司 Web page test method, device, electronic equipment and computer-readable medium
CN110399063A (en) * 2019-07-19 2019-11-01 口碑(上海)信息技术有限公司 The inspection method and device of page elements attribute
CN110727603A (en) * 2019-10-25 2020-01-24 重庆誉存大数据科技有限公司 Improved method for automatically testing positioning elements based on UI (user interface)
CN111221612A (en) * 2020-01-03 2020-06-02 北京小米移动软件有限公司 Method, device and medium for positioning user interface element
CN112083992A (en) * 2020-09-02 2020-12-15 李振 UI automation test method
CN113110991A (en) * 2021-03-29 2021-07-13 青岛海尔科技有限公司 Page element positioning method and device, storage medium and electronic device
CN115061927A (en) * 2022-06-27 2022-09-16 壹沓科技(上海)有限公司 Webpage element positioning method and device based on RPA and storage medium
CN115858401A (en) * 2023-02-27 2023-03-28 成都光合信号科技有限公司 Page detection method and device, electronic equipment and storage medium

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101089856A (en) * 2007-07-20 2007-12-19 李沫南 Method for abstracting network data and web reptile system
US20080162488A1 (en) * 2006-12-29 2008-07-03 Karle Christopher J Method, system and program product for updating browser page elements over a distributed network
CN101261642A (en) * 2008-04-10 2008-09-10 深圳市迅雷网络技术有限公司 Method and device for regulating internet page layout
CN101593184A (en) * 2008-05-29 2009-12-02 国际商业机器公司 The system and method for self-adaptively locating dynamic web page elements
CN103049493A (en) * 2012-12-07 2013-04-17 北京百度网讯科技有限公司 Method, device and equipment for determining presenting positions of target page elements
CN103177096A (en) * 2013-03-15 2013-06-26 百度在线网络技术(北京)有限公司 Page element positioning method based on text attribute and page element positioning device based on text attribute

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20080162488A1 (en) * 2006-12-29 2008-07-03 Karle Christopher J Method, system and program product for updating browser page elements over a distributed network
CN101089856A (en) * 2007-07-20 2007-12-19 李沫南 Method for abstracting network data and web reptile system
CN101261642A (en) * 2008-04-10 2008-09-10 深圳市迅雷网络技术有限公司 Method and device for regulating internet page layout
CN101593184A (en) * 2008-05-29 2009-12-02 国际商业机器公司 The system and method for self-adaptively locating dynamic web page elements
CN103049493A (en) * 2012-12-07 2013-04-17 北京百度网讯科技有限公司 Method, device and equipment for determining presenting positions of target page elements
CN103177096A (en) * 2013-03-15 2013-06-26 百度在线网络技术(北京)有限公司 Page element positioning method based on text attribute and page element positioning device based on text attribute

Cited By (21)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105279089A (en) * 2015-10-30 2016-01-27 中国人民财产保险股份有限公司 Method and device for obtaining page element
CN105279089B (en) * 2015-10-30 2017-12-12 中国人民财产保险股份有限公司 A kind of method and device for obtaining page elements
CN105743736B (en) * 2016-01-27 2019-01-04 武汉联影医疗科技有限公司 Automated testing method and system
CN105743736A (en) * 2016-01-27 2016-07-06 武汉联影医疗科技有限公司 Automated testing method and system
CN105528297A (en) * 2016-01-29 2016-04-27 广州酷狗计算机科技有限公司 Method and device for testing web page
CN106776301A (en) * 2016-12-01 2017-05-31 广州酷狗计算机科技有限公司 Daughter element method of testing and device
CN106991045A (en) * 2017-03-24 2017-07-28 广州酷狗计算机科技有限公司 Page method of calibration and device
CN107451052A (en) * 2017-07-11 2017-12-08 广州慧睿思通信息科技有限公司 One kind is based on Web system positioning webpage element test method
CN107861779A (en) * 2017-09-20 2018-03-30 东软集团股份有限公司 Page object localization method and device, storage medium, electronic equipment
CN107908639A (en) * 2017-09-26 2018-04-13 东软集团股份有限公司 Page object lookup method and device, storage medium, electronic equipment
CN108845925B (en) * 2018-03-30 2022-02-11 新华三技术有限公司 Web page testing method and device, electronic equipment and computer readable medium
CN108845925A (en) * 2018-03-30 2018-11-20 新华三技术有限公司 Web page test method, device, electronic equipment and computer-readable medium
CN110399063A (en) * 2019-07-19 2019-11-01 口碑(上海)信息技术有限公司 The inspection method and device of page elements attribute
CN110727603A (en) * 2019-10-25 2020-01-24 重庆誉存大数据科技有限公司 Improved method for automatically testing positioning elements based on UI (user interface)
CN111221612A (en) * 2020-01-03 2020-06-02 北京小米移动软件有限公司 Method, device and medium for positioning user interface element
CN111221612B (en) * 2020-01-03 2023-08-29 北京小米移动软件有限公司 Method, device and medium for positioning user interface element
CN112083992A (en) * 2020-09-02 2020-12-15 李振 UI automation test method
CN113110991A (en) * 2021-03-29 2021-07-13 青岛海尔科技有限公司 Page element positioning method and device, storage medium and electronic device
CN115061927A (en) * 2022-06-27 2022-09-16 壹沓科技(上海)有限公司 Webpage element positioning method and device based on RPA and storage medium
CN115858401A (en) * 2023-02-27 2023-03-28 成都光合信号科技有限公司 Page detection method and device, electronic equipment and storage medium
CN115858401B (en) * 2023-02-27 2023-05-16 成都光合信号科技有限公司 Page detection method and device, electronic equipment and storage medium

Also Published As

Publication number Publication date
CN104424087B (en) 2017-07-28

Similar Documents

Publication Publication Date Title
CN104424087A (en) Web page element positioning method, apparatus and system
US8219969B2 (en) Data structure used for directory structure navigation in a skeleton code creation tool
CN108459967B (en) Web application test case generation method based on user interface state flow diagram
CN102968373B (en) A kind of maintaining method of test macro and device
CN113392462B (en) Sewage pipe network rapid modeling method based on Revit secondary development
CN102567565B (en) Cable parameter processing method and system utilizing same
CN105279089A (en) Method and device for obtaining page element
US7237224B1 (en) Data structure used for skeleton function of a class in a skeleton code creation tool
CN104516813A (en) Method and device for selecting testing node of web page
CN102880500B (en) The optimization method of a kind of task tree and device
CN112328488A (en) Control object identification method for UI (user interface) automatic test
CN104461864A (en) Java source code defect detecting method and system based on Eclipse plugin
CN116630990B (en) RPA flow element path intelligent restoration method and system
US7793257B2 (en) Technique for automating code generation in developing software systems
CN114647416A (en) Method and device for realizing service flow based on annotation, storage medium and electronic equipment
CN108073511A (en) test code generating method and device
CN101751332A (en) Method, device and system for simulating process of workflow middleware
CN110688439A (en) Method for automatically identifying and analyzing enterprise information based on regional geocoding
CN112579456B (en) Web automatic testing method and device
CN104615536A (en) Test case control method and electronic device
CN115237387A (en) Rapid development method and system for digital twin application
CN106951273A (en) The method and apparatus that a kind of dynamic configuration generates professional workstation
CN109019217B (en) Elevator control software field debugging system
KR102413994B1 (en) Method for visualizing software source code after modifying it for improving performance and device thereof
CN115390853B (en) Structured analysis method, system, terminal and storage medium for multi-source process file

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant
TR01 Transfer of patent right
TR01 Transfer of patent right

Effective date of registration: 20240226

Address after: # 01-21, Lai Zan Da Building 1, 51 Belarusian Road, Singapore

Patentee after: Alibaba Singapore Holdings Ltd.

Country or region after: Singapore

Address before: A four-storey 847 mailbox in Grand Cayman Capital Building, British Cayman Islands

Patentee before: ALIBABA GROUP HOLDING Ltd.

Country or region before: Cayman Islands