A method and system for obtaining similar elements of web pages in an RPA system

By extracting the public mode of web page elements in the RPA system and performing DOM tree traversal, the difficulty of positioning and processing similar elements on the web page is solved, and efficient acquisition and batch operation of similar elements is achieved.

CN115270038BActive Publication Date: 2025-06-06ZHEJIANG DONGSHANG DIGITAL TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210922464.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-08-02
Publication Date
2025-06-06
Estimated Expiration
2042-08-02

AI Technical Summary

Technical Problem

In RPA systems, it is difficult to locate and process similar elements on web pages because the hierarchy and tag names of similar elements may be different, and it is impossible to simply use hierarchy or tag names for positioning.

Method used

The similar elements of the web page are obtained by selecting two similar web page elements during the automated process configuration phase, extracting their common patterns, and traversing the DOM tree for pattern matching using the breadth-first search algorithm.

Benefits of technology

It realizes efficient acquisition of similar elements of the web page, simplifies the configuration process of subsequent batch operations, and reduces the need for human selection and configuration.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115270038B_ABST
    Figure CN115270038B_ABST
Patent Text Reader

Abstract

The present invention discloses a method and system for obtaining similar elements of a web page of an RPA system, and belongs to the field of robotic process automation technology. In the automation process configuration stage, two similar web page elements are selected and stored in a first web page element selector and a second web page element selector respectively; according to the obtained first web page element selector and the second web page element selector, the common mode of the elements contained in the two web page element selectors is extracted, and the common mode list is output in the form of a Json object; the DOM structure tree of the web page interface is obtained by using the RPA system, and according to the obtained web page element common mode list, the DOM tree is traversed from bottom to top using a breadth-first search algorithm, and each node element in the DOM tree is pattern-matched with the web page element common mode list, and if the match is the same, the node element is saved in a similar element list. The present invention can realize the acquisition of similar elements of a web page, and then batch operations can be performed on them later.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of Robotic Process Automation (RPA), and in particular to a method for acquiring similar elements of a web page. Background Art

[0002] RPA can automatically process some of the rule-based, repetitive process tasks in people's work. People can configure the task process through the RPA system, and the RPA robot will automatically process according to the configured process. Among these process tasks, a considerable proportion of tasks are to operate web pages, such as clicking on hyperlinks in web pages or obtaining text and images in a certain area of ​​web pages.

[0003] Therefore, obtaining and accurately locating web page elements is an important technology for RPA. In particular, when people configure processes, they need to process some similar elements on the web page. However, similar elements may be at different levels or have different tag names. Therefore, it is not possible to simply use methods such as equal levels or similar tag names to locate other similar elements. Summary of the invention

[0004] In view of the above problems, the object of the present invention is to provide a method for obtaining similar elements of web pages in an RPA system.

[0005] To achieve the above object, the present invention provides the following technical solution, which specifically comprises the following steps:

[0006] In a first aspect, the present invention proposes a method for obtaining similar elements of a web page in an RPA system, comprising the following steps:

[0007] S1: In the automation process configuration stage, two similar web page elements are selected and stored in a first web page element selector and a second web page element selector respectively;

[0008] S2: extracting the common patterns of the elements contained in the two web page element selectors according to the first web page element selector and the second web page element selector obtained in step S1, and outputting the common pattern list in the form of a Json object;

[0009] S3: Use the RPA system to obtain the DOM structure tree of the web page interface. According to the common pattern list of web page elements obtained in step S2, use the breadth-first search algorithm to traverse the DOM tree from bottom to top, and match each node element in the DOM tree with the common pattern list of web page elements. If the match is the same, save the node element in the similar element list.

[0010] In a second aspect, the present invention proposes a system for acquiring similar elements of an RPA system web page, comprising:

[0011] A first web page element selection module, which is used to store the first web page element;

[0012] A second web page element selection module, which is used to store second web page elements similar to the first web page elements;

