A web-RPA script migration method based on a large language model

By combining a large language model with multi-dimensional page change detection and element feature mapping, the problem of inaccurate element location in web applications is solved, achieving efficient and reliable Web-RPA script migration and improving the quality and efficiency of automated processes.

CN120973416BActive Publication Date: 2026-02-06NAT INNOVATION INST OF DEFENSE TECH PLA ACAD OF MILITARY SCI
View PDF 3 Cites 0 Cited by

Patent Information

Application Number
CN202511099130.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-08-06
Publication Date
2026-02-06
Estimated Expiration
2045-08-06

AI Technical Summary

Technical Problem

Existing methods for locating web elements cannot accurately identify and locate elements in the context of rapid iteration and change in web applications. This leads to the failure of automation scripts, affecting script effectiveness, increasing maintenance costs, and making it difficult to achieve continuous automation tasks.

Method used

By obtaining the RPA script of the old version of the page and the URL mapping relationship between the old and new pages, the HTML code and DOM tree structure of the new version of the page are extracted using a large language model. Combined with multi-dimensional page change detection, the text existence, attribute quality and parent element context score of DOM elements are extracted, element feature mapping relationship is established, element positioning expression is reconstructed and the transformed RPA script is generated.

Benefits of technology

It achieves efficient and accurate Web-RPA script migration, reduces manual intervention, shortens the migration cycle, improves the robustness and accuracy of migration, and reduces maintenance costs.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120973416B_ABST
    Figure CN120973416B_ABST
Patent Text Reader

Abstract

The application relates to the field of script migration, in particular to a Web-RPA script migration method based on a large language model. The method comprises the following steps: obtaining an old version RPA script and a new-old page URL mapping, loading HTML code and a DOM tree of a new version page; detecting page changes through a URL, HTML code and a structure hash value, extracting text existence, attribute quality and parent element context scores of DOM elements, taking the highest score feature as an element feature, dividing a code segment of the old script containing all element locators of the current page, inputting the large language model to extract semantic features, and matching the semantic features with new version element features; establishing a mapping relationship according to a matching result, reconstructing a positioning expression to generate a new script and verifying the new script; and outputting the new script when the verification is successful. The method can improve the robustness and accuracy of script migration.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of script migration, in particular to a Web-RPA script migration method based on a large language model. BACKGROUND

[0002] With the rapid development of enterprise digital transformation technology, Robotic Process Automation (RPA) technology is widely used in the field of business process automation in the Web environment. RPA can simulate human operations on information systems, and according to pre-set rules and logic, realize the automation of tasks such as data capture, form filling, cross-platform operation, etc., greatly improving the efficiency of business processing. In the RPA automation process, Web element positioning is a key link. Traditional positioning methods mainly include positioning based on screen coordinates (x, y), positioning based on attributes, positioning based on Css-selector, positioning based on xpath, etc. These methods all follow the principle of uniqueness of the element of the locator, and rely on the HTML structure of the web page to obtain the DOM object.

[0003] However, the current traditional method of Web element positioning has significant defects in actual application. Due to the fast iteration speed of Web applications, the interface is frequently changed, and the HTML content is changed accordingly, causing the original selector to be invalid, which cannot effectively position the elements, and further cause the automation script based on these elements to fail to run normally, seriously affecting the effectiveness of the script. With the rapid development of large language models (LLM), its powerful semantic understanding and generation capabilities bring new opportunities to solve the problem of RPA script failure. However, due to the diversity of Web system implementation frameworks, the richness of element and tag types, and the complexity of the interface, when implementing RPA automation, there are still problems such as poor accuracy and stability of element positioning, frequent changes of scripts, high maintenance cost, and difficulty in continuous automation tasks. Therefore, there is an urgent need for an efficient, accurate and low-cost RPA migration method to accurately identify and position various elements, improve the overall quality and running efficiency of RPA automation processes, and promote the in-depth development of RPA technology in the Web application field. SUMMARY

[0004] Therefore, it is necessary to provide a Web-RPA script migration method based on a large language model in view of the above technical problems.

[0005] A Web-RPA script migration method based on a large language model, the method comprising:

[0006] An RPA script of an old version page and a URL mapping relationship between the old and new versions of the page are acquired, a current page is loaded through a mapped current URL, HTML code and a DOM tree structure of a new version page are acquired;

[0007] A page change detection is performed on the new version page according to a URL, HTML code and a structure hash value of the old and new versions of the page, if a page change is detected, a text existence score, an attribute quality score and a parent element context score of a DOM element in the DOM tree structure are extracted, a highest-score feature is taken as an element feature of the DOM element, the RPA script of the old version page is divided, a code segment containing all element locators of the current page is obtained, the code segment is input into a large language model, semantic features of the code segment are extracted by using the large language model, feature matching is performed according to the semantic features and the element feature of the new version page, and a matching result is obtained;

