A method and apparatus for simulating click testing on a view page

CN115292177BActive Publication Date: 2026-10-16CHINA TELECOM CORP LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210931255.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-08-04
Publication Date
2026-10-16
Estimated Expiration
2042-08-04

AI Technical Summary

Technical Problem

[0003]本发明实施例是提供一种针对视图页面的模拟点击测试方法、装置、电子设备以及计算机可读存储介质,以解决在针对视图页面的模拟点击测试过程中,当出现错误时,无法继续测试的问题

Benefits of technology

[0065] This invention, through the following embodiments, determines a target view page; the target view page has a corresponding child node hierarchy; the child node hierarchy has a corresponding parent node hierarchy; the parent node hierarchy includes a parent node hierarchy view page; a target element is determined from the target view page; a simulated click test is performed on the first test item of the target view page, and when the test result for the first test item is determined to be incorrect, the test returns to the parent node hierarchy view page; when the parent node hierarchy view page is determined to be the target parent node hierarchy view page corresponding to the target view page based on the target element, a simulated click test is performed on the second test item of the target view page. This solves the problem that testing cannot continue when an error occurs during the simulated click test of the view page, thereby enabling testing to continue when automated testing is interrupted, and thus improving the efficiency of simulated click testing of the view page.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115292177B_ABST
    Figure CN115292177B_ABST
Patent Text Reader

Abstract

The embodiment of the application provides a simulation click test method and device for a view page, which comprises the following steps: determining a target view page; performing simulation click test on a first test item of the target view page, and returning to a parent node level view page when it is determined that the test result of the first test item is wrong; and when it is determined that the parent node level view page is a target parent node level view page corresponding to the target view page through a target element, performing simulation click test on a second test item of the target view page, so as to solve the problem that the test cannot be continued when an error occurs in the simulation click test process for the view page, thereby realizing continuous test when the automatic test is interrupted, and further improving the simulation click test efficiency for the view page.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of simulated click testing technology for view pages, and in particular to a simulated click testing method for view pages, a simulated click testing device for view pages, an electronic device, and a computer-readable storage medium. Background Technology

[0002] Automated testing is a process that transforms human-driven testing behaviors into machine-executed ones. With the development of automated testing technology, automated testing applications have emerged, such as Appium, which is one of the mainstream automated testing applications on the current mobile platform. However, during the automated testing process of automated testing applications, multiple test scripts are usually written to test the main business process. When simulating click tests, opening subviews often results in the process getting stuck on the current page due to view errors, causing the subsequent process to be unable to continue, which in turn leads to the interruption of the overall test or serious deviation of the results. Summary of the Invention

[0003] The present invention provides a method, apparatus, electronic device, and computer-readable storage medium for simulating click testing of a view page, in order to solve the problem that the test cannot continue when an error occurs during the simulating click testing of a view page.

[0004] This invention discloses a method for simulating clicks on a view page, characterized in that it may include:

[0005] Determine the target view page; the target view page has a corresponding child node hierarchy; the child node hierarchy has a corresponding parent node hierarchy; the parent node hierarchy includes the parent node hierarchy view page;

[0006] Identify the target element from the target view page;

[0007] A simulated click test is performed on the first test item of the target view page, and when the test result for the first test item is determined to be incorrect, the parent node hierarchy view page is returned.

[0008] When the target element determines that the parent node hierarchy view page is the target parent node hierarchy view page corresponding to the target view page, a simulated click test is performed on the second test item of the target view page.

[0009] Optionally, the method is applied to an automation application that has a corresponding remote dictionary service database, and the step of determining the target element from the target view page may include:

[0010] All elements in the target view page are identified, and a target element is randomly selected from the elements according to a preset number; the target element has corresponding target element information;

[0011] The target element information is stored in the remote dictionary service database, and the target element information includes at least: target element name information and target element path information.

[0012] Optionally, before the step of performing a simulated click test on the second test item of the target view page when the parent node hierarchy view page is determined to be the target parent node hierarchy view page corresponding to the target view page through the target element, the method may further include:

[0013] The target element is used to determine whether the parent node hierarchy view page is the target parent node hierarchy view page corresponding to the target view page;

[0014] The step of determining whether the parent node hierarchy view page is the target parent node hierarchy view page corresponding to the target view page through the target element includes:

[0015] Extract the element name information and the target element path information from the remote dictionary service database;

[0016] The parent node hierarchy view page element for the parent node hierarchy view page is determined by the element name information and the target element path information.

[0017] Determine whether the parent node hierarchy view page element matches the target element.

[0018] Optionally, when the target element determines that the parent node hierarchy view page is the target parent node hierarchy view page corresponding to the target view page, the step of performing a simulated click test on the second test item of the target view page may include:

[0019] When the parent node hierarchical view page element matches the target element, a simulated click test is performed on the second test item of the target view page.

[0020] Optionally, the method is applied to an automation application that has a corresponding remote dictionary service database, and the step of determining the target element from the target view page may include:

[0021] Generate a first page image for the target view page;

[0022] A hash algorithm is used to generate a first image fingerprint for the first page image, and the first image fingerprint is stored as a target element in the remote dictionary service database.

[0023] Optionally, before the step of performing a simulated click test on the second test item of the target view page when the parent node hierarchy view page is determined to be the target parent node hierarchy view page corresponding to the target view page through the target element, the method may further include:

[0024] The target element is used to determine whether the parent node hierarchy view page is the target parent node hierarchy view page corresponding to the target view page;

[0025] The step of determining whether the parent node hierarchy view page is the target parent node hierarchy view page corresponding to the target view page through the target element includes:

[0026] Generate a second page image for the target view page;

[0027] A hash algorithm is used to generate a second image fingerprint for the image on the second page;

[0028] Extract the first fingerprint from the remote dictionary service database;