[0013] A common mode extraction module, which is used to extract the common modes of the elements stored in the first web page element selection module and the second web page element selection module, and output the common mode list in the form of a Json object;

[0014] The pattern matching module is used to obtain the DOM structure tree of the web page interface, and traverse the DOM tree from bottom to top using the breadth-first search algorithm based on the common pattern list of web page elements obtained by the common pattern extraction module, and perform pattern matching on each node element in the DOM tree with the common pattern list of web page elements. If the match is the same, the node element is saved in the similar element list.

[0015] In the application of RPA system, a series of operations are often required for web page elements, and the operations performed on similar elements of web pages are often consistent. The present invention can achieve the acquisition of similar elements of web pages, and then batch operations can be performed on them later, rather than manually selecting different similar elements and configuring corresponding operation processes. BRIEF DESCRIPTION OF THE DRAWINGS

[0016] The drawings described herein are used to provide further understanding of the present invention and constitute a part of the present invention. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute improper limitations on the present invention.

[0017] Figure 1 This is a flow chart of a method for obtaining similar elements of a web page in an RPA system according to an embodiment of the present invention;

[0018] Figure 2 is a schematic diagram of target element attributes in a DOM tree shown in an embodiment of the present invention;

[0019] Figure 3 It is a schematic diagram of a system for obtaining similar elements of a web page of an RPA system shown in an embodiment of the present invention;

[0020] Figure 4 It is a schematic diagram of the structure of an electronic device terminal of a method for obtaining similar elements of an RPA system web page shown in an embodiment of the present invention. DETAILED DESCRIPTION

[0021] In order to make the purpose, technical solution and advantages of the present application clearer, the technical solution of the present application will be clearly and completely described below in combination with the specific embodiments of the present application and the corresponding drawings. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present application.

[0022] The present invention proposes a method for obtaining similar elements of an RPA system web page, comprising the following steps:

[0023] S1: In the automation process configuration stage: autonomously select two similar web page elements and store them in the first web page element selector htmlSelector1 and the second web page element selector htmlSelector2 respectively. At the same time, the RPA system will automatically obtain the DOM tree of the web page. Figure 2 It is a schematic diagram of target element attributes in the DOM tree shown in this embodiment.

[0024] In this embodiment, since the process configuration stage of the RPA system requires manual selection of two web page elements as similar elements according to task requirements, for example, the web page similar elements selected in this embodiment are the titles of two articles in the web page.

[0025] S2: according to the first webpage element selector and the second webpage element selector obtained in step S1, extract the common patterns of the elements contained in the two webpage element selectors, and output the common pattern list in the form of a Json object.

[0026] In this embodiment, the following functions will be completed by the self-developed RPA system.

[0027] S2-1: Determine the number of elements in the first webpage element selector and the second webpage element selector. If either of them is empty, return an error message and report an error. If the number of elements in the two selectors is not equal, it means that the webpage elements contained in the two selectors are not similar elements, return an error message and report an error. If the number of elements in the two selectors is equal, go to step S2-2.

[0028] S2-2: Consider the elements in the element selector as nodes, synchronously traverse the selector nodes in the two selectors according to the element index in positive order, extract the common pattern of the two selector nodes, and add it to the common pattern list. Specifically:

[0029] S2-2-1: traverse the property property_k of the node node1_i in the first webpage element selector, and select the node node2_j with node_i.property_k.Name from the nodes of the second webpage element selector; wherein node1_i represents the i-th node in the first webpage element selector, property_k represents the k-th property, node1_i.property_k.Name represents the name of the k-th property of the i-th node in the first webpage element selector, and node2_j represents the j-th node in the second webpage element selector;

[0030] In this step, the node set in the first web page element selector is represented as [node1_1, node1_2, …, node1_n], where n is the number of nodes in the web page element selector; each node node1_i (i = 1, 2, …, n) contains several properties, represented as [property_1, property_2, …, property_K], where K is the number of properties; the structure of each property property_k (k = 1, 2, …, K) is represented as {Name_1: Value_1, Name_2: Value_2, …, Name_m: Value_m}, where m represents the number of property names, Name_m represents the name of the mth property, and Value_m represents the mth property value.