[0008] A mapping relationship between element positioning logic of the old version script and the element feature of the new version is established according to the matching result, an element positioning expression is reconstructed according to the mapping relationship, a converted RPA script is generated, and verification is performed on the converted RPA script.

[0009] When the verification is successful, the current RPA script is output.

[0010] In one of the embodiments, the method further includes collecting failure information if the verification fails and constructing a retry prompt according to the failure information, iteratively optimizing the matching result by using the retry prompt until the verification is successful, stopping iteration, and outputting the current RPA script.

[0011] In one of the embodiments, the page change detection on the new version page according to the URL, HTML code and structure hash value of the old version page is implemented by a page change perception unit; the page change perception unit comprises an input module, a state storage module, a page change detector and an output module; the page change detector comprises a URL comparator, a content difference analyzer, a structure hash comparator and a decision module; the page change detector is used to acquire the current URL, current HTML code of the new version page output by the input module and the historical URL, historical HTML code and historical structure hash value of the old version page stored in the state storage module; the current URL and the historical URL are input into the URL comparator for URL change detection to obtain a URL change detection result; the preprocessed current HTML code and historical HTML code are input into the content difference analyzer for content change detection to obtain a content change detection result; the structure hash value corresponding to the current HTML code and the historical structure hash value are input into the structure hash comparator for structure change detection to obtain a structure change detection result; the URL change detection result, content change detection result and structure change detection result are input into the decision module to obtain a page change detection result, which is output to the output module to form a change signal output.

[0012] In one of the embodiments, inputting the URL change detection result, content change detection result and structure change detection result into the decision module to obtain the page change detection result comprises: if the URL change detection result is true, or if the content change detection result and the structure change detection result are both true, the page change detection is true.

[0013] In one of the embodiments, the text existence score refers to a score corresponding to the text length of the DOM element, the attribute quality score refers to the weight of the most critical attribute of the DOM element, and the parent element context score refers to the text existence score of the parent element.

[0014] In one of the embodiments, extracting the text existence score of the DOM element in the DOM tree structure comprises: extracting the element text content of the DOM element in the DOM tree structure and removing the leading and trailing white spaces, then judging whether the text length exceeds a minimum text length threshold, if yes, returning 1, otherwise, returning 0, and multiplying the text length judgment result by a pre-set text existence weight to obtain the text existence score.

[0015] In one of the embodiments, extracting the attribute quality score of the DOM element in the DOM tree structure comprises: initializing the most critical attribute weight of the element as 0; traversing the DOM attributes and corresponding attribute weights in the attribute weight dictionary, if the current attribute exists in the DOM element in the DOM tree structure, updating the most critical attribute weight of the element according to the larger value of the attribute weight corresponding to the current attribute and the most critical attribute weight of the current element; and obtaining the attribute quality score by multiplying the most critical attribute weight of the element at the end of the traversal by the attribute quality weight.

[0016] In one of the embodiments, extracting the parent element context score of the DOM element in the DOM tree structure comprises: gradually searching for the parent element upwards, obtaining the parent element of the current element, calculating the text existence score of the parent element, multiplying the decay coefficient, and returning the contribution score of the parent element to the characteristics of the current element, wherein if the backtracking depth exceeds the backtracking depth threshold, 0 is returned, and if the parent element is the root element, 0 is returned; the decay coefficient is related to the backtracking depth corresponding to the current level; and the contribution score of the parent element to the characteristics of the current element is multiplied by the pre-set parent element context weight and then accumulated to obtain the parent element context score.

[0017] A Web-RPA script migration system based on a large language model, the system comprising:

[0018] An input layer for obtaining an RPA script of an old version page and a URL mapping relationship between the old and new pages, loading the page through the mapped current URL, obtaining HTML code and a DOM tree structure of the new version page;

[0019] A migration layer for detecting page changes of the new version page according to the URLs, HTML code and structure hash values of the old and new pages, if page changes are detected, extracting the text existence score, attribute quality score and parent element context score of the DOM element in the DOM tree structure, taking the highest-scored feature as the element feature of the DOM element, dividing the RPA script of the old version page to obtain a code segment containing all element locators of the current page, inputting the code segment into the large language model, extracting semantic features of the code segment using the large language model, and performing feature matching according to the semantic features and the element features of the new version page to obtain a matching result;

[0020] A verification layer for establishing a mapping relationship between the element positioning logic of the old version script and the element features of the new version according to the matching result, reconstructing the element positioning expression according to the mapping relationship, generating the converted RPA script, and performing verification on the converted RPA script;

[0021] An output layer for outputting the current RPA script when the verification is successful.