[0029] Determine whether the similarity between the first fingerprint code and the second image fingerprint code is greater than a preset threshold.

[0030] Optionally, when the target element determines that the parent node hierarchy view page is the target parent node hierarchy view page corresponding to the target view page, the step of performing a simulated click test on the second test item of the target view page may include:

[0031] When the similarity between the first fingerprint code and the second image fingerprint code is greater than a preset threshold, a simulated click test is performed on the second test item of the target view page.

[0032] This invention also discloses a simulated click testing device for a view page, characterized in that it can include:

[0033] A target view page determination module is used to determine a target view page; the target view page has a corresponding child node hierarchy; the child node hierarchy has a corresponding parent node hierarchy; the parent node hierarchy includes the parent node hierarchy view page;

[0034] The target element determination module is used to determine the target element from the target view page;

[0035] The parent node hierarchy view page return module is used to perform a simulated click test on the first test item of the target view page, and return to the parent node hierarchy view page when the test result for the first test item is determined to be incorrect.

[0036] The test restart module is used to perform simulated click tests on the second test item of the target view page when the target element determines that the parent node hierarchical view page is the target parent node hierarchical view page corresponding to the target view page.

[0037] Optionally, the device is applied to an automation application that has a corresponding remote dictionary service database, and the target element determination module may include:

[0038] The target element determination submodule is used to determine all elements in the target view page and randomly determine target elements from the elements according to a preset number; the target element has corresponding target element information;

[0039] The target element information storage submodule is used to store the target element information in the remote dictionary service database. The target element information includes at least: target element name information and target element path information.

[0040] Optionally, it may also include:

[0041] The first judgment module is used to determine whether the parent node hierarchy view page is the target parent node hierarchy view page corresponding to the target view page based on the target element;

[0042] The first judgment module includes:

[0043] The target element information extraction submodule is used to extract the element name information and the target element path information from the remote dictionary service database;

[0044] The parent node hierarchy view page element determination submodule is used to determine the parent node hierarchy view page element for the parent node hierarchy view page based on the element name information and the target element path information.

[0045] The first judgment submodule is used to determine whether the parent node hierarchical view page element matches the target element.

[0046] Optionally, the test restart module may include:

[0047] The first test restart submodule is used to perform a simulated click test on the second test item of the target view page when the parent node hierarchical view page element matches the target element.

[0048] Optionally, the device is applied to an automation application that has a corresponding remote dictionary service database, and the target element determination module may include:

[0049] The first page image generation submodule is used to generate a first page image for the target view page;

[0050] The first image fingerprint generation submodule is used to generate a first image fingerprint for the first page image using a hash algorithm, and store the first image fingerprint as a target element in the remote dictionary service database.

[0051] Optionally, it may also include:

[0052] The second judgment module is used to determine whether the parent node hierarchy view page is the target parent node hierarchy view page corresponding to the target view page based on the target element;

[0053] The second judgment module includes:

[0054] The second page image generation submodule is used to generate a second page image for the target view page;

[0055] The second image fingerprint generation submodule is used to generate a second image fingerprint for the second page image using a hash algorithm.

[0056] The first fingerprint code extraction submodule is used to extract the first fingerprint code from the remote dictionary service database;

[0057] The second judgment submodule is used to determine whether the similarity between the first fingerprint code and the second image fingerprint code is greater than a preset threshold.

[0058] Optionally, the test restart module may include:

[0059] The second test restart submodule is used to perform a simulated click test on the second test item of the target view page when the similarity between the first fingerprint code and the second image fingerprint code is greater than a preset threshold.

[0060] This invention also discloses an electronic device, including a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus;

[0061] The memory is used to store computer programs;

[0062] When the processor executes a program stored in the memory, it implements the method described in the embodiments of the present invention.

[0063] This invention also discloses a computer-readable storage medium storing instructions that, when executed by one or more processors, cause the processors to perform the methods described in this invention.

[0064] The embodiments of the present invention have the following advantages:

[0065] This invention, through the following embodiments, determines a target view page; the target view page has a corresponding child node hierarchy; the child node hierarchy has a corresponding parent node hierarchy; the parent node hierarchy includes a parent node hierarchy view page; a target element is determined from the target view page; a simulated click test is performed on the first test item of the target view page, and when the test result for the first test item is determined to be incorrect, the test returns to the parent node hierarchy view page; when the parent node hierarchy view page is determined to be the target parent node hierarchy view page corresponding to the target view page based on the target element, a simulated click test is performed on the second test item of the target view page. This solves the problem that testing cannot continue when an error occurs during the simulated click test of the view page, thereby enabling testing to continue when automated testing is interrupted, and thus improving the efficiency of simulated click testing of the view page. Attached Figure Description

[0066] Figure 1 This is a flowchart of the steps of a simulated click test method for a view page provided in an embodiment of the present invention;

[0067] Figure 2 This is a flowchart of another method for simulating click testing on a view page provided in an embodiment of the present invention;

[0068] Figure 3 This is a structural block diagram of a simulated click testing device for a view page provided in an embodiment of the present invention;

[0069] Figure 4 This is a hardware structure block diagram of an electronic device provided in various embodiments of the present invention. Detailed Implementation

[0070] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, the present invention will be further described in detail below with reference to the accompanying drawings and specific embodiments.

[0071] Reference Figure 1 The diagram illustrates a flowchart of a simulated click test method for a view page provided in an embodiment of the present invention, which may specifically include the following steps:

[0072] Reference Figure 1The diagram illustrates a flowchart of a simulated click test method for a view page provided in an embodiment of the present invention, which may specifically include the following steps:

[0073] Step 101: Determine the target view page; the target view page has a corresponding child node hierarchy; the child node hierarchy has a corresponding parent node hierarchy; the parent node hierarchy includes the parent node hierarchy view page;

[0074] Step 102: Determine the target element from the target view page;