[0031] Similarly, the node set in the second webpage element selector is represented as [node2_1, node2_2, ..., node2_n], where n is the number of nodes in the webpage element selector; the properties and structure of each node node2_i are represented in the same manner as above.

[0032] By selecting a property property_k in a node node1_i in the first webpage element selector, check whether there is a node node2_j with the same property in the second webpage element selector, that is, determine whether there is node_i.property_k.Name in node2. If yes, go to S2-2-2, otherwise select the next property property_k+1 in the node node1_i in the first webpage element selector, and repeat the above operation.

[0033] S2-2-2: According to the attribute matching pattern, merge the attribute values ​​of the two nodes node1_i and node2_j to obtain the attribute merge value. Specifically:

[0034] S2-2-2-1: If the attribute matching rules of nodes node1_i and node2_j are the same and the attribute values ​​are the same, then the attribute values ​​are directly returned as the attribute merge value; if the matching rules of the two nodes are the same but the attribute values ​​are different, then NULL is returned as the attribute merge value; if the matching rules of the two nodes are different, then regular matching is performed and the attribute values ​​of the two nodes are converted into regular values, and then step S2-2-2-2 is entered;

[0035] S2-2-2-2: Determine whether the regular expression values ​​of two nodes are equal. If they are equal, directly return the regular expression matching pattern and regular expression value as the attribute merge value. If they are not equal, add regular expressions to the original attribute values ​​of the two nodes respectively to obtain two processed strings, and return the result of adding the two strings as the attribute merge value.

[0036] S2-2-3: Combine the attribute matching pattern and the attribute merge value into a Jtoken object, and add the attribute name property_k.Name and JToken as a Json object to the public pattern list.

[0037] S3: Based on the web page element common pattern list obtained in step S2, the DOM tree is traversed from bottom to top using a breadth-first search algorithm, and each node element in the DOM tree is matched with the web page element common pattern list. If the matches are the same, the node element is saved in a similar element list. Specifically:

[0038] S3-1: Determine whether the current node element in the DOM tree is an or element. If so, go to S3-3, otherwise go to S3-2;

[0039] S3-2: Set the use attribute value of the current node element in the DOM tree to true, and perform pattern matching with the public pattern list obtained in step S2. If the match is successful, add the current node element in the DOM tree to the similar element list; return to step S3-1;

[0040] S3-3: Return a list of similar elements.

[0041] Corresponding to the aforementioned embodiment of a method for obtaining similar elements of a web page of an RPA system, the present application also provides an embodiment of a system for obtaining similar elements of a web page of an RPA system, such as Figure 3 As shown, it includes:

[0042] A first web page element selection module, which is used to store the first web page element;

[0043] A second web page element selection module, which is used to store second web page elements similar to the first web page elements;

[0044] A common mode extraction module, which is used to extract the common modes of the elements stored in the first web page element selection module and the second web page element selection module, and output the common mode list in the form of a Json object;

[0045] The pattern matching module is used to obtain the DOM structure tree of the web page interface, and traverse the DOM tree from bottom to top using the breadth-first search algorithm based on the common pattern list of web page elements obtained by the common pattern extraction module, and perform pattern matching on each node element in the DOM tree with the common pattern list of web page elements. If the match is the same, the node element is saved in the similar element list.

[0046] In this embodiment, the common mode extraction module includes:

[0047] The first judgment module is used to judge the number of elements in the first webpage element selection module and the second webpage element selection module. If either one of them is empty, an error message is returned and an error is reported. If the number of elements in the two selection modules is not equal, it means that the webpage elements contained in the two selection modules are not similar elements, and an error message is returned and an error is reported. If the number of elements in the two selection modules is equal, the second judgment module is entered;