[0022] The above-mentioned Web-RPA script migration method based on a large language model can provide basic data support for subsequent migration by obtaining the old version page RPA script, the new-old URL mapping relationship, and loading the new version page DOM tree, accurately identify page changes with the help of multi-dimensional page change detection, efficiently extract key element features through the feature distillation strategy of extracting text, attributes, parent element context scores and taking the maximum value, process single locator code fragments combined with the powerful semantic understanding ability of the large language model, establish accurate new-old element mapping relationship, reconstruct the positioning expression based on the matching result and generate the converted script, ensure script usability through execution verification, guarantee migration quality, output usable scripts after verification, form an end-to-end automatic migration closed loop, reduce manual intervention, shorten the migration period, and realize high-accuracy element migration at low cost. Meanwhile, the introduction of the large language model enables the system to more effectively understand the semantic association between code intent and element features when facing complex page structures, significantly improves the robustness and accuracy of migration compared with traditional methods, and provides strong support for efficient and reliable Web-RPA script migration. BRIEF DESCRIPTION OF DRAWINGS DETAILED DESCRIPTION OF THE INVENTION BRIEF DESCRIPTION OF DRAWINGS

[0023] Figure 1 A flowchart of a Web-RPA script migration method based on a large language model in one embodiment;

[0024] Figure 2 A structural diagram of a Web-RPA script migration system based on a large language model in one embodiment;

[0025] Figure 3 A structural diagram of a page change perception unit in one embodiment;

[0026] Figure 4 A flowchart of a page change detection algorithm (Page Change Detection) in one embodiment;

[0027] Figure 5 A flowchart of feature extraction in one embodiment;

[0028] Figure 6 A flowchart of an element feature scoring algorithm in one embodiment;

[0029] Figure 7 A data processing flowchart of a migration layer in one embodiment. DETAILED DESCRIPTION

[0030] In order to make the purposes, technical solutions and advantages of the present application clearer, the present application will be further described in detail below in combination with the drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and do not limit the present application.

[0031] In one embodiment, as shown in Figure 1 A large language model-based Web-RPA script migration method is provided, including the following steps:

[0032] Step 102, obtaining the RPA script of the old version page and the URL mapping relationship between the old and new pages, loading the page through the mapped current URL, obtaining the HTML code and DOM tree structure of the new version page.

[0033] Step 104, detecting the page change of the new version page according to the URL, HTML code and structure hash value of the old and new pages, if the page change is detected, extracting the text existence score, attribute quality score and parent element context score of the DOM elements in the DOM tree structure, taking the highest score feature as the element feature of the DOM element, dividing the RPA script of the old version page to obtain the code segment containing all element locators of the current page, inputting the code segment into the large language model, extracting the semantic features of the code segment using the large language model, and performing feature matching according to the semantic features and the element features of the new version page to obtain the matching result.

[0034] Step 106, establishing the mapping relationship between the element positioning logic of the old version script and the element features of the new version according to the matching result, reconstructing the element positioning expression according to the mapping relationship, generating the converted RPA script, and executing verification on the converted RPA script.

[0035] Step 108, when the verification is successful, outputting the current RPA script.

[0036] In the above Web-RPA script migration method based on a large language model, by obtaining the old version page RPA script, the new-old URL mapping relationship, and loading the new version page DOM tree, basic data support can be provided for subsequent migration. With multi-dimensional page change detection, the page changes can be accurately identified. Through the feature distillation strategy of extracting text, attributes, parent element context scores and taking the maximum value, the key element features can be efficiently refined. Combined with the powerful semantic understanding ability of the large language model, the single locator code fragment can be processed. The accurate new-old element mapping relationship can be established. Based on the matching result, the positioning expression is reconstructed and the converted script is generated. After execution verification, the script usability is ensured. The migration quality can be guaranteed. After verification, the available script is output. The whole process forms an end-to-end automatic migration closed loop, which can reduce manual intervention and shorten the migration period. With low cost, high accuracy element migration is realized. At the same time, the introduction of the large language model enables the system to more effectively understand the semantic association between code intent and element features when facing complex page structures. Compared with traditional methods, the robustness and accuracy of migration are significantly improved, providing strong support for efficient and reliable Web-RPA script migration.

[0037] In one embodiment, the method further comprises: if the verification fails, collecting failure information and constructing a retry prompt according to the failure information; iteratively optimizing the matching result using the retry prompt until the verification succeeds, stopping iteration, and outputting the current RPA script. In this embodiment, as shown in Figure 2 In one embodiment, the method further comprises: if the verification fails, collecting failure information and constructing a retry prompt according to the failure information; iteratively optimizing the matching result using the retry prompt until the verification succeeds, stopping iteration, and outputting the current RPA script. In this embodiment, as shown in

