Test case generation method and device, electronic equipment and storage medium

By detecting the operation behavior of browsing objects in the test environment and automatically generating test cases, the low coverage problem caused by manual generation of test cases is solved, and efficient test coverage and accuracy are achieved.

CN120295901APending Publication Date: 2025-07-11TENCENT TECHNOLOGY (SHENZHEN) CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410032901.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-01-08
Publication Date
2025-07-11

AI Technical Summary

Technical Problem

Existing test cases rely on manual generation, resulting in low test coverage and inability to effectively cover most page functions in the application, affecting the accuracy of the test results.

Method used

By detecting the operation behavior of browsing objects in the test environment, obtaining page data of specified behaviors and associated historical behaviors, automatically generating test cases, and using network crawling technology to obtain page data and generate test baselines.

Benefits of technology

It improves the coverage of test cases, ensures that the test cases cover the commonly used page functions of the current web browsing objects, reduces the complexity of manual screen recording and improves the accuracy of test results.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120295901A_ABST
    Figure CN120295901A_ABST
Patent Text Reader

Abstract

The invention discloses a test case generation method and device, electronic equipment and a storage medium, and relates to the technical field of data processing. According to the method, when it is detected that a specified behavior exists in multiple operation behaviors generated by a browsing object in an application program in a test environment, a target page triggering the specified behavior is obtained. Then, first page data generated by the specified behavior in the target page is obtained from a page document of the target page, and when it is determined that the specified behavior is associated with at least one historical behavior, second page data generated by the at least one historical behavior in the target page are obtained; and finally, according to the first page data and the obtained at least one second page data, generating a test case of the specified behavior. Through the process, the test case can be automatically generated according to the real operation behavior of the browsing object in the application program, so that the test coverage rate of the case is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the technical field of data processing, and specifically discloses a method, apparatus, electronic device, and storage medium for generating test cases. Background Art

[0002] Front-end testing is an important task in the process of application development and maintenance. By executing test cases in the application, it determines whether there are abnormalities in the page functions of the application for a specific test case based on the execution results of the application for the test case.

[0003] Currently, most test cases rely on manual generation. Mainly, testers perform preset operations within the front-end page to trigger the page functions to be tested. During this period, page testing tools such as Applitools and Testim are used to obtain the code execution logic for this page function and generate test cases corresponding to this page function.

[0004] For example, when testing whether the login function is available, the tester needs to manually enter the account and password on the login page, and then trigger the login jump function of the page by clicking the login button. During this period, the page testing tool is enabled to obtain the code execution logic for triggering the login jump, and test cases for testing the login jump function of the page are generated based on this code execution logic.

[0005] However, when the familiarity of the tester with the application is insufficient, it will lead to a low test coverage rate of the test cases, that is, many page functions carried by the application do not generate corresponding test cases, resulting in many page functions being missed in testing, and thus seriously affecting the accuracy of the test results. Summary of the Invention

[0006] Embodiments of this application provide a method, apparatus, electronic device, and storage medium for generating test cases, which are used to automatically generate test cases according to the actual operation behaviors of the browsing object in the application, so as to improve the test coverage rate of the test cases.

[0007] In a first aspect, an embodiment of this application provides a method for generating test cases, and the method includes:

[0008] When a specified behavior exists among multiple operation behaviors generated by a browsing object in an application under a test environment, obtain the target page that triggers the specified behavior;

[0009] Obtain first page data generated by the specified behavior in the target page from the page document of the target page;

[0010] When it is determined that the specified behavior is associated with at least one historical behavior, obtain the second page data generated by each of the at least one historical behavior within the target page; wherein, the historical behavior is a non-specified behavior among the multiple operation behaviors, and the trigger time is within a set time period before the specified behavior.

[0011] Generate a test case for the specified behavior according to the first page data and the at least one obtained second page data.

[0012] In some possible implementation manners, before obtaining the second page data generated by each of the at least one historical behavior within the target page, the method further includes:

[0013] If there are multiple first behaviors that trigger the same page component among the at least one historical behavior, retain the first behavior whose trigger time is adjacent to the specified behavior, and eliminate the other remaining first behaviors.

[0014] In some possible implementation manners, the generating a test case for the specified behavior according to the first page data and the at least one obtained second page data includes:

[0015] In response to a use case generation instruction, obtain a test process based on the trigger time and function call method of the specified behavior and each of the at least one historical behavior;

[0016] Select at least one behavior to be tested that conforms to a preset behavior criterion from the specified behavior and the at least one historical behavior;

[0017] For each of the at least one behavior to be tested, perform the following operations respectively: generate a corresponding test baseline according to the page data generated by the behavior to be tested within the target page; wherein, when the behavior to be tested is the specified behavior, the page data is the first page data; when the behavior to be tested is a historical behavior, the page data is the second page data of the historical behavior;

[0018] Determine the test case according to the test process and the at least one obtained test baseline.

[0019] In some possible implementation manners, the generating a corresponding test baseline according to the page data generated by the behavior to be tested within the target page includes:

[0020] Determine the hypertext markup language file of the target page according to the uniform resource locator of the behavior to be tested;

[0021] Obtain the historical trigger result of the behavior to be tested for the page component from the hypertext markup language file;

[0022] Determine the test baseline of the behavior to be tested according to the historical trigger result.

[0023] In some possible implementation manners, after generating the test case for the specified behavior, the method further includes:

[0024] In response to the test case test instruction, execute the test case, and after the execution of the test case is completed, obtain the trigger result of the behavior to be tested from the hypertext markup language;

[0025] Perform text similarity comparison on the behavior to be tested by using the test baseline, and obtain the text similarity between the historical trigger result and the trigger result;

[0026] Generate a test case test result for the test case according to the text similarity.

[0027] In some possible implementation manners, generating the corresponding test baseline according to the page data generated by the behavior to be tested on the target page includes:

[0028] When the browsing object finishes executing the behavior to be tested, capture a first page screenshot of the currently displayed page of the application;

[0029] Determine the test baseline of the behavior to be tested according to the first page screenshot.

[0030] In some possible implementation manners, after generating the test case for the specified behavior, the method further includes:

[0031] In response to the test case test instruction, execute the test case, and when the behavior to be tested in the test case is completed, capture a second page screenshot of the currently displayed page of the application;

[0032] Perform image anomaly comparison on the behavior to be tested by using the test baseline, and obtain the image anomaly area between the first page screenshot and the second page screenshot;

[0033] Generate a test case test result for the test case according to the image anomaly area.

[0034] In some possible implementation manners, performing image anomaly comparison on the behavior to be tested by using the test baseline, and obtaining the image anomaly area between the first page screenshot and the second page screenshot, includes:

[0035] Perform RGB conversion on the first page screenshot and the second page screenshot respectively to obtain the RGB values of the first pixel and the RGB values of the second pixel; wherein, the first pixel is a pixel of the first page screenshot, and the second pixel is a pixel of the second page screenshot;