[0048] The second judgment module is used to regard the elements in the element selection module as nodes, synchronously traverse the nodes in the two selection modules according to the element index in positive order, extract the common mode of the two selection module nodes, and add it to the common mode list.

[0049] In this embodiment, the second judgment module includes:

[0050] A node selection module, which is used to traverse the property property_k of the node node1_i in the first webpage element selection module, and select the node node2_j having node_i.property_k.Name from the nodes of the second webpage element selection module; wherein node1_i represents the i-th node in the first webpage element selection module, property_k represents the k-th property, node1_i.property_k.Name represents the name of the k-th property of the i-th node in the first webpage element selection module, and node2_j represents the j-th node in the second webpage element selection module;

[0051] An attribute value merging module is used to merge the attribute values ​​of the two nodes node1_i and node2_j selected in the node selection module according to the attribute matching mode to obtain an attribute merged value;

[0052] A public pattern list adding module is used to synthesize the attribute matching pattern and the attribute merge value into a Jtoken object, and add the attribute name property_k.Name and JToken as a Json object to the public pattern list.

[0053] In this embodiment, the attribute value merging module includes:

[0054] The attribute matching rule judgment module is used to judge the attribute matching rules and attribute values ​​of the two nodes node1_i and node2_j selected in the node selection module. If the attribute matching rules of nodes node1_i and node2_j are the same and the attribute values ​​are also the same, the attribute value is directly returned as the attribute merge value; if the matching rules of the two nodes are the same but the attribute values ​​are different, NULL is returned as the attribute merge value; if the matching rules of the two nodes are different, regular matching is performed and the attribute values ​​of the two nodes are converted into regular values ​​and enter the regular value matching module;

[0055] The regular value matching module is used to determine whether the regular values ​​of the two nodes output by the attribute matching rule judgment module are equal. If they are equal, the regular matching mode and regular value are directly returned as the attribute merge value; if they are not equal, the regular symbols are added to the original attribute values ​​of the two nodes respectively to obtain two processed strings, and the result of adding the two strings is returned as the attribute merge value.

[0056] In this embodiment, the pattern matching module includes:

[0057] DOM structure tree acquisition module, which is used to obtain the DOM structure tree of the web page interface;

[0058] DOM tree node traversal module, which is used to traverse the DOM tree from bottom to top using the breadth-first search algorithm to determine whether the current node element in the DOM tree is or element. If so, it enters the similar element list output module, otherwise it enters the DOM tree node matching module;

[0059] DOM tree node matching module, which is used to set the use attribute value of the current node element in the DOM tree to true, and perform pattern matching with the public pattern list obtained by the public pattern extraction module. If the match is successful, the current node element in the DOM tree is added to the similar element list;

[0060] The similar element list output module is used to return the final similar element list.

[0061] Regarding the system in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.

[0062] The embodiments of the system of the present invention can be applied to any device with data processing capabilities, and the device with data processing capabilities can be a device or apparatus such as a computer. The system embodiments can be implemented through software, or through hardware or a combination of software and hardware. Taking software implementation as an example, as a device in a logical sense, the processor of any device with data processing capabilities reads the corresponding computer program instructions in the non-volatile memory into the memory and runs them. From the hardware level, if Figure 4 As shown, it is a hardware structure diagram provided by this embodiment, except Figure 4 In addition to the processor, memory, network interface, and non-volatile memory shown, any device with data processing capabilities in which the system in the embodiments is located may also include other hardware, generally based on the actual functions of the device with data processing capabilities, which will not be described in detail.

[0063] An embodiment of the present invention also provides a computer-readable storage medium on which a program is stored. When the program is executed by a processor, the above-mentioned RPA system web page similar element acquisition method is implemented.

[0064] The computer-readable storage medium may be an internal storage unit of any device with data processing capability described in any of the aforementioned embodiments, such as a hard disk or a memory. The computer-readable storage medium may also be an external storage device of any device with data processing capability, such as a plug-in hard disk, a smart media card (SMC), an SD card, a flash card, etc. equipped on the device. Furthermore, the computer-readable storage medium may also include both an internal storage unit and an external storage device of any device with data processing capability. The computer-readable storage medium is used to store the computer program and other programs and data required by any device with data processing capability, and may also be used to temporarily store data that has been output or is to be output.