[0038] In one embodiment, the page change detection of the new version page according to the URL, HTML code and structure hash value of the old and new pages is implemented by a page change perception unit; the page change perception unit includes an input module, a state storage module, a page change detector and an output module; the page change detector includes a URL comparator, a content difference analyzer, a structure hash comparator and a decision module; the page change detector is used to obtain the current URL, the current HTML code of the new version page output by the input module and the historical URL, the historical HTML code and the historical structure hash value of the old version page stored in the state storage module; the current URL and the historical URL are input into the URL comparator for URL change detection to obtain a URL change detection result; the preprocessed current HTML code and the historical HTML code are input into the content difference analyzer for content change detection to obtain a content change detection result; the structure hash value corresponding to the current HTML code and the historical structure hash value are input into the structure hash comparator for structure change detection to obtain a structure change detection result; the URL change detection result, the content change detection result and the structure change detection result are input into the decision module to obtain a page change detection result, which is output to the output module to form a change signal output.

[0039] In the present embodiment, as shown in Figure 2 The migration layer is composed of the following three modules:

[0040] (1) Page change perception unit: use the old version RPA script to perceive the change of the page, and divide and mark the code blocks;

[0041] (2) Element feature extraction unit: based on the new Web page, obtain all the interactive elements and extract their high-value feature information;

[0042] (3) LLM element matching unit: use LLM to analyze the original script information and the new page element information to obtain the element mapping before and after migration.

[0043] The structural diagram of the page change perception unit is as shown in Figure 3As shown, the system needs to perceive page changes to more accurately migrate elements in individual pages and reduce the input of invalid information. The page change perception module is used to monitor the dynamic changes of the Web page during the original script runtime, and identify the change signal through URL, page content comparison, etc. The original script is divided into blocks, and the range of page element matching is reduced. Once the page change signal is detected, the system will insert a specific non-functional code line at the current line of the original script code. This code only serves as a block marker and does not have actual running function. This marker is used to identify the boundary of the code block, providing a reference for subsequent code block extraction. Before sending the code to the language model (LLM) for processing, the system will read the entire script code and traverse the block markers therein. By identifying these markers, the system can extract the code block matching the current page in sequence. This process avoids sending the entire script code to the LLM for processing, thereby significantly reducing the range of original code matching of page elements, improving processing efficiency and reducing the input of invalid information.

[0044] The page change perception unit adopts a multi-level hierarchical architecture, mainly composed of current page input, memory state, page change detector, and output. The input module is responsible for capturing the URL and HTML code of the current Web page and passing it to the page change detector for further processing. In this process, the state memory module plays a crucial role, which is responsible for storing key information in the previous detection period, including the URL, HTML code, and corresponding structure hash value of the previous version. The structure hash value is a value calculated by a specific algorithm, which is used to represent the integrity and consistency of the page structure.

[0045] During the interaction with the Web page, form filling, event triggering, and other operations often cause changes in the content and style of DOM elements, resulting in changes in HTML. However, these changes usually do not affect the structure of the DOM tree and cannot be used as the basis for judging changes. To improve the flexibility and robustness of the detection mechanism, interference filtering strategies need to be used to remove irrelevant structural changes such as styles and text content before detecting page changes to ensure the recognition of structural changes in the page. Therefore, in the new detection period, the current page information obtained by the input module will be compared and analyzed with the historical data stored in the state memory module, including URL change detection, HTML code comparison, and structure hash value difference evaluation. Through this multi-dimensional comparison, the system can accurately identify the DOM transformation caused by the page structure, thereby identifying the specific changes such as the addition, removal, and movement of page elements that require reprocessing of the page, to reduce unnecessary page analysis.

[0046] Specifically, as Figure 4The flowchart of the page change detection algorithm is shown, where the input includes current_url and current_html, the uniform resource locator (URL) and hypertext markup language (HTML) content of the current page, representing the current page state, the input also includes last_url and last_html, the last recorded page URL and HTML content, representing the previously saved page state, and the input also includes the content change threshold (threshold) for determining whether the HTML content change reaches a substantial change level.

[0047] Lines 6-9 represent the entry of the IsPAGECHANGED process, which first checks whether last_url or last_html is null (i.e., no previous page state has been saved), and if so, calls the UpdateState(current_url, current_html) function to update the page state (records the current URL and HTML as the last state), and then returns True, indicating that a page change has been detected.

[0048] Lines 10-13 represent URL change detection. If there is a previous page state (last_url and last_html are not null), check whether the current page URL (current_url) is different from the last recorded URL (last_url). If different, call UpdateState(current_url, current_html) to update the page state and return True, indicating that a page change has been detected due to URL change.

[0049] Lines 15-20 represent HTML content change detection. If the URL has not changed, call the CleanHTML function on the current page HTML (current_html) and the last HTML (last_html) to obtain cleaned (current cleaned content) and last_cleaned (last cleaned content). Call the CompareHTML(cleaned, last_cleaned) function to compare the cleaned HTML content and calculate the content difference. If the difference is greater than the set threshold, call UpdateState to update the state and return True, indicating that a page change has been detected due to HTML content change reaching the threshold.

