A method and system for writing and executing RPA scripts for terminal devices

By monitoring terminal device page changes in real time and constructing page status objects, it solves the problems of tedious RPA script writing and untimely response, improves the efficiency of RPA script writing and execution, and is suitable for RPA applications on Android devices.

CN114895884BActive Publication Date: 2024-10-29SHENZHEN BILIANG TECH MEDIA CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210548717.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-05-20
Publication Date
2024-10-29
Estimated Expiration
2042-05-20

AI Technical Summary

Technical Problem

Existing RPA scripts are cumbersome to write, the response page is not timely, and it is difficult to cope with multi-step tasks, resulting in low execution efficiency and poor accuracy.

Method used

By obtaining terminal device page information, use ADB tools to monitor page changes in real time, build page status objects, and match target page objects according to priority to perform actions, simplifying script writing logic and improving response speed and code reuse rate.

Benefits of technology

It improves the efficiency of writing and executing RPA scripts, simplifies script writing complexity, enables timely response to page changes, and enhances the ability to process multi-step tasks.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114895884B_ABST
    Figure CN114895884B_ABST
Patent Text Reader

Abstract

The present invention provides a method and system for writing and executing RPA scripts of terminal devices, the method comprising obtaining target page information, defining RPA script relationships on each target page respectively; when the RPA script is running, using the ADB tool to run the terminal APP on the terminal device and monitor the page information of the device in real time; when the RPA script is stable on the page, matching the page by priority and executing the page action, which comprises: when the RPA script receives the latest device page information, building a page status object; when the page status object is stable, matching the target page object in order of priority; executing the target action corresponding to the matched target page object. The application of the present invention can solve the problems existing in the prior art, such as cumbersome RPA script writing, untimely response page, and difficulty in coping with multi-step tasks, thereby improving the RPA script writing efficiency, script execution efficiency, and script execution accuracy.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular to a method for writing and executing an RPA script of a terminal device and a writing and executing system using the method. Background Art

[0002] At present, with the development of computer technology, script files are widely used in various scenarios. Scripting languages, such as Python (object-oriented, interpreted programming language), TCL (Tool Command Language, scripting language), etc., are also called dynamic languages. They are interpreted languages ​​that do not require compilation and can be run directly. Scripting languages ​​are interpreted and executed by interpreters. They are easy to master and have good rapid development efficiency. They are widely used in the fields of computers, electronic information, etc.

[0003] Currently, the existing script writing on the market has the following shortcomings:

[0004] Procedural execution: The execution action waits until a specific element appears on the page layout before executing the next action. In this process, script writing is cumbersome and repeated code frequently appears.

[0005] RPA recording actions: can only perform simple tasks and cannot do anything about NAF. The conventional method is to use visual analysis tools to find specific NAF tags and perform corresponding actions.

[0006] Through polling: waiting for the page to load, resulting in delayed execution of actions. Summary of the invention

[0007] In order to overcome the shortcomings of the prior art, the purpose of the present invention is to provide a method and system for writing and executing RPA scripts for terminal devices. The method and system can solve the problems existing in the prior art, such as cumbersome RPA script writing, untimely response pages, difficulty in dealing with multi-step tasks, etc., and can improve the RPA script writing efficiency, script execution efficiency and script execution accuracy.

[0008] To solve the above problems, the technical solution adopted by the present invention is as follows:

[0009] A method for writing and executing RPA scripts for terminal devices, comprising the following steps: obtaining target page information, and defining RPA script relationships on each target page respectively; after the RPA script is run, using an ADB tool to run a terminal APP on a terminal device and monitor the page information of the device in real time; after the RPA script is stable on the page, matching the page by priority and executing page actions, which comprises: after the RPA script receives the latest device page information, building a page status object; after the page status object is stable, matching the target page object by priority order; and executing the target action corresponding to the matched target page object.