[0036] For each second pixel, calculate the color similarity between the second pixel and its comparison pixel; wherein, the comparison pixel of the second pixel is the first pixel with the same coordinates as the second pixel;

[0037] Determine the image abnormal area according to the second pixels with color similarity lower than the similarity threshold.

[0038] In some possible implementation manners, the specified behavior includes an operation behavior that triggers a page jump operation, an operation behavior that triggers an upload operation, and an operation behavior that triggers a download operation.

[0039] In a second aspect, an embodiment of the present application further provides a test case generation device, and the device includes:

[0040] A page confirmation unit, configured to: when it is detected that there is a specified behavior among multiple operation behaviors generated by a browsing object in an application program in a test environment, obtain a target page that triggers the specified behavior;

[0041] A data acquisition unit, configured to: obtain first page data generated by the specified behavior in the target page from the page document of the target page;

[0042] A data processing unit, configured to: when it is determined that the specified behavior is associated with at least one historical behavior, obtain second page data generated by each of the at least one historical behavior in the target page; wherein, the historical behavior is a non-specified behavior among the multiple operation behaviors whose trigger time is within a set time period before the specified behavior;

[0043] A test case generation unit, configured to: generate a test case for the specified behavior according to the first page data and the obtained at least one second page data.

[0044] In some possible implementation manners, before performing the operation of obtaining the second page data generated by each of the at least one historical behavior in the target page, the data processing unit is further configured to:

[0045] If there are multiple first behaviors that trigger the same page component among the at least one historical behavior, retain the first behavior whose trigger time is adjacent to the specified behavior, and eliminate the other remaining first behaviors.

[0046] In some possible embodiments, the use case generation unit is configured to execute generating test cases for the specified behavior according to the first page data and at least one obtained second page data, specifically configured as follows:

[0047] In response to a use case generation instruction, obtain a test process based on the trigger time and function call method of each of the specified behavior and the at least one historical behavior;

[0048] Select at least one behavior to be tested that conforms to a preset behavior criterion from the specified behavior and the at least one historical behavior;

[0049] For each of the at least one behavior to be tested, perform the following operations respectively: generate a corresponding test baseline according to the page data generated by the behavior to be tested on the target page; wherein, when the behavior to be tested is the specified behavior, the page data is the first page data; when the behavior to be tested is a historical behavior, the page data is the second page data of the historical behavior; determine the test case according to the test process and the at least one obtained test baseline.

[0050] In some possible embodiments, the use case generation unit is configured to execute generating a corresponding test baseline according to the page data generated by the behavior to be tested on the target page, specifically configured as follows:

[0051] Determine the hypertext markup language file of the target page according to the uniform resource locator of the behavior to be tested;

[0052] Obtain the historical trigger result of the behavior to be tested for the page component from the hypertext markup language file;

[0053] Determine the test baseline of the behavior to be tested according to the historical trigger result.

[0054] In some possible embodiments, after executing generating the test cases for the specified behavior, the use case generation unit is further configured to:

[0055] In response to a use case test instruction, execute the test case, and after the test case is executed, obtain the trigger result of the behavior to be tested from the hypertext markup language;

[0056] Perform a text similarity comparison on the behavior to be tested using the test baseline to obtain the text similarity between the historical trigger result and the trigger result;

[0057] Generate a use case test result for the test case according to the text similarity.

[0058] In some possible embodiments, page data generated on the target page according to the behavior to be tested is executed to generate a corresponding test baseline. The test case generation unit is specifically configured to:

[0059] When the browsing object finishes executing the behavior to be tested, capture a first page screenshot of the currently displayed page of the application;

[0060] Determine the test baseline of the behavior to be tested according to the first page screenshot.

[0061] In some possible embodiments, after generating the test case for the specified behavior, the test case generation unit is further configured to:

[0062] In response to a test case execution instruction, execute the test case, and when the behavior to be tested in the test case is completed, capture a second page screenshot of the currently displayed page of the application;

[0063] Perform an image anomaly comparison on the behavior to be tested using the test baseline to obtain an image anomaly area between the first page screenshot and the second page screenshot;

[0064] Generate a test case result for the test case according to the image anomaly area.

[0065] In some possible embodiments, when performing an image anomaly comparison on the behavior to be tested using the test baseline to obtain an image anomaly area between the first page screenshot and the second page screenshot, the test case generation unit is specifically configured to:

[0066] Perform color space RGB conversion on the first page screenshot and the second page screenshot respectively to obtain the RGB values of the first pixel point and the RGB values of the second pixel point; wherein, the first pixel point is a pixel point of the first page screenshot, and the second pixel point is a pixel point of the second page screenshot;

[0067] For each second pixel point, calculate the color similarity between the second pixel point and the comparison pixel point of the second pixel point; wherein, the comparison pixel point of the second pixel point is the first pixel point having the same coordinates as the second pixel point;

[0068] Determine the image anomaly area according to the second pixel points with color similarity lower than the similarity threshold.

[0069] In some possible embodiments, the specified behavior includes an operation behavior that triggers a page jump operation, an operation behavior that triggers an upload operation, and an operation behavior that triggers a download operation.

[0070] In a third aspect, an embodiment of the present application further provides an electronic device, including a processor, a memory, and a display. The display provides a command-line interface for receiving triggered operations. The memory stores a computer program, and when the computer program is executed by the processor, the processor is caused to execute the steps of the above-mentioned method for generating a test case.

[0071] In a fourth aspect, an embodiment of the present application further provides a computer-readable storage medium, on which computer-executable instructions are stored. When the computer-executable instructions are executed by a computer device, the steps of the above-mentioned method for generating a test case are implemented.

[0072] In a fifth aspect, an embodiment of the present application further provides a computer program product, including a computer program. When the computer program is executed by a computer device, the steps of the above-mentioned method for generating a test case are implemented.

[0073] The beneficial effects of the present application are as follows:

[0074] An embodiment of the present application provides a method, a device, an electronic device, and a storage medium for generating a test case. In this method, when it is detected in a test environment that among multiple operation behaviors generated by a browsing object in an application program, there is a specified behavior, the target page that triggers the specified behavior is obtained. The specified behavior is an operation behavior that is preset for triggering a function to be tested.

[0075] Next, from the page document of the target page, the first page data generated by the specified behavior in the target page is obtained. When it is determined that the specified behavior is associated with at least one historical behavior, the second page data generated by each of the at least one historical behavior in the target page is obtained. A historical behavior is an operation behavior that the browsing object needs to perform on the target page before triggering the corresponding function to be tested for the specified news. Through the first page data generated by the specified behavior in the target page and the second page data generated by the associated historical behaviors in the target page, the specific operation process when the browsing object triggers the function to be tested in the application program can be known.