[0075] Step 103: Perform a simulated click test on the first test item of the target view page, and when it is determined that the test result for the first test item is incorrect, return to the parent node hierarchy view page;

[0076] Step 104: When the target element determines that the parent node hierarchy view page is the target parent node hierarchy view page corresponding to the target view page, a simulated click test is performed on the second test item of the target view page.

[0077] In specific implementations, embodiments of the present invention can be applied to automated testing programs, such as the automated testing program Appium.

[0078] In practical applications, a view page can be a page within an application or a webpage. For example, a fifth-generation Hypertext Markup Language (HTML) page, often abbreviated as H5 page, is the fifth version of HTML. Furthermore, multiple view pages form a tree structure, with the top-level view page being the root view page. The root view page can include one or more subview pages, and subview pages can further include other subview pages. For instance, assuming the root view page is level 0, it might contain three subview pages: view page A, view page B, and view page C. The layer corresponding to C is 1. View pages A, B, and C each have three sub-view pages. The sub-view pages of view page A are view page a1, view page a2, and view page a3. The sub-view pages of view page B are view page b1, view page b2, and view page b3. The sub-view pages of view page C are view page c1, view page c2, and view page c3. The layers corresponding to view pages a1, a2, a3, b1, b2, b3, c1, c2, and c3 are 2.

[0079] In this embodiment of the invention, a target view page can be determined first. The target view page has a corresponding child node hierarchy. For example, the child node hierarchy corresponding to view page a1, view page a2, view page a3, view page b1, view page b2, view page b3, view page c1, view page c2, and view page c3 is 2. The child node hierarchy has a corresponding parent node hierarchy. For example, the hierarchy 2 has a corresponding parent node hierarchy 1. The parent node hierarchy includes the parent node hierarchy view pages. For example, the parent node hierarchy 1 includes view page A, view page B, and view page C.

[0080] After determining the target view page, this embodiment of the invention can determine the target element from the target view page. In specific implementation, the process of determining the target element in the target view page can also be called plotting points on the target view page. Specifically, it involves finding the characteristic elements that can represent the view page in the target view page. Furthermore, the characteristic elements of a subview page are associated with the target parent node hierarchical view page corresponding to the subview page. For example, the connection data, icon data, special text data, etc. in the page. That is, the target element in this embodiment of the invention is the element that is associated with the target parent node hierarchical view page.

[0081] After identifying the target element from the target view page, this embodiment of the invention can perform a simulated click test on the first test item of the target view page. Specifically, the first test item can be any one of multiple test items on the target view page. When the test result for the first test item is determined to be incorrect, this invention can return the test to the parent node hierarchy view page.

[0082] In practical applications, related technologies cannot determine whether the returned parent node hierarchy view page is the target parent node hierarchy view page corresponding to the target view page. For example, view pages A, B, and C correspond to a single level, and each of them has three subview pages: view page A has subview pages a1, a2, and a3; view page B has subview pages b1, b2, and b3; and view page C has subview pages c1, b2, and b3. Image page c2 and view page c3; view pages a1, a2, a3, b1, b2, b3, c1, c2, and c3 correspond to two layers. Assuming the target view page is b2, a simulated click test is performed on the first test item of b2. When the test result for the first test item is determined to be incorrect, the parent node level view page is returned. At this time, the returned page may be any one of A, B, and C. However, in fact, the target parent node level view page corresponding to b2 is only B. Therefore, terminal testing is the only option. As can be seen from the above, the target element in this embodiment of the invention is an element that is associated with the target parent node hierarchical view page. Therefore, it is possible to determine whether the returned parent node hierarchical view page is the target parent node hierarchical view page corresponding to the target view page by using the target element. When it is determined by the target element that the parent node hierarchical view page is the target parent node hierarchical view page corresponding to the target view page, a simulated click test is performed on the second test item of the target view page. The second test item can be any test item other than the first test item among the multiple test items for the target view page.

[0083] This invention, through the following embodiments, determines a target view page; the target view page has a corresponding child node hierarchy; the child node hierarchy has a corresponding parent node hierarchy; the parent node hierarchy includes a parent node hierarchy view page; a target element is determined from the target view page; a simulated click test is performed on the first test item of the target view page, and when the test result for the first test item is determined to be incorrect, the test returns to the parent node hierarchy view page; when the parent node hierarchy view page is determined to be the target parent node hierarchy view page corresponding to the target view page based on the target element, a simulated click test is performed on the second test item of the target view page. This solves the problem that testing cannot continue when an error occurs during the simulated click test of the view page, thereby enabling testing to continue when automated testing is interrupted, and thus improving the efficiency of simulated click testing of the view page.

[0084] Based on the above embodiments, modified embodiments of the above embodiments are proposed. It should be noted that, in order to keep the description brief, only the differences from the above embodiments are described in the modified embodiments.

[0085] In an optional embodiment of the present invention, the method is applied to an automation application having a corresponding remote dictionary service database, and the step of determining the target element from the target view page includes:

[0086] All elements in the target view page are identified, and a target element is randomly selected from the elements according to a preset number; the target element has corresponding target element information;

[0087] The target element information is stored in the remote dictionary service database, and the target element information includes at least: target element name information and target element path information.

[0088] In practical applications, the target view page may be a relatively simple view page. Therefore, when the target view page is a simple view page, this embodiment of the invention can determine all elements in the target view page and randomly select the target element from all elements according to a preset number. In specific implementation, the target element has corresponding target element information, which includes at least the target element name information and the target element path information. This embodiment of the invention can store the target element name information and the target element path information in a remote dictionary service database so that when it is necessary to determine whether the parent node hierarchy view page is the target parent node hierarchy view page corresponding to the target view page, the target element name information and the target element path information can be retrieved from the remote dictionary service database.