[0010] A further solution is to obtain the target page information and define the RPA script relationship on each target page respectively; when the RPA script is running, use the ADB tool to run the terminal APP on the terminal device and monitor the page information of the device in real time; when the RPA script is stable on the page, match the page by priority and execute the page action, which includes: when the RPA script receives the latest device page information, build a page status object; when the page status object is stable, match the target page object in order of priority; execute the target action corresponding to the matched target page object.

[0011] A further solution is to obtain the target page information and define the RPA script relationship on each target page, including: building a standard atlas corresponding to all key page NAF nodes; defining each target page object, wherein the target page object is the interface state of the terminal device corresponding to the RPA script execution action.

[0012] A further solution is that the construction of a standard atlas corresponding to key NAF nodes of all pages includes: converting the screenshots corresponding to the NAF nodes on the key pages into standard images and assigning globally unique image numbers, wherein the NAF nodes refer to nodes whose attribute NAF is true on the terminal device page layout tree.

[0013] A further solution is that the parameters of the target page object include at least: a node element, which is a node element on the terminal device page layout tree; a top-level activity matching relationship, which is expressed as the top-level activity of the current interface state matches the top-level activity of the target page object; and a target action, which is the action that the RPA script will perform on the terminal device.

[0014] A further solution is that when the RPA script is running, the ADB tool will be used to start the terminal APP, which will obtain the page layout tree, screenshots and other information of the terminal device in real time, and transmit them to the RPA script in real time through the TCP protocol; the terminal APP uses UI Automator to obtain the page layout tree and mark the activated subtree; after the terminal APP finds that the screenshot has changed, it transmits the new screenshot to the RPA script.

[0015] A further solution is that the construction of the page status object includes: if the RPA script is configured with a NAF node replacement requirement, then traversing the NAF nodes in the node tree, each NAF node sequentially performs a screenshot and searches for a matching standard image in the standard image library, and for the NAF node that matches the standard image, updating the value of a specific attribute to the image number; if the RPA script is configured with a node cropping requirement, then traversing the node tree and deleting the subtree that meets the requirement; wherein the attributes of the page status object include at least a screenshot, a node tree, and a top-level activity.

[0016] A further solution is that when the page status object is stable, the target page object is matched in order of priority, including: the stability of the page status object is a description of the terminal device page being loaded, and when for the RPA script that defines the NAF node element, the judgment basis for the stability of the page status object is: all key page NAF nodes match the standard graph.

[0017] A further solution is that when the page status object is stable, the target page object is matched in order of priority, including: comparing the page status object with the target page object to determine whether the two satisfy a matching relationship, and if so, taking the target page object as the final result, ending subsequent matching operations, and directly executing the target action; wherein, comparing the page status object with the target page object specifically includes: determining whether the top-level activity matches; and determining whether all node elements match.

[0018] A further solution is that the page status object is constructed and NAF node element replacement is also performed: after the RPA script obtains the layout tree and screenshot of the terminal APP, the RPA script finds the NAF node in the layout tree, extracts the node screenshot, uses the image matching algorithm to search the standard gallery, and uses the number of the hit image to add the attribute img_tag = image number in the NAF node.

[0019] It can be seen that compared with the prior art, the present invention can find the target page and define the RPA script respectively. Then, ADB is used to run the terminal APP on the Android device to monitor the device page information in real time. After the RPA script is stable, the page is matched according to priority and the page action is executed. The script customized algorithm execution is completed, the script execution efficiency is improved, and the XPath syntax expression is replaced by standard images to simplify the RPA script writing logic.

[0020] Therefore, the present invention can simplify the complexity of RPA script writing, lower the code writing threshold; respond to pages in a timely manner; and improve the reuse rate of RPA script codes.

[0021] A terminal device RPA script writing and execution system includes: an RPA script definition module for defining a target page object; a terminal module for monitoring page information of a terminal device; and an RPA script execution module for matching a target page according to priority and executing a page action.

[0022] It can be seen that the present invention completes the writing and execution of RPA scripts through an execution system composed of an RPA script definition module, a terminal module and an RPA script execution module, which can solve the problems of cumbersome RPA script writing, inability to respond to page changes in a timely manner, and difficulty in dealing with multi-step tasks in the prior art, thereby improving the RPA script writing efficiency and execution efficiency, which is conducive to the promotion of RPA on Android devices.