[0065] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of patent protection. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the scope of protection of the present application. Therefore, the scope of protection of the present application shall be subject to the attached claims.

Claims

1. A method for obtaining similar elements of web pages in an RPA system. It is characterized in that The steps include: S1: In the automation process configuration stage, two similar web page elements are selected and stored in a first web page element selector and a second web page element selector respectively; S2: extracting the common patterns of the elements contained in the two web page element selectors according to the first web page element selector and the second web page element selector obtained in step S1, and outputting the common pattern list in the form of a Json object; step S2 includes the following steps: S2-1: Determine the number of elements in the first webpage element selector and the second webpage element selector. If either of them is empty, return an error message and report an error. If the number of elements in the two selectors is not equal, it means that the webpage elements contained in the two selectors are not similar elements, return an error message and report an error. If the number of elements in the two selectors is equal, go to step S2-2. S2-2: Consider the elements in the element selector as nodes, synchronously traverse the selector nodes in the two selectors according to the element index in positive order, extract the common pattern of the two selector nodes, and add it to the common pattern list; S3: Use the RPA system to obtain the DOM structure tree of the web page interface. According to the common pattern list of web page elements obtained in step S2, use the breadth-first search algorithm to traverse the DOM tree from bottom to top, and perform pattern matching on each node element in the DOM tree with the common pattern list of web page elements. If the matches are the same, save the node element into the similar element list. The step S3 of matching each node in the DOM tree with the common pattern of the web page elements includes: S3-1: Determine whether the current node element in the DOM tree is an or element. If so, go to S3-3, otherwise go to S3-2; S3-2: Set the use attribute value of the current node element in the DOM tree to true, and perform pattern matching with the public pattern list obtained in step S2. If the match is successful, add the current node element in the DOM tree to the similar element list; return to step S3-1; S3-3: Return a list of similar elements.

2. According to the RPA system web page similar element acquisition method according to claim 1, It is characterized in that The common pattern of extracting two selector nodes in step S2-2 is specifically: S2-2-1: traverse the property property_k of the node node1_i in the first webpage element selector, and select the node node2_j with node_i.property_k.Name from the nodes of the second webpage element selector; wherein node1_i represents the i-th node in the first webpage element selector, property_k represents the k-th property, node1_i.property_k.Name represents the name of the k-th property of the i-th node in the first webpage element selector, and node2_j represents the j-th node in the second webpage element selector; S2-2-2: According to the attribute matching pattern, merge the attribute values ​​of the two nodes node1_i and node2_j to obtain the attribute merge value; S2-2-3: Combine the attribute matching pattern and the attribute merge value into a Jtoken object, and add the attribute name property_k.Name and JToken as a Json object to the public pattern list.

3. According to the RPA system web page similar element acquisition method according to claim 2, It is characterized in that The method for obtaining the attribute merge value in step S2-2-2 is: S2-2-2-1: If the attribute matching rules of nodes node1_i and node2_j are the same and the attribute values ​​are the same, then the attribute values ​​are directly returned as the attribute merge value; if the matching rules of the two nodes are the same but the attribute values ​​are different, then NULL is returned as the attribute merge value; if the matching rules of the two nodes are different, then regular matching is performed and the attribute values ​​of the two nodes are converted into regular values, and then step S2-2-2-2 is entered; S2-2-2-2: Determine whether the regular expression values ​​of two nodes are equal. If they are equal, directly return the regular expression matching pattern and regular expression value as the attribute merge value. If they are not equal, add regular expressions to the original attribute values ​​of the two nodes respectively to obtain two processed strings, and return the result of adding the two strings as the attribute merge value.