[0089] For example, in the target view page, N element names and paths are randomly selected according to a preset number, and serialized into a JSON file with matching type and saved to Redis. JSON file is a lightweight data exchange format.

[0090] In practical applications, Redis (Remote Dictionary Server) is a key-value storage system. Similar to Memcached, it supports a wider range of value types, including string, list, set, sorted set (zset), and hash. These data types support push / pop, add / remove, intersection, union, difference, and more complex operations, all of which are atomic. Furthermore, Redis supports various sorting methods. Like Memcached, data is cached in memory for efficiency. However, Redis periodically writes updated data to disk or appends changes to a log file, and it implements master-slave synchronization. The emergence of Redis largely compensates for the shortcomings of key / value stores like Memcached, and in some cases, it can effectively supplement relational databases. It provides clients for Java, C / C++, C#, PHP, JavaScript, Perl, Objective-C, Python, Ruby, Erlang, etc., making it very convenient to use.

[0091] In an optional embodiment of the present invention, before the step of performing a simulated click test on the second test item of the target view page when the parent node hierarchy view page is determined to be the target parent node hierarchy view page corresponding to the target view page by the target element, the method further includes:

[0092] The target element is used to determine whether the parent node hierarchy view page is the target parent node hierarchy view page corresponding to the target view page;

[0093] The step of determining whether the parent node hierarchy view page is the target parent node hierarchy view page corresponding to the target view page through the target element includes:

[0094] Extract the element name information and the target element path information from the remote dictionary service database;

[0095] The parent node hierarchy view page element for the parent node hierarchy view page is determined by the element name information and the target element path information.

[0096] Determine whether the parent node hierarchy view page element matches the target element.

[0097] As can be seen from the above, in order to continue testing when the test is interrupted, it is necessary to determine whether the parent node hierarchy view page is the target parent node hierarchy view page before performing the simulated click test on the second test item of the target view page. Therefore, in this embodiment of the invention, when the target view page is a simple page, the element name information and the target element path information can be extracted from the remote dictionary service database. Based on the element name information and the target element path information, the parent node hierarchy view page element for the parent node hierarchy view page can be determined, and then it can be determined whether the parent node hierarchy view page element matches the target element.

[0098] For example, extract N element tags containing paths with specific names from Redis, and in the returned parent node hierarchy view page, use the ID selector and XPath selector to find the parent node hierarchy view page element corresponding to the parent node hierarchy view page. If the element tag matches all the parent node hierarchy view page elements, then the parent node hierarchy view page is considered to be the target parent node hierarchy view page corresponding to the target view page.

[0099] In an optional embodiment of the present invention, the step of performing a simulated click test on the second test item of the target view page when the target element determines that the parent node hierarchy view page is the target parent node hierarchy view page corresponding to the target view page includes:

[0100] When the parent node hierarchical view page element matches the target element, a simulated click test is performed on the second test item of the target view page.

[0101] Specifically, when a parent node hierarchy view page element matches a target element, the parent node hierarchy view page can be considered as the target parent node hierarchy view page corresponding to the target view page. Therefore, a simulated click test can be performed on the second test item of the target view page.

[0102] In this embodiment of the invention, by determining all elements in the target view page, a target element is randomly selected from the elements according to a preset number; the target element has corresponding target element information; the target element information is stored in the remote dictionary service database, and the target element information includes at least: target element name information and target element path information; the element name information and the target element path information are extracted from the remote dictionary service database; the parent node level view page element for the parent node level view page is determined through the element name information and the target element path information; it is determined whether the parent node level view page element matches the target element; when the parent node level view page element matches the target element, a simulated click test is performed on the second test item of the target view page, thereby solving the problem that the test cannot continue when an error occurs during the simulated click test of the view page when the target view page is a simple page, and also simplifying the process of determining the target element, thereby further improving the efficiency of the simulated click test of the view page.

[0103] In an optional embodiment of the present invention, the method is applied to an automation application having a corresponding remote dictionary service database, and the step of determining the target element from the target view page includes:

[0104] Generate a first page image for the target view page;

[0105] A hash algorithm is used to generate a first image fingerprint for the first page image, and the first image fingerprint is stored as a target element in the remote dictionary service database.

[0106] In practical applications, the target view page may be a view page with relatively complex content. Therefore, the embodiments of the present invention can generate a first page image for the target view page, and use a hash algorithm to generate a first image fingerprint code for the first page image, and store the first image fingerprint code as a target element in a remote dictionary service database.

[0107] For example, the target view page can be saved as an image by taking a screenshot. The image size can be reduced to 32*32 using a perceptual hash algorithm. The image grayscale can be adjusted to simplify the colors. The image can be transformed by DCT to calculate the average value. Finally, the image can be converted into a binary image fingerprint by calculating the hash value and stored in Redis along with the matching type.

[0108] In an optional embodiment of the present invention, before the step of performing a simulated click test on the second test item of the target view page when the parent node hierarchy view page is determined to be the target parent node hierarchy view page corresponding to the target view page by the target element, the method further includes:

[0109] The target element is used to determine whether the parent node hierarchy view page is the target parent node hierarchy view page corresponding to the target view page;

[0110] The step of determining whether the parent node hierarchy view page is the target parent node hierarchy view page corresponding to the target view page through the target element includes:

[0111] Generate a second page image for the target view page;

[0112] A hash algorithm is used to generate a second image fingerprint for the image on the second page;

[0113] Extract the first fingerprint from the remote dictionary service database;

[0114] Determine whether the similarity between the first fingerprint code and the second image fingerprint code is greater than a preset threshold.

[0115] As shown above, in order to continue testing if it is interrupted, it is necessary to determine whether the parent node hierarchy view page is the target parent node hierarchy view page before performing the simulated click test on the second test item of the target view page. Therefore,