[0023] The present invention is further described in detail below in conjunction with the accompanying drawings and specific embodiments. BRIEF DESCRIPTION OF THE DRAWINGS

[0024] Figure 1 It is a flowchart of a first embodiment of a method for writing and executing an RPA script for a terminal device of the present invention.

[0025] Figure 2 It is a table diagram of the definition of node elements in Embodiment 1 of a method for writing and executing an RPA script for a terminal device of the present invention.

[0026] Figure 3 It is a table diagram of the target action definition of the page object in the first embodiment of the method for writing and executing RPA script of a terminal device of the present invention.

[0027] Figure 4 It is a table diagram of page object definition in Embodiment 1 of a method for writing and executing an RPA script on a terminal device of the present invention.

[0028] Figure 5 It is a schematic diagram of a NAF node standard diagram in Embodiment 2 of a method for writing and executing an RPA script for a terminal device of the present invention.

[0029] Figure 6 It is a table diagram of the definition of node elements in Embodiment 2 of a method for writing and executing an RPA script on a terminal device of the present invention.

[0030] Figure 7 It is a table diagram of the target action definition of the page object in the second embodiment of the method for writing and executing RPA script of a terminal device of the present invention.

[0031] Figure 8 It is a table diagram of page object definition in Embodiment 2 of a method for writing and executing an RPA script on a terminal device of the present invention. DETAILED DESCRIPTION

[0032] The technical solutions in the embodiments of the present application are described clearly and completely below in conjunction with the accompanying 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 creative work are within the scope of protection of the present application.

[0033] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.

[0034] First, some of the terms and related technologies involved in this application are explained in conjunction with the accompanying drawings to facilitate understanding by those skilled in the art.

[0035] NAF: NAF stands for Not Accessibility Friendly, which means a node that is not easily accessible.

[0036] Terminal devices: Terminal devices may include but are not limited to other portable devices such as smart phones, tablet computers, wearable devices, etc.

[0037] RPA: RPA turns business into scripts. Through the flexible use of RPA, the scope of automation that was not possible before can be expanded, and business efficiency has been significantly improved.

[0038] Embodiment 1 of a method for writing and executing an RPA script of a terminal device:

[0039] like Figure 1 As shown, a method for writing and executing an RPA script of a terminal device includes the following steps:

[0040] Step S1, obtaining target page information, and defining RPA script relationships on each target page, including:

[0041] Step S1-1, constructing a standard atlas corresponding to all key page NAF nodes;

[0042] Step S1-2, define each target page object, wherein the target page object is the interface state of the terminal device corresponding to when the RPA script executes the action.

[0043] Step S2: After the RPA script runs, use the ADB tool to run the terminal APP on the terminal device and monitor the page information of the device in real time.

[0044] When the RPA script runs, the ADB tool is used to start the terminal APP, which obtains the page layout tree, screenshots and other information of the terminal device in real time and transmits it to the RPA script in real time through the TCP protocol.

[0045] Among them, the terminal APP uses UI Automator to obtain the page layout tree and mark the activated subtree;

[0046] Among them, after the terminal APP finds that the screenshot has changed, it transmits the new screenshot to the RPA script.

[0047] Step S3: After the RPA script is stable on the page, it matches the page according to priority and executes the page action, which includes:

[0048] Step S3-1: After the RPA script receives the latest device page information, it constructs a page status object.

[0049] Step S3-2: When the page status object is stable, match the target page object in order of priority.

[0050] Step S3-3, executing the target action corresponding to the matched target page object.

[0051] In the above step S1-1, a standard atlas corresponding to all key NAF nodes of the page is constructed, including:

[0052] The screenshot corresponding to the NAF node on the key page is converted into a standard image and assigned a globally unique image number, wherein the NAF node refers to a node whose attribute NAF is true on the terminal device page layout tree.

[0053] In the above step S1-2, the parameters of the target page object include at least:

[0054] Node element, which is a node element on the terminal device page layout tree.

[0055] The top-level activity matching relationship is expressed as the top-level activitiy of the current interface state matches the top-level activitiy of the target page object.

[0056] Target action is the action that the RPA script will perform on the terminal device.

[0057] In the above step S3-1, a page status object is constructed, including: if the RPA script is configured with a NAF node replacement requirement, the NAF nodes in the node tree are traversed, and each NAF node performs a screenshot and searches for a matching standard image in the standard image library in turn. For the NAF node that matches the standard image, the value of a specific attribute is updated to the image number.

[0058] If the RPA script is configured with node pruning requirements, it traverses the node tree and deletes the subtrees that meet the requirements.

[0059] The attributes of the page state object include at least a screenshot, a node tree, and a top-level activity.

[0060] In the above step S3, the page status object is stable as a description of the terminal device page being loaded. When the RPA script defines the NAF node element, the judgment basis for the stability of the page status object is that all key page NAF nodes match the standard graph.

[0061] In the above step S3-2, the page state object is compared with the target page object to determine whether the two satisfy a matching relationship. If so, the target page object is taken as the final result, the subsequent matching operation is terminated, and the target action is directly executed.

[0062] The comparing the page state object with the target page object specifically includes:

[0063] Determine whether the top-level activity matches;

[0064] Determine whether all node elements match.

[0065] In the above step S3-1, when constructing the page status object, NAF node element replacement is also performed: after the RPA script obtains the layout tree and screenshot of the terminal APP, the RPA script finds the NAF node in the layout tree, extracts the node screenshot, and uses the image matching algorithm to search the standard gallery, and uses the number of the hit image to add the attribute img_tag = image number in the NAF node.

[0066] Further, in step S1-1, a NAF node refers to a node whose attribute NAF is "true" on the Android device layout tree, and the screenshot corresponding to the NAF node on the key page is converted into a standard image and assigned a globally unique image number, the purpose of which is to improve the speed of image matching and enhance the robustness of matching. Its implementation may include methods such as image grayscale processing, image scaling, and image contour extraction. Preferably, the NAF screenshot can be converted into a standard image by first grayscale and then scaling to 64*64 pixels.

[0067] Furthermore, in step S1-2, the target page object refers to the interface state of the Android device corresponding to when the RPA script executes the action, which includes the interface layout tree, top-level activity, screenshots, etc.

[0068] Furthermore, in step S1-2, the target page object can be described in the RPA script system by three necessary parameters:

[0069] 1)Node element;

[0070] 2) Top-level Activitiy matching relationship;

[0071] 3) Target action.

[0072] Further, in step S1-2, the node element refers to a node element on the device page layout tree, such as an icon, button, radio button on an Android device page. Preferably, the xpath method is used to express a unique node element. Preferably, AND and NOT logic are used, the former expressing that the page object must contain the node element, and the latter expressing that the page object cannot contain the node element.

[0073] Further, in step S1-2, if the node element is a NAF attribute node, and the NAF node screenshot exists in the standard library of step S1-1, then preferably, in the xpath expression of the node element, the "img_tag=picture number" method can be used to express the selection of the NAF node.

[0074] Further, in step S1-2, the activitiy matching relationship expresses that the top activitiy of the current interface state matches the top activitiy of the target page object. Preferably, a regular expression is used to express the conditions that the activitiy must meet.

[0075] Furthermore, in step S1-2, the target action refers to the action that the RPA script will perform on the Android device. The action includes two categories, one is simple actions such as click, long press, slide, set text, etc., and the other is complex actions defined by script code, such as performing multiple consecutive clicks on the target node.

[0076] Furthermore, in step S1 - 2 , the target page object may include other parameters in addition to the three necessary parameters.

[0077] Furthermore, in step S1-2, the target page object preferably uses an inheritance relationship to express that the child page object includes the parent page object; using the inheritance relationship can simplify the definition of the target page object.