[0076] Subsequently, a test case for the specified behavior can be generated according to the first page data and the obtained at least one second page data. The test case generated in this way can cover the page functions frequently used by browsing objects on the live network in the application program, thereby improving the test coverage rate of the use cases.

[0077] Other features and advantages of the present application will be described in the subsequent specification, and some of them will become obvious from the specification, or can be understood by implementing the present application. The objectives and other advantages of the present application can be realized and obtained through the structures specifically pointed out in the written specification, claims, and drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0078] To more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the accompanying drawings required for description in the embodiments. Obviously, the accompanying 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 accompanying drawings can be obtained based on these drawings.

[0079] Figure 1 Schematic diagram of artificially generated test cases provided by the embodiments of the present application;

[0080] Figure 2 Schematic diagram of the artificial trigger process of the login jump function provided by the embodiments of the present application;

[0081] Figure 3 Overall flowchart of a method for generating test cases provided by the embodiments of the present application;

[0082] Figure 4 Schematic diagram of operation behavior reporting provided by the embodiments of the present application;

[0083] Figure 5 Schematic diagram of the process of selecting a specified behavior from multiple operation behaviors provided by the embodiments of the present application;

[0084] Figure 6 Schematic diagram of the process of obtaining page data provided by the embodiments of the present application;

[0085] Figure 7 Schematic diagram of operation behaviors generated during a single login of a browsing object provided by the embodiments of the present application;

[0086] Figure 8 Schematic diagram of the process of cleaning historical behaviors provided by the embodiments of the present application;

[0087] Figure 9 Schematic diagram of the process of test cases provided by the embodiments of the present application;

[0088] Figure 10 Schematic diagram of the process of obtaining an image abnormal area provided by the embodiments of the present application;

[0089] Figure 11 Schematic diagram of comparing pixel points provided by the embodiments of the present application;

[0090] Figure 12 Schematic diagram of the process of calculating color similarity provided by the embodiments of the present application;

[0091] Figure 13 Schematic diagram of the image abnormal area provided by the embodiments of the present application;

[0092] Figure 14Structural diagram of a test case generation device provided by an embodiment of the present application;

[0093] Figure 15 Structural diagram of an electronic device provided by an embodiment of the present application. Detailed implementation manners

[0094] To make the objectives, technical solutions, and advantages of the embodiments of the present application clearer, the technical solutions of the present application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present application. Apparently, the described embodiments are some, but not all, of the embodiments of the present application. All other embodiments obtained by those of ordinary skill in the art based on the embodiments described in this application document without creative efforts shall fall within the scope of protection of the technical solutions of the present application.

[0095] Some concepts involved in the embodiments of the present application are introduced below.

[0096] Test Case: A test case is a set of test inputs with an execution order, used to determine whether the implementation of a specific function meets the expected effect. A test case mainly includes a test process, a test baseline, and a checkpoint. Among them, the test process is the operation process specifically executed in the test phase. The test baseline represents the expected test result, used to compare with the actual test result to obtain the test result. The checkpoint represents the part in the actual test result that needs to be compared with the test baseline.

[0097] Document Object Model (DOM): The Document Object Model, abbreviated as the DOM tree, is currently the most widely used application programming interface (API) in the World Wide Web. It uses a node tree to represent the layout hierarchy of the front-end page. The nodes in the tree are used to indicate page information such as page elements, page attributes, and text. Through the DOM tree, the page document of the front-end page (for example, HyperText Markup Language HTML, Extensible Markup Language XML, etc.) can be directly accessed and operated on. For example, the page document can be accessed through the parent-child and sibling relationships between the tree nodes to obtain information such as the values, attributes, and styles of the page elements.

[0098] The design concept of the embodiments of the present application is briefly introduced below:

[0099] XML Path Language (XPath): XPath is a language used to locate elements in XML documents and also supports the parsing of HTML documents. Through XPath, specific page elements and components can be located from the page document.

[0100] Web crawler: A web crawler is a program script that automatically extracts web pages and can provide the front-end pages downloaded from the World Wide Web to search engines. Its workflow mainly includes steps such as obtaining the web page source code, parsing the web page content, and storing data, and is used to obtain content such as front-end pages, images, and videos according to preset rules and process the useful information obtained.

[0101] Currently, most test cases rely on manual generation. Mainly, testers perform preset operations within the front-end page to trigger the page functions to be tested. During this period, page testing tools such as Applitools and Testim are used to obtain the code execution logic for this page function and generate test cases corresponding to this page function.

[0102] Specifically, as Figure 1 shown, for example, when testing the login and jump function of an application, the test machine 100 needs to be connected to the PC 101 pre-embedded with the page testing tool through the network 10. The tester enables the application within the test machine 100 and triggers the page function to be tested. At this time, the page testing tool within the PC 101 can automatically obtain all the code processes that the application runs during the trigger of the page function to be tested. Among them, the test machine 100 can include terminal devices such as smartphones and tablets that can be connected to the network to participate in the test.

[0103] As previously mentioned, test cases mainly include test procedures, test baselines, and detection points. When generating the test cases for the login and jump function as Figure 1 shown above, the tester needs to execute the process as Figure 2 shown. The tester first enters the login page of the application on the test machine 100, and then performs operations such as entering the account, entering the password, and clicking the login button on the login page to make the application jump from the login page to the main application page.

[0104] During this period, the page testing tool will automatically obtain the code execution logic for triggering the login and jump, and generate the test procedure for the login and jump function of the test page according to this code execution logic. In addition, the code execution logic obtained by the page testing tool will be displayed and recorded and stored on the PC 101, and the recorded content is used for the tester to set the test baseline and detection points of the test cases.

[0105] Through the above-mentioned Figure 1As can be seen from the test case generation process shown above, there are the following drawbacks in the way of manually generating test cases:

[0106] First of all, the test case generation process is very complex. To meet the needs of customers, current application programs carry numerous functions. There can be thousands of high-frequency functions commonly used by browsing objects in an application program. Each test case needs to be obtained by testers manually triggering the function on the application program. This means that to obtain the test cases for the entire application program, testers need to perform thousands of function triggering operations and screen recording operations.

[0107] Secondly, when testers are not familiar enough with the application program, it will lead to a low test coverage rate of use cases, that is, many page functions carried by the application program do not generate corresponding test cases, resulting in missed testing of many page functions, and thus seriously affecting the accuracy of test results.

[0108] In view of this, the embodiments of the present application provide a method, device, electronic device, and storage medium for generating test cases. In this method, when it is detected that there is a specified behavior among multiple operation behaviors generated by a browsing object in an application program in a test environment, the target page that triggers the specified behavior is obtained. Then, from the page document of the target page, the first page data generated by the specified behavior in the target page is obtained, and when it is determined that the specified behavior is associated with at least one historical behavior, the second page data generated by each of the at least one historical behavior in the target page is obtained.

