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
positioning
parent
attribute information
current
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

Method, device and system for positioning web page elements
Technical Field
The present application relates to the field of internet technologies, and in particular, to a method for positioning web page elements, an apparatus for positioning web page elements, and a system for positioning web page elements.
Background
In the software development process, software testing is indispensable. The software test utilizes a test tool to carry out test operation according to a certain test scheme and flow, thereby achieving the purposes of discovering defects hidden in the software, reducing the cost of software development and maintenance and promoting the software quality to be improved. The cost of software testing accounts for 30% -50% of the whole software development process, and with the continuous improvement of the functional complexity of software, the corresponding automatic testing technology is continuously developed and advanced.
Among various types of automated tests, the test closest to the user requirement is the automated test of a User Interface (UI) related to user interaction, and writing a UI automated test script of a web page inevitably encounters a web page element identification problem. The positioning operation for the web page element is not only reflected in the operation process of the service flow, but also reflected in other aspects, such as content inspection of the web page text element, attribute inspection of the web page element, use of the attribute value of the web page element as a variable, inspection of complex web page elements, such as < table > sub web page elements, and the like. Since the automated testing of the UI is closest to the user's needs, the maintenance cost of the positioning information data of the web page elements also becomes an indispensable cost in the UI automation script maintenance process.
At present, the positioning mode of web page elements is based on a static mode, namely once a certain type of positioning mode is used, the actual positioning information is determined, and the positioning information cannot be automatically checked and repaired. For example, in the stage of writing the UI automation test script, the information that is found on the web page and can uniquely identify the web page element is recorded as the positioning information of the web page element, and in the subsequent test, the content is the content that needs to be mainly maintained in the UI automation test script. Often, the way to locate web page elements is also unique, for example, if id attributes are used to locate web page elements, manual correction is required once the id attributes change, and thus web page elements cannot be located efficiently and simply.
Therefore, one of the problems to be solved by those skilled in the art is to provide a method, an apparatus and a system for positioning web page elements, so as to quickly position web page elements, improve the execution efficiency of positioning web page elements, and enable automatic repair of positioning information of web page elements, thereby ensuring the adaptivity of positioning information of web page elements to the maximum extent and effectively reducing the maintenance cost of positioning information of web page elements.
Disclosure of Invention
The technical problem to be solved by the application is to provide a method for positioning web page elements, which is used for quickly positioning web page elements, improving the execution efficiency of positioning web page elements, automatically repairing the positioning information of the web page elements, ensuring the adaptivity of the positioning information of the web page elements to the maximum extent, and effectively reducing the maintenance cost of the positioning information of the web page elements.
Correspondingly, the application also provides a device for positioning the web page elements and a system for positioning the web page elements, which are used for ensuring the application of the method in practice.
In order to solve the above problem, the present application discloses a method for positioning web page elements, comprising:
acquiring at least two pieces of positioning information of one or more web page elements in a web page to be detected;
determining optimal positioning information in the at least two pieces of positioning information;
and when the web page element cannot be positioned by adopting the optimal positioning information and at least one piece of other positioning information which can be positioned to the web page element exists, updating the optimal positioning information by adopting the other positioning information.
Preferably, the method further comprises:
and positioning the web page element by adopting the optimal positioning information.
Preferably, the positioning information of the web page element includes three pieces, specifically:
first positioning information formed by attribute combination of the web page elements;
second positioning information formed by attribute combinations of parent class elements of the web page elements and relative positions of the web page elements in the parent class elements thereof;
and third positioning information formed by an XPATH path of the web page element.
Preferably, the step of obtaining at least two pieces of positioning information of one or more web page elements in the web page to be tested includes:
substep S1, respectively acquiring corresponding attribute information of one or more web page elements in the web page to be detected;
a substep S2 of determining whether there is attribute information that can be uniquely located to a corresponding web page element; if yes, go to substep S3; if not, go to substep S4;
a substep S3, recording the attribute combination of the attribute information forming the web page element;
substep S4, obtaining attribute information of parent class element of current web page element;
a substep S5 of determining whether there is attribute information that can be uniquely located to the parent element; if yes, go to substep S6; if not, returning the parent class element as the current web page element to the substep S4;
substep S6, recording attribute information of the parent element to form an attribute combination of the parent element of the web page element, and obtaining a relative position of the web page element in the parent element;
and a substep S7, for one or more web page elements in the web page to be tested, respectively generating an XPATH path of the web page elements by using an XPATH path positioning engine.
Preferably, the sub-step S2 further includes:
in the current traversing step, a current attribute information combination is adopted to traverse the web page element set of the web page to be detected, and a current set and a current number of the positioned web page elements are obtained;
a next traversal step, adopting a next attribute information combination to traverse the current set obtained in the current traversal step to obtain a next set and a next quantity of the positioned web page elements; the next attribute information combination comprises information in the current attribute information combination and newly added attribute information;
a judging step of judging whether the next number is less than or equal to the current number and whether the next number is 1; if yes, executing a success judging step; if not, executing an attribute information conversion step;
a success judgment step, namely combining the next attribute information and judging that the attribute information of the corresponding web page element can be uniquely positioned;
and an attribute combination conversion step, namely, taking the next attribute information combination as the current attribute information combination, taking the next set as the current set, taking the next quantity as the current quantity, and re-executing the next traversal step.
Preferably, before the sub-step S2, the method further includes:
the sub-step S11 is to filter out the attribute information with empty attribute value from the one or more attribute information of the web page element.
Preferably, the sub-step S5 further includes:
a parent class current traversal step, wherein a parent class element set of web page elements of the web page to be detected is traversed by adopting attribute information combination of current parent class elements, and a current set and a current number of the located parent class elements of the web page elements are obtained;
a parent next traversal step, wherein the current set of parent elements obtained in the parent current traversal step is traversed by adopting the attribute information combination of the next parent element, and the next set and the next quantity of the parent elements of the positioned web page elements are obtained; the attribute information combination of the next parent element comprises the information in the attribute information combination of the current parent element and the attribute information of a newly added parent element;
a parent class judgment step of judging whether the next number is less than or equal to the current number and whether the next number is 1; if yes, executing a parent class success judging step; if not, executing a parent attribute information conversion step;
a parent success judging step, namely combining the attribute information of the next parent element and judging that the attribute information of the parent element of the corresponding web page element can be uniquely positioned;
and a parent attribute combination and conversion step, namely, taking the attribute information combination of the next parent element as the attribute information combination of the current parent element, taking the next set as the current set, taking the next quantity as the current quantity, and re-executing the next traversal step of the parent.
Preferably, the step of determining the optimal positioning information among the positioning information of at least two web page elements comprises:
counting time consumed by adopting the first positioning information to position the web page elements of the web page to be detected as first processing time;
counting time consumed by the web page element positioning of the web page to be detected by adopting the second positioning information as second processing time;
counting time consumed by the web page element positioning of the web page to be detected by adopting the third positioning information as third processing time;
and performing reverse sequencing on the first processing time, the second processing time and the third processing time, and extracting positioning information corresponding to the processing time with the highest sequencing as optimal positioning information.
Preferably, when the optimal positioning information is the first positioning information, the step of positioning the web page element by using the optimal positioning information includes:
a current traversing step is positioned, wherein a current attribute information combination is adopted to traverse a web page element set of the web page to be detected, and a current set and a current number of the positioned web page elements are obtained;
a step of positioning next traversal, which is to traverse the current set obtained in the step of positioning the current traversal by adopting a next attribute information combination to obtain a next set and a next quantity of the positioned web page elements; the next attribute information combination comprises information in the current attribute information combination and newly added attribute information;
a positioning judgment step of judging whether the next number is less than or equal to the current number and whether the next number is 1; if yes, executing a positioning success judging step; if not, executing a positioning attribute combination conversion step;
a positioning success judging step, namely judging that the web page element is positioned by adopting the optimal positioning information;
and positioning attribute combination and conversion, namely, taking the next attribute information combination as the current attribute information combination, taking the next set as the current set, taking the next quantity as the current quantity, and re-executing the step of positioning the next traversal.
Preferably, when the optimal positioning information is the second positioning information, the step of positioning the web page element by using the optimal positioning information includes:
a parent positioning current traversal step, wherein a parent element set of the web page elements of the web page to be detected is traversed by adopting attribute information combination of the current parent element, and a current set and a current number of the located parent elements of the web page elements are obtained;
a next traversal step of parent positioning, which is to traverse the current set of parent elements obtained in the current traversal step of parent positioning by adopting the attribute information combination of the next parent element to obtain the next set and the next quantity of the parent elements of the positioned web page elements; the next attribute information combination of the parent element comprises information in the current attribute information combination of the parent element and attribute information of a newly added parent element;
a parent positioning judgment step of judging whether the next number is less than or equal to the current number and whether the next number is 1; if yes, executing a father positioning success judging step; if not, executing a parent positioning attribute information conversion step;
a parent positioning success judging step, namely combining the attribute information of the next parent element, judging that the attribute information of the parent element of the corresponding web page element can be uniquely positioned, and turning to a relative position positioning step;
a parent positioning attribute combination conversion step, namely, taking the attribute information combination of the next parent element as the attribute information combination of the current parent element, taking the next set as the current set, taking the next quantity as the current quantity, and re-executing the next traversal step of parent positioning;
and a relative position positioning step, namely judging to adopt the optimal positioning information to position the web page element when the web page element is positioned according to the relative position of the web page element in the range of the parent element.
Preferably, the step of updating the optimal positioning information with the other positioning information comprises:
adopting the other positioning information as the optimal positioning information;
or,
and restoring the optimal positioning information by adopting the other positioning information.
The application also discloses a device for positioning web page elements, which comprises:
the positioning information acquisition module is used for acquiring positioning information of at least two web page elements in the web page to be detected;
the optimal positioning information selection module is used for determining optimal positioning information in the at least two pieces of positioning information;
and the optimal positioning information updating module is used for updating the optimal positioning information by adopting other positioning information when the web page element cannot be positioned by adopting the optimal positioning information and at least one piece of other positioning information capable of being positioned to the web page element exists.
Preferably, the apparatus further comprises:
and the web page element positioning module is used for positioning the web page element by adopting the optimal positioning information.
Preferably, the positioning information of the web page element includes three pieces, specifically:
first positioning information formed by attribute combination of the web page elements;
second positioning information formed by attribute combinations of parent class elements of the web page elements and relative positions of the web page elements in the parent class elements thereof;
and third positioning information formed by an XPATH path of the web page element.
Preferably, the positioning information obtaining module includes:
the attribute information acquisition sub-module is used for respectively acquiring corresponding attribute information of one or more web page elements in the web page to be detected;
the positioning judgment submodule is used for judging whether attribute information which can be uniquely positioned to the corresponding web page element exists or not; if yes, calling an attribute information recording submodule; if not, calling a parent element acquisition submodule;
the attribute information recording submodule is used for recording the attribute combination of the web page elements formed by the attribute information;
the parent element acquisition submodule is used for acquiring attribute information of a parent element of the current web page element;
the parent positioning judgment submodule is used for judging whether attribute information which can be uniquely positioned to the parent element exists or not; if yes, calling a parent attribute information recording submodule; if not, taking the parent element as the current web page element, and calling a return parent element acquisition sub-module;
the parent attribute information recording submodule is used for recording attribute information of the parent elements to form attribute combinations of the parent elements of the web page elements and acquiring relative positions of the web page elements in the parent elements of the web page elements;
and the path generation submodule is used for generating an XPATH path of the web page elements by respectively adopting an XPATH path positioning engine aiming at one or more web page elements in the web page to be detected.
Preferably, the positioning judgment sub-module includes:
the current traversing unit is used for traversing the web page element set of the web page to be detected by adopting the current attribute information combination to obtain the current set and the current number of the positioned web page elements;
the next traversal unit is used for traversing the current set obtained by the current traversal unit by adopting the next attribute information combination to obtain the next set and the next quantity of the positioned web page elements; the next attribute information combination comprises information in the current attribute information combination and newly added attribute information;
a judging unit configured to judge whether the next number is less than or equal to the current number, and whether the next number is 1; if yes, calling a success judging unit; if not, calling an attribute information conversion unit;
a success judging unit, configured to combine the next attribute information and judge that the attribute information of the corresponding web page element can be uniquely located;
and the attribute combination conversion unit is used for combining the next attribute information as the current attribute information, using the next set as the current set and using the next quantity as the current quantity, and re-executing the next traversal step.
Preferably, the apparatus further comprises:
and the attribute information filtering submodule is used for filtering out attribute information with an empty attribute value from one or more attribute information of the web page elements.
Preferably, the parent positioning and determining sub-module includes:
the parent class current traversal unit is used for traversing the parent class element set of the web page elements of the web page to be detected by adopting the attribute information combination of the current parent class elements to obtain the current set and the current number of the located parent class elements of the web page elements;
the parent next traversal unit is used for traversing the current set of the parent elements obtained by the parent current traversal unit by adopting the attribute information combination of the next parent element to obtain the next set and the next quantity of the parent elements of the positioned web page elements; the attribute information combination of the next parent element comprises the information in the attribute information combination of the current parent element and the attribute information of a newly added parent element;
a parent class judgment unit, configured to judge whether the next number is less than or equal to the current number, and whether the next number is 1; if yes, calling a parent class success judging unit; if not, calling a parent attribute information conversion unit;
a parent success judging unit, configured to combine the attribute information of the next parent element, and judge that the attribute information of the parent element of the corresponding web page element can be uniquely located;
and the parent attribute combination conversion unit is used for taking the attribute information combination of the next parent element as the attribute information combination of the current parent element, taking the next set as the current set, taking the next quantity as the current quantity, and recalling the next traversal unit of the parent.
Preferably, the optimal positioning information selecting module includes:
the first statistic sub-module is used for counting time consumed by adopting the first positioning information to carry out web page element positioning on the web page to be detected as first processing time;
the second statistical submodule is used for counting time consumed by adopting the second positioning information to position the web page elements of the web page to be detected as second processing time;
a third statistical submodule, configured to count time consumed for performing web page element positioning on the web page to be detected by using the third positioning information as third processing time;
and the sorting and selecting submodule is used for carrying out reverse sorting on the first processing time, the second processing time and the third processing time and extracting the positioning information corresponding to the processing time with the highest sorting as the optimal positioning information.
Preferably, the web page element positioning module comprises:
a current traversing submodule is positioned and used for traversing the web page element set of the web page to be detected by adopting the current attribute information combination to obtain the current set and the current quantity of the positioned web page elements;
positioning a next traversal submodule for traversing the current set obtained by the current traversal submodule by adopting a next attribute information combination to obtain a next set and a next quantity of the positioned web page elements; the next attribute information combination comprises information in the current attribute information combination and newly added attribute information;
a positioning judgment submodule for judging whether the next number is less than or equal to the current number and whether the next number is 1; if yes, executing a positioning success judgment submodule; if not, executing a positioning attribute combination conversion sub-module;
the positioning success judging submodule is used for judging that the optimal positioning information is adopted to position the web page element;
and the positioning attribute combination conversion submodule is used for taking the next attribute information combination as the current attribute information combination, taking the next set as the current set, taking the next quantity as the current quantity, and calling the next traversal submodule again.
Preferably, the web page element positioning module comprises:
the parent positioning current traversal submodule is used for traversing the parent element set of the web page elements of the web page to be detected by adopting the attribute information combination of the current parent element to obtain the current set and the current number of the parent elements of the positioned web page elements;
the parent positioning next traversal submodule is used for traversing the current set of the parent elements obtained by the parent positioning current traversal submodule by adopting the attribute information combination of the next parent element to obtain the next set and the next quantity of the parent elements of the positioned web page elements; the next attribute information combination of the parent element comprises information in the current attribute information combination of the parent element and attribute information of a newly added parent element;
a parent positioning judgment submodule for judging whether the next number is less than or equal to the current number and whether the next number is 1; if yes, calling a parent positioning success judgment sub-module; if not, calling a parent positioning attribute information conversion sub-module;
the parent positioning success judging submodule is used for combining the attribute information of the next parent element, judging that the attribute information of the parent element corresponding to the web page element can be uniquely positioned, and switching to the relative position positioning submodule;
a parent positioning attribute combination conversion submodule for executing the next calling submodule of the parent again by taking the attribute information combination of the next parent element as the current attribute information combination of the parent element, taking the next set as the current set and the next quantity as the current quantity;
and the relative position positioning submodule is used for judging that the web page element is positioned by adopting the optimal positioning information when the web page element is positioned according to the relative position of the web page element in the range of the parent element of the web page element.
Preferably, the optimal positioning information updating module includes:
the optimal positioning information replacing module is used for adopting the other positioning information as the optimal positioning information;
and the optimal positioning information repairing module is used for repairing the optimal positioning information by adopting the other positioning information.
The application also discloses a system for web page element positioning, comprising:
the information extraction device is used for acquiring at least two pieces of positioning information of one or more web page elements in the web page to be detected and determining the optimal positioning information in the at least two pieces of positioning information;
the positioning engine device is used for positioning the web page elements by adopting the at least two pieces of positioning information;
and the feedback device is used for updating the optimal positioning information by adopting other positioning information when the web page element cannot be positioned by adopting the optimal positioning information and at least one piece of other positioning information capable of being positioned to the web page element exists.
Compared with the prior art, the method has the following advantages:
the method and the device realize the one-time establishment of the web page element positioning information, and solve the problem of single positioning information by acquiring the positioning information of at least two web page elements of the web page to be detected. According to the method and the device, the optimal positioning information can be determined from the acquired positioning information of at least two web page elements, so that the optimal positioning information can be directly selected when the positioning of the web page elements is executed, and the execution efficiency in the positioning process is improved. In addition, when the web page element cannot be positioned by adopting the optimal positioning information, the optimal positioning information can be updated by adopting other positioning information which can still be positioned to the web page element, so that the maintenance cost of the web page element positioning information can be avoided in the aspect of automatic test script maintenance, the script execution failure caused by the web page element positioning failure is reduced, the automatic repair of the positioning information is realized, and the self-adaptive capacity of the web page element positioning information is furthest ensured.
When the positioning of the web page elements is executed, the multi-path positioning of the web page elements is realized, the problem of single positioning path is solved, and the diversification of the positioning information is realized. When the currently used positioning information fails to position the web page element, other positioning information can be selected to position the web page element, so that the execution efficiency of positioning is guaranteed, and the response efficiency of script execution and the stability of test script execution are greatly improved.
According to the method and the device, the optimization of efficiency in the execution process of the web page element positioning is guaranteed through the priority of the positioning way, the time consumed by different positioning information for positioning the web page elements is counted for the positioning information of at least two acquired web page elements, the reverse sequencing is carried out according to the consumed time, the positioning information corresponding to the time consumed at the top in the sequencing is used as the optimal positioning information, namely the positioning information with the shortest time consumption in the web page element positioning is used as the optimal positioning information, and the time consumed by adopting the optimal positioning information to position the web page elements is short, so that the web page elements can be quickly positioned, and the execution efficiency of positioning the web page elements is improved.
Drawings
FIG. 1 is a flowchart of the steps of embodiment 1 of a method for web page element positioning according to the present application;
FIG. 2 is a schematic diagram of a web page element (element) multidimensional positioning information of the present application;
FIG. 3 is a flow diagram of a web page element multidimensional positioning information processing of the present application;
FIG. 4 is a flow chart of a process for attribute information of a web page element of the present application;
FIG. 5 is a flow diagram of attribute information determination for a web page element of the present application;
FIG. 6 is a flow chart of a process for attribute information of a parent element of a web page element of the present application;
FIG. 7 is a flow diagram of attribute information determination for a parent element of a web page element of the present application;
FIG. 8 is a flowchart of the steps of embodiment 2 of a method of web page element positioning of the present application;
FIG. 9 is a block diagram illustrating an embodiment of an apparatus for web page element positioning according to the present application;
FIG. 10 is a general block diagram of a web page element positioning information system of the present application.
Detailed Description
In order to make the aforementioned objects, features and advantages of the present application more comprehensible, the present application is described in further detail with reference to the accompanying drawings and the detailed description.
One of the core ideas of the embodiment of the application is that the positioning information with the highest priority is determined by recording the multi-dimensional positioning information with the priority of the web page to be detected, the optimal positioning information is automatically repaired, and accuracy guarantee is provided for the positioning information with the highest priority, so that the adaptivity of the web page element positioning information is guaranteed to the maximum extent on the whole, and the maintenance cost of the web page element positioning information is reduced to the maximum extent.
Referring to fig. 1, a flowchart illustrating steps of embodiment 1 of a method for positioning web page elements according to the present application is shown, where the method specifically includes the following steps:
step 101, acquiring at least two pieces of positioning information of one or more web page elements in a web page to be detected;
as an example of specific application of the embodiment of the present application, reference may be made to a schematic diagram of multi-dimensional positioning information of a web page element (element) in the present application shown in fig. 2, where the positioning information of the web page element in step 101 may include three, specifically:
r1: first positioning information formed by attribute combination of the web page elements;
r2: second positioning information formed by attribute combinations of parent class elements of the web page elements and relative positions of the web page elements in the parent class elements thereof;
r3: third positioning information formed by an XPATH path of the web page element.
Referring to the flow chart of the multi-dimensional positioning information processing of a web page element of the present application shown in fig. 3, in a preferred embodiment of the present application, the step 101 may include the following sub-steps:
substep S1, respectively acquiring corresponding attribute information of one or more web page elements in the web page to be detected;
for example, the web page to be tested includes 30 controls (a control is one of the web page elements), and the attribute information "tagName": INPUT "," name ": user", "type": text "," value ": and/or corresponding to a certain web page element can be obtained.
Preferably, the attribute information may include an attribute name and a corresponding attribute value, and before the sub-step of determining whether the attribute information uniquely locatable to the corresponding web page element exists, that is, before the sub-step S2, the method may further include:
and a substep S11, filtering out attribute information with an attribute value being null from the attribute information corresponding to the web page element.
Assume that there are several attribute names as follows: tagName, nodeName, src, title, and the corresponding attribute values are:
"tagName":"A"
"nodeName":"B"
"src":"/xxx/yy.html"
"title":""
since the attribute name whose attribute value is null does not contribute to the positioning of the web page element, the attribute information whose attribute value is null can be filtered, for example, "title": since its attribute value is "null", and it is filtered because it is a null value.
A substep S2 of determining whether there is attribute information that can be uniquely located to a corresponding web page element; if yes, go to substep S3; if not, go to substep S4;
a substep S3, recording the attribute combination of the attribute information forming the web page element;
for example, assuming that attribute information "tagName": INPUT "," name ": user", "type": text "corresponding to a certain web page element can be uniquely located to the attribute information of the corresponding web page element, the above attribute information is recorded to form an attribute combination {" tagName ": INPUT", "name": user "," type ": text", "of the web page element itself as the first location information R1.
Substep S4, obtaining attribute information of parent class element of current web page element;
a substep S5 of determining whether there is attribute information that can be uniquely located to the parent element; if yes, go to substep S6; if not, returning the parent class element as the current web page element to the substep S4;
substep S6, recording attribute information of the parent element to form an attribute combination of the parent element of the web page element, and obtaining a relative position of the web page element in the parent element;
in the embodiment of the application, the step of obtaining the attribute combination of the parent class element of the web page element is the same as the step of obtaining the attribute combination of the web page element.
Assuming that the attribute combination of the parent element of the web page element is { "tagName": form "and" index ": 1" }, if the web page element is arranged at the first bit of the parent element, the relative position information may be recorded as "index": 1", and the attribute combination and the relative position information of the parent element are recorded as { parent {" tagName ": form" "index": 1"}" tagName ": INPUT", "index": 1"}, which is used as the second positioning information R2
In addition, if the parent element of the web page element cannot be uniquely located, the parent element may be used as the current web page element, the parent element of the current web page element is acquired, and the substep S4 of acquiring the attribute information of the corresponding parent element is executed again.
And a substep S7, for one or more web page elements in the web page to be tested, respectively generating an XPATH path of the web page elements by using an XPATH path positioning engine.
In practical applications, the execution sequence of the sub-step S7 is not limited, for example, the sub-step S7 may be performed before the sub-step S1 is executed, or after all the sub-steps are completed, or may be performed simultaneously with other sub-steps, which is not limited in this application.
For the web page element, an XPATH path positioning engine may also be respectively adopted to generate an XPATH path of the web page element, for example,/html/body/form/input [ name = "user" ], as the third positioning information R3.
As an example of specific applications of the embodiment of the present application, the following sub-step may be further adopted to determine whether attribute information that can be uniquely located to a corresponding web page element exists, that is, the sub-step S2 may be referred to a processing flow chart of the attribute information of a web page element of the present application shown in fig. 4, and the specific sub-steps are as follows:
when step S21 is traversed: traversing a web page element set of the web page to be detected by adopting current attribute information combination to obtain a current set and a current number of the positioned web page elements;
next traversal of step S22: traversing the current set obtained in the current traversing step by adopting a next attribute information combination to obtain a next set and a next quantity of the positioned web page elements; the next attribute information combination comprises information in the current attribute information combination and newly added attribute information;
a judgment step S23 of judging whether the next number is less than or equal to the current number, and whether the next number is 1; if yes, execute success determination step S24; if not, executing an attribute information conversion step S25;
a success determination step S24 of determining that the attribute information of the corresponding web page element can be uniquely located by combining the attribute information of the next time;
an attribute combination converting step S25, re-executing the next traversal step S22, with the next attribute information combination as the current attribute information combination, the next set as the current set, and the next number as the current number.
In the embodiment of the present invention, it is assumed that attribute information "tagName": INPUT "," name ": user", "type": text "," value ": 1" of a web page element exists, if the current attribute information combination tagName "is adopted, the" INPUT "traverses the web page element set of the web page to be detected, the current set and the current number of the located web page elements are obtained, the next attribute information combination tagName": INPUT "," name ": user" traverses the current set, the next set and the next number 4 are obtained, since the next number 4 is smaller than the current number 5, the next attribute information combination is used as the current attribute information combination, the next set is used as the current set, the next number 4 is used as the current number 4, the next traversal step is executed again, and then the next attribute information combination is tagName ": INPUT", "next attribute information combination, and the name, the user, the type, the text are combined by adopting the next attribute information, the tagName, the INPUT, the name, the user, the type, the text are traversed through the current set, and the next set and the next quantity 1 of the positioned web page elements are obtained. Since the next number 1 is smaller than the current number 4 and the next number is 1, the next attribute information combination tagName ": INPUT", "name": user "," type ": text" is determined to be the attribute information that can be uniquely located to the corresponding web page element.
If other attribute information exists when the next quantity is 1, then other attribute information can be continuously added to continuously traverse the web page element set of the web page to be detected, and the obtained attribute information with the next quantity still being 1 is used as positioning information to form an attribute combination of the web page elements, and the attribute combination is used as first positioning information R1, so that the accuracy of the obtained web page element positioning information is improved.
It should be noted that the web page element can be correctly positioned only at the next time and when the number of times is equal to and equal to 1; if the number of the obtained current time is 1 for the first time and the number of the positioned web page elements calculated for other times is 0, the method indicates that only one web page element of the web page to be detected and the web page element to be found have the same value on the attribute information of the attribute information combination adopted for the first time, so the matching degree is not high and the condition for searching the web page element is not met; if the current number obtained for the first time is 0, the web page element positioning fails, and the web page element to be found cannot be positioned in the web page to be detected; if the current number obtained for the first time is greater than 1, but the number calculated for multiple subsequent times is not 1, it indicates that the positioning of the web page element at this time fails, and in order to save resources, the operation of obtaining the first positioning information R1 on the web page element may be stopped.
The following description will be given to a preferred example of the steps of determining whether there is attribute information that can be uniquely located to a corresponding web page element in the present application, with reference to a flowchart for determining attribute information of a web page element in the present application shown in fig. 5, and the specific steps are as follows:
substep SS21, traversing the web page element set of the web page to be detected by adopting the first attribute information combination, and obtaining a first set and a first quantity of the positioned web page elements; wherein the first attribute information combination includes first attribute information;
in a specific implementation, the attribute information may include an attribute name and a corresponding attribute value, where the first attribute name of the first attribute information may be a designated attribute name, and as an example, the designated attribute name may conform to a non-null attribute name specified by an HTML protocol, such as a tagName and a nodeName, and of course, other designated attribute names may be used, which is not limited in this application.
Sub-step SS22, traversing the first set by adopting the second attribute information combination to obtain a second set and a second quantity;
wherein the second attribute information combination comprises the first attribute information and second attribute information;
sub-step SS23, determining whether the first number is greater than or equal to the second number, if yes, performing sub-step SS24, and if no, performing sub-step SS 26;
substep SS24, determining whether said second number is 1; if yes, go to substep S210, if no, go to substep SS 25;
sub-step SS25, traversing the second set by adopting the third attribute information combination, and obtaining the number of the currently positioned web page elements as a third number;
wherein the third attribute information includes the first attribute information, the second attribute information, and third attribute information;
sub-step SS26, traversing the first set by adopting the third attribute information combination, and obtaining the number of the currently positioned web page elements as a third number; go to substep SS 27;
substep SS27, determining whether there is other attribute information, if yes, executing substep SS28, otherwise, executing substep SS 29;
substep SS28, returning to substep SS22 after the third attribute information combination is used as the first attribute information combination and one additional attribute information is added in the third attribute information combination as the second attribute information combination;
sub-step SS29, when the third number is 1 and the second number is greater than or equal to the third number, combining the third attribute information, and determining that the attribute information can be uniquely located to the corresponding web page element; otherwise, judging that the corresponding web page element cannot be uniquely positioned;
and a sub-step SS210 of combining the second attribute information and determining that the attribute information can be uniquely located to the corresponding web page element.
Assuming that attribute information 'tagName': INPUT ',' name ': user', 'type': text ',' value ': 1' of web page elements exists, if a first attribute information combination tagName ': INPUT' is adopted to traverse a web page element set of a web page to be detected, a first set and a first quantity 5 are obtained, a second attribute information combination tagName ': INPUT', 'name': user 'is adopted to traverse the first set, a second set and a second quantity 4 are obtained, and since the first quantity 5 is larger than the second quantity 4, a third attribute information tagName': INPUT ',' name ': user' and a type ': text' of the web page elements are continuously adopted to traverse the second set. If the other attribute information "value": 1 "of the web page element is used as the first attribute information combination, and one additional attribute information is added to the third attribute information combination to form a new second attribute information combination tagName": INPUT "," name ": user", "type": text "," value ": 1", and so on until the third number is 1 and the second number is greater than or equal to the third number, the third attribute information combination is determined as the attribute information that can be uniquely positioned to the corresponding web page element, for example, if the third attribute information combination tagName ": INPUT", "name": user "," type ": text" is positioned to the web page element in the third number of 1, the third attribute information combination may be determined as the third attribute information combination, "name": user "," type ": text" can be uniquely located to the attribute information of the corresponding web page element.
Of course, it may also be possible to traverse the first set by using the second attribute information combination tagName ": INPUT", "name": user "to obtain that the number of currently located web page elements is the second number 1, and then it may also be determined that the second attribute information combination tagName": INPUT "," name ": user" may uniquely locate the attribute information of the corresponding web page element at this time.
In order to further understand the embodiment of the present application, a specific example is used to describe the process of acquiring the first positioning information R1 according to the embodiment of the present application.
Assuming that attribute information "tagName": INPUT "," name ": user", "type": text "," value ": 1" of the web page element exists, traversing the web page to be detected by using the attribute information, and obtaining the number of the located web page elements, the table of the number of the located web page elements may be specifically referred to as shown in table 1 below:
as can be seen from table 1, the attribute information specified by the web page element is obtained as the current attribute information combination "tagName": INPUT ", the current attribute information combination" tagName ": INPUT" is used to traverse the web page element set of the whole web page to be detected, the number 5 of the elements positioned on the web page is obtained, then the attribute information is increased one by one and the number of the elements positioned on the web page is obtained, and when the obtained number of the elements positioned on the web page is 1, the corresponding attribute information is obtained to form an attribute combination as the first positioning information R1. It is easy to see that, when the number of web page elements located by "tagName": INPUT "+" name ": user" + "type": text "+" value ": 1" is 1, the above attribute information may be recorded to obtain the own attribute combination { "tagName": INPUT "," name ": user", "type": text "," value ": 1") of the web page as the first location information R1.
As an example of specific applications of the embodiment of the present application, the following sub-step may be further adopted to determine whether there is attribute information that can be uniquely located to a parent element of a corresponding web page element, that is, the sub-step S5 may refer to a processing flow chart of attribute information of a parent element of a web page element of the present application shown in fig. 5, where the specific steps are as follows:
a parent class current traversal step S31, wherein the parent class element set of the web page elements of the web page to be detected is traversed by adopting the attribute information combination of the current parent class elements, and the current set and the current number of the located parent class elements of the web page elements are obtained;
a parent next traversal step S32, which is to traverse the current set of parent elements obtained in the parent current traversal step by using the attribute information combination of the next parent element, to obtain a next set and a next number of the parent elements of the located web page elements; the next attribute information combination of the parent element comprises information in the current attribute information combination of the parent element and attribute information of a newly added parent element;
a parent class determination step S33 of determining whether the next number is less than or equal to the current number, and whether the next number is 1; if yes, go to the father class success determination step S34; if not, executing a parent attribute information conversion step S35;
a parent success determination step S34 of combining the attribute information of the next parent element and determining that the attribute information of the parent element that can be uniquely positioned to the corresponding web page element is present;
a parent attribute combination converting step S35, regarding the attribute information combination of the next parent element as the attribute information combination of the current parent element, regarding the next set as the current set, regarding the next number as the current number, and re-executing the next parent traversal step S32.
In the embodiment of the application, if the attribute information ' tagName ': form ' and ' index ': 1 ' of the parent element of the web page element exists, if the attribute information combination ' tagName ': form ' of the current parent element is adopted, the parent element set of the web page element of the web page to be detected is traversed, and the current set and the current number 3 of the parent element are obtained; and traversing the current set of the parent elements by adopting the attribute information combination 'tag name': form ',' index ': 1' of the next parent element to obtain the next set and the next quantity 1 of the parent elements of the positioned web page elements. Since the next number 1 of the parent element is smaller than the current number 3 of the parent element, and the next number of the parent element is 1, the next attribute information of the parent element may be combined with "tagName": form "and" index ": 1" to determine that the attribute information of the parent element can be uniquely located to the corresponding web page element.
The following description will be given to a preferred example of the step of determining whether there is attribute information that can be uniquely located to a parent element of a corresponding web page element in the present application, with reference to a flowchart for determining attribute information of a parent element of a web page element in the present application shown in fig. 6, and the specific steps are as follows:
sub-step SS31, traversing the web page element set of the web page to be tested by adopting a fourth attribute information combination to obtain a third set and a fourth quantity;
wherein the fourth attribute information combination includes fourth attribute information;
substep SS32, traversing the third set by adopting a fifth attribute information combination to obtain a fourth set and a fifth quantity;
wherein the fifth attribute information combination includes the fourth attribute information and fifth attribute information;
sub-step SS33, determining whether the fourth number is greater than or equal to the fifth number, if yes, performing sub-step SS34, and if no, performing sub-step SS 36;
substep SS34, determining whether said fifth number is 1; if yes, go to substep S310, otherwise go to substep SS 35;
sub-step SS35, traversing the fourth set by adopting a sixth attribute information combination, and obtaining the number of the currently positioned web page elements as a sixth number;
wherein the sixth attribute information includes the fourth attribute information, fifth attribute information, and sixth attribute information;
sub-step SS36, traversing the third set by adopting a sixth attribute information combination, and obtaining the number of the currently positioned web page elements as a sixth number; go to substep S37;
substep SS37, determining whether attribute information of other parent elements exists, if yes, executing substep SS38, otherwise, executing substep SS 39;
substep SS38, using the sixth attribute information combination as a fourth attribute information combination, and returning to substep SS32 after adding an attribute name and a corresponding attribute value of the other parent class element as a fifth attribute information combination in the sixth attribute information combination;
sub-step SS39, when the sixth number is 1 and the fifth number is greater than or equal to the sixth number, combining the sixth attribute information and determining that the attribute information can be uniquely located to the corresponding parent element; otherwise, judging that the corresponding parent class element cannot be uniquely positioned;
and a substep SS310 of combining the fifth attribute information and determining attribute information that can be uniquely located to the corresponding parent element.
Assuming that attribute information ' tagName ': form ', ' index ': 1 ' of a parent element of a web page element exists, if a fourth attribute information combination ' tagName ': form ' is adopted to traverse a web page element set of a web page to be detected to obtain a third set and a fourth quantity 3, a fifth attribute information combination ' tagName ': form ', ' index ': 1 ' is adopted to traverse the third set to obtain a fourth set and a fifth quantity 1, and because the fourth quantity 3 is greater than the fifth quantity 1, a sixth attribute information combination is adopted to traverse the fourth set to obtain a sixth quantity. Judging whether attribute information of other parent elements exists or not, if so, combining the sixth attribute information to serve as a fourth attribute information combination, combining and adding attribute information of one other parent element in the fifth attribute information to serve as a fifth attribute information combination, and so on, and when the sixth number is 1 and the fifth number is greater than or equal to the sixth number, combining the sixth attribute information to judge that the attribute information of the corresponding parent element can be positioned; otherwise, the attribute information of the corresponding parent class element cannot be positioned. In this example, since the obtained fifth number is 1, it may be determined that the fifth attribute information combination tagName ": form", "index": 1 "may be uniquely located to the attribute information of the corresponding web page element.
In a specific implementation, the number of the located web page elements that can be obtained only by adopting the attribute information combination with a plurality of attribute information is 1, or the number of the parent elements that can be obtained only by adopting the attribute information combination with a plurality of parent elements is 1; the number of the located web page elements may be 1 by using only the attribute information combination of the two attribute information, or the number of the parent elements of the located web page elements may be 1 by using only the attribute information combination of the attribute information of the two parent elements, which is determined by the condition of the web page element set in the specific web page to be detected, and the embodiment of the present application does not limit this.
It should be noted that the three types of generation manners of the positioning information R1, R2, and R3 are only examples, and in a specific implementation, other generation manners of the positioning information may be adopted according to an actual situation, for example, the positioning information of the web page element is generated by a table of the web page to be tested, which is not limited in this embodiment of the present application.
Step 102, determining the optimal positioning information in the at least two pieces of positioning information;
in a preferred embodiment of the present application, the step 102 may comprise the following sub-steps:
step S102-1, counting time consumed by adopting the first positioning information to position web page elements of the web page to be detected as first processing time;
step S102-2, counting time consumed for positioning web page elements on the web page to be detected by adopting the second positioning information as second processing time;
step S102-3, counting time consumed for positioning web page elements on the web page to be detected by adopting the third positioning information as third processing time;
and a substep S102-4 of performing reverse ordering on the first processing time, the second processing time and the third processing time, and extracting positioning information corresponding to the processing time with the highest ordering as optimal positioning information.
If three types of positioning information, namely R1, R2 and R3, are acquired by the information extraction device, the time consumed for positioning web page elements in a web page element set of a web page to be measured is counted respectively, and priority ranking is performed according to the processing time consumed by the three types of positioning information, for example, reverse ranking can be performed according to the time length, and the positioning information ranked at the top is used as the optimal positioning information. For example, if the processing time of the third positioning information R3 is shortest, the third positioning information R3 is set as the optimal positioning information.
Of course, the determination of the optimal positioning information is only an example, for example, some positioning information may also be directly selected as the optimal positioning information, and when the embodiment of the present application is implemented, the optimal positioning information may be determined in a manner according to an actual situation, which is not limited in this embodiment of the present application.
And 103, when the web page element cannot be positioned by adopting the optimal positioning information and at least one piece of other positioning information which can be positioned to the web page element exists, adopting the other positioning information to update the optimal positioning information.
As a preferred embodiment of the present application, the step 103 may include the following sub-steps:
substep S103-1, adopting the other positioning information as the optimal positioning information;
if the web page to be detected is changed and the optimal positioning information cannot be positioned to the web page element, other positioning information capable of being positioned to the web page element can be selected to replace the original optimal positioning information. For example, when the optimal positioning information R3 cannot be positioned to a web page element, the first positioning information R1 may be selected as the optimal positioning information, and the re-determined optimal positioning information R1 is updated to the multi-dimensional positioning information system.
As another preferred embodiment of the present application, the step 103 may include the following sub-steps:
and a substep S102-2 of repairing the optimal positioning information by using the other positioning information.
If the optimal positioning information cannot be positioned to the web page element and at least one piece of other positioning information can still be positioned to the web page element, then the related positioning information can be extracted from the positioning information which can still be positioned to the web page element to repair the optimal positioning information, so that the optimal positioning information can still continue to position the web page element, for example, when the optimal positioning information R3 cannot be positioned to the web page element, if the first positioning information R1 can still be positioned to the web page element, the related positioning information can be extracted from the first positioning information R1 to be updated to the optimal positioning information R3, the repair to the optimal positioning information R3 is completed, and finally, the re-determined optimal positioning information R3 is updated to the multi-dimensional positioning information system through a feedback device.
Referring to fig. 8, a flowchart illustrating steps of embodiment 2 of a method for positioning web page elements according to the present application is shown, where the method specifically includes the following steps:
step 201, acquiring positioning information of at least two web page elements in a web page to be detected;
step 202, determining optimal positioning information in the positioning information of the at least two web page elements;
step 203, when the web page element cannot be positioned by using the optimal positioning information and at least one piece of other positioning information which can be positioned to the web page element exists, updating the optimal positioning information by using the other positioning information;
and step 204, positioning the web page element by using the optimal positioning information.
In a preferred embodiment of the present application, when the optimal positioning information is the first positioning information R1, the step 204 may include the following sub-steps:
a current traversing step S41 is positioned, and a current attribute information combination is adopted to traverse the web page element set of the web page to be detected, so as to obtain a current set and a current number of the positioned web page elements;
a next traversal positioning step S42, wherein a next attribute information combination is adopted to traverse the current set obtained in the current traversal positioning step, so as to obtain a next set and a next quantity of the positioned web page elements; the next attribute information combination comprises information in the current attribute information combination and newly added attribute information;
a positioning determination step S43 of determining whether the next number is less than or equal to the current number, and whether the next number is 1; if yes, execute positioning success determination step S44; if not, executing a positioning attribute combination conversion step S45;
a positioning success determination step S44 of determining that the web page element is positioned by using the optimal positioning information;
and a positioning attribute combination converting step S45, re-executing the next traversal step, with the next attribute information combination as the current attribute information combination, the next set as the current set, and the next number as the current number.
In this embodiment of the application, when the optimal positioning information is the first positioning information R1, the corresponding attribute information may be read from the attribute combination of the web page element itself, the read attribute information is superimposed one by one and the web page element set of the web page to be detected is traversed in multiple times, until the number of currently positioned web page elements is 1, the web page element is uniquely positioned.
For example, assume that the attribute combinations are the following attribute names: (tagName \ name \ type \ value) (allowing the attribute values of some attribute information to be null), the process of using the first positioning information R1 to position the web page element is shown in the following table 2:
as can be seen from table 2, the attribute information is added one by one to locate the web page elements, and when the number of located web page elements is 1, the web page elements are located.
Firstly, extracting specified attribute information 'tagName' from attribute combination, using 'INPUT' as current attribute information combination, supposing that current attribute information combination is adopted, traversing a web page element set of a web page to be detected to obtain a current set and a current number of positioned web page elements, 5, using next attribute information combination 'tagName', using 'INPUT' + 'name', using ', traversing the current set obtained in the current traversing step to obtain a next set and a next number 3 of positioned web page elements, since the next number 3 is less than the current number 5, using the next attribute information combination as the current attribute information combination, using the next set as the current set, using the next number 3 as the current number 3, re-executing the next traversing step, and then combining the next attribute information combination into' tagName '+' name ', user' + 'type', and the like, until the web page elements are positioned to the number of 1 when the attribute combination of 'tagName': INPUT '+' name ': user' + 'type': text '+' value ': 1' is adopted.
The following description will be given of a preferred example of the step of positioning a web page element by using the optimal positioning information, with reference to a flowchart of positioning a web page element in the present application shown in fig. 9, and the specific steps are as follows:
sub-step SS41, traversing the web page element set of the web page to be tested by adopting the first attribute information combination to obtain a first set and a first quantity;
wherein the first attribute information includes first attribute information;
sub-step SS42, traversing the first set by adopting the second attribute information combination to obtain a second set and a second quantity;
wherein the second attribute information combination comprises the first attribute information and second attribute information;
sub-step SS43, determining whether the first number is greater than or equal to the second number, if yes, performing sub-step SS 44; if not, go to sub-step SS 46;
substep SS44, determining whether said second number is 1; if yes, performing sub-step SS411, otherwise, performing sub-step SS 45;
sub-step SS45, traversing the second set by adopting the third attribute information combination, and obtaining the number of the currently positioned web page elements as a third number;
wherein the third attribute information includes the first attribute information, the second attribute information, and third attribute information;
sub-step SS46, traversing the first set by adopting the third attribute information combination, and obtaining the number of the currently positioned web page elements as a third number;
sub-step SS47, determining whether the second number is 1, and if the first number is greater than or equal to the second number, performing sub-step SS 48; if not, go to sub-step SS 49;
sub-step SS48, determining to position to the web page element using the optimal positioning information;
substep S49, determining whether there is other attribute information, if yes, executing substep S49, otherwise, executing substep SS 410;
substep SS410, using said third attribute information combination as a first attribute information combination, and adding one of said other attribute information combinations as a second attribute information combination in said third attribute information combination, and returning to said substep SS 42;
sub-step SS411, determining that the web page element cannot be located using the optimal location information.
Referring to table 2, first, the specified attribute information "tagName": INPUT "is extracted from the attribute combination as the first attribute information combination, assuming that the first attribute information combination" tagName ": INPUT" is used to correspondingly locate the first number of web page elements to 5 and obtain the first set, and the second attribute information combination "tagName" + "name": user "is used, the second attribute information combination traverses the first set to correspondingly locate the second number of web page elements to 3 and obtain the second set, since the first number 5 is greater than the second number 3, the third attribute information combination traverses the second set, the third number of web page elements to 2 is located, and at the time, the web page elements are not located successfully, the third attribute information combination" tagName "+" name ": user" is used as the first attribute information combination, and the new attribute name "new name" is formed in the second attribute information combination of the other attribute information combinations of the third attribute information combination "user" + "type": text ", and so on, until the number of web page elements is 1, the web page element is located. Since the number of the web page elements positioned to be 1 is "1" in this example using the attribute combinations "tagName": "INPUT" + "name": user "+" type ": text" + "value": 1", it can be judged that the web page elements are positioned to be using the attribute combinations" tagName "+" name ": user" + "type": text "+" value ": 1".
When the optimal positioning information is the second positioning information R2, the step 204 may include the following sub-steps:
a parent positioning current traversal step S51, wherein a parent element set of the web page elements of the web page to be detected is traversed by adopting attribute information combination of the current parent element, and a current set and a current number of the located parent elements of the web page elements are obtained;
a parent positioning next traversal step S52, wherein the current set obtained in the parent positioning current traversal step is traversed by adopting the attribute information combination of the next parent element, and the next set and the next quantity of the parent elements of the positioned web page elements are obtained; the next attribute information combination of the parent element comprises information in the current attribute information combination of the parent element and attribute information of a newly added parent element;
a parent positioning determination step S53 of determining whether the next number is less than or equal to the current number, and whether the next number is 1; if yes, executing a parent class positioning success determination step S54; if not, executing a parent positioning attribute information conversion step S55;
a parent positioning success determining step S54 of combining the attribute information of the next parent element, determining that the attribute information of the parent element corresponding to the web page element can be uniquely positioned, and proceeding to the relative position positioning step;
a parent positioning attribute combination converting step S55 of re-executing the next parent positioning traversal step S52, with the attribute information combination of the next parent element as the attribute information combination of the current parent element, the next set as the current set, and the next number as the current number;
a step S56 of locating the web page element according to the relative position of the web page element within the range of the parent element, and then determining to locate the web page element by using the optimal location information.
Specifically, since the positioning process of the parent element of the web page element is the same as the positioning process of the web page element, it is not repeated here. The whole positioning process of the second positioning information R2 can be divided into 2 blocks: and the first block is used for positioning the parent element of the web page element according to the positioning information of the parent element. And the second block is used for positioning the parent element of the web page element based on the positioning information of the parent element, finding the relative position of the web page element in the range of the parent element and positioning the web page element.
The following description will be given to a preferred example of the step of determining whether there is attribute information that can be uniquely located to a corresponding web page element in the present application, referring to a locating flow chart of a parent element of a web page element in the present application shown in fig. 10, and the specific steps are as follows:
sub-step SS51, traversing the web page element set of the web page to be tested by adopting a fourth attribute information combination to obtain a third set and a fourth quantity;
wherein the fourth attribute information combination includes fourth attribute information;
substep SS52, traversing the third set by adopting the fifth attribute information combination, and obtaining the number of the currently positioned parent elements as a fifth number;
wherein the fifth attribute information combination includes the fourth attribute information and fifth attribute information;
substep SS53, determining whether the fourth number is greater than or equal to the fifth number, if yes, executing substep SS54, and if no, executing substep SS 55;
substep SS54, determining whether said fifth number is 1; if yes, performing sub-step SS511, otherwise, performing sub-step SS 56;
sub-step SS55 uses sixth attribute information combination to traverse the fourth set, and obtains the number of the currently positioned web page elements as a sixth number;
wherein the sixth attribute information combination includes the fourth attribute information, fifth attribute information, and sixth attribute information;
sub-step SS56, traversing the third set by adopting a sixth attribute information combination, and obtaining the number of the currently positioned web page elements as a sixth number;
substep SS57, determining whether the sixth number is 1, and if the fifth number is greater than or equal to the sixth number, executing substep SS511, if not, executing substep SS 59;
substep S58, determining the parent element located to the corresponding web page element using the sixth attribute information and executing substep SS 512;
substep SS59, determining whether attribute information of other parent elements exists, if yes, executing substep SS510, otherwise, executing substep SS 511;
substep SS510, taking the sixth attribute information combination as a fourth attribute information combination, adding an attribute name and a corresponding attribute value of another parent element in the sixth attribute information combination as a fifth attribute information combination, and returning to substep SS 52;
sub-step SS511, judging that the web page element can not be positioned by adopting the optimal positioning information;
substep SS512, if the web page element is positioned according to the relative position of the web page element in the range of the parent element, judging to adopt the optimal positioning information to position the web page element; otherwise, judging that the web page element cannot be positioned by adopting the optimal positioning information.
When the optimal positioning information is the third positioning information R3, the step 204 may include the following sub-steps:
and a substep S61, locating said web page element using said XPATH path.
In the embodiment of the present application, when the optimal positioning information is the third positioning information R3, the web page element can be found and positioned according to the XPATH path on the web page to be detected by using the XPATH language.
Assuming that the third positioning information R3= html/body/form/input [ name = "user" ], the child element body of html, the child element form in body, and the web page element with the user name "user" in the user input box input of the child element in form are searched for in the web page to be tested according to the third positioning information R3.
It is noted that, for simplicity of explanation, the method embodiments are described as a series of acts or combination of acts, but those skilled in the art will appreciate that the present application is not limited by the order of acts, as some steps may, in accordance with the present application, occur in other orders and concurrently. Further, those skilled in the art will appreciate that the embodiments described in the specification are presently preferred and that no particular act is required to implement the invention.
Referring to fig. 9, a block diagram of a structure of an embodiment of an apparatus for positioning web page elements of the present application is shown, which may specifically include the following modules:
the positioning information acquisition module 301 is configured to acquire positioning information of at least two web page elements in one or more web pages to be detected;
in a preferred embodiment of the present application, the positioning information of the web page element may include three items, specifically:
first positioning information formed by attribute combination of the web page elements;
second positioning information formed by attribute combinations of parent class elements of the web page elements and relative positions of the web page elements in the parent class elements thereof;
and third positioning information formed by an XPATH path of the web page element.
In a preferred embodiment of the present application, the positioning information obtaining module 301 may include:
the attribute information acquisition sub-module is used for respectively acquiring one or more attribute information corresponding to one or more web page elements in the web page to be detected;
the positioning judgment submodule is used for judging whether attribute information which can be uniquely positioned to the corresponding web page element exists or not; if yes, calling a first attribute information recording submodule; if not, calling a parent element acquisition submodule;
the attribute information recording submodule is used for recording the attribute combination of the web page elements formed by the attribute information;
the parent element acquisition submodule is used for acquiring attribute information of a parent element of the current web page element;
the parent positioning judgment submodule is used for judging whether attribute information which can be uniquely positioned to the parent element exists or not; if yes, calling a parent attribute information recording submodule; if not, taking the parent element as the current web page element, and calling a return parent element acquisition sub-module;
the parent attribute information recording submodule is used for recording attribute information of the parent elements to form attribute combinations of the parent elements of the web page elements and acquiring relative positions of the web page elements in the parent elements of the web page elements;
and the path generation submodule is used for generating an XPATH path of the web page elements by respectively adopting an XPATH path positioning engine aiming at one or more web page elements in the web page to be detected.
In a preferred embodiment of the present application, the positioning determination sub-module may include:
the current traversing unit is used for traversing the web page element set of the web page to be detected by adopting the current attribute information combination to obtain the current set and the current number of the positioned web page elements;
the next traversal unit is used for traversing the current set obtained by the current traversal unit by adopting the next attribute information combination to obtain the next set and the next quantity of the positioned web page elements; the next attribute information combination comprises information in the current attribute information combination and newly added attribute information;
a judging unit configured to judge whether the next number is less than or equal to the current number, and whether the next number is 1; if yes, calling a success judging unit; if not, calling an attribute information conversion unit;
a success judging unit, configured to combine the next attribute information and judge that the attribute information of the corresponding web page element can be uniquely located;
and the attribute combination conversion unit is used for combining the next attribute information as the current attribute information, using the next set as the current set and using the next quantity as the current quantity, and re-executing the next traversal step.
In a preferred embodiment of the present application, the positioning determining sub-module may further include:
and the attribute information filtering submodule is used for filtering out attribute information with a null attribute value from the attribute information of the web page elements.
In a preferred embodiment of the present application, the parent positioning determining sub-module may include:
the parent class current traversal unit is used for traversing the parent class element set of the web page elements of the web page to be detected by adopting the attribute information combination of the current parent class elements to obtain the current set and the current number of the located parent class elements of the web page elements;
the parent next traversal unit is used for traversing the current set of the parent elements obtained by the parent current traversal unit by adopting the attribute information combination of the next parent element to obtain the next set and the next quantity of the parent elements of the positioned web page elements; the attribute information combination of the next parent element comprises the information in the attribute information combination of the current parent element and the attribute information of a newly added parent element;
a parent class judgment unit, configured to judge whether the next number is less than or equal to the current number, and whether the next number is 1; if yes, calling a parent class success judging unit; if not, calling a parent attribute information conversion unit;
a parent success judging unit, configured to combine the attribute information of the next parent element, and judge that the attribute information of the parent element of the corresponding web page element can be uniquely located;
and the parent attribute combination conversion unit is used for taking the attribute information combination of the next parent element as the attribute information combination of the current parent element, taking the next set as the current set, taking the next quantity as the current quantity, and recalling the next traversal unit of the parent.
An optimal positioning information selecting module 302, configured to determine optimal positioning information from the positioning information of the at least two web page elements;
in a preferred embodiment of the present application, the optimal positioning information selecting module 302 may include:
the first statistic sub-module is used for counting time consumed by adopting the first positioning information to carry out web page element positioning on the web page to be detected as first processing time;
the second statistical submodule is used for counting time consumed by adopting the second positioning information to position the web page elements of the web page to be detected as second processing time;
a third statistical submodule, configured to count time consumed for performing web page element positioning on the web page to be detected by using the third positioning information as third processing time;
and the sorting and selecting submodule is used for carrying out reverse sorting on the first processing time, the second processing time and the third processing time and extracting the positioning information corresponding to the processing time with the highest sorting as the optimal positioning information.
An optimal positioning information updating module 303, configured to update the optimal positioning information with at least one piece of other positioning information that can be positioned to the web page element when the web page element cannot be positioned with the optimal positioning information and the other positioning information exists.
In a preferred embodiment of the present application, the optimal positioning information updating module 303 may include:
the optimal positioning information replacing module is used for adopting the other positioning information as the optimal positioning information;
and the optimal positioning information repairing module is used for repairing the optimal positioning information by adopting the other positioning information.
In a preferred embodiment of the present application, the apparatus may further include:
and the web page element positioning module is used for positioning the web page element by adopting the optimal positioning information.
In a preferred embodiment of the present application, the web page element positioning module may include:
a current traversing submodule is positioned and used for traversing the web page element set of the web page to be detected by adopting the current attribute information combination to obtain the current set and the current quantity of the positioned web page elements;
positioning a next traversal submodule for traversing the current set obtained by the current traversal submodule by adopting a next attribute information combination to obtain a next set and a next quantity of the positioned web page elements; the next attribute information combination comprises information in the current attribute information combination and newly added attribute information;
a positioning judgment submodule for judging whether the next number is less than or equal to the current number and whether the next number is 1; if yes, executing a positioning success judgment submodule; if not, executing a positioning attribute combination conversion sub-module;
the positioning success judging submodule is used for judging that the optimal positioning information is adopted to position the web page element;
and the positioning attribute combination conversion submodule is used for taking the next attribute information combination as the current attribute information combination, taking the next set as the current set, taking the next quantity as the current quantity, and calling the next traversal submodule again.
In a preferred embodiment of the present application, the web page element positioning module may include:
the parent positioning current traversal submodule is used for traversing the parent element set of the web page elements of the web page to be detected by adopting the attribute information combination of the current parent element to obtain the current set and the current number of the parent elements of the positioned web page elements;
the parent positioning next traversal submodule is used for traversing the current set of the parent elements obtained by the parent positioning current traversal submodule by adopting the attribute information combination of the next parent element to obtain the next set and the next quantity of the parent elements of the positioned web page elements; the next attribute information combination of the parent element comprises information in the current attribute information combination of the parent element and attribute information of a newly added parent element;
a parent positioning judgment submodule for judging whether the next number is less than or equal to the current number and whether the next number is 1; if yes, calling a parent positioning success judgment sub-module; if not, calling a parent positioning attribute information conversion sub-module;
the parent positioning success judging submodule is used for combining the attribute information of the next parent element, judging that the attribute information of the parent element corresponding to the web page element can be uniquely positioned, and switching to the relative position positioning submodule;
a parent positioning attribute combination conversion submodule for executing the next calling submodule of the parent again by taking the attribute information combination of the next parent element as the current attribute information combination of the parent element, taking the next set as the current set and the next quantity as the current quantity;
and the relative position positioning submodule is used for judging that the web page element is positioned by adopting the optimal positioning information when the web page element is positioned according to the relative position of the web page element in the range of the parent element of the web page element.
For the device embodiment, since it is basically similar to the method embodiment, the description is simple, and for the relevant points, refer to the partial description of the method embodiment.
Referring to fig. 10, a block diagram of a system embodiment of web page element positioning according to the present application is shown, which may specifically include the following modules:
the information extraction device 401 is configured to obtain at least two pieces of positioning information of one or more web page elements in a web page to be detected, and determine optimal positioning information among the at least two pieces of positioning information;
a positioning engine device 402, configured to perform positioning of a web page element by using the at least two pieces of positioning information;
a feedback device 403, configured to update the optimal positioning information with the other positioning information when the web page element cannot be positioned with the optimal positioning information and there is at least one piece of other positioning information that can be positioned to the web page element.
The web page element positioning system may implement a function of performing multi-dimensional positioning on each web page element in a web page to be detected, and specifically, the web page element positioning system may include an information extraction apparatus 401 for executing step1, a positioning engine apparatus 402 for executing step2, and a feedback apparatus 403 for executing step 3.
The page1 in fig. 8 is a dom (Document object model) tree of a dynamic web page to be tested, the information extraction device 401 can obtain multi-dimensional positioning information of web page elements of the web page to be tested (i.e., positioning information of at least two web page elements of the web page to be tested), after the layout structure of the page1 or the attribute information or other factors of the web page elements of the page1 change into the page2, the positioning engine device 402 can still position the changed web page elements by using the multi-dimensional positioning information of the web page elements, the feedback device 403 can update the multi-dimensional positioning information by using the positioned positioning information of the changed web page elements, and the positioning information of the changed web page elements is repaired.
The following is further explained for Step 1-Step 3:
Step1:
the information extraction device 401 may obtain three pieces of positioning information of the web page to be detected, which may specifically include: first positioning information R1 formed by attribute combinations of the web page elements themselves; second positioning information R2 formed by a combination of attributes of a parent class element of the web page element and the relative position of the web page element in its parent class element; third positioning information R3 formed by the XPATH path of said web page element.
The information extraction apparatus 401 can create a plurality of positioning information at a time, and thus can realize dual security of attribute positioning (R1 + R2) and coordinate positioning (R3).
Step2:
The positioning engine device 402 plays back the positioning information acquired by the information extraction device 401, performs web Page element positioning on the Page2 with the changed web Page layout to be detected, and checks whether the positioning information can also position the web Page element. In particular, using the positioning engine apparatus 402 may include the following processes:
1, selecting the positioning information with the highest priority for positioning processing, for example, the positioning information may be the third positioning information R3;
2, sequentially reading the attributes by using a positioning engine corresponding to the first positioning information R1, and respectively judging until only one web page element is positioned;
3, using a positioning engine corresponding to the second positioning information R2 to perform R1 engine positioning on the parent element of the web page element, and then positioning through the relative position sorting index of the web page element in the parent element;
and 4, positioning by using an XPATH positioning engine corresponding to the third positioning information R3 and a standard XPATH syntax parsing engine.
Step3:
The feedback means 403 repairs the positioning information acquired by the information extraction means 401 by the execution result of the played-back positioning engine means 402. Whether the priority of the information extraction device 401 is still unchanged in the positioning engine can be judged firstly, if the priority is unchanged, the optimal positioning information is still effective, the repairing is not needed, if the priority is changed, the positioning information of the web page elements needs to be repaired, the positioning information is obtained again through the information extraction device 401 and is fed back to the web page element positioning system for updating, and the self-repairing processing of the positioning information is carried out on the changed web page elements.
For the system embodiment, since it is basically similar to the method embodiment, the description is simple, and for the relevant points, refer to the partial description of the method embodiment.
The embodiments in the present specification are described in a progressive manner, each embodiment focuses on differences from other embodiments, and the same and similar parts among the embodiments are referred to each other.
As will be appreciated by one skilled in the art, embodiments of the present application may be provided as a method, apparatus, or computer program product. Accordingly, the present application may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application may take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, and the like) having computer-usable program code embodied therein.
The present application is described with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the application. It will be understood that each flow and/or block of the flow diagrams and/or block diagrams, and combinations of flows and/or blocks in the flow diagrams and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer-readable memory produce an article of manufacture including instruction means which implement the function specified in the flowchart flow or flows and/or block diagram block or blocks.
These computer program instructions may also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the functions specified in the flowchart flow or flows and/or block diagram block or blocks.
While the preferred embodiments of the present application have been described, additional variations and modifications in those embodiments may occur to those skilled in the art once they learn of the basic inventive concepts. Therefore, it is intended that the appended claims be interpreted as including preferred embodiments and all alterations and modifications as fall within the scope of the application.
Finally, it should also be noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
The method, the device and the system for positioning web page elements provided by the application are introduced in detail, specific examples are applied in the description to explain the principle and the implementation of the application, and the description of the above embodiments is only used for helping to understand the method and the core idea of the application; meanwhile, for a person skilled in the art, according to the idea of the present application, there may be variations in the specific embodiments and the application scope, and in summary, the content of the present specification should not be construed as a limitation to the present application.