[0078] Furthermore, in step S2, the terminal APP uses the dumpWindowHierarchy method of UiAutomator to obtain the page layout tree and mark the activated subtree. Preferably, the device layout tree is stored in XML format; the terminal APP transmits the new device layout tree to the RPA script only after discovering that the device layout tree has changed.

[0079] Further, in step S2, preferably, the terminal APP transmits the new screenshot to the RPA script only after discovering that the screenshot has changed.

[0080] Furthermore, in step S3, the attributes of the page state object include screenshots, node trees, top-level activities, and the like.

[0081] Preferably, in step S3-1, if the RPA script is configured with a NAF node replacement requirement, the NAF nodes in the node tree are traversed, and each NAF node sequentially performs a screenshot and searches for a matching standard image in the standard image library. For the NAF node that matches the standard image, the value of the specific attribute is updated to the image number.

[0082] Preferably, in step S3-1, if the RPA script is configured with a node pruning requirement, the node tree is traversed to delete subtrees that meet the requirement, for example, subtrees corresponding to non-top-level activities, subtrees that are blocked, etc.

[0083] Further, in step S3-2, the stability of the page status object refers to the description of the phenomenon that the Android device page is in the process of loading. Different RPA scripts have different judgment criteria. One criterion for judging whether the page status object is stable is that the layout tree remains unchanged and the screenshot content remains unchanged. In this embodiment, for the RPA script that defines the NAF node element, the stability criterion can be that all key NAF nodes match the standard graph.

[0084] Furthermore, in step S3-2, matching the target page object means comparing the page status object with the target page object to confirm whether the two satisfy a matching relationship. If they do, the target page object is taken as the final result, the subsequent matching operation is terminated, and step S3-3 is directly executed. Among them, the specific steps of comparing the page status object with the target page object include:

[0085] 1) Whether the top-level activity matches;

[0086] 2) Whether all node elements match.

[0087] It should be noted that the page status object can be compared with the target page object to match other relationships, depending on the properties of the target page object.

[0088] Furthermore, in step S3-3, the RPA script can directly execute the final action on the Android device by calling the terminal APP, calling the ADB command, etc.

[0089] Furthermore, the target page object defined in step S1 is executed 0 times and n times.

[0090] The RPA script can define initialization actions and exit actions. The exit action can be the target action of the target page object or a timeout action. A watchdog action can also be defined to destroy the unresponsive state.

[0091] In practical applications, in combination with Shenxin app (Shenxin app is a marketing application that mobilizes the ownership awareness of all employees in the enterprise, realizes full-staff marketing, crisis collaboration, and task statistics, and adopts three major technologies to mobilize the enthusiasm of employees and effectively improve employee office efficiency), a terminal device RPA script writing and execution method provided in this embodiment is described, which specifically includes:

[0092] Get the login account information on Shenxin APP.

[0093] Find the target page and define the RPA script respectively. The target page involves three target pages: Shenxin login page, Shenxin account page, and other pages. Shenxin login page refers to the Shenxin APP login interface, which means the account is not logged in; Shenxin account page refers to the login user information page, where the login account information can be extracted; other pages refer to other pages except the first two pages.

[0094] Constructing the standard atlas corresponding to all key NAF nodes of all pages. Since the target page and node elements involved in the first embodiment do not contain NAF nodes, it is not necessary to construct the standard atlas of NAF nodes.

[0095] Define each target page object. The target page object consists of at least three parts: node element, top-level activity, and target action.

[0096] like Figure 2As shown, the key node elements involved in the three target page objects are defined. Preferably, the xpath syntax is used to express the node element positioning; preferably, the AND relationship and the NOT relationship are used to express the two semantics of the existence and non-existence of the node element, respectively. The Shenxin login page of Example 1 contains three key node elements, namely, mobile phone login text, input mobile phone number, and obtain verification code. The Shenxin account page also contains three key node elements: the person to whom it belongs, account ID, and software version. For other pages, the universal node of xpath=' / / node' is used to express the scope of the page.