[0109] The specified behavior is the operation behavior that triggers the function to be tested, and the historical behavior associated with the specified behavior is the operation that the browsing object needs to perform on the target page before triggering the function to be tested. By obtaining the first page data generated by the specified behavior in the target page and the second page data generated by the associated historical behavior in the target page, the specific operation process when the browsing object triggers the function to be tested in the application program can be known. Based on this, test cases for the specified behavior can be generated according to the first page data and the obtained at least one second page data. The test cases generated in this way can cover the page functions frequently used by browsing objects in the live network on the application program, thereby improving the test coverage rate of use cases.

[0110] Furthermore, since the data source of the above test cases is the real operation behaviors of browsing objects in the application program, this means that the page data generated by the use case-related behaviors (i.e., the aforementioned specified behavior and historical behavior) can meet the needs of browsing objects and can be directly used as a test baseline, saving the process of generating a test baseline by screen recording.

[0111] Next, the preferred embodiments of the present application will be described in conjunction with the accompanying drawings of the specification. It should be understood that the preferred embodiments described herein are only used to illustrate and explain the present application, and are not used to limit the technical solutions of the present application. And without conflict, the embodiments of the present application and the features in the embodiments can be combined with each other.

[0112] See Figure 3 , Figure 3 which shows the overall process of a method for generating test cases provided by an embodiment of the present application, including the following steps:

[0113] Step 301: When it is detected that there is a specified behavior among multiple operation behaviors generated by a browsing object in an application program in a test environment, obtain the target page that triggers the specified behavior;

[0114] In the embodiment of the present application, by using the front-end data reporting of the application program, the operation behaviors generated by the browsing object in the application program are obtained in the test environment. During implementation, the paths of all operation behaviors executed by the browsing object in the application program can be concatenated through the identification information UUID of the operation behavior, and various operation behaviors executed by the browsing object are de-duplicated and cleaned to obtain the multiple operation behaviors generated by the browsing object in the application program in step 301.

[0115] Specifically during implementation, as Figure 4 shown, when the browsing object enables the application program, the operation behaviors triggered by the browsing object in the application program start to be reported. These operation behaviors may include: click behavior (Click), input behavior (inPut), upload behavior (upLoad), download behavior (downLoad), and sliding behavior (Scrili), etc.

[0116] Specifically, after the browsing object triggers an operation behavior in the application program, the specified fields representing the operation behavior are reported to the database. The reported specified fields can reflect the execution results of the operation behavior. For example, for click behavior and mouse sliding behavior, the page positions of the click and sliding are reported. The input behavior reports the specific content input. The upload behavior and download behavior report the file formats and sizes of the uploaded and downloaded files. The specified fields of each operation behavior may include Figure 4 the fields shown, such as ID, Class, Event, Xpath, CssSelector, etc., which characterize page elements, and fields related to the business. For example, the key fields for the commodity purchase behavior may include: business OfferId, country ReqUrl, channel PayChannel, item GoodsID, whether it is logged in QQUin, etc. fields. When the operation behavior of purchasing an item is triggered, as Figure 4As shown, report these fields. It should be noted that the specified fields for each operation behavior are stipulated by the front-end data reporting requirements, and the embodiments of the present application do not limit the setting method of the specified fields.

[0117] Triggering a function in an application usually requires executing multiple operation behaviors. The specified behavior in step 301 represents the last operation behavior among the multiple operation behaviors required to trigger a function. For ease of understanding, the following uses the Figure 2 triggering of the login jump function shown above as an example for explanation, specifically as Figure 5 shown:

[0118] In the application, the browsing object needs to enter the account password in the login page and click the login button to complete the login and enter the main application page. Therefore, to trigger the login jump function, the browsing object needs to perform the following three operation behaviors in the application. These three operation behaviors are sorted in ascending order of trigger time, and are: enter the account information in the account input box on the login page, enter the password information in the password input box on the login page, and click the login button.

[0119] Among these three operation behaviors, the operation behavior of clicking the login button is the last step to trigger the login jump function. This operation behavior can jump from the login page to the login success page (i.e., the Figure 2 main application page shown above), or jump to the login failure page. Therefore, this operation behavior is the specified behavior for generating a test case to test whether the login jump function is available.

[0120] In actual applications, page jumps and external parameter introductions are one of the main bases for function division. Based on this, to achieve automatic generation of test cases, it can be set that the operation behaviors that trigger page jump operations, the operation behaviors that trigger upload operations, and the operation behaviors that trigger download operations are all used as specified behaviors.

[0121] That is, when it is detected that among the various operation behaviors executed by the browsing object within a period of time, a specified behavior appears, it can be explained at this time that the browsing object has triggered a function built into the application. What specific function is triggered is mainly reflected by this specified behavior. For example, in the Figure 5 example above, by specifying the function "click the login button", it is determined that the browsing object has triggered the login jump function.

[0122] Step 302: Obtain the first page data generated by this specified behavior in the target page from the page document of the target page;

[0123] Step 303: When it is determined that at least one historical behavior is associated with the specified behavior, obtain the second page data generated by each of the at least one historical behavior within the target page; wherein, the historical behavior is a non-specified behavior among the multiple operation behaviors whose triggering time is within a set time period before the specified behavior.

[0124] As mentioned above Figure 4 In the foregoing part, it has been mentioned that the operation behaviors generated by the browsing object within the application in the embodiments of the present application will be reported to the database. On this basis, web crawler technology can be used to regularly obtain the data of the operation behaviors stored in the database.

[0125] When executing Step 301 to Step 303, obtain multiple operation behaviors generated by the same browsing object during a single login to the application from the database. That is, all the operation behaviors reported by the same browsing object during the period from logging in to the application to logging out of the application.

[0126] When it is detected that there is a specified behavior among the multiple operation behaviors, then as Figure 6 shown, determine the target page that triggers the specified behavior according to the Uniform Resource Locator (URL) carried by the specified behavior. Then, use web crawler technology to obtain the first page data generated by the specified behavior within the target page. Specifically, when implementing, locate the DOM tree of the target page through the URL address, and then obtain the first page data generated by the specified behavior within the target page from the HTML file of the DOM tree.

[0127] Meanwhile, detect whether there is a historical behavior associated with the specified behavior among the multiple operation behaviors. If there is an associated historical behavior, use web crawler technology to obtain the second page data generated by the historical behavior within the target page.

[0128] The historical behavior refers to a non-specified behavior among the foregoing multiple operation behaviors whose triggering time is within a set time period before the specified behavior. The purpose of finding the historical behavior associated with the specified behavior here is to obtain the operation process that needs to be executed within the target page when the browsing object triggers the page function corresponding to the specified behavior.

[0129] Specifically, when performing step 303, first specify the historical behaviors associated with the behavior from multiple operation behaviors. Then, obtain the second page data generated by these historical behaviors within the target page that triggers the specified behavior. It should be noted that the method for obtaining the second page data is the same as the method for obtaining the aforementioned first page data, that is, the second page data generated by each historical behavior within the target page is obtained through web crawler technology. The first page data and the second page data obtained thereby can represent the operation process that the browsing object needs to execute within the page where the specified behavior is located when triggering the corresponding page function through the specified behavior.