Claims (23)

1. A method of web page element positioning, comprising:
acquiring at least two pieces of positioning information of one or more web page elements in a web page to be detected;
determining optimal positioning information in the at least two pieces of positioning information;
and when the web page element cannot be positioned by adopting the optimal positioning information and at least one piece of other positioning information which can be positioned to the web page element exists, updating the optimal positioning information by adopting the other positioning information.
2. The method of claim 1, further comprising:
and positioning the web page element by adopting the optimal positioning information.
3. The method according to claim 1 or 2, wherein the positioning information of the web page element comprises three pieces, in particular:
first positioning information formed by attribute combination of the web page elements;
second positioning information formed by attribute combinations of parent class elements of the web page elements and relative positions of the web page elements in the parent class elements thereof;
and third positioning information formed by an XPATH path of the web page element.
4. The method according to claim 3, wherein the step of obtaining at least two pieces of positioning information of one or more web page elements in the web page to be tested comprises:
substep S1, respectively acquiring corresponding attribute information of one or more web page elements in the web page to be detected;
a substep S2 of determining whether there is attribute information that can be uniquely located to a corresponding web page element; if yes, go to substep S3; if not, go to substep S4;
a substep S3, recording the attribute combination of the attribute information forming the web page element;
substep S4, obtaining attribute information of parent class element of current web page element;
a substep S5 of determining whether there is attribute information that can be uniquely located to the parent element; if yes, go to substep S6; if not, returning the parent class element as the current web page element to the substep S4;
substep S6, recording attribute information of the parent element to form an attribute combination of the parent element of the web page element, and obtaining a relative position of the web page element in the parent element;
and a substep S7, for one or more web page elements in the web page to be tested, respectively generating an XPATH path of the web page elements by using an XPATH path positioning engine.
5. The method according to claim 4, wherein the sub-step S2 further comprises:
in the current traversing step, a current attribute information combination is adopted to traverse the web page element set of the web page to be detected, and a current set and a current number of the positioned web page elements are obtained;
a next traversal step, adopting a next attribute information combination to traverse the current set obtained in the current traversal step to obtain a next set and a next quantity of the positioned web page elements; the next attribute information combination comprises information in the current attribute information combination and newly added attribute information;
a judging step of judging whether the next number is less than or equal to the current number and whether the next number is 1; if yes, executing a success judging step; if not, executing an attribute information conversion step;
a success judgment step, namely combining the next attribute information and judging that the attribute information of the corresponding web page element can be uniquely positioned;
and an attribute combination conversion step, namely, taking the next attribute information combination as the current attribute information combination, taking the next set as the current set, taking the next quantity as the current quantity, and re-executing the next traversal step.
6. The method of claim 4, further comprising, before substep S2:
the sub-step S11 is to filter out the attribute information with empty attribute value from the one or more attribute information of the web page element.
7. The method according to claim 4, wherein the sub-step S5 further comprises:
a parent class current traversal step, wherein a parent class element set of web page elements of the web page to be detected is traversed by adopting attribute information combination of current parent class elements, and a current set and a current number of the located parent class elements of the web page elements are obtained;
a parent next traversal step, wherein the current set of parent elements obtained in the parent current traversal step is traversed by adopting the attribute information combination of the next parent element, and the next set and the next quantity of the parent elements of the positioned web page elements are obtained; the attribute information combination of the next parent element comprises the information in the attribute information combination of the current parent element and the attribute information of a newly added parent element;
a parent class judgment step of judging whether the next number is less than or equal to the current number and whether the next number is 1; if yes, executing a parent class success judging step; if not, executing a parent attribute information conversion step;
a parent success judging step, namely combining the attribute information of the next parent element and judging that the attribute information of the parent element of the corresponding web page element can be uniquely positioned;
and a parent attribute combination and conversion step, namely, taking the attribute information combination of the next parent element as the attribute information combination of the current parent element, taking the next set as the current set, taking the next quantity as the current quantity, and re-executing the next traversal step of the parent.
8. The method of claim 3, wherein the step of determining optimal positioning information among the positioning information of at least two web page elements comprises:
counting time consumed by adopting the first positioning information to position the web page elements of the web page to be detected as first processing time;
counting time consumed by the web page element positioning of the web page to be detected by adopting the second positioning information as second processing time;
counting time consumed by the web page element positioning of the web page to be detected by adopting the third positioning information as third processing time;
and performing reverse sequencing on the first processing time, the second processing time and the third processing time, and extracting positioning information corresponding to the processing time with the highest sequencing as optimal positioning information.
9. The method according to claim 4 or 5, wherein when the optimal positioning information is the first positioning information, the step of positioning the web page element by using the optimal positioning information comprises:
a current traversing step is positioned, wherein a current attribute information combination is adopted to traverse a web page element set of the web page to be detected, and a current set and a current number of the positioned web page elements are obtained;
a step of positioning next traversal, which is to traverse the current set obtained in the step of positioning the current traversal by adopting a next attribute information combination to obtain a next set and a next quantity of the positioned web page elements; the next attribute information combination comprises information in the current attribute information combination and newly added attribute information;
a positioning judgment step of judging whether the next number is less than or equal to the current number and whether the next number is 1; if yes, executing a positioning success judging step; if not, executing a positioning attribute combination conversion step;
a positioning success judging step, namely judging that the web page element is positioned by adopting the optimal positioning information;
and positioning attribute combination and conversion, namely, taking the next attribute information combination as the current attribute information combination, taking the next set as the current set, taking the next quantity as the current quantity, and re-executing the step of positioning the next traversal.
10. The method according to claim 4 or 7, wherein when the optimal positioning information is the second positioning information, the step of positioning the web page element by using the optimal positioning information comprises:
a parent positioning current traversal step, wherein a parent element set of the web page elements of the web page to be detected is traversed by adopting attribute information combination of the current parent element, and a current set and a current number of the located parent elements of the web page elements are obtained;
a next traversal step of parent positioning, which is to traverse the current set of parent elements obtained in the current traversal step of parent positioning by adopting the attribute information combination of the next parent element to obtain the next set and the next quantity of the parent elements of the positioned web page elements; the next attribute information combination of the parent element comprises information in the current attribute information combination of the parent element and attribute information of a newly added parent element;
a parent positioning judgment step of judging whether the next number is less than or equal to the current number and whether the next number is 1; if yes, executing a father positioning success judging step; if not, executing a parent positioning attribute information conversion step;
a parent positioning success judging step, namely combining the attribute information of the next parent element, judging that the attribute information of the parent element of the corresponding web page element can be uniquely positioned, and turning to a relative position positioning step;
a parent positioning attribute combination conversion step, namely, taking the attribute information combination of the next parent element as the attribute information combination of the current parent element, taking the next set as the current set, taking the next quantity as the current quantity, and re-executing the next traversal step of parent positioning;
and a relative position positioning step, namely judging to adopt the optimal positioning information to position the web page element when the web page element is positioned according to the relative position of the web page element in the range of the parent element.
11. The method of claim 1, wherein the step of updating the optimal positioning information with other positioning information comprises:
adopting the other positioning information as the optimal positioning information;
or,
and restoring the optimal positioning information by adopting the other positioning information.
12. An apparatus for web page element positioning, comprising:
the positioning information acquisition module is used for acquiring positioning information of at least two web page elements in the web page to be detected;
the optimal positioning information selection module is used for determining optimal positioning information in the at least two pieces of positioning information;
and the optimal positioning information updating module is used for updating the optimal positioning information by adopting other positioning information when the web page element cannot be positioned by adopting the optimal positioning information and at least one piece of other positioning information capable of being positioned to the web page element exists.
13. The apparatus of claim 12, further comprising:
and the web page element positioning module is used for positioning the web page element by adopting the optimal positioning information.
14. The apparatus according to claim 12 or 13, wherein the positioning information of the web page element comprises three, in particular:
first positioning information formed by attribute combination of the web page elements;
second positioning information formed by attribute combinations of parent class elements of the web page elements and relative positions of the web page elements in the parent class elements thereof;
and third positioning information formed by an XPATH path of the web page element.
15. The apparatus of claim 14, wherein the positioning information obtaining module comprises:
the attribute information acquisition sub-module is used for respectively acquiring corresponding attribute information of one or more web page elements in the web page to be detected;
the positioning judgment submodule is used for judging whether attribute information which can be uniquely positioned to the corresponding web page element exists or not; if yes, calling an attribute information recording submodule; if not, calling a parent element acquisition submodule;
the attribute information recording submodule is used for recording the attribute combination of the web page elements formed by the attribute information;
the parent element acquisition submodule is used for acquiring attribute information of a parent element of the current web page element;
the parent positioning judgment submodule is used for judging whether attribute information which can be uniquely positioned to the parent element exists or not; if yes, calling a parent attribute information recording submodule; if not, taking the parent element as the current web page element, and calling a return parent element acquisition sub-module;
the parent attribute information recording submodule is used for recording attribute information of the parent elements to form attribute combinations of the parent elements of the web page elements and acquiring relative positions of the web page elements in the parent elements of the web page elements;
and the path generation submodule is used for generating an XPATH path of the web page elements by respectively adopting an XPATH path positioning engine aiming at one or more web page elements in the web page to be detected.
16. The apparatus of claim 15, wherein the positioning determination sub-module comprises:
the current traversing unit is used for traversing the web page element set of the web page to be detected by adopting the current attribute information combination to obtain the current set and the current number of the positioned web page elements;
the next traversal unit is used for traversing the current set obtained by the current traversal unit by adopting the next attribute information combination to obtain the next set and the next quantity of the positioned web page elements; the next attribute information combination comprises information in the current attribute information combination and newly added attribute information;
a judging unit configured to judge whether the next number is less than or equal to the current number, and whether the next number is 1; if yes, calling a success judging unit; if not, calling an attribute information conversion unit;
a success judging unit, configured to combine the next attribute information and judge that the attribute information of the corresponding web page element can be uniquely located;
and the attribute combination conversion unit is used for combining the next attribute information as the current attribute information, using the next set as the current set and using the next quantity as the current quantity, and re-executing the next traversal step.
17. The apparatus of claim 15, further comprising:
and the attribute information filtering submodule is used for filtering out attribute information with an empty attribute value from one or more attribute information of the web page elements.
18. The apparatus of claim 15, wherein the parent positioning sub-module comprises:
the parent class current traversal unit is used for traversing the parent class element set of the web page elements of the web page to be detected by adopting the attribute information combination of the current parent class elements to obtain the current set and the current number of the located parent class elements of the web page elements;
the parent next traversal unit is used for traversing the current set of the parent elements obtained by the parent current traversal unit by adopting the attribute information combination of the next parent element to obtain the next set and the next quantity of the parent elements of the positioned web page elements; the attribute information combination of the next parent element comprises the information in the attribute information combination of the current parent element and the attribute information of a newly added parent element;
a parent class judgment unit, configured to judge whether the next number is less than or equal to the current number, and whether the next number is 1; if yes, calling a parent class success judging unit; if not, calling a parent attribute information conversion unit;
a parent success judging unit, configured to combine the attribute information of the next parent element, and judge that the attribute information of the parent element of the corresponding web page element can be uniquely located;
and the parent attribute combination conversion unit is used for taking the attribute information combination of the next parent element as the attribute information combination of the current parent element, taking the next set as the current set, taking the next quantity as the current quantity, and recalling the next traversal unit of the parent.
19. The apparatus of claim 14, wherein the optimal positioning information extracting module comprises:
the first statistic sub-module is used for counting time consumed by adopting the first positioning information to carry out web page element positioning on the web page to be detected as first processing time;
the second statistical submodule is used for counting time consumed by adopting the second positioning information to position the web page elements of the web page to be detected as second processing time;
a third statistical submodule, configured to count time consumed for performing web page element positioning on the web page to be detected by using the third positioning information as third processing time;
and the sorting and selecting submodule is used for carrying out reverse sorting on the first processing time, the second processing time and the third processing time and extracting the positioning information corresponding to the processing time with the highest sorting as the optimal positioning information.
20. The apparatus of claim 15 or 16, wherein the web page element positioning module comprises:
a current traversing submodule is positioned and used for traversing the web page element set of the web page to be detected by adopting the current attribute information combination to obtain the current set and the current quantity of the positioned web page elements;
positioning a next traversal submodule for traversing the current set obtained by the current traversal submodule by adopting a next attribute information combination to obtain a next set and a next quantity of the positioned web page elements; the next attribute information combination comprises information in the current attribute information combination and newly added attribute information;
a positioning judgment submodule for judging whether the next number is less than or equal to the current number and whether the next number is 1; if yes, executing a positioning success judgment submodule; if not, executing a positioning attribute combination conversion sub-module;
the positioning success judging submodule is used for judging that the optimal positioning information is adopted to position the web page element;
and the positioning attribute combination conversion submodule is used for taking the next attribute information combination as the current attribute information combination, taking the next set as the current set, taking the next quantity as the current quantity, and calling the next traversal submodule again.
21. The apparatus of claim 15 or 18, wherein the web page element positioning module comprises:
the parent positioning current traversal submodule is used for traversing the parent element set of the web page elements of the web page to be detected by adopting the attribute information combination of the current parent element to obtain the current set and the current number of the parent elements of the positioned web page elements;
the parent positioning next traversal submodule is used for traversing the current set of the parent elements obtained by the parent positioning current traversal submodule by adopting the attribute information combination of the next parent element to obtain the next set and the next quantity of the parent elements of the positioned web page elements; the next attribute information combination of the parent element comprises information in the current attribute information combination of the parent element and attribute information of a newly added parent element;
a parent positioning judgment submodule for judging whether the next number is less than or equal to the current number and whether the next number is 1; if yes, calling a parent positioning success judgment sub-module; if not, calling a parent positioning attribute information conversion sub-module;
the parent positioning success judging submodule is used for combining the attribute information of the next parent element, judging that the attribute information of the parent element corresponding to the web page element can be uniquely positioned, and switching to the relative position positioning submodule;
a parent positioning attribute combination conversion submodule for executing the next calling submodule of the parent again by taking the attribute information combination of the next parent element as the current attribute information combination of the parent element, taking the next set as the current set and the next quantity as the current quantity;
and the relative position positioning submodule is used for judging that the web page element is positioned by adopting the optimal positioning information when the web page element is positioned according to the relative position of the web page element in the range of the parent element of the web page element.
22. The apparatus of claim 12, wherein the optimal positioning information updating module comprises:
the optimal positioning information replacing module is used for adopting the other positioning information as the optimal positioning information;
and the optimal positioning information repairing module is used for repairing the optimal positioning information by adopting the other positioning information.
23. A system for web page element positioning, comprising:
the information extraction device is used for acquiring at least two pieces of positioning information of one or more web page elements in the web page to be detected and determining the optimal positioning information in the at least two pieces of positioning information;
the positioning engine device is used for positioning the web page elements by adopting the at least two pieces of positioning information;
and the feedback device is used for updating the optimal positioning information by adopting other positioning information when the web page element cannot be positioned by adopting the optimal positioning information and at least one piece of other positioning information capable of being positioned to the web page element exists.
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 (18)

