Page element positioning method and device, equipment and medium
By obtaining the element node rewriting path and matching degree screening, the problem of inaccurate positioning of page elements in dynamic pages is solved, and accurate positioning is achieved when the position of page elements changes.
Patent Information
- Application Number
- CN202410252221.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-05
- Publication Date
- 2025-09-16
AI Technical Summary
In a dynamic page, the display position of page controls changes, making it difficult for existing technologies to accurately locate page elements.
By obtaining the element node rewriting path of the target page element, the target page element is located from the candidate page elements based on the rewriting path, and the most likely page element is screened out through element matching to improve positioning accuracy.
Even if the page elements change, the target page elements can be located more accurately, which improves the positioning accuracy of the page elements.
Smart Images

Figure CN120653536A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of computer technology, and in particular to a method, device, equipment and medium for locating page elements. Background Art
[0002] Page automation testing involves automatically executing actions like clicks and input on a page to verify that the page design meets expectations. Specifically, it involves automatically locating a page element (e.g., page control A) on a page (e.g., page A). For example, you can specify the coordinates of page control A to be located (e.g., coordinates A), and use those coordinates to locate page control A on page A.
[0003] However, when the page is a dynamic page, the display position of page control A may change (that is, the coordinates of the page element on page A become coordinates B). At this time, if page control A is still positioned by coordinate A, page control A may not be positioned. For example, no page control can be found when positioning according to coordinate A. In other words, the positioning of page control A is not accurate enough. Summary of the Invention
[0004] The embodiments of the present application provide a method, apparatus, device, and medium for locating page elements, which can improve the positioning accuracy of page elements.
[0005] In one aspect, an embodiment of the present application provides a method for locating a page element, the method comprising:
[0006] Get the business page; the business page includes N page elements; N is a positive integer;
[0007] Obtaining the element node rewriting path of the target page element to be located; the element node rewriting path is a path obtained by rewriting the positioning element node path of the target page element; the positioning element node path belongs to the element node rewriting path;
[0008] Based on the element node rewriting path, a candidate page element of the target page element is located from N page elements; the element node path of the candidate page element belongs to the element node rewriting path;
[0009] Determining element matching between candidate page elements and target page elements;
[0010] Based on the element matching degree, the target page element is located from the candidate page elements.
[0011] In one aspect, an embodiment of the present application provides a device for locating a page element, the device comprising:
[0012] The page acquisition module is used to acquire the business page; the business page includes N page elements; N is a positive integer;
[0013] The element positioning module is used to obtain the element node rewriting path of the target page element to be positioned; the element node rewriting path is the path obtained by rewriting the positioning element node path of the target page element; the positioning element node path belongs to the element node rewriting path;
[0014] The element locating module is further used to locate candidate page elements of the target page element from N page elements based on the element node rewriting path; the element node path of the candidate page element belongs to the element node rewriting path;
[0015] An element matching module is used to determine the element matching degree between the candidate page elements and the target page elements;
[0016] The element matching module is used to locate the target page element from the candidate page elements based on the element matching degree.
[0017] On the one hand, an embodiment of the present application provides an electronic device, which includes a processor and a memory, wherein the memory is used to store a computer program, the computer program includes program instructions, and the processor is configured to call the program instructions to execute some or all of the steps in the above method.
[0018] On the one hand, an embodiment of the present application provides a computer-readable storage medium, which stores a computer program, and the computer program includes program instructions, which, when executed by a processor, are used to execute some or all of the steps in the above method.
[0019] Accordingly, according to one aspect of the present application, a computer program product is provided, which includes a computer program. The computer program includes program instructions, and when the program instructions are executed by a processor, some or all of the steps in the above method can be implemented.
[0020] In an embodiment of the present application, the positioning element node path can be rewritten to obtain an element node rewriting path, and the positioning element node path belongs to the element node rewriting path, that is, the element node rewriting path is a higher-level path of the positioning element node path. If the positioning element node path can be understood as being used to accurately locate the target page element, then the element node rewriting path can be understood as being used to fuzzily locate the target page element, that is, one or more candidate page elements can be located through the element node rewriting path, and the candidate page elements may include the target page element. Therefore, the candidate page element can be located from N page elements through the element node rewriting path (the element node path of the candidate page element in the page script of the business page belongs to the element node rewriting path), so that the element matching degree between the candidate page element and the target page element can be determined, thereby determining the candidate page element that is most likely to be the target page element as the located target page element. Through the above method, the fuzzy positioning of page elements can be combined with the element node rewriting path, and the candidate page elements that are most likely to be the target page elements can be further screened out through element matching. In this way, even if the page elements change, it is more likely to locate the page elements that should be located, thereby improving the positioning accuracy of the page elements. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following is a brief introduction to the drawings required for use in the description of the embodiments. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without any creative work.
[0022] Figure 1 A schematic diagram of a network architecture provided in an embodiment of the present application;
[0023] Figure 2 A schematic diagram of a page element positioning process provided in an embodiment of the present application;
[0024] Figure 3 A schematic diagram of an element node path provided in an embodiment of the present application;
[0025] Figure 4 A schematic diagram of a flow chart of a method for locating page elements provided in an embodiment of the present application;
[0026] Figure 5 A schematic diagram of a process for determining candidate page elements provided in an embodiment of the present application;
[0027] Figure 6 A schematic diagram of a process for determining element matching provided in an embodiment of the present application;
[0028] Figure 7 A flowchart of another method for locating page elements provided in an embodiment of the present application;
[0029] Figure 8 A schematic diagram of a dimension matching degree determination process provided in an embodiment of the present application;
[0030] Figure 9 A schematic diagram of another dimension matching degree determination process provided in an embodiment of the present application;
[0031] Figure 10 A schematic diagram of another dimension matching degree determination process provided in an embodiment of the present application;
[0032] Figure 11 A schematic diagram of another dimension matching degree determination process provided in an embodiment of the present application;
[0033] Figure 12 A schematic diagram of a process for locating page elements provided in an embodiment of the present application;
[0034] Figure 13 A schematic diagram of a scenario for positioning page elements provided in an embodiment of the present application;
[0035] Figure 14 A schematic diagram of another scenario for positioning page elements provided in an embodiment of the present application;
[0036] Figure 15 A schematic diagram of the structure of a page element positioning device provided in an embodiment of the present application;
[0037] Figure 16 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0038] The following will be combined with the drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.
[0039] like Figure 1As shown, the service terminals in the service terminal cluster 100 may specifically include: service terminal 100a, service terminal 100b, and service terminal 100c. Communication connections may exist between the service terminal clusters 100, for example, a communication connection exists between service terminal 100a and service terminal 100b, and a communication connection exists between service terminal 100b and service terminal 100c. At the same time, any service terminal in the service terminal cluster 100 may have a communication connection with the service server 200, so that each service terminal in the service terminal cluster 100 can exchange data with the service server 200 through this communication connection, for example, a communication connection exists between service terminal 100a and service server 200.
[0040] Among them, the above-mentioned communication connection does not limit the connection method. It can be directly or indirectly connected through wired communication, directly or indirectly connected through wireless communication, or through other methods. This application does not limit it here.
[0041] Among them, the business terminal may be installed with an application associated with page element positioning, for example, it may be an application for developing and testing pages. When the application runs in the business terminal, it can be used with the above Figure 1 The business servers 200 shown here interact with each other.
[0042] Among them, the application can be any type of application, such as a browser application, a social application, a view application, an instant messaging application (for example, a conference application), an entertainment application (for example, a game application, a live broadcast application), a multimedia application (for example, a video application), an information application (for example, a news information application), a development platform application, a car application, a smart home application, and the like, which has the function of displaying data information such as text, images, audio, and video. The specific type of application is not limited here. It can be understood that the business page can belong to an application page in the application, or a page loaded by the application based on the page resource address. Among them, the above-mentioned application can be an independent application, or it can be an embedded sub-application integrated in an application (such as a social application, etc.), which is not limited here. In addition, the client can be a software application or a web application.
[0043] It is understandable that the above Figure 1 The business server 200 shown can be a collection of multiple servers such as a backend server and a data processing server corresponding to a business page, for example, a page server associated with a business page. Therefore, the business terminals in the business terminal cluster 100 can communicate and interact with the above-mentioned business server through the business page.
[0044] For example, application 1 in the business terminal (such as a page testing platform) is used to test the business page. Application 1 can open the business page to be tested (such as a page under a certain website). Application 1 locates the target page element (such as a product details viewing control) on the business page under the website according to the technical solution of this application, and generates a product details viewing request by triggering the target page element, and sends the product details viewing request to the business server 200 corresponding to the business page. The business server 200 returns the product details page based on the product details viewing request, and application 1 can further display the product details page.
[0045] It is understood that the electronic device involved in the embodiment of the present application may be a server (for example, Figure 1 The service server 200 shown in FIG. 2 may also be a service terminal (eg, Figure 1 Any business terminal in the business terminal cluster 100 shown). Among them, the server can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers, or a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, CDN (Content Delivery Network), and big data and artificial intelligence platforms. The terminal can be a smart phone, tablet computer, laptop computer, desktop computer, smart speaker, smart TV, smart watch, car terminal, aircraft, etc., but is not limited to this. The embodiments of the present application can be applied to various scenarios, including but not limited to cloud technology, artificial intelligence, smart transportation, assisted driving, etc.
[0046] It is understandable that Figure 1 The present invention only exemplifies the possible application architectures of the technical solution of the present application and does not limit the specific architecture of the technical solution of the present application. That is, the technical solution of the present application can also provide other forms of application architectures.
[0047] Further, see Figure 2 , Figure 2A schematic diagram of a page element positioning process provided in an embodiment of the present application. In which, an electronic device obtains a business page, and the business page 20 includes N page elements (such as page elements 20a, 20b, and 20c). At this time, when the positioning element node path 21 of the target page element is obtained, the positioning element node path is rewritten to obtain an element node rewriting path 22. Based on the element node rewriting path, the candidate page element 23 of the target page element (such as including page elements 20a and 20b) is located from the N page elements, and the element matching degree 24a between the page element 20a in the candidate page element and the target page element is determined, and the element matching degree 24b between the page element 20b in the candidate page element and the target page element is determined. The target page element is located from the candidate page element according to the element matching degree. For example, if the element matching degree 24a is greater than the element matching degree 24b, the page element 20a is used as the target page element located from the N page elements. In other words, the purpose of locating the target page element from the business page is achieved in this way. In this way, when the business page is a dynamic page, even if the display form of the target page element as page element 20a changes (such as the display position on the business page changes), the target page element can still be accurately located from the business page. It can be understood that when the target page element to be located should be page element 20a, if no page element is located from the business page, or if another page element (such as page element 20b) is located, it is considered that the target page element has not been located.
[0048] To facilitate understanding, the following is an introduction to the technical terms involved in the technical fields to which the solutions of the embodiments of the present application may be applied:
[0049] 1. Artificial Intelligence
[0050] The embodiments of this application relate to the field of artificial intelligence technology. Artificial intelligence is the theory, method, technology, and application system that uses digital computers or machines controlled by digital computers to simulate, extend, and expand human intelligence, perceive the environment, acquire knowledge, and use knowledge to achieve optimal results. In other words, artificial intelligence is a comprehensive technology in computer science that attempts to understand the essence of intelligence and produce new intelligent machines that can respond in a manner similar to human intelligence. Artificial intelligence is the study of the design principles and implementation methods of various intelligent machines, giving them the capabilities of perception, reasoning, and decision-making.
[0051] In one possible implementation, the page element positioning method provided in the embodiment of the present application can be combined with the machine learning (ML) technology in artificial intelligence. ML is a multi-disciplinary interdisciplinary subject involving probability theory, statistics, approximation theory, convex analysis, algorithm complexity theory and other disciplines. It specializes in studying how computers simulate or implement human learning behavior to acquire new knowledge or skills and reorganize existing knowledge structures to continuously improve their own performance. Machine learning is the core of artificial intelligence and the fundamental way to make computers intelligent. Its applications are spread across all areas of artificial intelligence. Machine learning and deep learning generally include artificial neural networks, belief networks, reinforcement learning, transfer learning, inductive learning, and formulaic learning.
[0052] It can be understood that in the technical solution of the present application, the electronic device can apply ML technology to construct and train a business model for determining element matching. In this way, the element matching information of the candidate page element (such as the element node path of the candidate page element, etc.) and the element matching information of the target page element (such as the positioning element node path of the target page element, etc.) can be input into the business model, and the business model determines the element matching degree between the candidate page element and the target page element based on the element matching information of the candidate page element and the element matching information of the target page element.
[0053] 2. Cloud Technology
[0054] The embodiments of the present application relate to the field of cloud technology. Cloud technology is a general term for network technology, information technology, integration technology, management platform technology, application technology, etc. based on the cloud computing business model. It can form a resource pool that can be used on demand and is flexible and convenient. Cloud computing technology will become an important support. The background services of the technical network system require a large amount of computing and storage resources, such as video websites, picture websites and more portal websites. With the rapid development and application of the Internet industry, each item may have its own identification mark in the future, and all of them need to be transmitted to the background system for logical processing. Data of different levels will be processed separately. All kinds of industry data require strong system backing support, which can only be achieved through cloud computing.
[0055] In one possible implementation, the page element positioning method proposed in the embodiments of the present application can be combined with cloud applications in cloud technology. For example, the cloud application is cloud conferencing, which is an efficient, convenient, and low-cost conference format based on cloud computing technology. Users only need to use an Internet interface and perform simple and easy-to-use operations to quickly and efficiently share voice, data files, and videos with teams and customers around the world. The cloud conferencing service provider helps users with complex technologies such as data transmission and processing during the meeting. Currently, domestic cloud conferencing mainly focuses on service content based on the SaaS (Software as a Service) model, including telephone, network, video and other service forms. Video conferencing based on cloud computing is called cloud conferencing. In the cloud conferencing era, data transmission, processing, and storage are all handled by the computer resources of the video conferencing manufacturer. Users no longer need to purchase expensive hardware or install cumbersome software. They only need to open a browser and log in to the corresponding interface to conduct efficient remote conferencing. Cloud conferencing systems support dynamic cluster deployment of multiple servers and provide multiple high-performance servers, greatly improving the stability, security, and availability of conferences. In recent years, video conferencing has gained widespread popularity due to its ability to significantly improve communication efficiency, continuously reduce communication costs, and upgrade internal management. It has been widely adopted in various fields, including transportation, finance, operators, education, and enterprises. Undoubtedly, the use of cloud computing has made video conferencing even more appealing in terms of convenience, speed, and ease of use, which will undoubtedly trigger a new surge in video conferencing applications. The page element positioning method can be applied to cloud conferencing testing scenarios, such as testing whether the cloud conference login process meets design expectations. This involves automatically positioning the account information input area and cloud conference login controls on the cloud conference login interface.
[0056] 3. Page element positioning:
[0057] It is understood that the technical solution of this application can be applied to the automated testing of business pages, which can be web pages (i.e., World Wide Web pages). Specifically, it is to implement automatic click, input, scrolling and other actions on the front-end business page to simulate human input behavior, thereby verifying whether the front-end interaction meets the expectations of the software design.
[0058] This involves positioning page elements (such as controls and text input areas) on business pages. Positioning page elements can be achieved using their XPath and CSS styles. There are no restrictions on the type of page elements.
[0059] For example, through the given element node path and / or element style information of the page element to be located, positioning is performed from the page elements on the business page. For example, the element node path and / or element style information of the page element is obtained from the page script of the business page, and the element node path and / or element style information of the page element is searched for the element node path and / or element style information that matches the element node path and / or element style information of the page element to be located, and the page element corresponding to the found element node path and / or element style information is used as the located page element to be located.
[0060] Among them, XPath is a path representation language used to indicate the location path of the element node of a page element. It is understandable that a business page can be regarded as an XML (Extensible Markup Language) document, and XML documents are treated as node trees. Therefore, the page elements on the business page are treated as nodes in the node tree corresponding to the business page, that is, one page element corresponds to one element node. Locating the page element on the business page can be achieved by locating the element node corresponding to the page element on the node tree. In other words, the element node path of a page element can refer to the node location path of the element node corresponding to the page element on the node tree. At this time, the nodes passed through when locating a certain element node on the node tree are the path nodes associated with the element node (it is understandable that the path nodes include the element node to be located, that is, the nodes passed through when locating a certain element node include the element node to be located). These path nodes constitute the element node path of the page element.
[0061] At this time, the element node path of an element node is used to indicate the node hierarchy relationship and node mark of the path node associated with the element node. It can be understood that the node hierarchy relationship is used to indicate the node hierarchy where the path node is located (that is, the element hierarchy of the page element), and the node mark is the node label of the path node in the node hierarchy. For example, if the node hierarchy where a path node is located is "div", the node label of the path node under the node hierarchy is [1], which means that the path node is the first node under the node hierarchy div (or the second node if numbering starts from 0). It can be understood that when locating an element node, passing through multiple path nodes in sequence, the order of passing through the node hierarchies where the multiple path nodes are located constitutes a node hierarchy relationship.
[0062] For example, the path nodes that a certain element node passes through in sequence include path node 1 and path node 2. The node level 1 where path node 1 is located is "div", and the node level 2 where path node 2 is located is "div", and the node label of path node 1 under the node level 1 is [1], and the node label of path node 2 under the node level 2 is [2]. Therefore, the element node path consists of: div[1] / div[2], where "div / div" represents the node hierarchy relationship (i.e., the hierarchy relationship between node level 1 and node level 2), and "[1]" and "[2]" represent the node labels. It can be understood that the node labels in an element node path are extracted and spliced in sequence to form a node label array list. It can be understood that the node labels are presented in the element node path in the form of an array, i.e., "[1]". In other words, the array information in the element node path is the node label in the element node path.
[0063] For example, Figure 3 As shown, Figure 3 A schematic diagram of an element node path provided in an embodiment of the present application; wherein, node 32 in the node tree 31 corresponding to the business page is element node A corresponding to page element A. It can be seen from the node tree 31 that node 32 is located in the node tree 31, and the determined path nodes include: node 35, node 34, node 33, and node 32; wherein, node 35 is at node level 1 "body"; node 34 is at node level 2 "div", and the node mark of node 34 in node level 2 is [1]; node 33 is at node level 3 "div", and the node mark of node 33 in node level 3 is [2]; node 32 is at node level 4 "li". Since the determined element node path 36 is composed of the node levels and node marks of the nodes passed through in sequence, it is: body / div[1] / div[2] / li. It can be understood that the node tags in the element node path are extracted and spliced in sequence, and the array formed is used as the node tag array 37 ([1], [2]) in the element node path; the element node path after removing the node tag array represents the node hierarchical relationship 38, that is, body / div / div / li.
[0064] Among them, CSS (Cascading Style Sheets) is a cascading style sheet used to describe the style attributes of a page element (for example, if the page element is a text box control, the style attributes can refer to the border color, background color and other display style-related attributes of the text box control). Different page elements have different style attributes, so a page element can be located by specifying style attributes.
[0065] It can be understood that the page element positioning method proposed in the embodiment of the present application can be applied to any scenario of automatically positioning a page, such as in a test scenario of a business page, by automatically positioning the specified page element on the business page to test the business page to determine whether the design of the business page is correct. For example, it can be in an automatic click task scenario of a business page, such as a business activity that drops a red envelope when a control A is automatically clicked a specified number of times. At this time, when promoting the business activity, it is necessary to display the effect of the business activity. When generating the display effect for the business activity, an automatic click task for control A can be constructed, and the automatic click task is to locate control A and click it multiple times.
[0066] It is understandable that the business page can be a page under any business, such as a login page under a cloud conference business, or a product browsing page under an e-commerce business. This is not limited here. The purpose of this solution is to achieve accurate positioning of the target page elements even if the business page is a dynamic page and the target page elements change. In other words, the technical solution of this application can shield the changes in the business page, making the positioning of page elements more accurate.
[0067] It should be noted that when the electronic device in the embodiment of the present application obtains relevant data, such as the element location information configured by the user for locating the target page element in the page test scenario, it can display a prompt interface or pop-up window. The prompt interface or pop-up window is used to prompt the user that the element location information and other data are currently being obtained. Only after the user issues a confirmation operation on the prompt interface or pop-up window, the relevant steps of data acquisition are started, otherwise the process ends. It is understandable that in the specific implementation of the present application, user-related data (for example, element location information, etc.) may be involved. When the above embodiments of the present application are applied to specific products or technologies, the user's permission or consent needs to be obtained, and the collection, use and processing of relevant data need to comply with the relevant laws, regulations and standards of the relevant regions.
[0068] It is understood that the above scenarios are merely examples and do not limit the application scenarios of the technical solutions provided in the embodiments of this application. The technical solutions of this application can also be applied to other scenarios. For example, those skilled in the art will appreciate that with the evolution of system architecture and the emergence of new business scenarios, the technical solutions provided in the embodiments of this application will also be applicable to similar technical problems.
[0069] For further information, see Figure 4 , Figure 4 This is a page element positioning method provided by an embodiment of the present application, such as Figure 4 As shown, the method can be executed by the electronic device mentioned above, for example, Figure 1The service server shown in FIG. 1 may include the following steps S101 to S105:
[0070] S101. Obtain a business page.
[0071] The business page is the page on which the page element is currently being located. The business page includes N page elements, where N is a positive integer. These page elements can be controls, text input boxes, links, and so on, without limitation.
[0072] It can be understood that among the N page elements, there is a target page element to be located. The target page element is determined according to the specific business scenario. It is not limited here. For example, in the cloud conference login scenario, when the account information is entered, the page element that is automatically located at this time can be the login control on the business page. By locating and triggering the login control, it is possible to test whether the cloud conference can be successfully logged in. For another example, in the product browsing scenario, the page element that is automatically located can be a text input box for product search. By locating and triggering the text input box, relevant product search information can be entered to test whether the associated text information of the entered product search information will be automatically generated.
[0073] S102: Obtain an element node rewriting path of a target page element to be located.
[0074] When the positioning element node path specified by the user for the target page element to be currently positioned is obtained, the positioning element node path of the target page element may be rewritten, and the obtained path is the element node rewriting path.
[0075] Among them, it can be understood that the locating element node path is the element node path specified by the user for locating the target page element (at this time, the locating element node path may not be the current element node path of the target page element on the business page, for example, if the business page is a dynamic page, the path of the target page element changes).
[0076] It is understood that the positioning element node path is used to indicate the node hierarchy relationship of the target path node associated with the target element node and the node label of the target path node. The target path node is used to indicate the element node passed through when locating the target element node. It is understood that the target path node includes the target element node. The target element node is used to represent the target page element.
[0077] Therefore, obtaining the element node rewriting path can be, in the positioning element node path, removing the node mark of the target path node, obtaining the positioning element node path that retains the node hierarchy relationship of the target path node; and using the positioning element node path that retains the node hierarchy relationship of the target path node as the element node rewriting path.
[0078] That is, the path of the positioning element node path of the target page element is rewritten, that is, the node hierarchy relationship of the target path node is extracted from the positioning element node path to obtain the element node rewriting path.
[0079] It is understandable that when the business page is a dynamic page, the positioning element node path of the target page element may change. For example, in the business page loaded and displayed at time A, the node level of the corresponding target path node (node A) is "div" and the node number under this node level is [1]. In one case, at this time, because an advertisement is displayed in the business page loaded and displayed at time B, the node number of node A under this node level "div" changes from [1] to [2]. If the element is still positioned through the previous positioning element node path, the target page element cannot be located.
[0080] That is, when the business page is a dynamic page, the node label of the target path node may change (it is understood that the node hierarchy of the target path node will not change at this time). Therefore, the node label of the target path node can be removed to obtain the element node rewriting path. The element node rewriting path records the node hierarchy of the target path node associated with the target element node.
[0081] In other words, the location element node path belongs to the element node rewrite path. That is, the element node rewrite path is a higher-level node path corresponding to the location element node path. When locating the target page element using this element node rewrite path, it is more likely that the target page element will be located. It is understood that any page element whose element node path belongs to this element node rewrite path is likely to be the target page element.
[0082] It can be understood that when the node hierarchical relationship indicated by an element node path is consistent with the node hierarchical relationship indicated by the element node rewriting path, the element node path is regarded as belonging to the element node rewriting path.
[0083] Therefore, the positioning range of page elements can be expanded by rewriting the element node path. When the target page element cannot be located by locating the element node path, it can ensure that the required page element can be accurately located, while improving the positioning flexibility of the page element.
[0084] For example, the path to locate an element node is: body / div[1] / div[2] / li. By removing the array information ("[1]", "[2]") representing the node tags in the path to locate the element node, we can obtain the path to locate the element node that retains the node hierarchy relationship, that is, the element node rewrite path is: body / div / div / li.
[0085] It is understandable that the target page element can be located directly by rewriting the path through the element node, or precise positioning can be performed among N page elements first, and then fuzzy positioning can be performed when the target page element is not located.
[0086] Specifically, the target page element may be accurately located among the N page elements by using the location element style information and / or the location element node path (i.e., the element location information of the target page element) of the target page element. For example, based on the element node rewriting path, a candidate page element for locating the target page element from the N page elements may be: if the target page element is not located from the N page elements based on the element location information of the target page element, then a candidate page element for locating the target page element from the N page elements based on the element node rewriting path is located.
[0087] The element positioning information includes at least one of the following: positioning element style information and positioning element node path of the target page element, that is, the element style information and element node path specified by the user for positioning the target page element.
[0088] It can be understood that when the element positioning information is positioning element style information, if the target page element is not located from N page elements based on the positioning element style information of the target page element, the target page element is located by rewriting the path through the element node.
[0089] It can be understood that when the element positioning information is a positioning element node path, if the positioning element node path based on the target page element fails to locate the target page element from N page elements, the target page element is located by rewriting the element node path.
[0090] It can be understood that when the element positioning information includes positioning element style information and positioning element node path, if the target page element is not located from N page elements based on the positioning element style information and positioning element node path, the target page element is located by rewriting the element node path.
[0091] Among them, the positioning order of the positioning element style information and the positioning element node path is not limited here. The target page element can be positioned first by positioning the element style information, or by positioning the element node path.
[0092] Taking the location of element style information as an example, locating the target page element involves obtaining the element style information of N page elements from the page script of the business page, searching for element style information that matches the located element style information from the element style information of the N page elements, and using the page element corresponding to the found element style information as the target page element located from the N page elements. For example, the element style information of N page elements can be obtained from the page script of the business page by injecting js (JavaScript, a computer language).
[0093] S103 : rewriting the path based on the element node, and locating a candidate page element of the target page element from N page elements.
[0094] It can be understood that the element node path of the candidate page element belongs to the element node rewriting path. In other words, the element node path of the candidate page element in the page script of the business page belongs to the element node rewriting path.
[0095] The element node paths of N page elements can be obtained from the page script of the business page, and the page elements whose node hierarchical relationships indicated by the element node paths are consistent with the node hierarchical relationships indicated by the element node rewrite paths are determined from the N page elements to locate the page elements whose element node paths belong to the element node rewrite paths. The element node paths of the N page elements are the current element node paths of the N page elements on the business page.
[0096] For example, the element node paths of N page elements may be rewritten in the same manner as the path rewriting of the located element node path. If the path rewriting result corresponding to the element node path of the page element to be compared among the N page elements is consistent with the element node rewriting path, it means that the node hierarchy relationship indicated by the element node path of the page element to be compared is consistent with the node hierarchy relationship indicated by the element node rewriting path, that is, the page element to be compared is the page element whose element node path located among the N page elements belongs to the element node rewriting path.
[0097] It can be understood that there may be one or more candidate page elements, and the candidate page element that is most likely to be the target page element may be selected from the candidate page elements, that is, the target page element may be located from the candidate page elements.
[0098] S104: Determine the element matching degree between the candidate page element and the target page element.
[0099] The element matching degree between each candidate page element and the target page element is determined in the same manner, and is described here using one candidate page element as an example.
[0100] Among them, the element matching degree between the candidate page element and the target page element can be determined by the element matching information of the candidate page element and the element matching information of the target page element. The element matching information includes at least one of the following information: element node path, element style information, element display information, element size information. The matching degree of different dimensions can be determined by the one or more element matching information, and the element matching degree between the candidate page element and the target page element can be determined by the matching degree of different dimensions. For example, the sum of the matching degrees of different dimensions is used as the element matching degree between the candidate page element and the target page element. Alternatively, the matching degrees of different dimensions are weighted and summed to obtain the element matching degree between the candidate page element and the target page element.
[0101] Element display information refers to the display information of a page element on a business page, such as an image, text, or drawing information (such as a drawn icon or aperture). Element size information refers to the size information of a page element on a business page, such as the height and width of the page element on the business page.
[0102] For example, when the element matching information includes an element node path, the first dimension matching degree between the candidate page element and the target page element can be determined by the element node path of the candidate page element and the positioning element node path of the target page element.
[0103] It can be understood that the positioning element node path is the element node path specified by the user for locating the target page element. The element node path of the candidate page element is the current element node path of the candidate page element on the page script of the business page.
[0104] For another example, when the element matching information includes element style information, the second dimension matching degree between the candidate page element and the target page element may be determined by the element style information of the candidate page element and the positioning element style information of the target page element.
[0105] It can be understood that the positioning element style information is the element style information specified by the user for locating the target page element. The element style information of the candidate page element is the current element style information of the candidate page element on the page script of the business page.
[0106] For another example, when the element matching information includes element display information, the third dimension matching degree between the candidate page element and the target page element may be determined based on the element display information of the candidate page element and the positioning element display information of the target page element.
[0107] It can be understood that the positioning element style information is the element style information specified by the user for locating the target page element. The element style information of the candidate page element is the current element style information of the candidate page element on the page script of the business page.
[0108] For another example, when the element matching information includes element size information, the fourth dimension matching degree between the candidate page element and the target page element may be determined by the element size information of the candidate page element and the positioning element size information of the target page element.
[0109] It can be understood that the positioning element size information is the element size information specified by the user for positioning the target page element. The element size information of the candidate page element is the current element size information of the candidate page element on the page script of the business page.
[0110] Therefore, the element matching degree between the candidate page element and the target page element may be comprehensively determined by the matching degree of any one or more dimensions mentioned above.
[0111] The specific method of determining the matching degree of the above one or more dimensions can be found in the relevant description of the following embodiments.
[0112] S105: Locate the target page element from the candidate page elements based on the element matching degree.
[0113] The candidate page element with the highest element matching degree may be used as the located target page element.
[0114] It can be understood that if the candidate page element of the target page element is not located from N page elements based on the element node rewriting path, the positioning element display information of the target page element can be obtained, and the target page element can be located by using the positioning element display information of the target page element. For example, based on the positioning element display information, the transition candidate page element of the target page element is located from N page elements, and then the transition element matching degree between the transition candidate page element and the target page element is determined, and based on the transition element matching degree, the target page element is located from the transition candidate page element. Among them, the element display information of the transition candidate page element matches the positioning element display information. In other words, the element display information of the transition candidate page element in the page script matches the positioning element display information.
[0115] It is understood that the principle of determining the element matching degree between the transition candidate page element and the target page element (i.e., the transition element matching degree) is the same as that of determining the element matching degree between the candidate page element and the target page element. The principle of locating the target page element from the transition candidate page element is the same as that of locating the target page element from the candidate page element.
[0116] For example, the element display information of N page elements in the page script is sequentially obtained, and the display information similarity between the display information of the located element and the element display information of the N page elements is determined. The transition candidate page elements are determined based on the display information similarity. For example, page elements with display information similarity greater than a certain threshold are selected as transition candidate page elements.
[0117] When determining the transition candidate page element through the element display information, the element matching information used to determine the element matching degree may include the element display information or may not include the element display information.
[0118] Optionally, if a candidate transition page element for the target page element is not located from the N page elements based on the positioning element display information, the target page element may be located using the positioning element size information of the target page element. For example, based on the positioning element size information, a candidate transition page element for the target page element may be located from the N page elements, and then an element matching degree between the candidate transition page element and the target page element may be determined, so that the target page element is located based on the element matching degree.
[0119] For example, the element size information of N page elements in the page script is sequentially obtained, and the size information similarity between the positioning element size information and the element size information of the N page elements is determined (for example, the size information similarity between the positioning element size information and the element size information of the N page elements is determined based on the difference between the length in the positioning element size information and the length in the element size information of the N page elements, and the difference between the width in the positioning element size information and the width in the element size information of the N page elements). The transition candidate page elements are determined based on the size information similarity. For example, page elements whose size information similarity is greater than a certain threshold are selected as transition candidate page elements.
[0120] When determining the transition candidate page element through element size information, the element matching information used to determine the element matching degree may include the element size information or may not include the element size information.
[0121] For example, Figure 5 As shown, Figure 5A schematic diagram of a process for determining candidate page elements provided by an embodiment of the present application; wherein, S51, when N page elements are obtained, the target page element is located among the N page elements by using the positioning element node path of the target page element; S52, if a page element whose element node path matches the positioning element node path of the target page element is located among the N page elements, the page element is used as the located target page element; S53, if a page element whose element node path matches the positioning element node path of the target page element is not located among the N page elements, the target page element is located among the N page elements by using the positioning element style information of the target page element; S54, if a page element whose element style information matches the positioning element style information of the target page element is located among the N page elements, the page element is used as the located target page element; S55, if the element node is not located among the N page elements If the element node path of the target page element matches the positioning element node path of the target page element, the path obtained by path rewriting the positioning element node path of the target page element is obtained to obtain the element node rewriting path of the target page element, and the target page element is located among the N page elements through the element node rewriting path of the target page element; S56, among the N page elements, the page element whose element node path is located and belongs to the element node rewriting path is used as a candidate page element of the target page element; S57, if the page element whose element node path belongs to the element node rewriting path is not located from the N page elements, the target page element is located among the N page elements through the positioning element display information of the target page element; S58, if the page element whose element display information matches the positioning element display information is located from the N page elements, the located page element is used as a transition candidate page element (that is, a candidate page element).
[0122] For example, Figure 6 As shown, Figure 6A schematic diagram of a process for determining element matching provided in an embodiment of the present application; wherein, S61, determining a first dimension matching degree 63a between a candidate page element and a target page element based on an element node path (reference element node path 61a) of the candidate page element and a positioning element node path 62a of the target page element; S62, determining a second dimension matching degree 66a between the candidate page element and the target page element based on element style information (reference element style information 64a) of the candidate page element and positioning element style information 65a of the target page element; S63, determining a second dimension matching degree 66a between the candidate page element and the target page element based on element display information of the candidate page element (reference element display information 67a) and the positioning element display information 68a of the target page element determine the third dimension matching degree 69a between the candidate page element and the target page element; S64, according to the element size information of the candidate page element (reference element size information 610a) and the positioning element size information 611a of the target page element, determine the fourth dimension matching degree 612a between the candidate page element and the target page element; S65, according to the first dimension matching degree, the second dimension matching degree, the third dimension matching degree, and the fourth dimension matching degree, determine the element matching degree 613a between the candidate page element and the target page element.
[0123] In an embodiment of the present application, the positioning element node path can be rewritten to obtain an element node rewriting path, and the positioning element node path belongs to the element node rewriting path, that is, the element node rewriting path is a higher-level path of the positioning element node path. If the positioning element node path can be understood as being used to accurately locate the target page element, then the element node rewriting path can be understood as being used to fuzzily locate the target page element, that is, one or more candidate page elements can be located through the element node rewriting path, and the candidate page elements may include the target page element. Therefore, the candidate page element can be located from N page elements through the element node rewriting path (the element node path of the candidate page element in the page script of the business page belongs to the element node rewriting path), so that the element matching degree between the candidate page element and the target page element can be determined, thereby determining the candidate page element that is most likely to be the target page element as the located target page element. Through the above method, the fuzzy positioning of page elements can be combined with the element node rewriting path, and the candidate page elements that are most likely to be the target page elements can be further screened out through element matching. In this way, even if the page elements change, it is more likely to locate the page elements that should be located, thereby improving the positioning accuracy of the page elements.
[0124] For further information, see Figure 7 , Figure 7 This is a page element positioning method provided by an embodiment of the present application, such as Figure 7 As shown, the method can be executed by the electronic device mentioned above, for example, Figure 1 The service server shown in FIG. 1 may include the following steps S201 to S209:
[0125] S201: Obtain a business page. The specific implementation of step S201 can be found in the relevant description of the above embodiment and will not be repeated here.
[0126] S202: Obtain element location information of the target page element to be located.
[0127] The element positioning information includes at least one of the following: positioning element style information and positioning element node path of the target page element.
[0128] S203: Locate the target page element from the N page elements based on the element location information of the target page element.
[0129] The target page element may be located by locating element style information and / or locating element node path.
[0130] It is understood that when a page element (such as page element A) whose element style information matches the located element style information is located from N page elements, the page element A can be used as the located target page element. Optionally, the page element A can be further verified.
[0131] For example, when the element node path of page element A in the page script is consistent with the positioning element node path, the page element A is determined to be the located target page element. Alternatively, when the element size information of page element A in the page script matches the positioning element size information of the target page element (for example, the element size information of page element A is consistent with the positioning element size information; or the difference between the length in the element size information of page element A in the page script and the length in the positioning element size information is less than a certain threshold, and the difference between the width in the element size information of page element A and the width in the positioning element size information is less than a certain threshold), the page element A is determined to be the located target page element. Alternatively, when the element display information of page element A in the page script matches the positioning element display information of the target page element, the page element A is determined to be the located target page element.
[0132] Similarly, when a page element (such as page element A) whose element node path matches the location element node path is located from N page elements, the page element A can be used as the located target page element. Optionally, the page element A can be further verified.
[0133] For example, when the element style information of page element A in the page script is consistent with the positioning element style information, the page element A is determined to be the located target page element. Alternatively, when the element size information of page element A in the page script matches the positioning element size information of the target page element (for example, the element size information of page element A is consistent with the positioning element size information; or the difference between the length in the element size information of page element A in the page script and the length in the positioning element size information is less than a certain threshold, and the difference between the width in the element size information of page element A in the page script and the width in the positioning element size information is less than a certain threshold), the page element A is determined to be the located target page element. Alternatively, when the element display information of page element A in the page script matches the positioning element display information of the target page element, the page element A is determined to be the located target page element.
[0134] Optionally, a positioning repetition condition timeout can also be set. For example, due to the large amount of data on the business page, it takes a certain amount of time to load the business page. Therefore, a positioning repetition condition can be set, and multiple positioning can be performed based on the positioning repetition condition. For example, when locating the element of the target page through an element positioning information, positioning can be performed every 3 seconds until it is repeated 5 times. For example, when locating through positioning element style information, positioning can be performed every 3 seconds until it is repeated 5 times. If the target page element is still not located, it is deemed that the target page element has not been located from the N page elements through the positioning element style information. It can be understood that the N page elements are the page elements currently loaded on the business page.
[0135] S204: If the target page element is not located from the N page elements, obtain the element node rewriting path of the target page element.
[0136] It can be understood that when the target page element is not located from N page elements through the positioning element style information and the positioning element node path, the positioning element node path of the target page element can be rewritten to obtain the element node rewriting path of the target page element.
[0137] The path rewriting process of the positioning element node path can refer to the relevant description of the above embodiment, which will not be repeated here.
[0138] S205 : Based on the element node rewriting path, a candidate page element of the target page element is located from the N page elements.
[0139] The element node path of the candidate page element belongs to the element node rewriting path.
[0140] Among them, any one of the N page elements is a page element to be compared. Locating the target page element can be by taking the element node path of the page element to be compared in the page script of the business page as the element node path to be compared; the page element to be compared is any one of N page elements; the element node path to be compared is used to indicate the node hierarchy relationship of the path node to be compared associated with the element node to be compared and the node mark of the path node to be compared; the path node to be compared is used to indicate the element node passed through when locating the element node to be compared, and the path node to be compared includes the element node to be compared; the element node to be compared is used to represent the page element to be compared; in the element node path to be compared, the node mark of the path node to be compared is removed to obtain the element node path to be compared that retains the node hierarchy relationship of the path node to be compared, and the element node path to be compared that retains the node hierarchy relationship of the path node to be compared is used as the node rewrite path to be compared; if the node rewrite path to be compared is the same as the element node rewrite path, the page element to be compared is used as the candidate page element located from the N page elements.
[0141] That is to say, the path of the element node path to be compared is rewritten. If the path rewriting result corresponding to the element node path to be compared is the same as the element node rewriting path, it means that the element node path to be compared belongs to the element node rewriting path, that is, the element node path to be compared is a candidate page element whose element node path located belongs to the element node rewriting path.
[0142] S206: If the candidate page element is not located among the N page elements, the located element display information of the target page element is obtained.
[0143] It can be understood that when any candidate page element is not located through the element node rewriting path, the page element can be located through the positioning element display information of the target page element.
[0144] S207: Locate a candidate page element of the target page element from the N page elements based on the positioning element display information.
[0145] The candidate page element located by the element node rewriting path may be referred to as a transition candidate page element, wherein the element display information of the transition candidate page element matches the located element display information.
[0146] Therefore, the element display information of N page elements can be extracted from the page script corresponding to the business page, and the display information similarity between the element display information of the N page elements and the positioning element display information can be determined in turn, and the transition page element whose element display information matches the positioning element display information can be selected based on the display information similarity.
[0147] S208: Determine the element matching degree between the candidate page element and the target page element.
[0148] The degree of element matching between the candidate page element and the target page element may be determined by one or more element matching information, which may include at least one of the following: element node path, element style information, element display information, and element size information.
[0149] Among them, when the element matching information includes the element node path, determining the element matching degree between the candidate page element and the target page element can be: obtaining the positioning element node path of the target page element; the positioning element node path is used to indicate the node tag of the target path node associated with the target element node; the target path node is used to indicate the element node passed through when locating the target element node; the target element node is used to characterize the target page element; the element node path of the candidate page element in the page script of the business page is used as the reference element node path; the reference element node path is used to indicate the node tag of the reference path node associated with the reference element node; the reference path node is used to indicate the element node passed through when locating the reference element node; the reference element node is used to characterize the candidate page element; based on the node tag association information between the node tag of the target path node and the node tag of the reference path node, determine the first dimension matching degree between the candidate page element and the target page element; determine the element matching degree based on the first dimension matching degree.
[0150] Among them, if the node tag association information indicates that the last node tag in the node tags of the target path node matches the last node tag in the node tags of the reference path node, then the first dimension matching degree is determined to be a first value (it can be understood that at this time, not all node identifiers except the last node identifier in the node tags of the target path node match the node tags of the reference path node); if the node tag association information indicates that the node tags of the target path node match the node tags of the reference path node, then the first dimension matching degree is determined to be a second value. The first value is less than the second value.
[0151] It can be understood that a match between a node identifier A and a node identifier B may mean that the value of the array information corresponding to the node identifier A is the same as the value of the array information corresponding to the node identifier B, and the node level at which the array information corresponding to the node identifier A is located is the same as the node level at which the array information corresponding to the node identifier B is located.
[0152] For example, the node labels of the target path nodes include [A1], [B1], and [C1]; the node labels of the reference path nodes include [A2], [B2], and [C2]; if [A1] does not have a matching node identifier in [A2], [B2], and [C2] (for example, the values in [A1] are different from those in [A2] and [B2], and the node level corresponding to [A1] is different from the node level corresponding to [C2]), and [C1] matches [C2] (for example, the values in [C1] and [C2] are the same, and the node levels corresponding to [C1] and [C2] are the same), then the first dimension matching degree is equal to the second dimension matching degree. A value (such as 5); if [A1] and [A2] match (for example, the values in [A1] and [A2] are the same, and the node levels corresponding to [A1] and [A2] are the same), [B1] and [B2] match (for example, the values in [B1] and [B2] are the same, and the node levels corresponding to [B1] and [B2] are the same), and [C1] and [C2] match (for example, the values in [C1] and [C2] are the same, and the node levels corresponding to [C1] and [C2] are the same), then the first dimension matching degree is equal to the second value (such as 10).
[0153] That is to say, when the node tag of the target path node and the node tag of the reference path node fully match, the first dimension matching degree is the second value; when they partially match, the first dimension matching degree is the first value. Among them, the full match of the node identifier means that all the node identifiers of the target path node are in the node tag of the reference path node, and there are matching node identifiers, and all the node identifiers of the reference path node are in the node tag of the target path node, and there are matching node identifiers. In other words, all the node identifiers of the target path node can be found in the node tag of the reference path node, and all the node identifiers of the reference path node can be found in the node tag of the target path node.
[0154] It can be understood that the above is explained by taking the example of matching node identifiers in the node identifier of the reference element node path according to the node identifier of the positioning element node path. It can also be that the node identifier is matched in the node identifier of the positioning element node path according to the node identifier of the reference element node path. The process and principle are the same as above (wherein, in the above two scenarios, full matching means that the node identifiers of the positioning element node path can all be found in the node identifier of the reference element node path, and the node identifiers of the reference element node path can all be found in the node identifier of the positioning element node path; partial matching means that the node identifier of the positioning element node path can be partially found in the node identifier of the reference element node path, or the node identifier of the reference element node path can be partially found in the node identifier of the positioning element node path).
[0155] For example, Figure 8 As shown, Figure 8 A schematic diagram of a dimension matching degree determination process provided for an embodiment of the present application; wherein, the positioning element node path is: abc / abm[A1] / abk[B1] / abj / abj[C1], and the node identifier 1 in the positioning element node path includes [A1], [B1], and [C1]; if the reference path node is abc / abm[A2] / abk[B2] / abj / abj[C2], then the node identifier 2 in the reference element node path includes [A2], [B2], and [C2].
[0156] Among them, if [A1] is [1], [B2] is [1], [C1] is [1], and [A2] is [2], [B2] is [2], and [C1] is [1], then the values of [A1] in node identifier 1 are different from those in [A2] and [B2], and the node level ("abm") corresponding to [A1] is different from the node level ("abj") corresponding to [C2], then [A1] does not have a matching node identifier in [A2], [B2], and [C2], and the values of [C1] in node identifier 1 and [C2] in node identifier 2 are the same, and the node level ("abj") corresponding to [C1] is the same as the node level ("abj") corresponding to [C2], then the partial match situation is satisfied (that is, [A1] does not match node identifier 2, and [C1] matches [C2]), so the first dimension matching degree is determined to be the first value.
[0157] Wherein, if [A1] is [1], [B2] is [1], [C1] is [2], and [A2] is [1], [B2] is [1], [C1] is [2], then the value of [A1] in node ID 1 is the same as the value of [A2] in node ID 2, and the node level ("abm") corresponding to [A1] is the same as the node level ("abm") corresponding to [A2], and the value of [B1] in node ID 1 is the same as the value of [B2] in node ID 2, and the value of [B1] corresponding to [B2] is the same. The node level ("abk") is the same as the node level ("abk") corresponding to [B2], and the values of [C1] in node identifier 1 and [C2] in node identifier 2 are the same, and the node level ("abj") corresponding to [C1] is the same as the node level ("abj") corresponding to [C2], which satisfies the full matching condition (i.e., [A1] matches [A2], [B1] matches [B2], and [C1] matches [C2]). Therefore, the first dimension matching degree is determined to be the second value.
[0158] Alternatively, the first dimension matching degree may be determined based on the number of matching node identifiers between the node tags of the target path node and the node tags of the reference path node. For example, the first dimension matching degree between the candidate page element and the target page element may be determined based on the correlation between the number of matching node identifiers indicated by the node tag association information and the matching degree.
[0159] Among them, when the element matching information includes element style information, determining the element matching degree between the candidate page element and the target page element can be: obtaining the positioning element style information of the target page element; the positioning element style information is used to indicate M1 positioning element style attributes associated with the target page element, that is, the element style attributes used to locate the target page element; M1 is a positive integer; the element style information of the candidate page element in the page script of the business page is used as the reference element style information; the reference element style information is used for M2 reference element style attributes associated with the candidate page element, that is, the current element style attributes of the candidate page element on the business page, which can be obtained from the page script; M2 is a positive integer; based on the style attribute association information between the M1 positioning element style attributes and the M2 reference element style attributes, determine the second dimension matching degree between the candidate page element and the target page element; determine the element matching degree based on the second dimension matching degree.
[0160] It is understood that the positioning element style information may specify one or more positioning element style attributes for locating the target page element, such as the font size, font format, font color, etc. of the target page element.
[0161] Similarly, the element style information of the candidate page element can be extracted from the page script of the business page, so that the element style attributes of the candidate page element can be obtained from the element style information of the candidate page element (refer to element style attributes).
[0162] Among them, if the style attribute association information indicates that the last positioning element style attribute among the M1 positioning element style attributes matches the last positioning element style attribute among the M2 reference element style attributes, then the second dimension matching degree is determined to be a third value (it can be understood that at this time, the positioning element style attributes other than the last positioning element style attribute among the M1 positioning element style attributes are not all matched with the M2 reference element style attributes); if the node mark association information indicates that the M1 positioning element style attributes match the M2 reference element style attributes (it can be understood that at this time, all positioning element style attributes in the M1 positioning element style attributes have the same element style attributes in the M2 reference element style attributes), then the second dimension matching degree is determined to be a fourth value. The third value is less than the fourth value. Optionally, the second dimension matching degree can also be determined based on the number of element style attributes matched between the M1 positioning element style attributes and the M2 reference element style attributes. For example, the second dimension matching degree between the candidate page element and the target page element is determined based on the correlation between the number of element style attributes matched by the node mark association information and the matching degree.
[0163] It can be understood that the above is explained by taking the example of attribute matching among M1 positioning element style attributes in M2 reference element style attributes (wherein, in this scenario, full matching means that all M1 positioning element style attributes can be found in M2 reference element style attributes; partial matching means that M1 positioning element style attributes can be partially found in M2 reference element style attributes). It can also be attribute matching among M1 positioning element style attributes based on M2 reference element style attributes, and the process and principle are the same as above (wherein, in this scenario, full matching means that all M2 reference element style attributes can be found in M1 positioning element style attributes; partial matching means that M2 reference element style attributes can be partially found in M1 positioning element style attributes).
[0164] It can be understood that an element style attribute A is the same as an element style attribute B, which means that the element style attribute A and the element style attribute B match.
[0165] That is to say, when the M1 positioned element style attributes and the M2 reference element style attributes fully match, the second dimension matching degree is the fourth value; when there is a partial match, the second dimension matching degree can be the third value, or it can be determined based on the number of matched element style attributes. Among them, the full match of element style attributes means that all element style attributes of the M1 positioned element style attributes are in the M2 reference element style attributes, and there are matching element style attributes, that is, all element style attributes of the M1 positioned element style attributes can be found in the M2 reference element style attributes.
[0166] For example, Figure 9 As shown, Figure 9 A schematic diagram of a dimension matching degree determination process provided for an embodiment of the present application; wherein, the M1 positioning element style attributes obtained from the positioning element style information include [Xa1], [Xa2], and [Xa3]; the M2 reference element style attributes obtained from the reference element style information include [Xb1], [Xb2], [Xb3], and [Xb4].
[0167] Among them, if [Xa1] is equal to [Xb1], [Xa2] is equal to [Xb2], [Xa3] is different from [Xb3] and [Xb4], then the partial match situation is satisfied (i.e., [Xa1] matches [Xb1], [Xa2] matches [Xb2], and [Xb3] does not match the reference element style attribute). Therefore, the second dimension matching degree is determined based on the number of matched element style attributes (number of attribute matches). For example, the matching degree corresponding to the ratio between the number of matched element style attributes and the number of M1 located element style attributes is used as the second dimension matching degree.
[0168] Among them, if [Xa1] is equal to [Xb1], [Xa2] is equal to [Xb2], and [Xa3] is the same as [Xb3], then the full matching situation is satisfied (that is, [Xa1] matches [Xb1], [Xa2] matches [Xb2], and [Xb3] matches [Xb3]), so the second dimension matching degree is determined to be the fourth value.
[0169] Wherein, when the element matching information includes element display information, determining the element matching degree between the candidate page element and the target page element may include: obtaining the positioning element display information of the target page element; using the element display information of the candidate page element in the page script of the business page as reference element display information; determining the third dimension matching degree between the candidate page element and the target page element based on display association information between the positioning element display information and the reference element display information; and determining the element matching degree based on the third dimension matching degree. Wherein, the element display information of the candidate page element may be extracted from the page script of the business page.
[0170] The display information similarity between the positioning element display information and the reference element display information can be determined, and the display information similarity can be used as the display association information between the positioning element display information and the reference element display information. The matching degree corresponding to the display association information can be determined based on the correlation relationship between the display association information and the matching degree, as the third dimension matching degree.
[0171] For example, Figure 10 As shown, Figure 10A schematic diagram of a dimensional matching degree determination process provided for an embodiment of the present application; wherein, positioning element display information of a target page element (such as text Y) is obtained, and element display information (reference element display information) of a candidate page element is obtained in a page script. For example, the reference element display information is text X, and text X is the information displayed on the candidate page element in the business page. The text similarity between text X and text Y is determined as display association information between the positioning element display information and the reference element display information. Based on the association relationship between the display association information and the matching degree, the third dimensional matching degree between the candidate page element and the target page element is determined.
[0172] When the element matching information includes element size information, determining the element matching degree between the candidate page element and the target page element may include: obtaining the positioning element size information of the target page element; using the element size information of the candidate page element in the page script of the business page as reference element size information; determining the fourth dimension matching degree between the candidate page element and the target page element based on the size association information between the positioning element size information and the reference element size information; and determining the element matching degree based on the fourth dimension matching degree. The element display information of the candidate page element may be extracted from the page script of the business page.
[0173] The similarity between the size information of the positioning element and the size information of the reference element can be determined, and the size information similarity can be used as the size association information between the positioning element display information and the reference element display information. The matching degree corresponding to the size association information can be determined based on the correlation between the size association information and the matching degree as the fourth dimension matching degree.
[0174] The size information similarity may be a length difference between the length in the positioning element size information and the length in the reference element size information, or a width difference between the width in the positioning element size information and the width in the reference element size information.
[0175] For example, Figure 11 As shown, Figure 11A schematic diagram of a dimension matching determination process provided for an embodiment of the present application; wherein, the positioning element size information of the target page element is obtained (such as length H1 and width W1), and the reference element size information of the candidate page element is obtained in the page script (such as length H2 and width W2), the length difference between the length H1 and the length H2 and the width difference between the width W1 and the width W2 are determined, the width difference and the length difference are used as the size information similarity, and the size information similarity is used as the size association information between the positioning element display information and the reference element display information, and the fourth dimension matching between the candidate page element and the target page element is determined based on the association relationship between the size association information and the matching degree.
[0176] S209: Locate the target page element from the candidate page elements based on the element matching degree.
[0177] The candidate page elements may be sorted in descending order of element matching, and the candidate page element with the highest element matching degree is selected from the sorted candidate page elements as the located target page element.
[0178] Therefore, the present application solution can be applied to the automatic positioning scenario of page elements, and by providing more positioning information (such as positioning element style information, positioning element node path, element node rewriting path, positioning element display information, positioning element size information, etc.), it can achieve enhanced positioning of target page elements and improve the accuracy of page element positioning, thereby solving the problem of unstable page element positioning during page automation testing, improving the success rate of page automation testing, and providing reliable page automation testing services.
[0179] For example, Figure 12 As shown, Figure 12A schematic diagram of a process for locating a page element provided in an embodiment of the present application; wherein, S121, element-related information of a target page element to be located is input; the element-related information includes positioning element style information, positioning element node path, element node rewriting path, positioning element display information, and positioning element size information; S122, firstly positioning the target page element according to the positioning element node path; if the target page element is located among N page elements, subsequent business processing is performed on the located target page element (such as clicking the target page element); S123, if the target page element is not located among N page elements, the target page element is positioned according to the positioning element style information. Positioning; if the target page element is located among N page elements, subsequent business processing is performed on the located target page element (such as clicking the target page element); S124, if the target page element is not located among the N page elements, the target page element is located according to the element node rewriting path; if the candidate page element of the target page element is located among the N page elements, the element matching of the candidate page element is waited for; S125, if the target page element is not located among the N page elements, the target page element is located according to the positioning element display information; if the candidate page element of the target page element is located among the N page elements, the element matching of the candidate page element is waited for.
[0180] Among them, the element matching of the candidate page element is as follows: S126, determining the matching degree 1 between the candidate page element and the target page element according to the element size information, that is, determining the matching degree 1 between the candidate page element and the target page element through the reference element size information of the candidate page element and the positioning element size information of the target page element; S127, determining the matching degree 2 between the candidate page element and the target page element according to the element display information, that is, determining the matching degree 2 between the candidate page element and the target page element through the reference element display information of the candidate page element and the positioning element display information of the target page element; S128, determining the matching degree 3 between the candidate page element and the target page element according to the element style information, That is, the matching degree 3 between the candidate page element and the target page element is determined by the reference element style information of the candidate page element and the positioning element style information of the target page element; S129, the matching degree 4 between the candidate page element and the target page element is determined according to the element node path, that is, the matching degree 4 between the candidate page element and the target page element is determined by the reference element node path of the candidate page element and the positioning element node path of the target page element; S1210, the element matching degree between the candidate page element and the target page element is determined according to the matching degree 1-4; S1211, the candidate page elements are sorted according to the element matching degree; S1212, the target page element is determined from the sorted candidate page elements.
[0181] For example, Figure 13 As shown, Figure 13 A schematic diagram of a scenario for positioning page elements provided in an embodiment of the present application; wherein a business page such as Figure 13 As shown in 131a, the business page 131a includes multiple page elements, such as page controls (such as "Create" control 131b, "Confirm" control 132b, and "Cancel" control 133b), text input boxes (such as text box 134b displaying "Please enter a title", and text box 135b displaying "Please enter" for the processor), etc.; for example, the target page element's positioning element node path xpath1 = ' / html / body / div
[10] / div / div / div / div / ul[2] / div / div[1] / div[1] / li', at this time, if any page element is not located among the N page elements by positioning the element node path, the positioning element node path xpath1 can be rewritten to obtain the element node rewriting path xpath2 = ' / html / body / div / div / div / div / div / ul / div / div / div / li'.
[0182] Among them, the code for path rewriting is:
[0183] var reg= / \[\d+\] / g
[0184] var xpathStrModifyStr=xpathStr.replace(reg,”)
[0185] / / In other words, remove the array information "[\d+\]" in the element node path xpath1 to obtain the element node rewriting path xpath2.
[0186] Among them, the candidate page element (page elements 131b, 132b, 133b) is located among the above-mentioned multiple page elements (such as 131b-135b) through the element node rewriting path. It can be understood that the path rewriting result corresponding to the element node path of the candidate page element in the page script is equal to xpath2.
[0187] At this time, the element matching degrees 1-3 between the page elements 131b, 132b, and 133b and the target page element can be determined, so as to sort the page elements 131b, 132b, and 133b and determine the target page element. For example, the page element 131b is determined to be the target page element from the page elements 131b, 132b, and 133b.
[0188] For example, Figure 14 As shown, Figure 14A schematic diagram of a scenario for positioning page elements provided in an embodiment of the present application; wherein a business page such as Figure 13 As shown in 131a; for example, the element style information of the page element on the business page in the page script is obtained, and the element style attributes are extracted from the element style information. For example, the element style attributes (that is, the class attribute value) of the page element on the business page can be obtained through the attribute acquisition statement "element.getAttribute('class')"; and the positioning element style attributes of the target page element can be obtained from the positioning element style information of the target page element.
[0189] For example, positioning element style information A = 'button.t-button.t-size-mt-button--variant-base.t-button--theme-primary'; positioning element style attribute B = 't-button t-size-m t-button--variant-base t-button--theme-primary' is extracted from positioning element style information A through the above attribute acquisition statement.
[0190] Similarly, when obtaining the reference element style information of the page elements on the business page from the page script, the reference element style attributes are extracted from the reference element style information according to the above-mentioned attribute acquisition statement, and the positioning element style attributes and the reference element style attributes are matched, such as determining the number of matched style attributes between the positioning element style attributes and the reference element style attributes to determine the element matching degree.
[0191] Among them, the code of the attribute acquisition statement is:
[0192] var selectorStrModifyStr=selectorStr.replaceAll('>',").replaceAll('.',")
[0193] const targetClassArr=selectorStrModifyStr.split(”)
[0194] const elementClassArr=elCls.split(”)
[0195] / / That is, delete the '>' in the element style information and replace the '.' with a space to obtain multiple element style attributes extracted from the element style information.
[0196] For example, the reference element style attribute C = 't-button--variant-base t-button--theme-primary' is extracted from the element style information of page element 131b in the page script as a candidate page element. The number of matching style attributes between the positioning element style attribute B and the reference element style attribute C is determined (e.g., "t-button--variant-base" in B is the same as "t-button--variant-base" in C, and "t-button--theme-primary" in B is the same as "t-button--theme-primary" in C, so the number of matching style attributes is 2). The degree of element matching between page element 131b and the target page element is then determined. In other words, it is determined whether the style attributes in the reference element style attribute C can be found in the positioning element style attribute B.
[0197] In an embodiment of the present application, the target page element can be first accurately located among N page elements through the element location information of the target page element, and when the target page element is not located, the location element node path can be rewritten to obtain the element node rewriting path, and the location element node path belongs to the element node rewriting path, that is, the element node rewriting path is a higher-level path of the location element node path. If the location element node path can be understood as being used to accurately locate the target page element, then the element node rewriting path can be understood as being used to fuzzily locate the target page element, that is, one or more candidate page elements can be located through the element node rewriting path, and the candidate page element may include the target page element. Optionally, if the candidate page element is not located through the element node rewriting path, the candidate page element can be located through the location element display information of the target page element. Therefore, the candidate page element can be located from N page elements through a variety of positioning information (such as element node rewriting path, positioning element display information), so that the element matching degree between the candidate page element and the target page element can be determined, thereby determining the candidate page element that is most likely to be the target page element (the element node path of the candidate page element in the page script of the business page belongs to the element node rewriting path) as the located target page element. Through the above method, the fuzzy positioning of the page element can be combined with the element node rewriting path and the positioning element display information, and the candidate page element that is most likely to be the target page element can be further screened out through the element matching degree. In this way, even if the page element changes, the positioning of the specified page element can be achieved through a variety of positioning information (such as element positioning information, element node rewriting path, positioning element display information), thereby making it more likely to locate the page element to be located, thereby improving the positioning accuracy of the page element.
[0198] For further information, see Figure 15 , Figure 15 This is a schematic diagram of the structure of a page element positioning device provided by an embodiment of the present application. Figure 15 As shown, the page element positioning device 1 can be applied to an electronic device, for example, the electronic device can be the above-mentioned Figure 1 The business server in the corresponding embodiment. It should be understood that the page element positioning device 1 can be a computer program (including program code) running in an electronic device, for example, the page element positioning device 1 can be an application software; it can be understood that the page element positioning device 1 can be used to execute the corresponding steps in the method provided in the embodiment of the present application. Figure 15 As shown, the page element positioning device 1 may include: a page acquisition module 11, an element positioning module 12, and an element matching module 13; wherein:
[0199] The page acquisition module 11 is used to acquire a business page; the business page includes N page elements; N is a positive integer;
[0200] The element locating module 12 is used to obtain the element node rewriting path of the target page element to be located; the element node rewriting path is the path obtained by rewriting the locating element node path of the target page element; the locating element node path belongs to the element node rewriting path;
[0201] The element locating module 12 is further configured to locate a candidate page element of the target page element from the N page elements based on the element node rewriting path; the element node path of the candidate page element belongs to the element node rewriting path;
[0202] An element matching module 13 is used to determine the element matching degree between the candidate page element and the target page element;
[0203] The element matching module 13 is used to locate the target page element from the candidate page elements based on the element matching degree.
[0204] The element locating module 12 is used to locate candidate page elements of the target page element from N page elements based on the element node rewriting path, specifically to:
[0205] If the target page element is not located from N page elements based on the element positioning information of the target page element, the candidate page element of the target page element is located from N page elements based on the element node rewriting path; the element positioning information includes at least one of the following: the positioning element style information of the target page element and the positioning element node path.
[0206] The positioning element node path is used to indicate the node hierarchical relationship of the target path node associated with the target element node and the node label of the target path node; the target path node is used to indicate the element node passed through when locating the target element node; the target element node is used to represent the target page element;
[0207] When the element locating module 12 is used to obtain the element node rewriting path of the target page element to be located, it is specifically used to:
[0208] In the positioning element node path, the node mark of the target path node is removed to obtain the positioning element node path that retains the node hierarchical relationship of the target path node;
[0209] The positioning element node path that retains the node hierarchy relationship of the target path node is used as the element node rewriting path.
[0210] The element locating module 12 is used to locate candidate page elements of the target page element from N page elements based on the element node rewriting path, specifically to:
[0211] The element node path of the page element to be compared in the page script of the business page is used as the element node path to be compared; the page element to be compared is any one of the N page elements; the element node path to be compared is used to indicate the node hierarchical relationship of the path nodes to be compared associated with the element node to be compared and the node label of the path node to be compared; the path node to be compared is used to indicate the element node passed through when locating the element node to be compared; the element node to be compared is used to represent the page element to be compared;
[0212] In the element node path to be compared, the node mark of the path node to be compared is removed to obtain the element node path to be compared that retains the node hierarchical relationship of the path node to be compared, and the element node path to be compared that retains the node hierarchical relationship of the path node to be compared is used as the node rewriting path to be compared;
[0213] If the rewriting path of the node to be compared is the same as the rewriting path of the element node, the page element to be compared is used as the candidate page element located from the N page elements.
[0214] The element matching module 13 is specifically used to determine the element matching degree between the candidate page element and the target page element:
[0215] Obtaining the positioning element node path of the target page element; the positioning element node path is used to indicate the node tag of the target path node associated with the target element node; the target path node is used to indicate the element node passed through when locating the target element node; the target element node is used to represent the target page element;
[0216] The element node path of the candidate page element in the page script of the business page is used as the reference element node path; the reference element node path is used to indicate the node tag of the reference path node associated with the reference element node; the reference path node is used to indicate the element node passed through when locating the reference element node; the reference element node is used to represent the candidate page element;
[0217] Determining a first dimension matching degree between the candidate page element and the target page element based on node tag association information between the node tag of the target path node and the node tag of the reference path node;
[0218] The element matching degree is determined based on the first dimension matching degree.
[0219] The element matching module 13 is specifically used to determine the element matching degree between the candidate page element and the target page element:
[0220] Get the positioning element style information of the target page element; the positioning element style information is used to indicate M1 positioning element style attributes associated with the target page element; M1 is a positive integer;
[0221] The element style information of the candidate page element in the page script of the business page is used as the reference element style information; the reference element style information is used for M2 reference element style attributes associated with the candidate page element; M2 is a positive integer;
[0222] Determining a second dimension matching degree between the candidate page element and the target page element based on style attribute association information between the M1 positioning element style attributes and the M2 reference element style attributes;
[0223] The element matching degree is determined based on the second dimension matching degree.
[0224] The element matching module 13 is specifically used to determine the element matching degree between the candidate page element and the target page element:
[0225] Get the positioning element display information of the target page element;
[0226] The element display information of the candidate page element in the page script of the business page is used as the reference element display information;
[0227] Determining a third dimension matching degree between the candidate page element and the target page element based on display association information between the positioning element display information and the reference element display information;
[0228] The element matching is determined based on the third dimension matching.
[0229] The element matching module 13 is specifically used to determine the element matching degree between the candidate page element and the target page element:
[0230] Get the positioning element size information of the target page element;
[0231] Using element size information of the candidate page element in the page script of the business page as reference element size information;
[0232] Determining a fourth dimension matching degree between the candidate page element and the target page element based on size association information between the positioning element size information and the reference element size information;
[0233] The element matching is determined based on the fourth dimension matching.
[0234] The element matching module 13 is further configured to:
[0235] If the candidate page element of the target page element is not located among the N page elements based on the element node rewriting path, the located element display information of the target page element is obtained;
[0236] Based on the positioning element display information, a transition candidate page element of the target page element is located from the N page elements; the element display information of the transition candidate page element matches the positioning element display information;
[0237] A transition element matching degree between the transition candidate page element and the target page element is determined, and based on the transition element matching degree, the target page element is located from the transition candidate page elements.
[0238] The specific implementation of the page acquisition module 11, the element positioning module 12, and the element matching module 13 can be found in the relevant descriptions of the above embodiments, and will not be further described here. It should be understood that the description of the beneficial effects obtained by adopting the same method will not be repeated.
[0239] In the embodiments of the present application, the term "module" or "unit" refers to a computer program or a part of a computer program that has a predetermined function and works together with other related parts to achieve a predetermined goal, and can be implemented in whole or in part by using software, hardware (such as processing circuits or memories) or a combination thereof. Similarly, a processor (or multiple processors or memories) can be used to implement one or more modules or units. In addition, each module or unit can be part of an overall module or unit that includes the function of the module or unit.
[0240] According to one embodiment of the present application, Figure 15The various modules in the page element positioning device shown can be separately or all merged into one or several other modules to constitute, or one (some) of the modules can also be split into multiple smaller modules in function to constitute, which can achieve the same operation without affecting the realization of the technical effects of the embodiments of the present application. The above modules are divided based on logical functions. In actual applications, the functions of one module can also be implemented by multiple modules, or the functions of multiple modules can be implemented by one module. In other embodiments of the present application, the page element positioning device can also include other modules. In actual applications, these functions can also be implemented with the assistance of other modules, and can be implemented by the collaboration of multiple modules.
[0241] According to another embodiment of the present application, the program can be executed by running on a general computing device such as a computer including a central processing unit (CPU), a random access memory (RAM), a read-only memory (ROM) and other processing elements and storage elements. Figure 4 and Figure 7 A computer program (including program code) for each step of the corresponding method shown in FIG. Figure 15 The page element positioning device shown in and the page element positioning method of the embodiment of the present application are implemented. The computer program can be recorded on a computer readable recording medium, for example, and loaded into the above-mentioned computing device through the computer readable recording medium and run therein.
[0242] In an embodiment of the present application, the page acquisition module acquires the business page; the element positioning module acquires the element node rewriting path of the target page element to be located; the element positioning module locates the candidate page element of the target page element from N page elements based on the element node rewriting path; the element matching module determines the element matching degree between the candidate page element and the target page element; the element matching module locates the target page element from the candidate page elements based on the element matching degree. In this way, the fuzzy positioning of the page element can be performed in combination with the element node rewriting path, and the candidate page element that is most likely to be the target page element can be further screened out through the element matching degree. In this way, even if the page element changes, it is more likely to locate the page element to be located, thereby improving the positioning accuracy of the page element.
[0243] The functional modules in each embodiment of the present application may be integrated into one module, or each module may exist physically separately, or two or more modules may be integrated into one module. The above-mentioned integrated modules may be implemented in the form of hardware or software functional modules, which is not limited in this application.
[0244] Further, see Figure 16 , Figure 16This is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. Figure 16 As shown, the electronic device 1500 can be a user terminal or a server, without limitation. For ease of understanding, this application uses the electronic device as a server as an example. The electronic device 1500 may include at least one processor 1501 and a memory 1502. Optionally, the electronic device may also include a user interface, at least one communication bus, and a network interface. The communication bus is used to enable communication between these components.
[0245] The user interface may also include a standard wired interface or a wireless interface. The network interface may optionally include a standard wired interface or a wireless interface (such as a Wi-Fi interface). Memory 1502 may include volatile memory, such as random-access memory (RAM); non-volatile memory, such as flash memory or a solid-state drive (SSD); or a combination of two or more of the aforementioned types of memory. Memory 1502 may optionally be at least one storage device located remote from the processor 1501. Memory 1502, as a computer-readable storage medium, may include an operating system, a network communication module, a user interface module, and a device control application. Processor 1501 may be a central processing unit (CPU). In one embodiment, processor 1501 may also be a graphics processing unit (GPU). Processor 1501 may also be a combination of a CPU and a GPU.
[0246] The network interface in the electronic device 1500 can also provide network communication functions. The user interface is mainly used to provide an input interface for the user; and the processor 1501 can be used to call the device control application stored in the memory 1502 to execute the above Figure 4 and Figure 7 The description of the page element positioning method in the corresponding embodiment can also be performed Figure 15 The description of the page element positioning device (ie, the above-mentioned page element positioning device 1) in the corresponding embodiment will not be repeated here. In addition, the description of the beneficial effects of adopting the same method will not be repeated here either.
[0247] In one possible implementation, the memory 1502 is used to store program instructions. The processor 1501 may call the program instructions to perform the following steps:
[0248] Get the business page; the business page includes N page elements; N is a positive integer;
[0249] Obtaining the element node rewriting path of the target page element to be located; the element node rewriting path is a path obtained by rewriting the positioning element node path of the target page element; the positioning element node path belongs to the element node rewriting path;
[0250] Based on the element node rewriting path, a candidate page element of the target page element is located from N page elements; the element node path of the candidate page element belongs to the element node rewriting path;
[0251] Determining element matching between candidate page elements and target page elements;
[0252] Based on the element matching degree, the target page element is located from the candidate page elements.
[0253] The processor 1501, when used to rewrite the path based on the element node and locate the candidate page element of the target page element from N page elements, is specifically used to:
[0254] If the target page element is not located from N page elements based on the element positioning information of the target page element, the candidate page element of the target page element is located from N page elements based on the element node rewriting path; the element positioning information includes at least one of the following: the positioning element style information of the target page element and the positioning element node path.
[0255] The positioning element node path is used to indicate the node hierarchical relationship of the target path node associated with the target element node and the node label of the target path node; the target path node is used to indicate the element node passed through when locating the target element node; the target element node is used to represent the target page element;
[0256] When the processor 1501 is used to obtain the element node rewriting path of the target page element to be located, it is specifically used to:
[0257] In the positioning element node path, the node mark of the target path node is removed to obtain the positioning element node path that retains the node hierarchical relationship of the target path node;
[0258] The positioning element node path that retains the node hierarchy relationship of the target path node is used as the element node rewriting path.
[0259] The processor 1501, when used to rewrite the path based on the element node and locate the candidate page element of the target page element from N page elements, is specifically used to:
[0260] The element node path of the page element to be compared in the page script of the business page is used as the element node path to be compared; the page element to be compared is any one of the N page elements; the element node path to be compared is used to indicate the node hierarchical relationship of the path nodes to be compared associated with the element node to be compared and the node label of the path node to be compared; the path node to be compared is used to indicate the element node passed through when locating the element node to be compared; the element node to be compared is used to represent the page element to be compared;
[0261] In the element node path to be compared, the node mark of the path node to be compared is removed to obtain the element node path to be compared that retains the node hierarchical relationship of the path node to be compared, and the element node path to be compared that retains the node hierarchical relationship of the path node to be compared is used as the node rewriting path to be compared;
[0262] If the rewriting path of the node to be compared is the same as the rewriting path of the element node, the page element to be compared is used as the candidate page element located from the N page elements.
[0263] When determining the element matching degree between the candidate page element and the target page element, the processor 1501 is specifically configured to:
[0264] Obtaining the positioning element node path of the target page element; the positioning element node path is used to indicate the node tag of the target path node associated with the target element node; the target path node is used to indicate the element node passed through when locating the target element node; the target element node is used to represent the target page element;
[0265] The element node path of the candidate page element in the page script of the business page is used as the reference element node path; the reference element node path is used to indicate the node tag of the reference path node associated with the reference element node; the reference path node is used to indicate the element node passed through when locating the reference element node; the reference element node is used to represent the candidate page element;
[0266] Determining a first dimension matching degree between the candidate page element and the target page element based on node tag association information between the node tag of the target path node and the node tag of the reference path node;
[0267] The element matching degree is determined based on the first dimension matching degree.
[0268] When determining the element matching degree between the candidate page element and the target page element, the processor 1501 is specifically configured to:
[0269] Get the positioning element style information of the target page element; the positioning element style information is used to indicate M1 positioning element style attributes associated with the target page element; M1 is a positive integer;
[0270] The element style information of the candidate page element in the page script of the business page is used as the reference element style information; the reference element style information is used for M2 reference element style attributes associated with the candidate page element; M2 is a positive integer;
[0271] Determining a second dimension matching degree between the candidate page element and the target page element based on style attribute association information between the M1 positioning element style attributes and the M2 reference element style attributes;
[0272] The element matching degree is determined based on the second dimension matching degree.
[0273] When determining the element matching degree between the candidate page element and the target page element, the processor 1501 is specifically configured to:
[0274] Get the positioning element display information of the target page element;
[0275] The element display information of the candidate page element in the page script of the business page is used as the reference element display information;
[0276] Determining a third dimension matching degree between the candidate page element and the target page element based on display association information between the positioning element display information and the reference element display information;
[0277] The element matching is determined based on the third dimension matching.
[0278] When determining the element matching degree between the candidate page element and the target page element, the processor 1501 is specifically configured to:
[0279] Get the positioning element size information of the target page element;
[0280] Using element size information of the candidate page element in the page script of the business page as reference element size information;
[0281] Determining a fourth dimension matching degree between the candidate page element and the target page element based on size association information between the positioning element size information and the reference element size information;
[0282] The element matching is determined based on the fourth dimension matching.
[0283] The processor 1501 is further configured to:
[0284] If the candidate page element of the target page element is not located among the N page elements based on the element node rewriting path, the located element display information of the target page element is obtained;
[0285] Based on the positioning element display information, a transition candidate page element of the target page element is located from the N page elements; the element display information of the transition candidate page element matches the positioning element display information;
[0286] A transition element matching degree between the transition candidate page element and the target page element is determined, and based on the transition element matching degree, the target page element is located from the transition candidate page elements.
[0287] In specific implementations, the devices, processors, memories, etc. described in the embodiments of this application can execute the implementation methods described in the above method embodiments, and can also execute the implementation methods described in the embodiments of this application, which will not be repeated here.
[0288] In addition, it should be pointed out that: the embodiment of the present application also provides a computer-readable storage medium, and the computer-readable storage medium stores a computer program executed by the page element positioning device 1 mentioned above, and the computer program includes program instructions. When the processor executes the program instructions, it can execute the above-mentioned Figure 4 、 Figure 7 The description of the page element positioning method in the corresponding embodiment will not be repeated here. In addition, the description of the beneficial effects of adopting the same method will not be repeated. For technical details not disclosed in the computer-readable storage medium embodiment involved in this application, please refer to the description of the method embodiment of this application. As an example, the program instructions can be deployed on a computing device for execution, or on multiple computing devices located in one location, or on multiple computing devices distributed in multiple locations and interconnected by a communication network. Multiple computing devices distributed in multiple locations and interconnected by a communication network can constitute a blockchain system.
[0289] In addition, it should be noted that: the embodiment of the present application also provides a computer program product, the computer program product includes a computer program, the computer program includes program instructions, and the program instructions can be stored in a computer-readable storage medium. The processor of the electronic device reads the program instructions from the computer-readable storage medium, and the processor can execute the program instructions, so that the electronic device performs the above Figure 4 、 Figure 7 The description of the page element positioning method in the corresponding embodiment will not be repeated here. In addition, the description of the beneficial effects of using the same method will not be repeated here. For technical details not disclosed in the computer program product or computer program embodiments involved in this application, please refer to the description of the method embodiments of this application.
[0290] It should be noted that for the aforementioned various method embodiments, for the sake of simplicity, they are all expressed as a series of action combinations, but those skilled in the art should be aware that this application is not limited by the order of the actions described, because according to this application, some steps can be performed in other orders or simultaneously. Secondly, those skilled in the art should also be aware that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by this application.
[0291] The steps in the method of the embodiment of the present application can be adjusted in order, combined and deleted according to actual needs.
[0292] The modules in the device of the embodiment of the present application can be merged, divided and deleted according to actual needs.
[0293] Those skilled in the art will appreciate that all or part of the processes in the above-described method embodiments can be implemented by instructing related hardware through a computer program. The computer program can be stored in a computer-readable storage medium. When executed, the program can include the processes in the above-described method embodiments. The storage medium can be a magnetic disk, an optical disk, a read-only memory (ROM), or a random access memory (RAM).
[0294] The above disclosure is only a preferred embodiment of the present application, and certainly cannot be used to limit the scope of rights of the present application. Therefore, equivalent changes made according to the claims of the present application are still within the scope covered by the present application.
Claims
1. A page element positioning method, characterized in that: The method comprises: Obtain a business page; the business page includes N page elements; N is a positive integer; Obtaining an element node rewriting path of a target page element to be located; the element node rewriting path is a path obtained by rewriting the locating element node path of the target page element; the locating element node path belongs to the element node rewriting path; Based on the element node rewriting path, locating a candidate page element of the target page element from the N page elements; the element node path of the candidate page element belongs to the element node rewriting path; Determining an element matching degree between the candidate page element and the target page element; Based on the element matching degree, the target page element is located from the candidate page elements.
2. The method according to claim 1, characterized in that The step of rewriting the path of the element node and locating a candidate page element of the target page element from the N page elements includes: If the target page element is not located from the N page elements based on the element positioning information of the target page element, then based on the element node rewriting path, a candidate page element of the target page element is located from the N page elements; the element positioning information includes at least one of the following: the positioning element style information of the target page element and the positioning element node path.
3. The method according to claim 1, characterized in that The positioning element node path is used to indicate the node hierarchical relationship of the target path node associated with the target element node and the node label of the target path node; the target path node is used to indicate the element node passed through when locating the target element node; The target element node is used to represent the target page element; The obtaining of the element node rewriting path of the target page element to be located includes: In the positioning element node path, removing the node mark of the target path node, to obtain a positioning element node path that retains the node hierarchical relationship of the target path node; The positioning element node path that retains the node hierarchy relationship of the target path node is used as the element node rewriting path.
4. The method according to claim 3, characterized in that The step of rewriting the path of the element node and locating a candidate page element of the target page element from the N page elements includes: The element node path of the page element to be compared in the page script of the business page is used as the element node path to be compared; the page element to be compared is any one of the N page elements; the element node path to be compared is used to indicate the node hierarchical relationship of the path nodes to be compared associated with the element node to be compared and the node label of the path node to be compared; the path node to be compared is used to indicate the element node passed through when locating the element node to be compared; the element node to be compared is used to represent the page element to be compared; In the element node path to be compared, the node mark of the path node to be compared is removed to obtain the element node path to be compared that retains the node hierarchical relationship of the path node to be compared, and the element node path to be compared that retains the node hierarchical relationship of the path node to be compared is used as the node rewriting path to be compared; If the rewriting path of the node to be compared is the same as the rewriting path of the element node, the page element to be compared is used as the candidate page element located from the N page elements.
5. The method according to claim 1, wherein Determining the element matching degree between the candidate page element and the target page element includes: Obtaining a positioning element node path of the target page element; the positioning element node path is used to indicate a node tag of a target path node associated with a target element node; the target path node is used to indicate an element node passed through when locating the target element node; the target element node is used to represent the target page element; The element node path of the candidate page element in the page script of the business page is used as a reference element node path; the reference element node path is used to indicate a node tag of a reference path node associated with a reference element node; the reference path node is used to indicate an element node passed through when locating the reference element node; the reference element node is used to represent the candidate page element; Determining a first dimension matching degree between the candidate page element and the target page element based on node tag association information between the node tag of the target path node and the node tag of the reference path node; The element matching degree is determined based on the first dimension matching degree.
6. The method according to claim 1, characterized in that Determining the element matching degree between the candidate page element and the target page element includes: Acquire the positioning element style information of the target page element; the positioning element style information is used to indicate M1 positioning element style attributes associated with the target page element; M1 is a positive integer; The element style information of the candidate page element in the page script of the business page is used as reference element style information; the reference element style information is used for M2 reference element style attributes associated with the candidate page element; M2 is a positive integer; Determining a second dimension matching degree between the candidate page element and the target page element based on style attribute association information between the M1 positioning element style attributes and the M2 reference element style attributes; The element matching degree is determined based on the second dimension matching degree.
7. The method according to claim 1, characterized in that Determining the element matching degree between the candidate page element and the target page element includes: Obtaining the positioning element display information of the target page element; Using the element display information of the candidate page element in the page script of the business page as reference element display information; determining a third dimension matching degree between the candidate page element and the target page element based on display association information between the positioning element display information and the reference element display information; The element matching degree is determined based on the third dimension matching degree.
8. The method according to claim 1, characterized in that Determining the element matching degree between the candidate page element and the target page element includes: Obtaining the size information of the positioning element of the target page element; Using element size information of the candidate page element in the page script of the business page as reference element size information; determining a fourth dimension matching degree between the candidate page element and the target page element based on size association information between the positioning element size information and the reference element size information; The element matching degree is determined based on the fourth dimension matching degree.
9. The method according to claim 1, characterized in that The method further comprises: If, based on the element node rewriting path, no candidate page element of the target page element is located from the N page elements, then obtaining the located element display information of the target page element; Based on the positioning element display information, locating a transition candidate page element of the target page element from the N page elements; the element display information of the transition candidate page element matches the positioning element display information; A transition element matching degree between the transition candidate page element and the target page element is determined, and based on the transition element matching degree, the target page element is located from the transition candidate page elements.
10. A page element positioning device, characterized in that: The device comprises: The page acquisition module is used to acquire a business page; the business page includes N page elements; N is a positive integer; An element locating module, configured to obtain an element node rewriting path of a target page element to be located; the element node rewriting path is a path obtained by rewriting the locating element node path of the target page element; the locating element node path belongs to the element node rewriting path; The element locating module is further configured to locate a candidate page element of the target page element from the N page elements based on the element node rewriting path; the element node path of the candidate page element belongs to the element node rewriting path; An element matching module, configured to determine an element matching degree between the candidate page element and the target page element; The element matching module is configured to locate the target page element from the candidate page elements based on the element matching degree.
11. An electronic device, characterized in that: The method comprises a processor and a memory, wherein the memory is used to store a computer program, the computer program includes program instructions, and the processor is configured to call the program instructions to execute the method according to any one of claims 1 to 9.
12. A computer-readable storage medium, characterized in that The computer-readable storage medium stores a computer program, wherein the computer program includes program instructions, and when the program instructions are executed by a processor, the processor is caused to perform the method according to any one of claims 1 to 9.
13. A computer program product, characterized in that The computer program product comprises a computer program, wherein the computer program comprises program instructions, and when the program instructions are executed by a processor, the method according to any one of claims 1 to 9 is implemented.