[0116] In embodiments of the present invention, when the target view page is a complex page, a second page image for the target view page is generated, a second image fingerprint code for the second page image is generated using a hash algorithm, a first fingerprint code is extracted from a remote dictionary service database, and it is determined whether the similarity between the first fingerprint code and the second image fingerprint code is greater than a preset threshold.

[0117] For example, Appium can be used to take a screenshot of the parent node-level view page to generate an image of the parent node-level view page. A fingerprint of the image is constructed using a perceptual hash algorithm. The similarity between the two image fingerprints is then used to identify the similarity between the images. Based on the actual situation, when the similarity meets a preset threshold, the parent node-level view page is considered to be the target parent node-level view page corresponding to the target view page.

[0118] In an optional embodiment of the present invention, the step of performing a simulated click test on the second test item of the target view page when the target element determines that the parent node hierarchy view page is the target parent node hierarchy view page corresponding to the target view page includes:

[0119] When the similarity between the first fingerprint code and the second image fingerprint code is greater than a preset threshold, a simulated click test is performed on the second test item of the target view page.

[0120] Specifically, when the similarity between the first fingerprint code and the second image fingerprint code is greater than a preset threshold, the parent node hierarchical view page can be considered as the target parent node hierarchical view page corresponding to the target view page. Therefore, a simulated click test can be performed on the second test item of the target view page.

[0121] This invention, in its embodiment, generates a first page image for the target view page; generates a first image fingerprint for the first page image using a hash algorithm, and stores the first image fingerprint as a target element in the remote dictionary service database; determines whether the parent node hierarchy view page is the target parent node hierarchy view page corresponding to the target view page based on the target element; generates a second page image for the target view page; generates a second image fingerprint for the second page image using a hash algorithm; extracts the first fingerprint from the remote dictionary service database; determines whether the similarity between the first fingerprint and the second image fingerprint is greater than a preset threshold; and when the similarity between the first fingerprint and the second image fingerprint is greater than the preset threshold, performs a simulated click test on the second test item of the target view page. This solves the problem of being unable to continue testing when an error occurs during the simulated click test of the view page, especially when the target view page is a complex page, and simplifies the process of determining the target element, thereby further improving the efficiency of the simulated click test of the view page.

[0122] To enable those skilled in the art to better understand the embodiments of the present invention, a complete example is provided below to illustrate the embodiments of the present invention.

[0123] refer to Figure 2 , Figure 2 This is a flowchart of another method for simulating click testing on a view page provided in an embodiment of the present invention.

[0124] 1. Identify the target element from the target view page:

[0125] For simple views, a method of uniformly extracting and signing element information from multiple points can be used to save the data. This involves randomly selecting the element names and paths of N points from the target view page according to a preset number, adding matching types, serializing them into a JSON file, and saving it to Redis. JSON is a lightweight data exchange format.

[0126] For complex and similar views, the target view page can be saved as an image by taking a screenshot. The image size is reduced to 32*32 using a perceptual hash algorithm. The colors are simplified by adjusting the grayscale of the image. The image is then subjected to DCT transformation to calculate the average value. Finally, the image is converted into a binary image fingerprint by calculating the hash value and stored in Redis along with the matching type.

[0127] 2. When performing simulated click tests on the target view page, retrieve the target element from Redis. If an interruption occurs due to the target view page failing to display correctly, write the interruption error information to the log. Depending on whether the view type is a native application or embedded H5, perform one or more rollback operations to forcibly roll back to the previous parent node level view page. Then, match the retrieved target element against the current view element. If the match is correct, skip the current exception and continue the test process. Finally, output the error information for troubleshooting. The target element matching is based on the matching type of the input target element. For example, if the target element matching type is element name information and target element path information, then retrieve N points of the anchor data. For element tags with specific names and paths, the returned page directly searches for elements using the id selector and XPath selector. If all matches are found, the parent node hierarchy view page is considered the target parent node hierarchy view page corresponding to the target view page, and the next test is performed. If the target element's matching type is an image fingerprint, Appium is used to take a screenshot of the parent node hierarchy view page to generate an image of the parent node hierarchy view page. An image fingerprint of the parent node hierarchy view page is constructed using a perceptual hash algorithm. The similarity between the two image fingerprints is identified. Based on the actual situation, when the similarity meets a preset threshold, the parent node hierarchy view page is considered the target parent node hierarchy view page corresponding to the target view page.

[0128] The embodiments of the present invention can effectively avoid overall test interruption or serious deviation of results caused by abnormal test of target view page in automated testing, and return to the main process in a timely manner to ensure the integrity of the test process, the accuracy of test results, and the optimization of test instructions by analyzing error logs.

[0129] It should be noted that, for the sake of simplicity, the method embodiments are all described as a series of actions. However, those skilled in the art should understand that the embodiments of the present invention are not limited to the described order of actions, because according to the embodiments of the present invention, some steps can be performed in other orders or simultaneously. Furthermore, those skilled in the art should also understand that the embodiments described in the specification are preferred embodiments, and the actions involved are not necessarily essential to the embodiments of the present invention.

[0130] Reference Figure 3 The diagram illustrates a structural block diagram of a simulated click testing device for a view page provided in an embodiment of the present invention, which may specifically include the following modules:

[0131] The target view page determination module 301 is used to determine the target view page; the target view page has a corresponding child node hierarchy; the child node hierarchy has a corresponding parent node hierarchy; the parent node hierarchy includes the parent node hierarchy view page;

[0132] The target element determination module 302 is used to determine the target element from the target view page;

[0133] The parent node hierarchy view page return module 303 is used to perform a simulated click test on the first test item of the target view page, and return to the parent node hierarchy view page when the test result for the first test item is determined to be incorrect.

[0134] The test restart module 304 is used to perform a simulated click test on the second test item of the target view page when the target element determines that the parent node hierarchical view page is the target parent node hierarchical view page corresponding to the target view page.