[0130] For ease of understanding the above process, as follows Figure 7 shown. Figure 7 Shows multiple operation behaviors generated during a single login of the browsing object, which are: operation behavior 1, enter account information in the account input box on the login page; operation behavior 2, enter password information in the password input box on the login page; operation behavior 3, click the login button to jump to the product display page; operation behavior 4, scroll the page to the bottom; operation behavior 5, click the purchase button of product A to jump to the payment page.

[0131] Since operation behaviors 3 and 5 among the above operation behaviors 1 - 5 both trigger the page jump function, so operation behaviors 3 and 5 are the specified behaviors, and the remaining operation behaviors are non-specified behaviors. Next, an explanation will be given respectively on how to obtain the first page data of each specified behavior and the second page data of the historical behaviors associated with each specified behavior through the aforementioned steps 302 - 303:

[0132] For the specified behavior 3, as Figure 7 shown: First, the target page that triggers the specified behavior 3 is the login page. Second, among the operation behaviors 1 - 5, the non-specified behaviors whose operation time is before the specified behavior 3 are operation behaviors 1 - 2, so the historical behaviors associated with the specified behavior 3 are operation behaviors 1 - 2.

[0133] Since both operation behaviors 1 - 2 and the specified behavior 3 are triggered on the login page, after obtaining the first page data of the specified behavior 3 within the login page through the aforementioned step 302, the second page data generated by operation behaviors 1 - 2 respectively within the login page can be obtained through step 303.

[0134] Thus, the first page data of the specified behavior 3 generated on the login page and the second page data generated by operation behaviors 1 - 2 respectively on the login page are obtained. The first page data and the second page data obtained here can represent all the operation processes that the browsing object needs to execute within the login page when performing the page function (login page jump) corresponding to the specified behavior 3.

[0135] For the specified behavior 3, such as Figure 7 shown: First, the target page for triggering the specified behavior 3 is the product display page. Second, among the operation behaviors 1 to 5, the non-specified behaviors whose operation time is before the specified behavior 5 are operation behaviors 1, 2, and 4. Therefore, the historical behaviors associated with the specified behavior 5 are operation behaviors 1, 2, and 4.

[0136] Since operation behaviors 1 to 2 and the specified behavior 5 are not on the same page, after obtaining the first page data generated by the specified behavior 5 in the product display page through the aforementioned step 302, the second page data of operation behavior 4 in the product display page can be obtained through step 303. The first page data and the second page data obtained here indicate that when the browsing object executes the page function corresponding to the specified behavior 5 (payment page jump), all operation processes need to be executed in the product display page. It can be seen that in this process, the page data generated by operation behaviors 1 to 2 in the login page will not be used to generate test cases for testing the page function corresponding to the specified behavior 5. The advantage of doing this is that it can effectively reduce the amount of data when generating test cases in the subsequent process, only retain the operation processes necessary to trigger the page function corresponding to the specified behavior, and then improve the quality of the test cases.

[0137] In addition, according to the actual test requirements, all operation behaviors triggered by the browsing object during a single login before the specified behavior can be used as the historical behaviors associated with this specified behavior. And the web crawler technology is used to obtain the first page data generated by the specified behavior on the target page, and the second page data generated by each associated historical behavior on the corresponding intermediate page, and generate test cases for this specified behavior according to the first page data and the second page data. The intermediate page corresponding to the above historical behavior refers to the page where the historical behavior is triggered, and this page may be the same page as the target page where the specified behavior is located, or it may be a different page.

[0138] In addition, to further improve the quality of the test cases, the embodiments of the present application will perform a filtering operation on the historical behaviors before obtaining the second page data generated by the historical behaviors in the target page, and eliminate redundant behaviors. During implementation, after determining the historical behaviors associated with the specified behavior from multiple operation behaviors, it is detected whether there is a first behavior that triggers the same page component among these historical behaviors. If there is a first behavior that triggers the same page component, the first behavior whose trigger time is adjacent to the specified behavior is retained, and the other remaining first behaviors are eliminated.

[0139] Specifically, such as Figure 8As shown, assuming that the browsing object is performing the specified behavior: the historical behaviors before clicking the login button are: historical behavior 1, entering the account 123 in the account input box on the login page; historical behavior 2, entering the password abc in the password input box on the login page; historical behavior 3, entering the password abcd in the password input box on the login page, which means that the password was entered incorrectly for the first time, and the browsing object re-entered the password in the password input box.

[0140] In the above historical behaviors 1 to 3, historical behaviors 2 and 3 both triggered the same page component (password input box) on the same page (login page). Therefore, historical behaviors 2 and 3 are the first behaviors in historical behaviors 1 to 3 that trigger the password input box page component. At this time, retain historical behavior 3 whose trigger time is adjacent to the specified behavior and remove the remaining historical behavior 2. If this step is not performed, a meaningless operation of incorrect password input will be automatically performed in the test cases generated subsequently, that is, the redundant operations of the browsing object can be automatically removed through the above process, which improves the quality of test case generation.

[0141] Step 304: Generate a test case of a specified behavior according to the first page data and the obtained at least one second page data.

[0142] During implementation, the corresponding test cases are generated by calling pre-defined public methods that are used to update the behavior-triggered page components according to the specific behavior content (i.e. the aforementioned click, input, upload, download, and slide behaviors), and connecting the specified behavior with the associated historical behavior in series according to the triggering sequence. Figure 9 As shown, the following steps are included:

[0143] Step 901: In response to a use case generation indication, a test process is obtained based on the triggering time and function calling method of each of a specified behavior and at least one historical behavior;

[0144] First, the function calling methods of the specified behavior and the associated historical behaviors are obtained, and then these function calling methods are sorted from early to late according to the triggering time recorded by the timestamp to obtain the test process.

[0145] Step 902: Selecting at least one behavior to be tested that meets a preset behavior criterion from the specified behavior and at least one historical behavior;

[0146] As mentioned above, a test case usually includes a test process, a test baseline, and a checkpoint. This step is used to obtain the checkpoint from the specified behavior and the associated historical behavior.

[0147] It should be noted that the detection points in the embodiments of the present application can be set according to actual test requirements. For example, only a specified behavior can be set as the behavior to be tested as the detection point. For another example, the specified behavior and all historical behaviors can be used as the behaviors to be tested. For yet another example, the specified behavior and some historical behaviors can be used as the behaviors to be tested. The embodiments of the present application do not limit the setting rules of the detection points.

[0148] Step 903: For at least one behavior to be tested, perform the following operations respectively: Generate a corresponding test baseline according to the page data generated by the behavior to be tested on the target page; wherein, when the behavior to be tested is a specified behavior, the page data is the first page data; when the behavior to be tested is a historical behavior, the page data is the second page data of the historical behavior.