[0050] 21-26 lines represent DOM structure hash change detection, if the HTML content difference does not exceed the threshold, the ComputeStructureHash function is called to calculate the DOM structure hash value of the current cleaned HTML (cleaned), and the structure_hash (structure hash) is obtained. Compare the current calculated structure_hash with the last saved structure hash (if there is one before), if they are not the same, call UpdateState to update the state, return True, which means that the DOM structure change causes the page to change. If none of the above detection conditions are met (URL does not change, HTML content difference does not exceed threshold, DOM structure hash does not change), return False (no), indicating that no substantial page change is detected.

[0051] In one embodiment, the URL change detection result, the content change detection result and the structure change detection result are input into the decision module to obtain the page change detection result, including: if the URL change detection result is true, or the content change detection result and the structure change detection result are true at the same time, the page change detection is true.

[0052] The formula and algorithm of the decision module are as follows:

[0053] Among them, the first formula of the page change (PageChanged) represents the judgment logic, when "URL change (URL_Changed)" is true, or "content change (Content_Changed) and structure change (Structure_Changed)" are true at the same time, it is judged that the page has substantial change. The second formula represents the judgment method of URL change, if the current URL (current_url) and the last recorded URL (last_url) are not equal, URL_Changed is true (I can be understood as an indication function, the condition is met, return true, not met, return false). The third formula represents the judgment rule of content change, calculate the difference degree D of the current cleaned HTML (cleanhtml1) and the historical cleaned HTML (cleanhtml2), when the difference degree is greater than the set threshold θ, Content_Changed is true. The fourth formula represents the judgment basis of structure change, the hash values of the current HTML structure (shtml1) and the historical HTML structure (shtml2) are calculated by the hash function H respectively, if the hash values are not equal, Structure_Changed is true.

[0054] In one embodiment, the text presence score refers to the score corresponding to the length of the DOM element text, the attribute quality score refers to the weight of the most critical attribute of the DOM element, and the parent element context score refers to the text presence score of the parent element.

[0055] In this embodiment, in order to realize accurate matching between new and old page elements, the system extracts element features to reduce unnecessary input and computational consumption. The extracted features will serve as the basis for the subsequent matching process, therefore, the selection of features must be comprehensive and representative to ensure that different elements can be effectively distinguished and the corresponding elements in the new and old pages can be accurately identified. In addition, the feature extraction process should also take into account the dynamic and variable nature of elements to adapt to the common dynamic content loading and real-time updating of element attributes in Web pages.

[0056] In the element feature extraction layer, an element feature scoring method is introduced, which comprehensively considers text presence, attribute quality and parent context. Through this multi-dimensional feature scoring mechanism, the amount of feature information of elements can be more comprehensively evaluated, providing high-quality input for LLM, thereby improving the accuracy and robustness of element matching.

[0057] Text presence refers to the richness and information value of visible text in Web page elements. These texts usually provide prompt information for user interaction, therefore, have high information value. In automated script migration, the completeness and accuracy of text content are crucial for element identification and matching. By evaluating the text presence, it can be determined whether the element has sufficient information to support the migration process.

[0058] Attribute quality involves the attributes of elements such as class, role, etc. These attributes usually reflect the function and purpose of the element. The evaluation of attribute quality needs to consider the semantic information content and representativeness of the attributes. In the element feature extraction process, these attributes are screened to ensure that the extracted features can effectively distinguish different elements and accurately identify the corresponding elements in the new and old pages. The attribute quality directly affects the accuracy of element matching and the success of script migration.

[0059] When the amount of information provided by the element itself is insufficient for effective feature extraction, parent context information becomes particularly important. Parent context refers to the context information provided by the parent element of the element, as well as the use of the hierarchical relationship and semantic features of the page structure. By analyzing the information of the parent element, more rich input can be provided for the LLM, thereby assisting in further screening and matching of the element. The use of parent context helps to solve the problem of insufficient information and enhances the system's understanding of complex Web page structures. When calculating the feature score, a depth attenuation factor is used to ensure that the influence of parent nodes gradually decreases with increasing depth, avoiding excessive reliance on distant nodes.

[0060] The flowchart of feature extraction is shown in Figure 5 DOM (Document Object Model) tree data representing the structure of the Web page is taken as the initial input of the entire process. After the element feature extraction engine receives the DOM tree input data, it will extract and process element features through multiple paths. The various features extracted through different paths (including features from the hierarchical relationship backtracking mechanism, text semantic features, and structured attribute features) are finally integrated into a multi-dimensional feature fusion link, which integrates these different dimensional features to form more representative element features.

[0061] In one embodiment, extracting the text existence score of the DOM element in the DOM tree structure includes: extracting the element text content of the DOM element in the DOM tree structure and removing the leading and trailing white spaces, then judging whether the text length exceeds the minimum text length threshold, if yes, returning 1, otherwise returning 0, multiplying the text length judgment result by the pre-set text existence weight to obtain the text existence score.