[0135] Optionally, the device is applied to an automation application that has a corresponding remote dictionary service database, and the target element determination module may include:

[0136] The target element determination submodule is used to determine all elements in the target view page and randomly determine target elements from the elements according to a preset number; the target element has corresponding target element information;

[0137] The target element information storage submodule is used to store the target element information in the remote dictionary service database. The target element information includes at least: target element name information and target element path information.

[0138] Optionally, it may also include:

[0139] The first judgment module is used to determine whether the parent node hierarchy view page is the target parent node hierarchy view page corresponding to the target view page based on the target element;

[0140] The first judgment module includes:

[0141] The target element information extraction submodule is used to extract the element name information and the target element path information from the remote dictionary service database;

[0142] The parent node hierarchy view page element determination submodule is used to determine the parent node hierarchy view page element for the parent node hierarchy view page based on the element name information and the target element path information.

[0143] The first judgment submodule is used to determine whether the parent node hierarchical view page element matches the target element.

[0144] Optionally, the test restart module may include:

[0145] The first test restart submodule is used to perform a simulated click test on the second test item of the target view page when the parent node hierarchical view page element matches the target element.

[0146] Optionally, the device is applied to an automation application that has a corresponding remote dictionary service database, and the target element determination module may include:

[0147] The first page image generation submodule is used to generate a first page image for the target view page;

[0148] The first image fingerprint generation submodule is used to generate a first image fingerprint for the first page image using a hash algorithm, and store the first image fingerprint as a target element in the remote dictionary service database.

[0149] Optionally, it may also include:

[0150] The second judgment module is used to determine whether the parent node hierarchy view page is the target parent node hierarchy view page corresponding to the target view page based on the target element;

[0151] The second judgment module includes:

[0152] The second page image generation submodule is used to generate a second page image for the target view page;

[0153] The second image fingerprint generation submodule is used to generate a second image fingerprint for the second page image using a hash algorithm.

[0154] The first fingerprint code extraction submodule is used to extract the first fingerprint code from the remote dictionary service database;

[0155] The second judgment submodule is used to determine whether the similarity between the first fingerprint code and the second image fingerprint code is greater than a preset threshold.

[0156] Optionally, the test restart module may include:

[0157] The second test restart submodule is used to perform a simulated click test on the second test item of the target view page when the similarity between the first fingerprint code and the second image fingerprint code is greater than a preset threshold.

[0158] As the device embodiment is basically similar to the method embodiment, the description is relatively simple, and relevant parts can be found in the description of the method embodiment.

[0159] In addition, this invention also provides an electronic device, including: a processor, a memory, and a computer program stored in the memory and executable on the processor. When the computer program is executed by the processor, it implements the various processes of the above-described simulated click test method embodiment for a view page and achieves the same technical effect. To avoid repetition, it will not be described again here.

[0160] This invention also provides a computer-readable storage medium storing a computer program. When executed by a processor, the computer program implements the various processes of the above-described simulated click test method embodiments for view pages, achieving the same technical effects. To avoid repetition, these details are not repeated here. The computer-readable storage medium may be a read-only memory (ROM), a random access memory (RAM), a magnetic disk, or an optical disk.

[0161] Figure 4 A schematic diagram of the hardware structure of an electronic device for implementing various embodiments of the present invention.

[0162] The electronic device 400 includes, but is not limited to, components such as: a radio frequency unit 401, a network module 402, an audio output unit 403, an input unit 404, a sensor 405, a display unit 406, a user input unit 407, an interface unit 408, a memory 409, a processor 410, and a power supply 411. Those skilled in the art will understand that... Figure 4The electronic device structures shown are not intended to limit the electronic device. An electronic device may include more or fewer components than shown, or combine certain components, or have different component arrangements. In embodiments of the present invention, the electronic device includes, but is not limited to, mobile phones, tablet computers, laptops, PDAs, in-vehicle terminals, wearable devices, and pedometers.

[0163] It should be understood that, in this embodiment of the invention, the radio frequency unit 401 can be used for receiving and transmitting signals during information transmission or calls. Specifically, it receives downlink data from the base station and processes it with the processor 410; additionally, it transmits uplink data to the base station. Typically, the radio frequency unit 401 includes, but is not limited to, an antenna, at least one amplifier, a transceiver, a coupler, a low-noise amplifier, a duplexer, etc. Furthermore, the radio frequency unit 401 can also communicate with networks and other devices through a wireless communication system.

[0164] The electronic device provides users with wireless broadband internet access through network module 402, such as helping users send and receive emails, browse web pages, and access streaming media.

[0165] The audio output unit 403 can convert audio data received by the radio frequency unit 401 or the network module 402 or stored in the memory 409 into audio signals and output them as sound. Furthermore, the audio output unit 403 can also provide audio output related to specific functions performed by the electronic device 400 (e.g., call signal reception sound, message reception sound, etc.). The audio output unit 403 includes a speaker, a buzzer, and a receiver, etc.

[0166] Input unit 404 is used to receive audio or video signals. Input unit 404 may include a graphics processing unit (GPU) 4041 and a microphone 4042. The GPU 4041 processes image data of still images or videos acquired by an image capture device (such as a camera) in video capture mode or image capture mode. The processed image frames can be displayed on display unit 406. The image frames processed by GPU 4041 can be stored in memory 409 (or other storage medium) or transmitted via radio frequency unit 401 or network module 402. Microphone 4042 can receive sound and process such sound into audio data. The processed audio data can be converted into a format that can be transmitted to a mobile communication base station via radio frequency unit 401 in telephone call mode.

