Page element positioning method and device, equipment, storage medium and program product
By obtaining page data, generating attribute configuration files, and using multi-dimensional attribute information and priority information for page elements to locate page elements, the problem of positioning errors during page changes is solved, and higher accuracy and stability are achieved.
Patent Information
- Application Number
- CN202510458805.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-11
- Publication Date
- 2025-07-25
AI Technical Summary
The existing page element positioning method is prone to positioning errors when the web page is changed, and the page elements cannot be operated accurately.
By obtaining the page data of the target page, determining the attribute information of the page element, generating attribute configuration files, and positioning page elements based on the attribute configuration files, using multi-dimensional attribute information and priority information for positioning.
It improves the accuracy and flexibility of page element positioning, adapts to the dynamic testing environment where pages are frequently updated, and enhances the stability and success rate of positioning.
Smart Images

Figure CN120371701A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of web automated testing technologies, and particularly to a method, apparatus, device, storage medium, and program product for page element positioning. Background Art
[0002] Web automated testing is a process of verifying the functions of a software system by simulating user operations in a browser. Web automated testing can reduce the workload and testing costs of manual testing, improve the testing efficiency, and ensure the quality of the software system. In web automated testing, when operating on elements on a web page, it is first necessary to locate the page elements to be operated.
[0003] Currently, the common method for page element positioning is to construct an information mapping table, and then construct an xpath (XML Path Language) expression for the page element to be operated based on the field name, type of the page element to be operated, and the information mapping table. The page element to be operated can be located in the web page according to the xpath expression. However, in this way, when the web page changes, positioning errors will occur, and further operations on the page elements cannot be performed. Summary of the Invention
[0004] Based on this, it is necessary to provide a page element positioning method, apparatus, device, storage medium, and program product that can accurately locate page elements for the above technical problems.
[0005] In a first aspect, this application provides a page element positioning method, including:
[0006] Obtain the page data of the target page;
[0007] Determine the attribute information of the page elements included in the target page according to the page data;
[0008] Generate an attribute configuration file according to the attribute information of the page elements included in the target page;
[0009] Locate the target page element in the target page according to the attribute configuration file.
[0010] In the above embodiments, first, page data of the target page is obtained. Next, according to the page data, attribute information of page elements included in the target page is determined. Then, according to the attribute information of page elements included in the target page, an attribute configuration file is generated. Finally, according to the attribute configuration file, the target page elements in the target page are located. In this way, by obtaining the page data of the target page, all the attribute information of page elements included in the target page can be obtained. Generating an attribute configuration file according to the attribute information can locate the target page elements, rather than using a fixed xpath expression to locate the target page elements, solving the problem that page elements cannot be located when the target page changes.
[0011] In one embodiment, the attribute configuration file includes attribute information of different dimensions of page elements. Locating the target page elements in the target page according to the attribute configuration file includes:
[0012] Obtain the identification information of the target page element;
[0013] According to the identification information and the attribute configuration file, determine the attribute information of different dimensions corresponding to the target page element;
[0014] Locate the target page element according to the attribute information of different dimensions corresponding to the target page element.
[0015] In the above embodiments, the target page elements can be located through multiple attribute information of different dimensions in the attribute configuration file. There are more positioning options, effectively avoiding positioning failures caused by changes in single attribute information. Even when the style, position, or name of the page element changes, the accuracy of locating the target page element can be ensured, enhancing the flexibility and adaptability of page element location, and being applicable to dynamic test environments with frequent page updates.
[0016] In one embodiment, the attribute configuration file includes priority information. Locating the target page element according to the attribute information of different dimensions corresponding to the target page element includes:
[0017] According to the priority information, determine the respective positioning priorities of the attribute information of different dimensions corresponding to the target page element;
[0018] According to the order of the positioning priorities from high to low, locate the target page element according to the attribute information of different dimensions corresponding to the target page element in turn;
[0019] If the target page element is located successfully, return the location result of the target page element. If the target page element is not located successfully, continue to locate according to the attribute information corresponding to the next positioning priority until the target page element is located successfully.
[0020] In the above embodiments, by setting priority information and positioning the target page elements according to the priority information, the attribute information with high positioning accuracy can correspond to a higher positioning priority, so that the target page elements can be successfully positioned quickly, improving the stability and success rate of page element positioning, and is particularly suitable for automated testing of complex page structures.
[0021] In one of the embodiments, obtaining the page data of the target page includes:
[0022] According to the uniform resource locator (URL) of the target page, obtaining the hypertext markup language (HTML) parsing data of the target page as the page data.
[0023] In the above embodiments, the page data is obtained in an automated manner, so that the attribute data of the page elements can be obtained by parsing the page data, greatly improving the accuracy and efficiency of page element positioning.
[0024] In one of the embodiments, after positioning the target page elements according to the attribute configuration file, the method further includes:
[0025] If a target resource needs to be called during the testing process of the target page element, receiving a call request for the target resource through a preset resource call interface;
[0026] Obtaining the input parameter information of the preset resource call interface, where the input parameter information includes the resource name and resource category of the target resource;
[0027] Matching in the resource pool according to the resource name and resource category;
[0028] Calling the target resource according to the matching result.
[0029] In the above embodiments, the call of various types of co-testing resources is realized through a unified resource call interface, the test script is simple to write and more convenient to maintain. At the same time, in the process of resource pool matching, by using a fuzzy matching algorithm to search the resource pool, the target resource can be quickly searched and the call of the target resource can be realized, and the efficiency of resource call is higher.
[0030] In one of the embodiments, the process of establishing the resource pool includes:
[0031] Parsing a preset resource configuration file to obtain the attribute information of the resource;
[0032] Registering and initializing the attribute information of the resource to obtain a resource pool.
[0033] In the above embodiments, by establishing a resource pool, the resource loading time during the test can be reduced by preloading and initializing resources. By performing matching in the resource pool, the invocation of target resources can be achieved, improving the execution efficiency and reliability of automated tests.
[0034] In a second aspect, the present application further provides a page element positioning device, which includes:
[0035] An acquisition module, configured to acquire page data of a target page;
[0036] A determination module, configured to determine the attribute information of page elements included in the target page according to the page data;
[0037] A generation module, configured to generate an attribute configuration file according to the attribute information of page elements included in the target page;
[0038] A positioning module, configured to position a target page element in the target page according to the attribute configuration file.
[0039] In a third aspect, the present application further provides a computer device, including a memory and a processor. The memory stores a computer program, and when the processor executes the computer program, it implements the page element positioning method according to any one of the first aspects described above.
[0040] In a fourth aspect, the present application further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, it implements the page element positioning method according to any one of the first aspects described above.
[0041] In a fifth aspect, the present application further provides a computer program product, including a computer program. When the computer program is executed by a processor, it implements the page element positioning method according to any one of the first aspects described above.
[0042] For the above page element positioning method, device, equipment, storage medium, and program product, first, acquire the page data of the target page. Then, determine the attribute information of the page elements included in the target page according to the page data. Next, generate an attribute configuration file according to the attribute information of the page elements included in the target page. Finally, position the target page element in the target page according to the attribute configuration file. In this way, by acquiring the page data of the target page, the attribute information of all page elements included in the target page can be obtained. Generating an attribute configuration file according to the attribute information can be used to position the target page element, rather than using a fixed xpath expression to position the target page element, solving the problem that the page element cannot be positioned when the target page changes. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] To more clearly illustrate the technical solutions in the embodiments of the present application or the related art, the following will briefly introduce the drawings required for use in the description of the embodiments of the present application or the related art. Obviously, the drawings in the following description are only some embodiments of the present application. For those of ordinary skill in the art, without creative efforts, other related drawings can also be obtained based on these drawings.
[0044] Figure 1 It is a schematic flowchart of a page element positioning method in an embodiment;
[0045] Figure 2 It is a schematic flowchart of a page element positioning method in another embodiment;
[0046] Figure 3 It is a schematic flowchart of a page element positioning method in another embodiment;
[0047] Figure 4 It is a schematic structural diagram of an attribute configuration file in an embodiment;
[0048] Figure 5 It is a schematic flowchart of a page element positioning method in another embodiment;
[0049] Figure 6 It is a schematic flowchart of a page element positioning method in another embodiment;
[0050] Figure 7 It is a schematic structural diagram of a preset resource configuration file in an embodiment;
[0051] Figure 8 It is a schematic flowchart of a page element positioning method in another embodiment;
[0052] Figure 9 It is a schematic block diagram of a page element positioning device in an embodiment;
[0053] Figure 10 It is an internal structural diagram of a computer device in an embodiment. Detailed implementation manners
[0054] In order to make the objectives, technical solutions and advantages of the present application clearer, the following further details the present application in combination with the drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0055] In an exemplary embodiment, as Figure 1As shown, a resource determination method is provided. Taking the application of this method to a terminal as an example for illustration, the terminal can be, but is not limited to, various personal computers, laptops, smartphones, tablets, Internet of Things devices, and portable wearable devices. The Internet of Things devices can be smart speakers, smart TVs, smart air conditioners, smart in-vehicle devices, projection devices, etc. It can be understood that this method can also be applied to a server, and can also be applied to a system including a terminal and a server, and is implemented through the interaction between the terminal and the server, including the following steps:
[0056] Step 101, obtain the page data of the target page.
[0057] Among them, the target page can be a web page or a mobile application interface, etc. The page data of the target page can include the basic information of the target page, such as title information and source code information, and can also include the data of the page elements on the target page. The page data of the target page can be obtained through an automated testing tool, or by calling the corresponding software interface, or directly extracted through a visual interface.
[0058] Step 102, determine the attribute information of the page elements included in the target page according to the page data.
[0059] According to the obtained page data, all the data of the page elements on the target page can be obtained by parsing the page data. Optionally, it includes the attribute information of the page elements, such as attributes like class, id, name, etc. of the page elements, and the xpath path attribute of the page elements can also be parsed. Among them, the class attribute is the class name of the page element, the id is the unique identifier of the page element, the name is the name of the page element, and the xpath is the path of the page element.
[0060] Step 103, generate an attribute configuration file according to the attribute information of the page elements included in the target page.
[0061] Generate an attribute configuration file according to the multiple attribute information of the above-obtained page elements. The attribute configuration file includes the identifier of the page element and multiple different attribute information corresponding to the page element. Optionally, the multiple attribute information of the above-obtained page elements can be saved as a table file to obtain the attribute configuration file, or can be saved as a file in XML format, or a document format file, thereby obtaining the attribute configuration file. Generating the attribute configuration file facilitates subsequent maintenance and update, and enhances the flexibility and scalability of the page element positioning method.
[0062] Step 104, locate the target page element in the target page according to the attribute configuration file.
[0063] During the automated testing process, it is necessary to accurately locate page elements so that the automated testing can truly simulate user behavior and precisely achieve the testing objectives. According to the attribute information of the target page elements in the attribute configuration file, the target page elements can be located. For example, the target page elements can be located by the class, id, name, or xpath of the target page elements in the attribute configuration file.
[0064] In the above embodiment, first, obtain the page data of the target page. Then, according to the page data, determine the attribute information of the page elements included in the target page. Next, generate an attribute configuration file according to the attribute information of the page elements included in the target page. Finally, according to the attribute configuration file, locate the target page elements in the target page. In this way, by obtaining the page data of the target page, the attribute information of all page elements included in the target page can be obtained. Generating an attribute configuration file according to the attribute information can locate the target page elements, rather than using a fixed xpath expression to locate the target page elements, solving the problem that the page elements cannot be located when the target page changes.
[0065] In an embodiment of the present application, in order to improve the accuracy of target page element location, the attribute configuration file includes attribute information of page elements in different dimensions. The above step 104 is as Figure 2 shown and may include:
[0066] Step 201, obtain the identification information of the target page element.
[0067] Optionally, the attribute configuration file includes multiple sets of corresponding relationships between the identification information of the page elements and the attribute information of the page elements in different dimensions. The attribute information in different dimensions may include multiple dimensions such as class, id, name, xpath, link_text, etc. Among them, link_text is the link text of the target page element. To determine the attribute information of the target page element in different dimensions, obtain the identification information of the target page element that needs to be located in the current test process according to the test requirements.
[0068] Step 202, according to the identification information and the attribute configuration file, determine the attribute information of the target page element in different dimensions.
[0069] Query the attribute configuration file according to the identification information of the target page element to determine the multiple different dimension attribute information corresponding to the identification information of the target page element.
[0070] Step 203, according to the attribute information of the target page element in different dimensions, locate the target page element.
[0071] Optionally, the positioning of the target page element can be achieved through an automated testing tool. For example, through the Selenium tool, attribute information of different dimensions can be selected to achieve the positioning of the target page element. For example, the target page element can be positioned through the class attribute, or through the id attribute, or through the name attribute, or through the xpath attribute, or through the link_text attribute.
[0072] In the above embodiments, the target page element can be positioned through attribute information of multiple different dimensions in the attribute configuration file, providing more positioning options. This effectively avoids positioning failures caused by changes in a single attribute information. Even when the style, position, or name of the page element changes, the accuracy of the target page element positioning can be ensured, enhancing the flexibility and adaptability of the page element positioning, and making it suitable for dynamic testing environments with frequent page updates.
[0073] In one embodiment, the attribute configuration file includes priority information. In step 203 above, the target page element is positioned according to the attribute information of different dimensions corresponding to the target page element, as Figure 3 shown, including:
[0074] Step 301: Determine the positioning priority of the attribute information of different dimensions corresponding to the target page element according to the priority information.
[0075] Among them, the priority information is used to set the positioning priority of the target page element. For example, the priority information can be xpath, id, class, name, link_text, indicating that the positioning priority of the attribute information is from high to low as xpath, id, class, name, link_text. That is, the positioning priority of the xpath attribute information is the highest, and the positioning priority of the link_text attribute information is the lowest.
[0076] Step 302: Position the target page element according to the attribute information of different dimensions corresponding to the target page element in order from high to low according to the positioning priority.
[0077] Step 303: If the target page element is successfully positioned, return the positioning result of the target page element. If the target page element is not successfully positioned, continue to position according to the attribute information corresponding to the next positioning priority until the target page element is successfully positioned.
[0078] According to the order of decreasing positioning priority, the target page element is located according to the corresponding attribute information in turn. Taking the above priority information as an example, the target page element is located through the xpath attribute information first. If the positioning is successful, the positioning result of the target page element is returned. If the element is not located, the target element is continued to be located through the id attribute information. If the positioning is successful, the positioning result of the target page element is returned. If the element is not located, the target element is continued to be located through the class attribute information. If the positioning is successful, the positioning result of the target page element is returned. If the element is not located, the target element is continued to be located through the name attribute information. If the positioning is successful, the positioning result of the target page element is returned. If the element is not located, the target element is continued to be located through the link_text attribute information, and the positioning is carried out in turn until the target page element is found and the target page element is successfully located. Optionally, the attribute configuration file can be stored in a table format as follows Figure 4 as shown
[0079] In the above embodiment, by setting the priority information, the target page element is located according to the priority information. The attribute information with high positioning accuracy can correspond to a higher positioning priority, so that the target page element can be quickly located successfully, improving the stability and success rate of page element positioning, and is particularly suitable for automated testing of complex page structures.
[0080] In one embodiment, the page data of the target page can be obtained. According to the uniform resource locator (URL) of the target page, the hypertext markup language (HTML) parsing data of the target page can be obtained as the page data.
[0081] Among them, Selenium is an automated testing tool for web applications. It can perform automated testing by simulating the interaction behavior of real users and browsers. Optionally, by using Selenium to simulate a browser and inputting the URL of the target page, the corresponding HTML parsing data of the target page can be obtained, and the HTML parsing data is saved to a file as the page data.
[0082] In the above embodiment, the page data is obtained in an automated manner, so that the attribute data of the page element can be obtained by parsing the page data, which can greatly improve the accuracy and efficiency of page element positioning.
[0083] In an alternative embodiment of the present application, after the target page element is located, if other accompanying test resources need to be called during the test process, such as Figure 5 as shown, the method further includes:
[0084] Step 501, if a target resource needs to be called during the testing process of a target page element, receive a call request for the target resource through a preset resource call interface.
[0085] Among them, during the testing process of common network devices, such as the testing of traffic diversion devices, some accompanying testing resources need to be introduced for auxiliary testing. The accompanying testing resources can include external resources such as switches, Linux servers, or packet sending instruments. Currently, during the testing process, if external accompanying testing resources need to be introduced, they need to be called in the test script according to the resources to be introduced. Different resources need to call different resource interfaces, which is inconvenient to use and may lead to difficulties in script maintenance.
[0086] Therefore, in order to improve the efficiency of calling accompanying testing resources, the target resource can be other accompanying testing resources. If a target resource needs to be called during the testing process of a target page element, a call request for the target resource can be received through a preset resource call interface. The preset resource call interface is a unified resource call interface that can realize the calling of various types of accompanying testing resources.
[0087] Step 502, obtain the input parameter information of the preset resource call interface.
[0088] Among them, the input parameter information includes the resource name and resource category of the target resource.
[0089] Step 503, perform matching in the resource pool according to the resource name and resource category.
[0090] Perform matching in the resource pool according to the resource name and resource category input by the preset resource call interface to obtain the target resource to be called. Among them, the resource pool is registered and initialized according to a preset resource configuration file at the beginning stage of the testing process, and includes all the resources and their sub-resources required during the entire testing process. The matching process in the resource pool according to the resource name and resource category can be performed through a fuzzy matching algorithm. For example, according to the idea of the BFS algorithm, perform fuzzy matching on the attributes of each resource, and immediately return the resource if one is successfully matched. Optionally, other fuzzy matching algorithms can also be used for matching, and the embodiments of the present application do not limit this.
[0091] Step 504, call the target resource according to the matching result.
[0092] If the matching is successful, return the target resource, and the target resource can be called according to the matching result.
[0093] In the above embodiments, the invocation of various types of co-testing resources is achieved through a unified resource invocation interface. The test script is simple to write and more convenient to maintain. At the same time, during the resource pool matching process, the fuzzy matching algorithm is used to search the resource pool, enabling the rapid search for target resources and the invocation of target resources, with higher resource invocation efficiency.
[0094] Optionally, after the web automation test starts, a resource pool can be established according to the resource configuration file, such as Figure 6 shown, including:
[0095] Step 601, parse the preset resource configuration file to obtain the attribute information of the resources.
[0096] Among them, the format of the preset resource configuration file can be as Figure 7 shown, including multiple pieces of information such as the resource name, resource category, IP, username, password, port, etc. of each resource. By parsing the preset resource configuration file, the attribute information of each resource and its sub-resources can be obtained.
[0097] Step 602, perform registration and initialization processing on the attribute information of the resources to obtain a resource pool.
[0098] According to the obtained resource name and resource category of each resource, perform registration and initialization processing on the resources, associate each resource with the corresponding interface file, and then associate each sub-resource included in the resource with the corresponding interface file. After all resources are registered and initialized, a resource pool is obtained.
[0099] In this embodiment, by establishing a resource pool, resources can be pre-loaded and initialized, reducing the resource loading time during the test. By performing matching in the resource pool, the invocation of target resources can be achieved, improving the execution efficiency and reliability of the automation test.
[0100] In the embodiments of the present application, as Figure 8 shown, a page element positioning method is provided, including:
[0101] Step 801, according to the uniform resource locator URL of the target page, obtain the hypertext markup language HTML parsing data of the target page as page data.
[0102] Step 802, determine the attribute information of the page elements included in the target page according to the page data.
[0103] Step 803, generate an attribute configuration file according to the attribute information of the page elements included in the target page.
[0104] Step 804, obtain the identification information of the target page element.
[0105] Step 805: Determine the attribute information of the target page element in different dimensions according to the identification information and the attribute configuration file.
[0106] Step 806: Determine the positioning priority of the attribute information of the target page element in different dimensions according to the priority information.
[0107] Step 807: According to the order from high to low of the positioning priority, position the target page element in turn according to the attribute information of the target page element in different dimensions.
[0108] Step 808: If the positioning of the target page element is successful, return the positioning result of the target page element; if the positioning of the target page element is unsuccessful, continue to position according to the attribute information corresponding to the next positioning priority until the positioning of the target page element is successful.
[0109] It should be understood that although each step in the flowcharts involved in the above-described embodiments is displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise clearly stated in this article, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-described embodiments may include multiple steps or multiple stages. These steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be executed alternately or in turn with at least a part of other steps or steps or stages in other steps.
[0110] Based on the same inventive concept, an embodiment of the present application also provides a page element positioning device for implementing the above-mentioned page element positioning method. The solution provided by this device to solve the problem is similar to the solution described in the above method. Therefore, the specific limitations in one or more embodiments of the following page element positioning device can refer to the limitations on the page element positioning method in the above text, and will not be repeated here.
[0111] In an exemplary embodiment, as Figure 9 shown, a page element positioning device 900 is provided, including: an acquisition module 901, a determination module 902, a generation module 903, and a positioning module 904, where:
[0112] The acquisition module 901 is configured to acquire the page data of the target page;
[0113] The determination module 902 is configured to determine the attribute information of the page elements included in the target page according to the page data;
[0114] A generation module 903, configured to generate an attribute configuration file according to the attribute information of page elements included in a target page;
[0115] A positioning module 904, configured to position a target page element in the target page according to the attribute configuration file.
[0116] In one embodiment, the attribute configuration file includes attribute information of different dimensions of a page element. The positioning module 904 is specifically configured to obtain the identification information of the target page element; determine the attribute information of different dimensions corresponding to the target page element according to the identification information and the attribute configuration file; and position the target page element according to the attribute information of different dimensions corresponding to the target page element.
[0117] In one embodiment, the attribute configuration file includes priority information. The positioning module 904 is specifically configured to determine the positioning priority of the attribute information of different dimensions corresponding to the target page element according to the priority information; position the target page element according to the attribute information of different dimensions corresponding to the target page element in order from high to low of the positioning priority; if the target page element is successfully positioned, return the positioning result of the target page element, and if the target page element is not successfully positioned, continue to position according to the attribute information corresponding to the next positioning priority until the target page element is successfully positioned.
[0118] In one embodiment, the obtaining module 901 is specifically configured to obtain the HyperText Markup Language (HTML) parsing data of the target page as page data according to the Uniform Resource Locator (URL) of the target page.
[0119] In one embodiment, the apparatus further includes a calling module, configured to, if a target resource needs to be called during the testing process of a target page element, receive a call request for the target resource through a preset resource call interface; obtain the input parameter information of the preset resource call interface, where the input parameter information includes the resource name and resource category of the target resource; perform matching in a resource pool according to the resource name and resource category; and call the target resource according to the matching result.
[0120] In one embodiment, the apparatus further includes a parsing module, configured to parse a preset resource configuration file to obtain the attribute information of a resource; perform registration and initialization processing on the attribute information of the resource to obtain a resource pool.
[0121] Each module in the above page element positioning apparatus can be implemented in whole or in part by software, hardware, and their combination. The above modules can be embedded in a processor in a computer device in a hardware form or be independent of the processor, or can be stored in a memory in the computer device in a software form, so that the processor can call and execute the operations corresponding to the above respective modules.
[0122] In an exemplary embodiment, a computer device is provided. The computer device may be a terminal, and its internal structural diagram may be as shown in Figure 10 . The computer device includes a processor, a memory, an input / output interface, a communication interface, a display unit, and an input device. Among them, the processor, the memory, and the input / output interface are connected through a system bus, and the communication interface, the display unit, and the input device are connected to the system bus through the input / output interface. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The input / output interface of the computer device is used to exchange information between the processor and external devices. The communication interface of the computer device is used to communicate with external terminals in a wired or wireless manner. The wireless manner can be implemented through WIFI, a mobile cellular network, near field communication (NFC), or other technologies. When the computer program is executed by the processor, it implements a method for positioning page elements. The display unit of the computer device is used to form a visually visible picture, which may be a display screen, a projection device, or a virtual reality imaging device. The display screen may be a liquid crystal display screen or an electronic ink display screen. The input device of the computer device may be a touch layer covering the display screen, or a button, a trackball, or a touchpad provided on the housing of the computer device, or an external keyboard, touchpad, or mouse, etc.
[0123] Those skilled in the art can understand that Figure 10 the structure shown in is only a block diagram of some structures related to the solution of this application, and does not constitute a limitation on the computer device to which the solution of this application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine some components, or have different component arrangements.
[0124] In an exemplary embodiment, a computer device is provided, including a memory and a processor. A computer program is stored in the memory. When the processor executes the computer program, the following steps are implemented: obtaining page data of a target page; determining attribute information of page elements included in the target page according to the page data; generating an attribute configuration file according to the attribute information of the page elements included in the target page; and positioning a target page element in the target page according to the attribute configuration file.
[0125] In one embodiment, the attribute configuration file includes attribute information of different dimensions of page elements. When the processor executes the computer program, the following steps are further implemented: obtaining the identification information of the target page element; determining the attribute information of different dimensions corresponding to the target page element according to the identification information and the attribute configuration file; and positioning the target page element according to the attribute information of different dimensions corresponding to the target page element.
[0126] In one embodiment, the attribute configuration file includes priority information. When the processor executes the computer program, the following steps are further implemented: determining the positioning priority of each of the attribute information of different dimensions corresponding to the target page element according to the priority information; positioning the target page element according to the attribute information of different dimensions corresponding to the target page element in turn in the order from the highest to the lowest positioning priority; if the target page element is successfully positioned, returning the positioning result of the target page element; if the target page element is not successfully positioned, continuing to position according to the attribute information corresponding to the next positioning priority until the target page element is successfully positioned.
[0127] In one embodiment, when the processor executes the computer program, the following steps are further implemented: obtaining the HyperText Markup Language (HTML) parsing data of the target page as page data according to the Uniform Resource Locator (URL) of the target page.
[0128] In one embodiment, when the processor executes the computer program, the following steps are further implemented: if a target resource needs to be called during the testing process of the target page element, receiving a call request for the target resource through a preset resource call interface; obtaining the input parameter information of the preset resource call interface, where the input parameter information includes the resource name and resource category of the target resource; performing matching in the resource pool according to the resource name and resource category; and calling the target resource according to the matching result.
[0129] In one embodiment, when the processor executes the computer program, the following steps are further implemented: parsing a preset resource configuration file to obtain the attribute information of the resource; and performing registration and initialization processing on the attribute information of the resource to obtain a resource pool.
[0130] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the following steps are implemented: obtaining the page data of the target page; determining the attribute information of the page elements included in the target page according to the page data; generating an attribute configuration file according to the attribute information of the page elements included in the target page; and positioning the target page element in the target page according to the attribute configuration file.
[0131] In one embodiment, the attribute profile includes attribute information of different dimensions of page elements. When the computer program is executed by a processor, the following steps are implemented: obtaining the identification information of a target page element; determining the attribute information of different dimensions corresponding to the target page element according to the identification information and the attribute profile; positioning the target page element according to the attribute information of different dimensions corresponding to the target page element.
[0132] In one embodiment, the attribute profile includes priority information. When the computer program is executed by a processor, the following steps are implemented: determining the positioning priority of the attribute information of different dimensions corresponding to the target page element according to the priority information; positioning the target page element according to the attribute information of different dimensions corresponding to the target page element in order from the highest to the lowest positioning priority; if the target page element is successfully positioned, returning the positioning result of the target page element, and if the target page element is not successfully positioned, continuing to position according to the attribute information corresponding to the next positioning priority until the target page element is successfully positioned.
[0133] In one embodiment, when the computer program is executed by a processor, the following steps are implemented: obtaining the HyperText Markup Language (HTML) parsing data of the target page as page data according to the Uniform Resource Locator (URL) of the target page.
[0134] In one embodiment, when the computer program is executed by a processor, the following steps are implemented: if a target resource needs to be called during the testing process of the target page element, receiving a call request for the target resource through a preset resource call interface; obtaining the input parameter information of the preset resource call interface, where the input parameter information includes the resource name and resource category of the target resource; performing matching in the resource pool according to the resource name and resource category; and calling the target resource according to the matching result.
[0135] In one embodiment, when the computer program is executed by a processor, the following steps are implemented: parsing a preset resource configuration file to obtain the attribute information of the resource; and performing registration and initialization processing on the attribute information of the resource to obtain a resource pool.
[0136] In one embodiment, a computer program product is provided, including a computer program. When the computer program is executed by a processor, the following steps are implemented: obtaining the page data of a target page; determining the attribute information of the page elements included in the target page according to the page data; generating an attribute profile according to the attribute information of the page elements included in the target page; and positioning the target page element in the target page according to the attribute profile.
[0137] In one embodiment, the attribute profile includes attribute information of different dimensions of page elements. When the computer program is executed by a processor, the following steps are implemented: obtaining the identification information of the target page element; determining the attribute information of different dimensions corresponding to the target page element according to the identification information and the attribute profile; and positioning the target page element according to the attribute information of different dimensions corresponding to the target page element.
[0138] In one embodiment, the attribute profile includes priority information. When the computer program is executed by a processor, the following steps are implemented: determining the positioning priority of the attribute information of different dimensions corresponding to the target page element according to the priority information; positioning the target page element according to the attribute information of different dimensions corresponding to the target page element in order from high to low according to the positioning priority; if the target page element is successfully positioned, returning the positioning result of the target page element, and if the target page element is not successfully positioned, continuing to position according to the attribute information corresponding to the next positioning priority until the target page element is successfully positioned.
[0139] In one embodiment, when the computer program is executed by a processor, the following steps are implemented: obtaining the HyperText Markup Language (HTML) parsing data of the target page as page data according to the Uniform Resource Locator (URL) of the target page.
[0140] In one embodiment, when the computer program is executed by a processor, the following steps are implemented: if a target resource needs to be called during the testing process of the target page element, receiving a call request for the target resource through a preset resource call interface; obtaining the input parameter information of the preset resource call interface, where the input parameter information includes the resource name and resource category of the target resource; performing matching in the resource pool according to the resource name and resource category; and calling the target resource according to the matching result.
[0141] In one embodiment, when the computer program is executed by a processor, the following steps are implemented: parsing a preset resource configuration file to obtain the attribute information of the resource; and performing registration and initialization processing on the attribute information of the resource to obtain a resource pool.
[0142] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use, and processing of relevant data need to comply with relevant regulations.
[0143] Those of ordinary skill in the art can understand that all or part of the processes in the above-described method embodiments can be completed by instructing relevant hardware through a computer program. The computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the method embodiments as described above. Among them, any reference to a memory, database, or other medium used in the embodiments provided in the present application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetoresistive random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. By way of illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM), etc. The databases involved in the embodiments provided in the present application can include at least one of relational databases and non-relational databases. Non-relational databases can include distributed databases based on blockchain, etc., without limitation. The processors involved in the embodiments provided in the present application can be general-purpose processors, central processing units, graphics processing units, digital signal processors, programmable logic devices, data processing logics based on quantum computing, artificial intelligence (AI) processors, etc., without limitation.
[0144] The technical features of the above embodiments can be combined arbitrarily. For the sake of concise description, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, it should be considered to be within the scope recorded in the present application.
[0145] The above-described embodiments merely represent several implementation manners of the present application. The description thereof is relatively specific and detailed, but it should not be construed as a limitation on the patent scope of the present application. It should be noted that for those of ordinary skill in the art, without departing from the concept of the present application, several modifications and improvements can still be made, and these all fall within the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the appended claims.
Claims
1. A method for positioning page elements, characterized in that, The method includes: Obtaining page data of a target page; Determining attribute information of page elements included in the target page according to the page data; Generating an attribute configuration file according to the attribute information of the page elements included in the target page; Locating a target page element in the target page according to the attribute configuration file.
2. The method according to claim 1, characterized in that, The attribute configuration file includes attribute information of different dimensions of the page element. The locating of the target page element in the target page according to the attribute configuration file includes: Obtaining identification information of the target page element; Determining attribute information of different dimensions corresponding to the target page element according to the identification information and the attribute configuration file; Locating the target page element according to the attribute information of different dimensions corresponding to the target page element.
3. The method according to claim 2, wherein The attribute configuration file includes priority information. The locating of the target page element according to the attribute information of different dimensions corresponding to the target page element includes: Determining respective location priorities of the attribute information of different dimensions corresponding to the target page element according to the priority information; Sequentially locating the target page element according to the attribute information of different dimensions corresponding to the target page element in the order from high to low of the location priorities; If the target page element is successfully located, returning the location result of the target page element; if the target page element is not successfully located, continuing to locate according to the attribute information corresponding to the next location priority until the target page element is successfully located.
4. The method according to claim 1, characterized in that The obtaining of the page data of the target page includes: Obtaining hypertext markup language (HTML) parsing data of the target page according to the uniform resource locator (URL) of the target page as the page data.
5. The method according to claim 1, wherein After the locating of the target page element according to the attribute configuration file, the method further includes: If a target resource needs to be called during the testing process of the target page element, receiving a call request for the target resource through a preset resource call interface; Obtaining input parameter information of the preset resource call interface, where the input parameter information includes a resource name and a resource category of the target resource; Performing matching in a resource pool according to the resource name and the resource category; Invoking the target resource according to the matching result.
6. The method according to claim 5, characterized in that, The establishment process of the resource pool includes: Parsing a preset resource configuration file to obtain attribute information of a resource; Performing registration and initialization processing on the attribute information of the resource to obtain the resource pool.
7. A page element positioning device, characterized in that, The apparatus includes: An obtaining module, configured to obtain page data of a target page; A determining module, configured to determine attribute information of page elements included in the target page according to the page data; A generating module, configured to generate an attribute configuration file according to the attribute information of the page elements included in the target page; A locating module, configured to locate a target page element in the target page according to the attribute configuration file.
8. A computer device, comprising a memory and a processor, the memory storing a computer program, characterized in that, When the processor executes the computer program, the steps of the method according to any one of claims 1 to 6 are implemented.
9. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 6.
10. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the steps of the method according to any one of claims 1 to 6.