[0097] like Figure 3 As shown in the figure, define the target actions involved in the three target page objects. The Shenxin login page and Shenxin account page use custom functions as target actions respectively. For other pages, use the built-in start_deep_link action type, with the deeplink of the Shenxin account page as a parameter, to execute the action of automatically opening the Shenxin account page.

[0098] like Figure 4 As shown in the figure, three target page objects are completely defined. Page objects can use rules to express the relationship between pages, thereby simplifying the definition of target objects.

[0099] In this embodiment, a target page object inheritance relationship rule is defined: for target page objects A and B, if B inherits from A, that is, the parent page of B is A, then: 1) if the page status is to match the target page object B, the page status must match the target page object A; 2) the matching priority of the target page object B is higher than that of A.

[0100] In this embodiment, the Shenxin login page and the Shenxin account page are inherited from other pages, and only when the Shenxin login page and the Shenxin account page are not matched, can other pages be matched. In this way, the definition between the three pages is simplified.

[0101] exist Figure 4 In the code, the three key attributes of the node element, top-level activity, and target action of the three target page objects are fully defined.

[0102] Then, use ADB to run the terminal APP on the Android device to monitor the device page information in real time. The purpose of starting the terminal APP on the Android device through ADB is to allow the terminal APP to obtain the necessary permissions. The terminal APP provides at least two functions: 1) using the dumpWindowHierarchy method of UiAutomator to obtain the page layout tree; 2) obtaining a screenshot.

[0103] In this embodiment, in order to reduce the running load of the Android terminal, the terminal APP starts to collect information such as the page layout tree and screenshots only when the RPA script notifies the start of receiving the page layout tree and screenshots. The terminal APP sends a new page layout tree to the RPA script only after determining that the page layout tree has changed; and sends a new screenshot to the RPA script only after determining that the screenshot has changed. Both the page layout tree and the screenshot need to be real-time, that is, the page layout tree and screenshots of the current state should be obtained as much as possible.

[0104] The page layout tree obtained by the terminal APP needs to mark the node tree corresponding to the top-level activity as activated.

[0105] Then, the RPA script matches the page by priority and executes the page action after the page is stable.

[0106] After the RPA script receives the latest device page information, it constructs a page status object, which contains at least three attributes: screenshot, node tree, and top-level activity.

[0107] When the page status object is stable, the target page object is matched in order of priority. The matching order depends on the rules, but it is clear that due to the use of inheritance rules, the priority of Shenxin login page and Shenxin account page is higher than other pages.

[0108] Execute the target action corresponding to the matched target page object. For example, if the Android device interface is on the Shenxin account page, the Shenxin account page target page object will be matched, and the RPA script will execute the action corresponding to the Shenxin account page: obtain account information, execute successfully and exit.

[0109] For the RPA task corresponding to the first embodiment, the traditional RPA script construction method is as follows:

[0110] 1) The RPA script opens the deeplink of the Shenxin account page;

[0111] 2) If after waiting for a certain period of time, the layout tree shows the specific node information of the deep core account page, then obtain the account information and execute the exit;

[0112] 3) If the layout tree contains specific node information of the Deepin login page, the account acquisition fails and the system exits;

[0113] 4) If you wait for more than the specified time and no specific information about the Deepin account and Deepin login page appears, try to open the Deepin account page deeplink again.

[0114] Based on the RPA task in Example 1, compared with the traditional method, the method proposed in the present invention has the following advantages:

[0115] 1) The RPA script writing process saves a lot of logic for waiting for a specified time and judging whether a specific node element appears on the current page, reducing the amount of code.

[0116] 2) Thinking based on the target page object makes it easy to organize page matching logic and target actions.

[0117] Embodiment 2 of a method for writing and executing RPA scripts of a terminal device:

[0118] See also Figures 5 to 8 In this embodiment, an RPA script is executed on a chat application. The task of this embodiment is to select two specified users in the address book.

[0119] like Figure 5 As shown, two key NAF node elements appear on the chat application address book interface of Example 2, namely, the search icon and the multi-select icon of the page to be selected. If these two NAF nodes do not exist, it may be that the chat application address book interface is not currently in place, or the chat application address book interface may not be fully rendered.