[0062] In one embodiment, extracting the attribute quality score of the DOM element in the DOM tree structure includes: initializing the element's most critical attribute weight to 0; traversing the DOM attributes and corresponding attribute weights in the attribute weight dictionary, if the current attribute exists in the DOM element in the DOM tree structure, updating the element's most critical attribute weight according to the larger value of the attribute weight corresponding to the current attribute and the element's most critical attribute weight; multiplying the element's most critical attribute weight at the end of the traversal by the attribute quality weight to obtain the attribute quality score.

[0063] In one embodiment, the parent context score of the DOM element in the DOM tree structure includes: step by step looking up the parent element, obtaining the parent element of the current element, calculating the text existence score of the parent element, multiplying the decay coefficient, and returning the contribution score of the parent element to the characteristics of the current element, wherein if the backtracking depth exceeds the backtracking depth threshold, 0 is returned, and if the parent element is a root element, 0 is returned; the decay coefficient is related to the backtracking depth corresponding to the current level; the contribution score of the parent element to the characteristics of the current element is multiplied by the pre-set parent element context weight to obtain the parent element context score.

[0064] In one specific embodiment, the flowchart of the element feature score algorithm is as shown in Figure 6 The input includes element: the DOM element to be extracted from the feature, which is the target object of feature extraction; depth: the current backtracking depth, the default value is 0, which is used to control the hierarchical limit of the parent element context backtracking; threshold: the minimum text length threshold, the default value is 2, which is used to judge whether the element text is valid. The output is the element feature score, the value range is [0, 1], which is used to quantify the effectiveness of the element feature. The core function EXTRACTFEATURESCORE (extract feature score) calculates the final feature score of the element by integrating the results of multiple sub-functions, and the steps are as follows:

[0065] Parameter initialization (line 7): define the weight coefficients α=1.0 (text existence weight), β=0.6 (attribute quality weight), and γ=0.3 (parent element context weight), define the attribute weight dictionary weights, and assign weights to different DOM attributes (id, class, placeholder, title) to reflect the difference in the importance of the attributes to the features, wherein id is the identifier, class is the class name, placeholder is the placeholder, and title is the title.

[0066] Sub-function call and score calculation (lines 9-11): text existence score (text_score): call the TEXTPRESENCE (text existence) function, multiply the result by α, and measure the contribution of the element text content to the feature. Attribute quality score (attr_score): call the ATTRQUALITY (attribute quality) function, multiply the result by β, and evaluate the effectiveness and importance of the element attribute. Parent element context score (parent_score): call the PARENTCONTEXT (parent element context) function, multiply the result by γ, and use the parent element information to supplement the characteristics of the current element.

[0067] Determine the final feature score (line 12) returns the maximum of text_score, attr_score, parent_score as the final feature score of the element.

[0068] where the sub-functions include:

[0069] TEXTPRESENCE: Extract the element text content and remove leading and trailing whitespaces, TRIM(element.text_content). Determine if the text length exceeds threshold, if yes return 1 (text valid), otherwise return 0 (text invalid), output the boolean converted score.

[0070] ATTRQUALITY: Initialize the maximum weight max_weight = 0, to store the weight of the most important attribute of the element. Iterate over the attributes (attr) and corresponding weights (w) in weights: if the element has the attribute (element.has_attribute(attr)), update max_weight as the current maximum value (max(max_weight, w)). Return max_weight.

[0071] PARENTCONTEXT: If depth >= 3, it means the backtracking level is too deep, return 0 to avoid meaningless depth backtracking. Get the parent element of the current element (parent = element.parent_element). If the parent element is null (no parent element), return 0. Call the TEXTPRESENCE function to calculate the text presence score of the parent element, and multiply it by the attenuation coefficient 1 / 2^(depth), return the score of the parent element's contribution to the feature of the current element.

[0072] For example, Figure 7As shown, a data processing flow diagram of a migration layer is provided, the input layer is responsible for receiving and preprocessing the original data required for migration, mainly including two input sources. The old version code snippet is an automated script code snippet extracted from the old version web page, which contains the original positioning that needs to be migrated, and is dynamically divided by page to ensure that only the element locator of the current page is provided each time. The new version element feature is the element feature information extracted from the new version web page, which is used to match the elements in the old version code snippet. The core processing layer is the center of the entire migration process, mainly composed of LLM agent and migration decision engine: the LLM agent is responsible for receiving the data of the input layer, and uses its powerful semantic understanding and generation ability to analyze and process the old version code snippet and the new version element feature, and outputs the matching result. The migration decision engine processes the result and generates the mapping relationship between the new and old elements, and generates the converted code according to the mapping relationship. The verification layer is responsible for verifying the correctness and effectiveness of the migrated code, and executing the converted code in the actual new version web page environment to verify whether it can correctly execute the predetermined automated task. The feedback layer is responsible for handling possible failures during the execution verification process and providing feedback to optimize the migration process. When the execution verification fails, the relevant information of the failure is obtained, based on the failure information, a retry prompt is constructed to guide the LLM agent to further optimize and adjust. The retry prompt is fed back to the LLM agent to trigger further iterative optimization to improve the success rate of migration.