[0149] Step 904: Determine test cases according to the test process and the at least one obtained test baseline.

[0150] In the embodiments of the present application, two methods for generating test baselines are provided, namely generating test baselines based on HTML and generating test baselines based on page screenshots. Next, the two methods for generating test baselines will be explained respectively:

[0151] Generating test baselines based on HTML: As mentioned above, the embodiments of the present application adopt web crawler technology to obtain the page data generated by an operation behavior through its URL. Therefore, for each behavior to be tested, the HTML file of the target page can be determined according to the URL carried by the behavior to be tested. Then, obtain the historical trigger results of the behavior to be tested for the page components from the HTML file.

[0152] For example, if the behavior to be tested is clicking the login button, the target page triggering this behavior to be tested is the login page. After the browsing object clicks the login button on the login page, the currently displayed page of the application jumps from the login page to the main application page. At this time, locate the target page triggering this behavior to be tested through the URL carried by this behavior to be tested, that is, the login page). Then, obtain the historical trigger results of this behavior to be tested generated on the target page from the HTML of the target page, and use this historical trigger result as the test baseline of this behavior to be tested.

[0153] In the process of generating test baselines based on HTML, the historical trigger results of the behavior to be tested are the page data generated by it within the target page. The historical trigger results can record the page components (login button) triggered by this behavior to be tested within the target page, the specific operation content (click operation) for the page components, and the changes in the target page after executing this behavior to be tested (the page jumps to the main application page).

[0154] By performing the above processing on each behavior to be tested in the specified behavior and associated historical behaviors, the test baseline for each behavior to be tested is obtained. In this way, when using test cases for page function testing, after selecting a test case, the test case can be executed through a test account, and after the execution of the test case is completed, the trigger result of each behavior to be tested in this test can be obtained from the HTML.

[0155] Then, for each behavior to be tested, the trigger result of this behavior to be tested in this test is compared with the test baseline (i.e., the historical trigger result) of this behavior to be tested for text similarity, and the text similarity between the historical trigger result and the trigger result is obtained. Finally, the test result of the test case is generated based on this text similarity. For example, the behaviors to be tested with a text similarity lower than the text similarity threshold are annotated for technical personnel to review.

[0156] Generating a test baseline based on page screenshots: After selecting the behaviors to be tested from the specified behavior and associated historical behaviors, for each behavior to be tested, when triggering this behavior to be tested within the target page, capture the first page screenshot currently displayed by the application. Then, use this first page screenshot as the test baseline for this behavior to be tested.

[0157] For example, if the behavior to be tested is to click the login button, the target page for triggering this behavior to be tested is the login page. After the browser object clicks the login button on the login page, the currently displayed page of the application jumps from the login page to the main application page. Here, capture the screenshot of the page that has jumped to the main application page as the first page screenshot of this test data. In the process of generating a test baseline based on page screenshots, the first page screenshot corresponding to the behavior to be tested is the page data generated by it within the target page.

[0158] By performing the above processing on each behavior to be tested in the specified behavior and associated historical behaviors, the test baseline for each behavior to be tested is obtained. In this way, when using test cases for page function testing, after selecting a test case, the test case can be executed through a test account, and when the execution of each behavior to be tested in this test case is completed, capture the second page screenshot currently displayed by the application.

[0159] Then, the test baseline of this behavior to be tested (i.e., the first page screenshot) is used to compare the second page screenshot generated in this test for this test case for image anomalies, and the image anomaly area between this first page screenshot and this second page screenshot is obtained. When implementing, it can be as Figure 10 shown, including the following steps:

[0160] Step S101: performing color space RGB conversion on the first page screenshot and the second page screenshot respectively to obtain the RGB value of the first pixel and the RGB value of the second pixel; wherein the first pixel is the pixel of the first page screenshot, and the second pixel is the pixel of the second page screenshot;

[0161] Step S102: for each second pixel, calculating the color similarity between the second pixel and a comparison pixel of the second pixel; wherein the comparison pixel of the second pixel is a first pixel having the same coordinates as the second pixel;

[0162] Figure 11 The comparison pixel of the second pixel A is shown as an example. Figure 11 As shown, the position of the second pixel point A in the second page screenshot is the second row and third column, with coordinates (x, y). The first page screenshot and the second page screenshot have the same size, so the first pixel point B at the coordinates (x, y) is found from the first page screenshot, and the first pixel point B is the comparison pixel point of the second pixel point A.

[0163] Further, such as Figure 12 As shown, the color differences △R, △G and △B of the second pixel point A and the first pixel point B in the three color channels of R, G and B are calculated respectively, and then the color similarity P between the second pixel point A and the first pixel point B is calculated according to the color difference. It should be noted that the embodiment of the present application does not limit which specific algorithm is used to calculate the color similarity. Figure 12 The calculation process of obtaining the color similarity of the RGB values ​​of two pixels is described only by way of example.

[0164] Step S103: determining the abnormal area of ​​the image according to the second pixel point whose color similarity is lower than the similarity threshold.

[0165] During implementation, first, from all the second pixel points in the second page screenshot, find the second pixel points whose color similarity is lower than the similarity threshold, i.e., the abnormal pixel points. Then, the image abnormal area is determined based on these abnormal pixel points. Figure 13 As shown, after the abnormal pixels are determined through the above process, the minimum circumscribed rectangular area of ​​these abnormal pixels is obtained, and the minimum circumscribed rectangular area is used as the image abnormal area. Finally, based on the image abnormal area, the test result for the test case is generated. For example, when the size of the image abnormal area is greater than the preset size threshold, the behavior to be tested is annotated and reported to the technician for review.

[0166] The technical solution provided by the embodiments of the present application can analyze the operation behaviors reported by the front end, obtain the specified behaviors and the historical behaviors associated with the specified behaviors therefrom. Then, based on web crawler technology, it obtains the page data generated by these behaviors, and automatically generates relevant test cases according to the page data. The entire process does not require manual participation. In addition, since the data comes from the real operation data of the browsing object in the live network within the application, the finally generated test cases can reflect the common page functions of the browsing object in the live network for the application, and have a high test coverage rate. Furthermore, the present application can be applied to different platforms and applications to achieve cross-platform and cross-application UI automated testing.

[0167] Based on the same inventive concept, the embodiments of the present application also provide a device for generating test cases, specifically as Figure 14 shown. The device includes:

[0168] A page confirmation unit 141, configured to: when it is detected that among multiple operation behaviors generated by a browsing object in an application in a test environment, there is a specified behavior, obtain the target page that triggers the specified behavior;

[0169] A data acquisition unit 142, configured to: obtain the first page data generated by the specified behavior in the target page from the page document of the target page;