* 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
CN112667502A (en) * 2020-12-23 2021-04-16 平安普惠企业管理有限公司 Page testing method, device and medium
CN113110991A (en) * 2021-03-29 2021-07-13 青岛海尔科技有限公司 Page element positioning method and device, storage medium and electronic device
CN113553254A (en) * 2020-04-24 2021-10-26 阿里巴巴集团控股有限公司 Page testing method and device and electronic equipment
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 (23)

* 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
CN108845925A (en) * 2018-03-30 2018-11-20 新华三技术有限公司 Web page test method, device, electronic equipment and computer-readable medium
CN108845925B (en) * 2018-03-30 2022-02-11 新华三技术有限公司 Web page testing method and 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
CN113553254A (en) * 2020-04-24 2021-10-26 阿里巴巴集团控股有限公司 Page testing method and device and electronic equipment
CN112083992A (en) * 2020-09-02 2020-12-15 李振 UI automation test method
CN112667502A (en) * 2020-12-23 2021-04-16 平安普惠企业管理有限公司 Page testing method, device and medium
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
CN104424087B (en) A kind of method of Web page surface element positioning, apparatus and system
CN102831052B (en) Test exemple automation generating apparatus and method
CN104657274B (en) software interface test method and device
CN103019925A (en) Selector acquisition method and device
CN107315764B (en) Method and system for updating non-relational database associated data
CN105279089B (en) A kind of method and device for obtaining page elements
CN102521121A (en) Page testing method and page testing device
US8904352B2 (en) Systems and methods for processing source code during debugging operations
CN113177168B (en) Positioning method based on Web element attribute characteristics
CN105335246B (en) A kind of program crashing defect self-repairing method based on question and answer web analytics
CN104516813B (en) The choosing method and device of the test node of Webpage
US11675690B2 (en) Lineage-driven source code generation for building, testing, deploying, and maintaining data marts and data pipelines
CN101174237B (en) Automatic test method, system and test device
CN101499063A (en) Tracing-based database schema evolution method and system
CN101814052A (en) Automatic test method
CN102193993A (en) Method, device and facility for determining similarity information between character string information
CN107729234A (en) The scheduling of test case performs method, apparatus, equipment and computer-readable storage medium
CN104461864A (en) Java source code defect detecting method and system based on Eclipse plugin
CN103365640A (en) Cascading style sheet style transformation method and device
CN101727451B (en) Method and device for extracting information
WO2021262283A1 (en) Reduced processing loads via selective validation specifications
CN102043853A (en) Method and device for updating stored data
CN112579456B (en) Web automatic testing method and device
CN107196789B (en) Method and device for checking base station parameters
CN102955761A (en) Size information output system and size information output method

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