4. A system for obtaining similar elements of web pages in an RPA system. It is characterized in that include: A first web page element selection module, which is used to store the first web page element; A second web page element selection module, which is used to store second web page elements similar to the first web page elements; A common mode extraction module is used to extract the common modes of elements stored in the first web page element selection module and the second web page element selection module, and output a common mode list in the form of a Json object; the common mode extraction module includes: a first judgment module, which is used to judge the number of elements in the first web page element selection module and the second web page element selection module. If any one of them is empty, an error message is returned and an error is reported. If the number of elements in the two selection modules is not equal, it means that the web page elements contained in the two selection modules are not similar elements, and an error message is returned and an error is reported; if the number of elements in the two selection modules is equal, the second judgment module is entered; the second judgment module is used to regard the elements in the element selection module as nodes, synchronously traverse the nodes in the two selection modules according to the positive order of the element index, extract the common mode of the nodes of the two selection modules, and add it to the common mode list; A pattern matching module is used to obtain the DOM structure tree of the web page interface, and according to the web page element common pattern list obtained by the common pattern extraction module, the DOM tree is traversed from bottom to top by using a breadth-first search algorithm, and each node element in the DOM tree is pattern-matched with the web page element common pattern list. If the matches are the same, the node element is saved in a similar element list. The pattern matching module includes: a DOM structure tree acquisition module, which is used to obtain the DOM structure tree of the web page interface; a DOM tree node traversal module, which is used to traverse the DOM tree from bottom to top by using a breadth-first search algorithm, and determine whether the current node element in the DOM tree is or element. If so, it enters the similar element list output module, otherwise it enters the DOM tree node matching module; the DOM tree node matching module is used to set the use attribute value of the current node element in the DOM tree to true, and pattern match it with the common pattern list obtained by the common pattern extraction module. If the match is successful, the current node element in the DOM tree is added to the similar element list; and a similar element list output module is used to return the final similar element list.

5. According to claim 4, the RPA system web page similar element acquisition system, It is characterized in that The second judgment module comprises: A node selection module, which is used to traverse the property property_k of the node node1_i in the first webpage element selection module, and select the node node2_j having node_i.property_k.Name from the nodes of the second webpage element selection module; wherein node1_i represents the i-th node in the first webpage element selection module, property_k represents the k-th property, node1_i.property_k.Name represents the name of the k-th property of the i-th node in the first webpage element selection module, and node2_j represents the j-th node in the second webpage element selection module; An attribute value merging module is used to merge the attribute values ​​of the two nodes node1_i and node2_j selected in the node selection module according to the attribute matching mode to obtain an attribute merged value; A public pattern list adding module is used to synthesize the attribute matching pattern and the attribute merge value into a Jtoken object, and add the attribute name property_k.Name and JToken as a Json object to the public pattern list.

6. According to claim 5, the RPA system web page similar element acquisition system, It is characterized in that The attribute value merging module includes: The attribute matching rule judgment module is used to judge the attribute matching rules and attribute values ​​of the two nodes node1_i and node2_j selected in the node selection module. If the attribute matching rules of nodes node1_i and node2_j are the same and the attribute values ​​are also the same, the attribute value is directly returned as the attribute merge value; if the matching rules of the two nodes are the same but the attribute values ​​are different, NULL is returned as the attribute merge value; if the matching rules of the two nodes are different, regular matching is performed and the attribute values ​​of the two nodes are converted into regular values ​​and enter the regular value matching module; The regular value matching module is used to determine whether the regular values ​​of the two nodes output by the attribute matching rule judgment module are equal. If they are equal, the regular matching mode and regular value are directly returned as the attribute merge value; if they are not equal, the regular symbols are added to the original attribute values ​​of the two nodes respectively to obtain two processed strings, and the result of adding the two strings is returned as the attribute merge value.

Citation Information

Patent Citations

  • Cross-domain element positioning and tree generating method for browser RPA system

    CN113420201A

  • Graphical element search technique selection, fuzzy logic selection of anchors and targets, and / or hierarchical graphical element identification for robotic process automation

    US20210349430A1