[0073] In one embodiment, as Figure 2 shown, a Web-RPA script migration system based on a large language model is provided, comprising:

[0074] The input layer is used to obtain the RPA script of the old version page and the URL mapping relationship of the new and old pages, load the page through the mapped current URL, obtain the HTML code and DOM tree structure of the new version page;

[0075] The migration layer is used to detect page changes of the new version page according to the URL, HTML code and structure hash value of the new and old pages. If a page change is detected, the text existence score, attribute quality score and parent element context score of the DOM elements in the DOM tree structure are extracted, the highest score feature is taken as the element feature of the DOM element, the RPA script of the old version page is divided to obtain a code snippet containing all element locators of the current page, the semantic features of the code snippet are extracted by using the large language model, and the semantic features are matched with the element features of the new version page to obtain a matching result;

[0076] The verification layer is configured to establish a mapping relationship between the old version script element positioning logic and the new version element features according to the matching result, reconstruct an element positioning expression according to the mapping relationship, generate a converted RPA script, and perform verification on the converted RPA script.

[0077] The output layer is configured to output the current RPA script when the verification is successful.

[0078] In one of the embodiments, the method further includes collecting failure information if the verification fails, constructing a retry prompt according to the failure information, iteratively optimizing the matching result by using the retry prompt, stopping the iteration when the verification is successful, and outputting the current RPA script.

[0079] In one of the embodiments, the migration layer includes a page change perception unit; the page change perception unit includes an input module, a state storage module, a page change detector, and an output module; the page change detector includes a URL comparator, a content difference analyzer, a structure hash comparator, and a decision module; the page change detector is configured to obtain a current URL, a current HTML code of a new version page output by the input module, and a historical URL, a historical HTML code, and a historical structure hash value of an old version page stored in the state storage module; input the current URL and the historical URL into the URL comparator to perform URL change detection, and obtain a URL change detection result; input the preprocessed current HTML code and the historical HTML code into the content difference analyzer to perform content change detection, and obtain a content change detection result; input the structure hash value corresponding to the current HTML code and the historical structure hash value into the structure hash comparator to perform structure change detection, and obtain a structure change detection result; input the URL change detection result, the content change detection result, and the structure change detection result into the decision module to obtain a page change detection result, and output the page change detection result to the output module to form a change signal output.

[0080] In one of the embodiments, the text existence score refers to a score corresponding to the length of the text of the DOM element, the attribute quality score refers to the weight of the most critical attribute of the DOM element, and the parent element context score refers to the text existence score of the parent element.

[0081] In one of the embodiments, the text existence score of the DOM element in the DOM tree structure includes: extracting the element text content of the DOM element in the DOM tree structure and removing the leading and trailing whitespaces, then judging whether the text length exceeds a minimum text length threshold, returning 1 if yes, and returning 0 if no, and multiplying the text length judgment result by a pre-set text existence weight to obtain the text existence score.

[0082] In one of the embodiments, the extracting the attribute quality score of the DOM element in the DOM tree structure comprises: initializing the most critical attribute weight of the element as 0; traversing the DOM attributes and corresponding attribute weights in the attribute weight dictionary, if the current attribute exists in the DOM element in the DOM tree structure, updating the most critical attribute weight of the element according to the larger value between the attribute weight corresponding to the current attribute and the most critical attribute weight of the element; and obtaining the attribute quality score by multiplying the most critical attribute weight of the element at the end of the traversal by the attribute quality weight.

[0083] In one of the embodiments, the extracting the parent element context score of the DOM element in the DOM tree structure comprises: finding the parent element step by step, obtaining the parent element of the current element, calculating the text existence score of the parent element, multiplying the decay coefficient, and returning the contribution score of the parent element to the feature of the current element, wherein if the backtracking depth exceeds the backtracking depth threshold, 0 is returned, and if the parent element is the root element, 0 is returned; the decay coefficient is related to the backtracking depth corresponding to the current level; and the contribution score of the parent element to the feature of the current element is multiplied by the pre-set parent element context weight to obtain the parent element context score.

[0084] The specific limitations of the Web-RPA script migration method based on the large language model can refer to the limitations of the Web-RPA script migration system based on the large language model in the above, which will not be repeated here. Each module in the above Web-RPA script migration system based on the large language model can be realized by software, hardware, and combinations thereof, in whole or in part. The above modules can be embedded in or independent of the processor in the computer device in hardware form, or can be stored in the memory in the computer device in software form, so as to be called and executed by the processor to perform the operations corresponding to each of the above modules.