[0170] A data processing unit 143, configured to: when it is determined that the specified behavior is associated with at least one historical behavior, obtain the second page data generated by each of the at least one historical behavior in the target page; wherein, the historical behavior is a non-specified behavior among the multiple operation behaviors whose triggering time is within a set time period before the specified behavior;

[0171] A test case generation unit 144, configured to: generate a test case for the specified behavior according to the first page data and the obtained at least one second page data.

[0172] In some possible implementation manners, before obtaining the second page data generated by each of the at least one historical behavior in the target page, the data processing unit 143 is further configured to:

[0173] If there are multiple first behaviors that trigger the same page component among the at least one historical behavior, retain the first behavior whose triggering time is adjacent to the specified behavior, and exclude the other remaining first behaviors.

[0174] In some possible implementation manners, when generating a test case for the specified behavior according to the first page data and the obtained at least one second page data, the test case generation unit 144 is specifically configured to:

[0175] In response to a use case generation instruction, obtain a test process based on the triggering time and function call method of each of the specified behavior and at least one historical behavior;

[0176] Select at least one behavior to be tested that meets the preset behavior criteria from the specified behavior and at least one historical behavior;

[0177] For at least one behavior to be tested, perform the following operations respectively: generate a corresponding test baseline according to the page data generated by the behavior to be tested on the target page; wherein, when the behavior to be tested is the specified behavior, the page data is the first page data; when the behavior to be tested is a historical behavior, the page data is the second page data of the historical behavior;

[0178] Determine the test case according to the test process and the at least one test baseline obtained.

[0179] In some possible implementation manners, when performing to generate a corresponding test baseline according to the page data generated by the behavior to be tested on the target page, the use case generation unit 144 is specifically configured to:

[0180] Determine the hypertext markup language file of the target page according to the uniform resource locator of the behavior to be tested;

[0181] Obtain the historical trigger result of the behavior to be tested for the page component from the hypertext markup language file;

[0182] Determine the test baseline of the behavior to be tested according to the historical trigger result.

[0183] In some possible implementation manners, after performing to generate the test case of the specified behavior, the use case generation unit 144 is further configured to:

[0184] In response to a use case test instruction, execute the test case, and after the test case is executed, obtain the trigger result of the behavior to be tested from the hypertext markup language;

[0185] Perform a text similarity comparison on the behavior to be tested using the test baseline to obtain the text similarity between the historical trigger result and the trigger result;

[0186] Generate a use case test result for the test case according to the text similarity.

[0187] In some possible implementation manners, when performing to generate a corresponding test baseline according to the page data generated by the behavior to be tested on the target page, the use case generation unit 144 is specifically configured to:

[0188] When the browsing object finishes executing the behavior to be tested, determine the first page screenshot of the target page;

[0189] Determine the test baseline for the behavior to be tested according to the first page screenshot.

[0190] In some possible implementation manners, after the test case generation unit 144 executes to generate the test case for the specified behavior, the test case generation unit 144 is further configured to:

[0191] In response to the test case test indication, execute the test case, and when the behavior to be tested in the test case is completed, determine the second page screenshot of the target page;

[0192] Perform image anomaly comparison on the behavior to be tested using the test baseline to obtain the image anomaly area between the first page screenshot and the second page screenshot;

[0193] Generate a test case test result for the test case according to the image anomaly area.

[0194] In some possible implementation manners, when performing image anomaly comparison on the behavior to be tested using the test baseline to obtain the image anomaly area between the first page screenshot and the second page screenshot, the test case generation unit 144 is specifically configured to:

[0195] Perform RGB conversion of the color space on the first page screenshot and the second page screenshot respectively to obtain the RGB value of the first pixel and the RGB value of the second pixel; wherein, the first pixel is the pixel of the first page screenshot, and the second pixel is the pixel of the second page screenshot;

[0196] For each second pixel, calculate the color similarity between the second pixel and the comparison pixel of the second pixel; wherein, the comparison pixel of the second pixel is the first pixel with the same coordinate as the second pixel;

[0197] Determine the image anomaly area according to the second pixels with color similarity lower than the similarity threshold.

[0198] In some possible implementation manners, the specified behavior includes an operation behavior for triggering a page jump operation, an operation behavior for triggering an upload operation, and an operation behavior for triggering a download operation.

[0199] Based on the same inventive concept as the above method embodiment, an electronic device is further provided in the embodiment of the present application. In one embodiment, the electronic device may be a single server, may also be a distributed cluster including multiple servers, or may be a terminal device. In this embodiment, the structure of the electronic device may be as Figure 15 shown, including a memory 151, a communication module 153, and one or more processors 152.

[0200] A memory 151 for storing computer programs executed by a processor 152. The memory 151 may mainly include a program storage area and a data storage area. Among them, the program storage area may store an operating system, an operation instruction set, etc.

[0201] The memory 151 may be a volatile memory, such as a random-access memory (RAM); the memory 151 may also be a non-volatile memory, such as a read-only memory, a flash memory, a hard disk drive (HDD), or a solid-state drive (SSD); or the memory 151 is any other medium that can be used to carry or store a desired computer program in the form of instructions or data structures and can be accessed by a computer, but is not limited thereto. The memory 151 may be a combination of the above memories.

[0202] The processor 152 may include one or more central processing units (CPUs) or be a digital processing unit, etc. The processor 152 is used to implement the above test case generation method when calling the computer program stored in the memory 151.

[0203] The communication module 153 is used to communicate with terminal devices and other servers.

[0204] In the embodiments of the present application, the specific connection medium between the above memory 151, communication module 153, and processor 152 is not limited. In the embodiments of the present application Figure 15 it is described that the memory 151 and the processor 152 are connected through a bus 154, and the bus 154 is described in thick lines in Figure 15 The connection methods between other components are only for illustrative purposes and are not to be construed as limitations. The bus 154 may be divided into an address bus, a data bus, a control bus, etc. For ease of description, Figure 15 only a thick line is used to describe it in

[0205] The memory 151 stores a computer storage medium, and the computer storage medium stores computer-executable instructions for implementing the test case generation method of the embodiments of the present application. The processor 152 is used to execute the steps of the above test case generation method.

[0206] In some possible embodiments, various aspects of a method for generating test cases provided in this application can also be implemented in the form of a program product, which includes a computer program. When the program product runs on an electronic device, the computer program is used to cause the electronic device to execute the steps in the method for generating test cases according to various exemplary embodiments of this application described above in this specification.

[0207] The program product can adopt any combination of one or more readable media. The readable media can be a readable signal medium or a readable storage medium. The readable storage medium can be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the above. More specific examples of the readable storage medium include: an electrical connection with one or more wires, a portable disk, a hard disk, a random access memory, a read-only memory, an erasable programmable read-only memory, an optical fiber, a portable compact disk read-only memory, an optical storage device, a magnetic storage device, or any suitable combination of the above.