[0120] Since NAF node elements appear in the RPA script of this embodiment, according to step S1-1, the screenshots corresponding to the two NAF node elements need to be extracted to generate Figure 5 The standard images shown above are given image numbers img_001 and img_002 respectively.

[0121] like Figure 6 As shown, when writing the two NAF node elements of the candidate page search icon and the multiple selection icon, @img_tag="img_001" and @img_tag="img_002" are used in the xpath to express that the screenshot corresponding to the candidate page-search icon node element must match the img_001 picture of the standard library, and the screenshot corresponding to the candidate page-multiple selection icon node element must match the img_002 picture of the standard library. Figure 6 In the figure, the two node elements, unchecked contact A and unchecked contact B, use the NOT relationship to express the meaning of unchecked.

[0122] In this embodiment, four target page objects are defined, namely, a page to be selected, a page to select contact A, a page to select contact B, and a page to select contacts AB. The existence of these four target page objects can ensure that the two contacts can be correctly selected to the greatest extent.

[0123] In step S3, the RPA script of this embodiment needs to specifically define the judgment option of whether the page state object is stable. Optionally, when the top-level activity corresponding to the page state object matches ".*contact.controller.SelectActivity" (that is, the top-level activity is the address book interface of the chat application) and all NAF nodes are matched by the standard library images, it can be considered that the page state object is stable.

[0124] In step S3-1, in addition to performing conventional layout tree pruning, the RPA script also performs NAF node element replacement based on the configuration. For example, for the address book interface of the chat application, after the RPA script obtains the layout tree and screenshots of the terminal APP, the RPA script finds the NAF node in the layout tree, extracts the node screenshot, uses the image matching algorithm to search the standard image library, and uses the number of the hit image to add the attribute img_tag = image number in the NAF node.

[0125] Based on the first and second embodiments, it can be seen that compared with the traditional method, the method provided by the present invention has the following advantages:

[0126] 1) Organizing matching logic and target functions based on target page objects helps reduce the complexity of RPA scripts and improve efficiency;

[0127] 2) The definition rules of node elements and target page objects have wide applicability;

[0128] 3) Solve the problem that NAF node elements are difficult to utilize.

[0129] An embodiment of a system for writing and executing RPA scripts of a terminal device:

[0130] A terminal device RPA script writing and execution system, comprising:

[0131] RPA script definition module, used to define the target page object.

[0132] The terminal module is used to monitor the page information of the terminal device.

[0133] The RPA script execution module is used to match the target page by priority and execute page actions.

[0134] Therefore, this embodiment completes the writing and execution of RPA scripts through an execution system composed of an RPA script definition module, a terminal module and an RPA script execution module. It can solve the problems of cumbersome RPA script writing, inability to respond to page changes in a timely manner, and difficulty in dealing with multi-step tasks in the prior art, thereby improving the RPA script writing efficiency and execution efficiency, which is conducive to the promotion of RPA on Android devices.

[0135] It can be seen that each embodiment in this specification is described in a progressive manner, and each embodiment focuses on the differences from other embodiments, and the same or similar parts between the embodiments can be referred to each other. For the system embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.

[0136] The present application is described with reference to the flowcharts and / or block diagrams of the methods, devices (apparatus), and computer program products according to the embodiments of the present application. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0137] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0138] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.

[0139] The method and system provided by the present application are introduced in detail above. Specific examples are used in this article to illustrate the principles and implementation methods of the present application. The description of the above embodiments is only used to help understand the method and core idea of ​​the present application. At the same time, for general technical personnel in this field, according to the idea of ​​the present application, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present application.

[0140] The above-mentioned embodiments are only preferred embodiments of the present invention and cannot be used to limit the scope of protection of the present invention. Any non-substantial changes and substitutions made by technicians in this field on the basis of the present invention shall fall within the scope of protection required by the present invention.

Claims