[0085] The above-described embodiments only express several implementation manners of the present application, and the description is relatively specific and detailed, but it should not be understood as a limitation on the scope of the application. It should be noted that, for those skilled in the art, without departing from the concept of the present application, some modifications and improvements can be made, which are all within the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the appended claims.

Claims

1. A Web-RPA script migration method based on a large language model, characterized in that, The method includes: Get the RPA script of the old version page and the URL mapping relationship between the old and new pages, load the page through the mapped current URL, and get the HTML code and DOM tree structure of the new version page; Based on the URLs, HTML code, and structural hash values ​​of the old and new pages, page change detection is performed on the new page. If a page change is detected, the text existence score, attribute quality score, and parent element context score of the DOM elements in the DOM tree structure are extracted respectively. The feature with the highest score is taken as the element feature of the DOM element. The RPA script of the old page is divided to obtain code snippets containing all element locators of the current page. The code snippets are input into a large language model, and the semantic features of the code snippets are extracted using the large language model. Feature matching is performed based on the semantic features and the element features of the new page to obtain the matching results. Based on the matching results, establish a mapping relationship between the old script element location logic and the new script element features, reconstruct the element location expression based on the mapping relationship, generate the converted RPA script, and perform verification on the converted RPA script. If the verification is successful, output the current RPA script.

2. The method according to claim 1, characterized in that, The method further includes: If verification fails, collect failure information and construct retry prompts based on the failure information. Use the retry prompts to iteratively optimize the matching results until verification is successful, then stop iterating and output the current RPA script.

3. The method according to claim 1, characterized in that, The page change detection based on the URLs, HTML code, and structural hash values ​​of the old and new pages is achieved through a page change perception unit. The page change sensing unit includes an input module, a state storage module, a page change detector, and an output module; The page change detector includes a URL comparator, a content difference analyzer, a structure hash comparator, and a decision module; The page change detector is used to obtain the current URL and current HTML code of the new version of the page output by the input module, as well as the historical URL, historical HTML code, and historical structure hash value of the old version of the page stored in the state storage module. Input the current URL and historical URLs into the URL comparator to perform URL change detection and obtain the URL change detection results; The preprocessed current HTML code and historical HTML code are input into the content difference analyzer to detect content changes and obtain the content change detection results. The structure hash value corresponding to the current HTML code and the historical structure hash value are input into the structure hash comparator to detect structure changes and obtain the structure change detection result. The URL change detection results, content change detection results, and structure change detection results are input into the decision module to obtain the page change detection results, which are then output to the output module to form a change signal output.

4. The method according to claim 3, characterized in that, Inputting the URL change detection results, content change detection results, and structure change detection results into the decision module yields the following page change detection results: The page change detection is true if the URL change detection result is true, or if both the content change detection result and the structure change detection result are true.

5. The method according to claim 1, characterized in that, The text existence score refers to the score corresponding to the text length of the DOM element, the attribute quality score refers to the weight of the most critical attribute of the DOM element, and the parent element context score refers to the text existence score of the parent element.

6. The method according to claim 1, characterized in that, Extracting the text existence score of DOM elements in the DOM tree structure includes: Extract the text content of DOM elements in the DOM tree structure and remove leading and trailing whitespace. Then determine whether the text length exceeds the minimum text length threshold. If it does, return 1; otherwise, return 0. The text existence score is obtained by multiplying the pre-set text existence weight by the text length judgment result.

7. The method according to claim 1, characterized in that, Extracting attribute quality scores from DOM elements in the DOM tree structure includes: Initialize the element's most critical attribute weight to 0; Iterate through the DOM attributes and their corresponding weights in the attribute weight dictionary. If the current attribute exists in the DOM tree structure, update the weight of the most critical attribute of the element based on the larger value between the weight of the current attribute and the weight of the most critical attribute of the current element. The attribute quality score is obtained by multiplying the weight of the most critical attribute of the element at the end of the traversal by the attribute quality weight.

8. The method according to claim 1, characterized in that, Extracting the parent element context score of DOM elements in the DOM tree structure includes: The parent element is searched upwards step by step to obtain the parent element of the current element. The text existence score of the parent element is calculated and multiplied by the decay coefficient. The contribution score of the parent element to the features of the current element is returned. If the backtracking depth exceeds the backtracking depth threshold, 0 is returned. If the parent element is the root element, 0 is returned. The decay coefficient is related to the backtracking depth corresponding to the current level. The parent element's contribution score to the current element's features is multiplied by the pre-set parent element context weight and then summed to obtain the parent element's context score.

Citation Information

Patent Citations

  • Web application test repair method based on semantic path search

    CN113032279A

  • Webpage processing method and device, electronic equipment and storage medium

    CN117520678A

  • Front-end automatic testing method of large language model based on LLM (Logistics Language Model)

    CN120216385A