[0167] The electronic device 400 also includes at least one sensor 405, such as a light sensor, a motion sensor, and other sensors. Specifically, the light sensor includes an ambient light sensor and a proximity sensor. The ambient light sensor can adjust the brightness of the display panel 4061 according to the ambient light level, and the proximity sensor can turn off the display panel 4061 and / or backlight when the electronic device 400 is moved to the ear. As a type of motion sensor, an accelerometer sensor can detect the magnitude of acceleration in various directions (generally three axes). When stationary, it can detect the magnitude and direction of gravity and can be used to identify the posture of the electronic device (such as landscape / portrait switching, related games, magnetometer posture calibration), vibration recognition related functions (such as pedometer, tapping), etc. The sensor 405 may also include a fingerprint sensor, pressure sensor, iris sensor, molecular sensor, gyroscope, barometer, hygrometer, thermometer, infrared sensor, etc., which will not be described in detail here.

[0168] The display unit 406 is used to display information input by the user or information provided to the user. The display unit 406 may include a display panel 4061, which may be configured in the form of a liquid crystal display (LCD), an organic light-emitting diode (OLED), or the like.

[0169] User input unit 407 can be used to receive input numerical or character information, and generate key signal inputs related to user settings and function control of electronic devices. Specifically, user input unit 407 includes a touch panel 4071 and other input devices 4072. Touch panel 4071, also known as a touch screen, can collect touch operations performed by the user on or near it (such as operations performed by the user using a finger, stylus, or any suitable object or accessory on or near touch panel 4071). Touch panel 4071 may include two parts: a touch detection device and a touch controller. The touch detection device detects the user's touch position and the signal generated by the touch operation, and transmits the signal to the touch controller; the touch controller receives touch information from the touch detection device, converts it into touch point coordinates, and sends it to the processor 410, which receives and executes commands from the processor 410. In addition, touch panel 4071 can be implemented using various types such as resistive, capacitive, infrared, and surface acoustic wave. Besides touch panel 4071, user input unit 407 may also include other input devices 4072. Specifically, other input devices 4072 may include, but are not limited to, physical keyboards, function keys (such as volume control buttons, power buttons, etc.), trackballs, mice, joysticks, etc., which will not be described in detail here.

[0170] Furthermore, the touch panel 4071 can cover the display panel 4061. When the touch panel 4071 detects a touch operation on or near it, it transmits the information to the processor 410 to determine the type of touch event. Subsequently, the processor 410 provides corresponding visual output on the display panel 4061 based on the type of touch event. Although in Figure 4 In this embodiment, the touch panel 4071 and the display panel 4061 are two independent components to realize the input and output functions of the electronic device. However, in some embodiments, the touch panel 4071 and the display panel 4061 can be integrated to realize the input and output functions of the electronic device. The specific implementation is not limited here.

[0171] Interface unit 408 serves as an interface for connecting external devices to electronic device 400. For example, external devices may include a wired or wireless headphone port, an external power supply (or battery charger) port, a wired or wireless data port, a memory card port, a port for connecting a device with an identification module, an audio input / output (I / O) port, a video I / O port, a headphone port, and so on. Interface unit 408 can be used to receive input from external devices (e.g., data, power, etc.) and transmit the received input to one or more components within electronic device 400, or it can be used to transmit data between electronic device 400 and external devices.

[0172] The memory 409 can be used to store software programs and various data. The memory 409 may primarily include a program storage area and a data storage area. The program storage area may store the operating system, applications required for at least one function (such as sound playback, image playback, etc.), etc.; the data storage area may store data created based on the use of the mobile phone (such as audio data, phonebook, etc.). Furthermore, the memory 409 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, or other volatile solid-state storage device.

[0173] The processor 410 is the control center of the electronic device. It connects various parts of the electronic device via various interfaces and lines. By running or executing software programs and / or modules stored in the memory 409, and by calling data stored in the memory 409, it performs various functions and processes data, thereby providing overall monitoring of the electronic device. The processor 410 may include one or more processing units; preferably, the processor 410 may integrate an application processor and a modem processor. The application processor mainly handles the operating system, user interface, and applications, while the modem processor mainly handles wireless communication. It is understood that the modem processor may not be integrated into the processor 410.

[0174] The electronic device 400 may also include a power supply 411 (such as a battery) for supplying power to various components. Preferably, the power supply 411 can be logically connected to the processor 410 through a power management system, thereby enabling functions such as managing charging, discharging, and power consumption through the power management system.

[0175] In addition, the electronic device 400 includes some functional modules not shown, which will not be described in detail here.

[0176] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes that element.

[0177] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes several instructions to cause a terminal (which may be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in the various embodiments of the present invention.

[0178] The embodiments of the present invention have been described above with reference to the accompanying drawings. However, the present invention is not limited to the specific embodiments described above. The specific embodiments described above are merely illustrative and not restrictive. Those skilled in the art can make many other forms under the guidance of the present invention without departing from the spirit and scope of the claims, and all of these forms are within the protection scope of the present invention.

[0179] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed in this invention can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of this invention.

[0180] Those skilled in the art will understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.

[0181] In the embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative. For instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.

[0182] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0183] In addition, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.

[0184] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this invention, essentially, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, ROM, RAM, magnetic disks, or optical disks.

[0185] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the technical scope disclosed in the present invention should be included within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.

Claims