1. A method for writing and executing RPA scripts for terminal devices, characterized in that: The following steps are involved: Get the target page information, and define the RPA script relationship on each target page, including: constructing the corresponding standard atlas of all key page NAF nodes; defining each target page object, where the target page object is the interface state of the terminal device corresponding to the RPA script execution action; the parameters of the target page object include at least: node elements, which are node elements on the terminal device page layout tree; top-level activity matching relationship, which is expressed as the top-level activitiy of the current interface state matches the top-level activitiy of the target page object; target action, which is the action that the RPA script will perform on the terminal device; After the RPA script runs, use the ADB tool to run the terminal APP on the terminal device and monitor the device's page information in real time; When the RPA script is stable on the page, it matches the page by priority and executes page actions, including: When the RPA script receives the latest device page information, it constructs a page status object; When the page status object is stable, the target page object is matched in order of priority, which includes: the stability of the page status object is a description of the terminal device page being loaded, and for the RPA script that defines the NAF node element, the judgment basis for the stability of the page status object is: all key page NAF nodes match the standard graph; compare the page status object with the target page object to determine whether the two meet the matching relationship, if so, take the target page object as the final result, end the subsequent matching operation, and directly execute the target action; wherein, the comparison of the page status object with the target page object specifically includes: determining whether the top-level activity matches; determining whether all node elements match; Execute the target action corresponding to the matched target page object.

2. The method according to claim 1, characterized in that The construction of the standard atlas corresponding to all key page NAF nodes includes: The screenshot corresponding to the NAF node on the key page is converted into a standard image and assigned a globally unique image number, wherein the NAF node refers to a node whose attribute NAF is true on the terminal device page layout tree.

3. The method according to claim 1, characterized in that: When the RPA script runs, the ADB tool is used to start the terminal APP, which obtains the page layout tree and screenshots of the terminal device in real time and transmits them to the RPA script in real time through the TCP protocol. Among them, the terminal APP uses UI Automator to obtain the page layout tree and mark the activated subtree; Among them, after the terminal APP finds that the screenshot has changed, it transmits the new screenshot to the RPA script.

4. The method according to claim 1, characterized in that The page state object is constructed, including: If the RPA script is configured with the NAF node replacement requirement, the NAF nodes in the node tree are traversed. Each NAF node performs the screenshot operation and searches for a matching standard image in the standard image library in turn. For the NAF node that matches the standard image, the attribute img_tag=image number is added to the NAF node using the number of the matching image. If the RPA script is configured with node pruning requirements, the node tree is traversed and the subtrees that meet the requirements are deleted; The attributes of the page state object include at least a screenshot, a node tree, and a top-level activity.

5. A terminal device RPA script writing and execution system, characterized in that: include: The RPA script definition module defines the RPA script relationship on each target page, including: building a standard atlas corresponding to all key page NAF nodes; defining each target page object, where the target page object is the interface state of the terminal device corresponding to the RPA script execution action; the parameters of the target page object include at least: node elements, which are node elements on the terminal device page layout tree; top-level activity matching relationship, which is expressed as the top-level activitiy of the current interface state matches the top-level activitiy of the target page object; target action, which is the action that the RPA script will perform on the terminal device; Terminal module: After the RPA script runs, use the ADB tool to run the terminal APP on the terminal device and monitor the device's page information in real time; The RPA script execution module is used to match the target page according to priority and execute the page action after the page status object is stable, which includes: the stability of the page status object is a description of the terminal device page being loaded. When it is for the RPA script that defines the NAF node element, the judgment basis for the stability of the page status object is: all key page NAF nodes match the standard graph; compare the page status object with the target page object to determine whether the two satisfy the matching relationship. If so, the target page object is used as the final result, the subsequent matching operation is terminated, and the target action is directly executed; wherein, the comparison of the page status object with the target page object specifically includes: determining whether the top-level activity matches; determining whether all node elements match; and executing the target action corresponding to the matched target page object.

Citation Information

Patent Citations

  • Application testing method and device in terminal equipment

    CN105335283A

  • Script-based task processing method and device

    CN113010159A