[0208] The program product of the embodiments of this application can adopt a portable compact disk read-only memory and include a computer program, and can run on an electronic device. However, the program product of this application is not limited to this. In this document, the readable storage medium can be any tangible medium that contains or stores a program that can be used by or in conjunction with a command execution system, apparatus, or device.

[0209] The readable signal medium can include a data signal propagated in a baseband or as part of a carrier wave, in which a readable computer program is carried. Such a propagated data signal can take various forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. The readable signal medium can also be any readable medium other than the readable storage medium, which can send, propagate, or transmit a program for use by or in conjunction with a command execution system, apparatus, or device.

[0210] The computer program contained on the readable medium can be transmitted by any suitable medium, including but not limited to wireless, wired, optical cable, RF, etc., or any suitable combination of the above.

[0211] The computer program for performing the operations of this application can be written in any combination of one or more programming languages, including object-oriented programming languages such as Java, C++, etc., and also including conventional procedural programming languages such as the "C" language or similar programming languages. The computer program can be executed entirely on the user's computing device, partially on the user's computing device, executed as a stand-alone software package, partially on the user's computing device and partially on a remote computing device, or entirely on a remote computing device or server. In the case of a remote computing device, the remote computing device can be connected to the user's computing device through any type of network including a local area network or a wide area network, or can be connected to an external computing device.

[0212] Those skilled in the art should understand that the embodiments of this application can be provided as a method, a system, or a computer program product. Therefore, this application can take the form of an entirely hardware embodiment, an entirely software embodiment, or an embodiment combining software and hardware aspects. Moreover, this application can take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) that contain computer-usable computer programs.

[0213] Although the preferred embodiments of this application have been described, those skilled in the art can make additional changes and modifications to these embodiments once they learn the basic creative concepts. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of this application.

Claims

1. A method for generating test cases, characterized in that, The method includes: When it is detected in a test environment that among multiple operation behaviors generated by a browsing object within an application, there is a specified behavior, obtain the target page that triggers the specified behavior; From the page document of the target page, obtain the first page data generated by the specified behavior within the target page; When it is determined that the specified behavior is associated with at least one historical behavior, obtain the second page data generated by each of the at least one historical behavior within the target page; wherein, the historical behavior is a non-specified behavior among the multiple operation behaviors whose trigger time is within a set time period before the specified behavior; Generate a test case for the specified behavior according to the first page data and the obtained at least one second page data.

2. The method according to claim 1, characterized in that, Before obtaining the second page data generated by each of the at least one historical behavior within the target page, the method further includes: If there are multiple first behaviors that trigger the same page component among the at least one historical behavior, retain the first behavior whose trigger time is adjacent to the specified behavior, and eliminate the other remaining first behaviors.

3. The method according to claim 1 or 2, characterized in that, The generating a test case for the specified behavior according to the first page data and the obtained at least one second page data includes: In response to a use case generation instruction, obtain a test process based on the trigger time and function call method of each of the specified behavior and the at least one historical behavior; Select at least one behavior to be tested that conforms to a preset behavior criterion from the specified behavior and the at least one historical behavior; For each of the at least one behavior to be tested, perform the following operations respectively: generate a corresponding test baseline according to the page data generated by the behavior to be tested within the target page; wherein, when the behavior to be tested is the specified behavior, the page data is the first page data; when the behavior to be tested is the historical behavior, the page data is the second page data of the historical behavior; Determine the test case according to the test process and the obtained at least one test baseline.

4. The method according to claim 3, wherein The generating a corresponding test baseline according to the page data generated by the behavior to be tested within the target page includes: Determine the hypertext markup language file of the target page according to the uniform resource locator of the behavior to be tested; Obtain the historical trigger result of the behavior to be tested for the page component from the hypertext markup language file; Determine the test baseline of the behavior to be tested according to the historical trigger result.

5. The method according to claim 4, wherein After generating the test case for the specified behavior, the method further includes: In response to a use case test instruction, execute the test case, and after one test case is executed, obtain the trigger result of the behavior to be tested from the hypertext markup language; Perform a text similarity comparison on the behavior to be tested using the test baseline to obtain the text similarity between the historical trigger result and the trigger result; Generate a use case test result for the test case according to the text similarity.

6. The method according to claim 3, characterized in that, The generating a corresponding test baseline according to the page data generated by the behavior to be tested within the target page includes: When the browsing object finishes executing the behavior to be measured, capture a first page screenshot of the current display page of the application program. Determine a test baseline for the one behavior to be measured according to the first page screenshot.

7. The method according to claim 6, characterized in that, After generating the test case for the specified behavior, the method further includes: In response to a test case test instruction, execute the test case, and when the behavior to be measured in the test case is finished, capture a second page screenshot of the current display page of the application program. Perform image anomaly comparison on the behavior to be measured using the test baseline to obtain an image anomaly area between the first page screenshot and the second page screenshot. Generate a test case test result for the test case according to the image anomaly area.

8. The method according to claim 7, wherein The performing image anomaly comparison on the behavior to be measured using the test baseline to obtain an image anomaly area between the first page screenshot and the second page screenshot includes: Perform RGB conversion of the color space on the first page screenshot and the second page screenshot respectively to obtain the RGB values of a first pixel point and the RGB values of a second pixel point; wherein, the first pixel point is a pixel point of the first page screenshot, and the second pixel point is a pixel point of the second page screenshot. For each second pixel point, calculate the color similarity between the second pixel point and the comparison pixel point of the second pixel point; wherein, the comparison pixel point of the second pixel point is the first pixel point having the same coordinates as the second pixel point. Determine the image anomaly area according to the second pixel points with color similarity lower than the similarity threshold.

9. The method according to claim 1 or 2, characterized in that, The specified behavior includes an operation behavior that triggers a page jump operation, an operation behavior that triggers an upload operation, and an operation behavior that triggers a download operation.

10. A test case generation device, characterized in that, The device includes: A page confirmation unit configured to: when it is detected in a test environment that among multiple operation behaviors generated by a browsing object in an application program, there is a specified behavior, obtain a target page that triggers the specified behavior. A data acquisition unit configured to: obtain first page data generated by the specified behavior in the target page from the page document of the target page. A data processing unit configured to: when it is determined that the specified behavior is associated with at least one historical behavior, obtain second page data generated by each of the at least one historical behavior in the target page; wherein, the historical behavior is a non-specified behavior among the multiple operation behaviors whose trigger time is within a set time period before the specified behavior. A test case generation unit configured to: generate a test case for the specified behavior according to the first page data and the at least one obtained second page data.

11. An electronic device, characterized in that, It includes a processor and a memory, wherein the memory stores a computer program, and when the computer program is executed by the processor, the processor is caused to execute the steps of the method according to any one of claims 1-9.

12. A computer-readable storage medium, characterized in that, It includes a computer program, and when the computer program runs on an electronic device, the computer program is used to cause the electronic device to execute the steps of the method according to any one of claims 1-9.