1. A method for simulating clicks on a view page, characterized in that, include: Determine the target view page; The target view page has a corresponding child node hierarchy; The child node hierarchy has a corresponding parent node hierarchy; The parent node hierarchy includes the parent node hierarchy view page; Identify the target element from the target view page; A simulated click test is performed on the first test item of the target view page, and when the test result for the first test item is determined to be incorrect, the parent node hierarchy view page is returned. When the target element determines that the parent node hierarchy view page is the target parent node hierarchy view page corresponding to the target view page, a simulated click test is performed on the second test item of the target view page; The method is applied to an automation application that has a corresponding remote dictionary service database. The step of determining the target element from the target view page includes: All elements in the target view page are identified, and a target element is randomly selected from the elements according to a preset number; the target element has corresponding target element information; The target element information is stored in the remote dictionary service database, and the target element information includes at least: target element name information and target element path information; Before the step of performing a simulated click test on the second test item of the target view page when the target element determines that the parent node hierarchy view page is the target parent node hierarchy view page corresponding to the target view page, the method further includes: The target element is used to determine whether the parent node hierarchy view page is the target parent node hierarchy view page corresponding to the target view page; The step of determining whether the parent node hierarchy view page is the target parent node hierarchy view page corresponding to the target view page through the target element includes: Extract the element name information and the target element path information from the remote dictionary service database; The parent node hierarchy view page element for the parent node hierarchy view page is determined by the element name information and the target element path information. Determine whether the parent node hierarchy view page element matches the target element.

2. The method according to claim 1, characterized in that, When the target element determines that the parent node hierarchy view page is the target parent node hierarchy view page corresponding to the target view page, the step of simulating a click test for the second test item of the target view page includes: When the parent node hierarchical view page element matches the target element, a simulated click test is performed on the second test item of the target view page.

3. The method according to claim 1, characterized in that, The method is applied to an automation application that has a corresponding remote dictionary service database. The step of determining the target element from the target view page includes: Generate a first page image for the target view page; A hash algorithm is used to generate a first image fingerprint for the first page image, and the first image fingerprint is stored as a target element in the remote dictionary service database.

4. The method according to claim 3, characterized in that, Before the step of performing a simulated click test on the second test item of the target view page when the target element determines that the parent node hierarchy view page is the target parent node hierarchy view page corresponding to the target view page, the method further includes: The target element is used to determine whether the parent node hierarchy view page is the target parent node hierarchy view page corresponding to the target view page; The step of determining whether the parent node hierarchy view page is the target parent node hierarchy view page corresponding to the target view page through the target element includes: Generate a second page image for the target view page; A hash algorithm is used to generate a second image fingerprint for the image on the second page; Extract the fingerprint code of the first image from the remote dictionary service database; Determine whether the similarity between the fingerprint code in the first image and the fingerprint code in the second image is greater than a preset threshold.

5. The method according to claim 4, characterized in that, When the target element determines that the parent node hierarchy view page is the target parent node hierarchy view page corresponding to the target view page, the step of simulating a click test for the second test item of the target view page includes: When the similarity between the first image fingerprint code and the second image fingerprint code is greater than a preset threshold, a simulated click test is performed on the second test item of the target view page.

6. A device for simulating clicks on a view page, characterized in that, include: The target view page determination module is used to determine the target view page; The target view page has a corresponding child node hierarchy; The child node hierarchy has a corresponding parent node hierarchy; The parent node hierarchy includes the parent node hierarchy view page; The target element determination module is used to determine the target element from the target view page; The parent node hierarchy view page return module is used to perform a simulated click test on the first test item of the target view page, and return to the parent node hierarchy view page when the test result for the first test item is determined to be incorrect. The test restart module is used to perform a simulated click test on the second test item of the target view page when the target element determines that the parent node hierarchy view page is the target parent node hierarchy view page corresponding to the target view page; The device is applied to an automation application, which has a corresponding remote dictionary service database. The target element determination module includes: The target element determination submodule is used to determine all elements in the target view page and randomly determine target elements from the elements according to a preset number; the target element has corresponding target element information; The target element information storage submodule is used to store the target element information in the remote dictionary service database. The target element information includes at least: target element name information and target element path information. The first judgment module is used to determine whether the parent node hierarchy view page is the target parent node hierarchy view page corresponding to the target view page based on the target element; The first judgment module includes: The target element information extraction submodule is used to extract the element name information and the target element path information from the remote dictionary service database; The parent node hierarchy view page element determination submodule is used to determine the parent node hierarchy view page element for the parent node hierarchy view page based on the element name information and the target element path information. The first judgment submodule is used to determine whether the parent node hierarchical view page element matches the target element.

7. The apparatus according to claim 6, characterized in that, The test restart module includes: The first test restart submodule is used to perform a simulated click test on the second test item of the target view page when the parent node hierarchical view page element matches the target element.

8. The apparatus according to claim 6, characterized in that, The device is used in an automation application, which has a corresponding remote dictionary service database. The target element determination module includes: The first page image generation submodule is used to generate a first page image for the target view page; The first image fingerprint generation submodule is used to generate a first image fingerprint for the first page image using a hash algorithm, and store the first image fingerprint as a target element in the remote dictionary service database.

9. The apparatus according to claim 8, characterized in that, Also includes: The second judgment module is used to determine whether the parent node hierarchy view page is the target parent node hierarchy view page corresponding to the target view page based on the target element; The second judgment module includes: The second page image generation submodule is used to generate a second page image for the target view page; The second image fingerprint generation submodule is used to generate a second image fingerprint for the second page image using a hash algorithm. The first image fingerprint extraction submodule is used to extract the first image fingerprint from the remote dictionary service database; The second judgment submodule is used to determine whether the similarity between the fingerprint code of the first image and the fingerprint code of the second image is greater than a preset threshold.

10. The apparatus according to claim 9, characterized in that, The test restart module includes: The second test restart submodule is used to perform a simulated click test on the second test item of the target view page when the similarity between the first image fingerprint code and the second image fingerprint code is greater than a preset threshold.

11. An electronic device, characterized in that, It includes a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus; The memory is used to store computer programs; When the processor executes a program stored in the memory, it implements the method as described in any one of claims 1-5.

12. A computer-readable storage medium having instructions stored thereon that, when executed by one or more processors, cause the processors to perform the method as described in any one of claims 1-5.

Citation Information

Patent Citations

  • Application page traversal detection method, device and equipment, and readable storage medium

    CN112115051A

  • Page skip test method and device, equipment and storage medium

    CN112256562A