An automated testing method and device

By recording user operation flow and generating operation text, we optimize web automation test cases, and solve the problems of unstable use cases execution and unintelligent manual update code, achieving higher execution stability and intelligent repair capabilities.

CN111831536BActive Publication Date: 2025-05-27BEIJING JINGDONG SHANGKE INFORMATION TECH CO LTD +1
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN201910307487.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2019-04-17
Publication Date
2025-05-27
Estimated Expiration
2039-04-17

AI Technical Summary

Technical Problem

In the existing Web automation testing technology, the use case execution is not stable enough, and the manual update of the code segment is not intelligent enough, resulting in dirty data generated in the database and cannot be rolled back.

Method used

By recording the user's operation flow on the page, the corresponding operation text is generated, and the operation use cases are generated based on the operation flow. Send instructions to execute the operation use case, receive the execution results, and optimize the operation flow based on the results and operation text.

Benefits of technology

It improves the stability of use cases during execution, reduces the need for manual code updates, can intelligently repair use cases, and automatically adapt when the elements of the page to be tested change, enhancing the intelligence of automated testing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN111831536B_ABST
    Figure CN111831536B_ABST
Patent Text Reader

Abstract

The present invention discloses an automated testing method and apparatus, relating to the field of computer technology. A specific embodiment of the method includes: generating a corresponding operation text according to an operation flow obtained by a user's operation on a page; wherein each operation flow includes a plurality of element information and the order between the respective element information; generating an operation test case based on the operation flow, and sending an instruction to execute the operation test case; receiving an execution result of the operation test case, and optimizing the operation flow according to the execution result and the operation text. This embodiment can solve the technical problems of unstable execution of test cases and lack of intelligence in manually updating code segments.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer technology, and in particular, to an automated testing method and apparatus. Background Art

[0002] In the existing Web (World Wide Web) automated testing technology, an operation use case for a user usage scenario is implemented by positioning page elements and simulating browser operations. Specifically, for relevant business operations on a page, according to the PageObject design pattern, they are encapsulated into a page class and several business operation methods, and then the business class is called in the operation use case to implement the automated test case. The principle of simulating browser operations is that the Selenium (browser automated testing framework) client sends operation instructions to the Selenium server, the server parses the operation instructions, and calls the interfaces provided by the webdriver (World Wide Web driver) to complete browser operations. Among them, the use case optimization process is to analyze the reasons for use case failures based on the report after use case execution, and perform code optimization on the failed scripts by adding operations such as delayed waiting or retry. If the page text information of the system under test changes, the elements need to be repositioned, and the use cases and scripts also need to be modified and updated.

[0003] In the process of implementing the present invention, the inventors found that there are at least the following problems in the prior art:

[0004] Since the execution and optimization process of use cases is based on the result log, special processing is added to the code segments that handle failures in the script, such as waiting, delaying, or retrying. Although it can partially solve the problem of unstable use case execution, it still cannot be completely solved, and at the same time, it adds dirty data to the database, resulting in inability to roll back. Moreover, when the elements on the page under test change, the code segments need to be manually updated according to the page changes, so it is not intelligent enough. Summary of the Invention

[0005] In view of this, embodiments of the present invention provide an automated testing method and apparatus to solve the technical problems of unstable use case execution and insufficient intelligence in manually updating code segments.

[0006] To achieve the above object, according to one aspect of the embodiments of the present invention, an automated testing method is provided, including:

[0007] Generating corresponding operation text according to the operation flow obtained from the user's operations on the page; wherein, each operation flow includes multiple element information and the order between each element information;

[0008] Generating an operation use case based on the operation flow, and sending an instruction to execute the operation use case;

[0009] Receive the execution result of the operation use case, and optimize the operation flow according to the execution result and the operation text.

[0010] Optionally, before generating the corresponding operation text according to the operation flow of the user on the page, it further includes:

[0011] Record the operations of the user on the page to obtain an operation flow set; wherein, the operation flow set includes at least one operation flow.

[0012] Filter out the N most frequently occurring element information from the operation flow set, obtain the element information groups in pairwise combinations according to the operation flows where the N element information is located, and configure the optimization rules of the element information groups as transaction processing.

[0013] Wherein, N is a positive integer.

[0014] Optionally, generating the corresponding operation text according to the operation flow obtained by the user's operation on the page includes:

[0015] Obtain the text information corresponding to each element information in the operation flow obtained by the user's operation on the page, and obtain the operation text according to the order between the element information; wherein, the operation text includes multiple text information and the order between each text information.

[0016] Save the operation flow and its corresponding operation text to the semantic library.

[0017] Optionally, generating an operation use case based on the operation flow and sending an instruction to execute the operation use case includes:

[0018] Generate an operation use case based on the operation flow, and repeatedly send an instruction to execute the operation use case until the number of operation use cases with a failed execution result received is zero or a fixed value.

[0019] Wherein, for each operation use case: generate operation instructions respectively according to each element information in the operation flow corresponding to the operation use case, and send the operation instructions one by one according to the order between the element information.

[0020] Optionally, receiving the execution result of the operation use case and optimizing the operation flow according to the execution result and the operation text includes:

[0021] Receive the execution result of the operation use case, and locate the abnormal result in the execution result.

[0022] Match the target text information and its corresponding target operation text in the semantic library according to the abnormal result.

[0023] Replace the position of the target text information in the target operation text with a synonym of the target text information, so as to optimize the operation flow.

[0024] Optionally, replacing the position of the target text information in the target operation text with a synonym of the target text information to optimize the operation flow includes:

[0025] Find each synonym that matches the target text information in the synonym set;

[0026] Replace the position of the target text information in the target operation text with each of the synonyms respectively to obtain multiple synonym operation texts;

[0027] Calculate the similarity between each of the multiple synonym operation texts and the target operation text respectively, and use the operation flow corresponding to the synonym operation text with a similarity greater than a preset threshold as the optimized operation flow.

[0028] In addition, according to another aspect of the embodiments of the present invention, an automated testing device is provided, including:

[0029] A text module, configured to generate a corresponding operation text according to the operation flow obtained from the user's operation on the page; wherein, each operation flow includes multiple element information and the order between each element information;

[0030] A sending module, configured to generate an operation use case based on the operation flow and send an instruction to execute the operation use case;

[0031] An optimization module, configured to receive the execution result of the operation use case and optimize the operation flow according to the execution result and the operation text.

[0032] Optionally, the text module is further configured to:

[0033] Record the user's operations on the page to obtain an operation flow set; wherein, the operation flow set includes at least one operation flow;

[0034] Screen the N element information with the highest occurrence frequency from the operation flow set, obtain an element information group of pairwise combinations according to the operation flow where the N element information is located, and configure the optimization rule of the element information group as a transaction process;

[0035] Wherein, N is a positive integer.

[0036] Optionally, the text module is configured to:

[0037] Obtain the text information corresponding to each element information in the operation stream obtained by the user's operations on the page, and obtain the operation text according to the order among the various element information; wherein, the operation text includes multiple text information and the order among the various text information;

[0038] Save the operation stream and its corresponding operation text to the semantic library.

[0039] Optionally, the sending module is used for:

[0040] Generate an operation use case based on the operation stream, and repeatedly send instructions to execute the operation use case until the number of operation use cases with a failed execution result received is zero or a fixed value;

[0041] Wherein, for each operation use case: generate operation instructions respectively according to the various element information in the operation stream corresponding to the operation use case, and send the operation instructions item by item according to the order among the various element information.

[0042] Optionally, the optimization module is used for:

[0043] Receive the execution result of the operation use case, and locate the abnormal result in the execution result;

[0044] Match the target text information and its location in the target operation text in the semantic library according to the abnormal result;

[0045] Use the synonyms of the target text information to replace the position of the target text information in the target operation text, thereby optimizing the operation stream.

[0046] Optionally, using the synonyms of the target text information to replace the position of the target text information in the target operation text to optimize the operation stream includes:

[0047] Find each synonym that matches the target text information in the synonym set;

[0048] Replace the position of the target text information in the target operation text with each of the synonyms respectively to obtain multiple synonym operation texts;

[0049] Calculate the similarity between the multiple synonym operation texts and the target operation text respectively, and use the operation stream corresponding to the synonym operation text with a similarity greater than the preset threshold as the optimized operation stream.

[0050] According to another aspect of the embodiments of the present invention, there is also provided an electronic device, including:

[0051] One or more processors;

[0052] A storage device for storing one or more programs,

[0053] When the one or more programs are executed by the one or more processors, the one or more processors implement the method described in any of the above embodiments.

[0054] According to another aspect of the embodiments of the present invention, there is also provided a computer-readable medium having a computer program stored thereon, and when the program is executed by a processor, it implements the method described in any of the above embodiments.

[0055] One embodiment of the above invention has the following advantages or beneficial effects: Since the operation text is generated according to the operation flow obtained from the user's operations on the page, the operation use cases are generated based on the operation flow, and the operation flow is optimized according to the execution results and operation text of the operation use cases, the technical problems of unstable use case execution and non-intelligent manual update of code segments are overcome. The embodiments of the present invention generate the corresponding operation text based on the operation flow, that is, optimize the operation flow through natural language processing, improve the execution stability of the operation use cases during the execution process through iteration, and at the same time, due to the ability to understand text information, when the element information of the page under test changes, it can understand and infer the execution scenario and automatically repair the use cases, making the automated execution more intelligent.

[0056] The further effects of the above non-conventional optional methods will be described in combination with specific embodiments below. BRIEF DESCRIPTION OF THE DRAWINGS

[0057] The drawings are used to better understand the present invention and do not constitute an improper limitation to the present invention. Among them:

[0058] Figure 1 is a schematic diagram of the main process of the automated testing method according to the embodiments of the present invention;

[0059] Figure 2 is a schematic diagram of the main modules of the client and the server according to the embodiments of the present invention;

[0060] Figure 3 is an interaction schematic diagram of the client and the server according to the embodiments of the present invention;

[0061] Figure 4 is a schematic diagram of the main process of the automated testing method according to a reference embodiment of the present invention;

[0062] Figure 5 is a schematic diagram of the main process of the automated testing method according to another reference embodiment of the present invention;

[0063] Figure 6It is a schematic diagram of the main modules of the automated testing device according to an embodiment of the present invention;

[0064] Figure 7 It is an exemplary system architecture diagram to which the embodiment of the present invention can be applied;

[0065] Figure 8 It is a schematic structural diagram of a computer system of a terminal device or a server suitable for implementing the embodiment of the present invention. Detailed implementation manners

[0066] The following describes exemplary embodiments of the present invention with reference to the accompanying drawings. Various details of the embodiments of the present invention are included to facilitate understanding, and they should be considered merely exemplary. Therefore, those of ordinary skill in the art should recognize that various changes and modifications can be made to the embodiments described herein without departing from the scope and spirit of the present invention. Similarly, for the sake of clarity and conciseness, descriptions of well-known functions and structures are omitted in the following description.

[0067] Figure 1 It is a schematic diagram of the main process of the automated testing method according to an embodiment of the present invention. As an embodiment of the present invention, as Figure 1 shown, the automated testing method may include:

[0068] Step 101, generating a corresponding operation text according to the operation flow obtained from the user's operations on the page; wherein, each operation flow includes multiple element information and the order between each piece of element information.

[0069] First, the user performs operations such as clicking and inputting on the page. Therefore, an operation flow can be generated according to the user's operations on the page. Each operation flow records the user's operations on the page and the order before and after each operation. In the embodiment of the present invention, each operation flow includes multiple element information and the order between each piece of element information. Then, a corresponding operation text is generated according to each piece of element information and the order between each piece of element information in each operation flow.

[0070] For example, the operation process of the user on the page is: {work order management -> initiate work order -> enter initiation content}, then the corresponding operation flow of this operation process is: {<action:click id:woTest>, <action:click,id:newWO>, <action:input,id:content>}. For example, the operation process of the user on the page is: {work order management -> work order status view}, then the corresponding operation flow of this operation process is: {<action:click id:woTest>, <action:click id:wostate}. Each element information includes the event type (action) and the element identifier (id).

[0071] Optionally, step 101 may include: obtaining the text information corresponding to each element information in the operation flow obtained by the user's operation on the page, and obtaining the operation text according to the order between the element information; wherein, the operation text includes a plurality of text information and the order between each text information; saving the operation flow and its corresponding operation text to the semantic library. It should be noted that the correspondence between the element information and the text information can be pre-stored in the database, so the corresponding text information can be found through the element identifier, so as to obtain the operation text corresponding to each operation flow, and then save each operation flow and its corresponding operation text to the semantic library. Optionally, the text information refers to natural language information, such as Chinese text information, English text information, Korean text information, etc., that is, non-code language.

[0072] For example, based on the above two operation flows, two operation texts can be obtained as follows: work order management, initiate work order, enter initiation content; work order management, work order status view.

[0073] Before step 101, the method may further include: recording the operations of the user on the page to obtain an operation flow set; wherein, the operation flow set includes at least one operation flow; screening the N most frequently occurring element information from the operation flow set, obtaining an element information group in pairwise combination according to the operation flows where the N element information is located, and configuring the optimization rules of the element information group as a transaction process; wherein, N is a positive integer. Specifically, the operation steps of the user on the page can be recorded and saved through a browser plugin, and the operation process of each scenario is an operation flow, so an operation flow set can be obtained, and the operation flow set includes multiple operation flows. Then, count the occurrence times of each element information in the operation flow set and save it into a Multimap (a data structure in the C++ language, which supports automatic sorting and duplicate key values), the key value corresponds to each element identifier, and the value value is the occurrence times of each element. Then reverse the key-value pair to obtain a new target Multimap, and the target multimap will be sorted in descending order automatically according to the value, and take the first N element information as the initial optimization operation. Finally, according to the operation flows where the N element information is located, obtain an element information group in pairwise combination, and configure the optimization rules of the element information group as a transaction process.

[0074] In the embodiment of the present invention, multiple operations are combined together as an atomic operation. Each operation is not directly written into the database, but first written into the cache to facilitate data rollback and cancel the previous operation.

[0075] For example, take the first 3 element information as the initial optimization operation to obtain the following element information:

[0076] {woTest:2,content:1,newWO:1,wostate:1} => {woTest,content,newWO}

[0077] According to the operation flows where the first 3 element information is located, obtain an element information group in pairwise combination:

[0078] The combination of woTest and newWO

[0079] The combination of woTest and wostate

[0080] The combination of newWO and content

[0081] Configure the optimization rules of the above combinations as a transaction process.

[0082] The optimization rules need to be configured manually. The default optimization rule is a transaction process. The optimization rules are configured as shown in the following table:

[0083]

[0084] Step 102: Generate an operation use case based on the operation flow and send an instruction to execute the operation use case.

[0085] In this step, the client generates an operation use case based on the operation flow and sends an instruction to execute the operation use case; the server receives the instruction and executes the operation use case, and then returns the execution result to the client. Optionally, the client generates an operation use case based on the operation flow and repeatedly sends an instruction to execute the operation use case until the number of failed operation use cases received is zero or a fixed value; wherein, for each operation use case: operation instructions are respectively generated according to the respective element information in the operation flow corresponding to the operation use case, and the operation instructions are sent one by one in the order between the respective element information.

[0086] Generally speaking, one operation flow can generate one operation use case, and the client can repeatedly send an instruction to execute the operation use case multiple times, then the server repeatedly executes the operation use case multiple times and returns the execution result. For example, assume that the client generates 5 operation use cases based on 5 operation flows respectively, and repeatedly sends an instruction to execute the operation use case 10 times respectively. If the number of failed operation use cases is zero, or the number of failed operation use cases is a certain fixed value, such as 2, 3, 4, etc., then stop sending an instruction to execute the operation use case. This indicates that these operation use cases are all normal, or the failed operation use cases have been located, and no matter how many times they are executed again, the number of failed operation use cases will not change. In the embodiment of the present invention, by continuously running the operation use cases to collect the failed use cases, and then strengthening and optimizing the use cases according to the configured optimization rule table rules, the execution stability of the operation use cases during execution is improved.

[0087] Optionally, the client may be a Selenium client, and the server may be a Selenium server. Selenium is a series of Web-based automation tools that provide a set of test functions for supporting Web automation testing. The functions are very flexible and can complete interface element positioning, window jumping, and result comparison. Such as Figure 2 and 3As shown, the client establishes an Http connection with the server, and the SMAgent establishes a TCP connection with the optimizer. The client generates operation use cases based on the operation flow. The operation use cases include operation instructions corresponding to each element information, such as operation instruction 1, operation instruction 2, operation instruction 3, etc. Therefore, the client sends operation instructions to the client one by one. The SMAgent receives operation instruction 1, sends the operation instruction to the driver and the optimizer, and monitors the execution status of the wire protocol command. The execution status of the instruction is judged through the proxy function provided by the SMAgent. The optimizer reads the pre-set optimization rule configuration according to the status information of the command execution to optimize the operation use case. Among them, the SMAgent is a pseudo proxy used to simulate the functions provided by the Restful Webservice interface. Therefore, the SMAgent can return the status of whether the operation can be successfully executed to the client in real time, and the client can configure the optimization rules accordingly and re-send the operation instructions.

[0088] Webdriver is developed for different browsers, and different browsers have different webdrivers. For example, chromedriver is used for Chrome, and the browser corresponds to the corresponding Webdriver. The test code contains various desired operations on the browser interface, such as clicking. The test code sends operation instructions to the Webdriver, and the Webdriver controls on the browser interface according to these operation instructions, so that the test code achieves the purpose of operating on the browser interface.

[0089] The existing Web automation technology is based on the v protocol and belongs to asynchronous execution, and cannot obtain the operation status in real time. However, in the embodiments of the present invention, the server returns the execution status of an operation every time an operation is executed. During the process of the server executing the operation instruction, for the combined operation configured for transaction processing, when the operation status of each step is successful, the data result in the cache is written into the database. If the operation status is not successful, a failure status is returned to the client, and the data in the cache is cleared.

[0090] The client waits. After the driver (Webdriver) of the server executes the operation instructions one by one, it returns the execution result of the final operation use case to the client.

[0091] Step 103, receive the execution result of the operation use case, and optimize the operation flow according to the execution result and the operation text

[0092] In step 102, the server returns the execution result of the operation use case to the client. In step 103, the client receives the execution result of the operation use case, and optimizes the operation flow according to the execution result and the operation text in step 101.

[0093] Since in step 101, each operation flow and its corresponding operation text have been saved in the semantic library, the operation flow and the abnormal page elements can be located through the execution result of the operation case, so as to automatically optimize the abnormal operation flow in combination with the matching operation text. Optionally, step 103 may include: the client receives the execution result of the operation case, and locates the abnormal result in the execution result; matches the target text information and its location in the target operation text in the semantic library according to the abnormal result; replaces the position of the target text information in the target operation text with a synonym of the target text information, so as to optimize the operation flow.

[0094] It should be noted that it is foreseeable to establish a synonym set, so that the target text information can be replaced based on each synonym in the synonym set, and the corresponding replaced operation text can be obtained. Finally, the optimal operation text can be selected from these replaced operation texts, and the matching operation flow can be obtained.

[0095] After obtaining the optimized operation flow, steps 102 and 103 can be continuously executed until the number of operation cases with failed execution results received is zero.

[0096] According to the various embodiments described above, it can be seen that the present invention generates the corresponding operation text according to the operation flow obtained by the user's operation on the page, generates the operation case based on the operation flow, and optimizes the operation flow according to the execution result and the operation text of the operation case, thereby solving the problems of unstable use case execution and insufficient intelligence in manually updating code segments. The embodiment of the present invention generates the corresponding operation text based on the operation flow, that is, optimizes the operation flow through natural language processing, improves the execution stability of the operation case during the execution process through iteration, and at the same time, due to the ability to understand text information, it can understand and infer the execution scenario when the element information of the page under test changes, automatically repair the use case, and make the automated execution more intelligent.

[0097] Figure 4 It is a schematic diagram of the main process of an automated testing method according to a reference embodiment of the present invention. The automated testing method may specifically include:

[0098] Step 401, generate the corresponding operation text according to the operation flow obtained by the user's operation on the page.

[0099] Users perform operations such as clicking and inputting on the page. Therefore, an operation flow can be generated based on the operations of the users on the page. Each operation flow records the operations of the users on the page and the sequence before and after each operation. Among them, each operation flow includes multiple element information and the sequence between each element information. Then, according to each element information and the sequence between each element information in the operation flow, a corresponding operation text is generated. Specifically, the text information corresponding to each element information in the operation flow can be obtained, and according to the sequence between the element information, the operation text is obtained, and the operation flow and its corresponding operation text are saved to the semantic library. Among them, the operation text includes multiple text information and the sequence between each text information.

[0100] Step 402, generate a test case for the operation based on the operation flow, and send an instruction to execute the test case for the operation.

[0101] The client generates a test case for the operation based on the operation flow, and sends an instruction to execute the test case for the operation; the server receives the instruction and executes the test case for the operation, and then returns the execution result to the client. Optionally, the client generates a test case for the operation based on the operation flow, and repeatedly sends an instruction to execute the test case for the operation until the number of failed test cases received is zero or a fixed value; among them, for each test case for the operation: operation instructions are respectively generated according to each element information in the operation flow corresponding to the test case for the operation, and the operation instructions are sent item by item according to the sequence between each element information.

[0102] Step 403, receive the execution result of the test case for the operation, and locate the abnormal result in the execution result.

[0103] After the client receives the execution result of the test case for the operation, it analyzes the execution result, and thus can locate the abnormal result in the execution result.

[0104] Step 404, match the target text information and its corresponding target operation text in the semantic library according to the abnormal result.

[0105] After locating the abnormal result, the client locates the abnormal element information by analyzing the abnormal result, so as to match the target text information and its corresponding target operation text in the semantic library.

[0106] Step 405, use the synonyms of the target text information to replace the position of the target text information in the target operation text, so as to optimize the operation flow.

[0107] Optionally, step 405 may include: finding each synonym that matches the target text information in the synonym set; replacing the positions of the target text information in the target operation text with the respective synonyms to obtain multiple synonym operation texts; calculating the similarity between each of the multiple synonym operation texts and the target operation text, and taking the operation flow corresponding to the synonym operation text with a similarity greater than a preset threshold as the optimized operation flow.

[0108] For example, if the target text information located through the abnormal element information is a new processing order, and the target operation text where it is located is new processing order (page element) + product function consultation (test data) + processing department (page element), then the synonyms "new work order" and "new added work order" are obtained from the synonym set {new work order, new added work order, new processing order}, and these two synonyms are used to replace "new processing order", thus obtaining the synonym operation texts:

[0109] new work order (page element) + product function consultation (test data) + processing department (page element)

[0110] new added work order (page element) + product function consultation (test data) + processing department (page element)

[0111] Then, calculate the similarity between each of these two synonym operation texts and the target operation text respectively, and take the operation flow corresponding to the synonym operation text with a similarity greater than a preset threshold as the optimized operation flow. Optionally, the edit distance can be used to calculate the similarity.

[0112] Next, generate operation test cases based on the optimized operation flow, that is, repeat the above test steps until the number of operation test cases with a received execution result of failure is zero. Therefore, the embodiment of the present invention optimizes the operation test cases through the similarity of texts, so as to achieve the effect of automatically repairing test cases.

[0113] In addition, the specific implementation content of the automated testing method in a referenceable embodiment of the present invention has been described in detail in the above-mentioned automated testing method, so the repeated content will not be described here again.

[0114] Figure 5 is a schematic diagram of the main process of the automated testing method according to another referenceable embodiment of the present invention. The automated testing method may specifically include:

[0115] Step 501, record the operations of the user on the page to obtain an operation flow set; wherein, the operation flow set includes multiple operation flows.

[0116] Step 502: Screen the N elements with the highest occurrence frequencies from the operation flow set, obtain the element information groups in pairwise combinations according to the operation flows where the N elements are located, and configure the optimization rules for the element information groups as transaction processing; where N is a positive integer.

[0117] Step 503: Obtain the text information corresponding to each element information in each operation flow, and obtain multiple operation texts according to the order among the element information; where the operation text includes multiple text information and the order among each text information.

[0118] Step 504: Save each operation flow and its corresponding operation text to the semantic library, and the pairwise combined element information groups can also be stored in the semantic library.

[0119] Step 505: Generate respective operation use cases based on each operation flow, and repeatedly send instructions to execute each operation use case.

[0120] Step 506: Receive the execution results of each operation use case, and locate the abnormal results in the execution results.

[0121] Step 507: Match the target text information and its corresponding target operation text in the semantic library according to the abnormal results.

[0122] Step 508: Search for each synonym that matches the target text information in the synonym set.

[0123] Step 509: Replace the positions of the target text information in the target operation text with the respective synonyms, and obtain multiple synonym operation texts respectively.

[0124] Step 510: Calculate the similarity between each synonym operation text and the target operation text respectively, and use the operation flow corresponding to the synonym operation text with a similarity greater than the preset threshold as the optimized operation flow.

[0125] In addition, the specific implementation content of the automated testing method in another referenceable embodiment of the present invention has been described in detail in the above-mentioned automated testing method, so the repeated content will not be described here again.

[0126] Figure 6 is a schematic diagram of the main modules of the automated testing device according to an embodiment of the present invention, as Figure 6As shown, the automated test device 600 includes a text module 601, a sending module 602, and an optimization module 603. Among them, the text module 601 is used to generate corresponding operation texts according to the operation flows obtained from the user's operations on the page; among them, each operation flow includes multiple element information and the order between each element information; the sending module 602 is used to generate operation test cases based on the operation flows and send instructions to execute the operation test cases; the optimization module 603 is used to receive the execution results of the operation test cases and optimize the operation flows according to the execution results and the operation texts.

[0127] Optionally, the text module 601 is further used to:

[0128] Record the user's operations on the page to obtain an operation flow set; among them, the operation flow set includes at least one operation flow;

[0129] Screen the N most frequently occurring element information from the operation flow set, obtain element information groups in pairwise combinations according to the operation flows where the N element information is located, and configure the optimization rules of the element information groups as transaction processing;

[0130] Among them, N is a positive integer.

[0131] Optionally, the text module 601 is used to:

[0132] Obtain the text information corresponding to each element information in the operation flow obtained from the user's operations on the page, and obtain the operation text according to the order between each element information; among them, the operation text includes multiple text information and the order between each text information;

[0133] Save the operation flow and its corresponding operation text to the semantic library.

[0134] Optionally, the sending module 602 is used to:

[0135] Generate operation test cases based on the operation flows, and repeatedly send instructions to execute the operation test cases until the number of operation test cases with failed execution results received is zero or a fixed value;

[0136] Among them, for each operation test case: generate operation instructions respectively according to each element information in the operation flow corresponding to the operation test case, and send the operation instructions one by one according to the order between each element information.

[0137] Optionally, the optimization module 603 is used to:

[0138] Receive the execution results of the operation test cases and locate the abnormal results in the execution results;

[0139] Match the target text information and its corresponding target operation text in the semantic library according to the abnormal result;

[0140] Use the synonyms of the target text information to replace the position of the target text information in the target operation text, so as to optimize the operation flow.

[0141] Optionally, using the synonyms of the target text information to replace the position of the target text information in the target operation text to optimize the operation flow includes:

[0142] Find each synonym that matches the target text information in the synonym set;

[0143] Replace the position of the target text information in the target operation text with each of the synonyms respectively to obtain multiple synonym operation texts;

[0144] Calculate the similarity between the multiple synonym operation texts and the target operation text respectively, and use the operation flow corresponding to the synonym operation text with a similarity greater than the preset threshold as the optimized operation flow.

[0145] According to the various embodiments described above, it can be seen that the present invention generates corresponding operation texts based on the operation flow obtained from the user's operations on the page, generates operation test cases based on the operation flow, and optimizes the operation flow according to the execution results and operation texts of the operation test cases, thereby solving the problems of unstable execution of test cases and insufficient intelligence in manually updating code segments. The embodiments of the present invention generate corresponding operation texts based on the operation flow, that is, optimize the operation flow through natural language processing, improve the execution stability of the operation test cases during the execution process through iterative enhancement, and at the same time, due to the ability to understand text information, when the element information of the page to be tested changes, it can understand and infer the execution scenario and automatically repair the test cases, making the automated execution more intelligent.

[0146] It should be noted that the specific implementation content of the automated test device of the present invention has been described in detail in the above-mentioned automated test method, so the repeated content will not be described here.

[0147] Figure 7 An exemplary system architecture 700 is shown to which the automated test method or automated test device of the embodiments of the present invention can be applied.

[0148] Such as Figure 7As shown, the system architecture 700 may include terminal devices 701, 702, 703, a network 704, and a server 705. The network 704 serves as a medium for providing communication links between the terminal devices 701, 702, 703 and the server 705. The network 704 may include various connection types, such as wired, wireless communication links, or fiber optic cables, etc.

[0149] Users can use the terminal devices 701, 702, 703 to interact with the server 704 via the network 704 to receive or send messages, etc. Various communication client applications can be installed on the terminal devices 701, 702, 703, such as shopping applications, web browser applications, search applications, instant messaging tools, email clients, social platform software, etc. (for example only).

[0150] The terminal devices 701, 702, 703 can be various electronic devices with a display screen and supporting web browsing, including but not limited to smartphones, tablets, laptop computers, and desktop computers, etc.

[0151] The server 705 can be a server that provides various services, such as a background management server that supports the shopping websites browsed by users using the terminal devices 701, 702, 703 (for example only). The background management server can analyze and process data such as product information query requests received, and feedback the processing results (such as target push information, product information - for example only) to the terminal devices.

[0152] It should be noted that the automated test method provided by the embodiments of the present invention is generally executed on the terminal devices 701, 702, 703 in public places, and can also be executed by the server 705. Correspondingly, the automated test device is generally set on the terminal devices 701, 702, 703 in public places, and can also be set in the server 705.

[0153] It should be understood that Figure 7 the numbers of terminal devices, networks, and servers in

[0154] are merely illustrative. According to actual needs, there can be any number of terminal devices, networks, and servers. Figure 8 The following refers to Figure 8 which shows a schematic structural diagram of a computer system 800 of a terminal device suitable for implementing the embodiments of the present invention. Figure 8 The shown terminal device is merely an example and should not impose any limitations on the functions and usage scope of the embodiments of the present invention.

[0155] As Figure 8As shown, computer system 800 includes a central processing unit (CPU) 801, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 802 or a program loaded from a storage section 808 into a random access memory (RAM) 803. In the RAM 803, various programs and data required for the operation of the system 800 are also stored. The CPU 801, ROM 802, and RAM 803 are connected to each other via a bus 804. An input / output (I / O) interface 805 is also connected to the bus 804.

[0156] The following components are connected to the I / O interface 805: an input section 806 including a keyboard, a mouse, etc.; an output section 807 including, for example, a cathode ray tube (CRT), a liquid crystal display (LCD), etc. and a speaker, etc.; a storage section 808 including a hard disk, etc.; and a communication section 809 including a network interface card such as a LAN card, a modem, etc. The communication section 809 performs communication processing via a network such as the Internet. A drive 810 is also connected to the I / O interface 805 as needed. A removable medium 811, such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc., is installed on the drive 810 as needed so that a computer program read from it can be installed into the storage section 808 as needed.

[0157] Specifically, according to an embodiment disclosed by the present invention, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment disclosed by the present invention includes a computer program product, which includes a computer program carried on a computer-readable medium, and the computer program contains program codes for performing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from a network via the communication section 809, and / or installed from the removable medium 811. When the computer program is executed by a central processing unit (CPU) 801, the above functions defined in the system of the present invention are executed.

[0158] It should be noted that the computer-readable medium shown in the present invention can be a computer-readable signal medium, a computer-readable storage medium, or any combination of the two. The computer-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 computer-readable storage medium can include, but are not limited to: an electrical connection having one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present invention, the computer-readable storage medium can be any tangible medium that contains or stores a program, and this program can be used by or in conjunction with an instruction execution system, apparatus, or device. In the present invention, the computer-readable signal medium can include a data signal propagated in a baseband or as part of a carrier wave, in which the computer-readable program code 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 computer-readable signal medium can also be any computer-readable medium other than the computer-readable storage medium, and this computer-readable medium can send, propagate, or transmit a program for use by or in conjunction with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium can be transmitted using any appropriate medium, including but not limited to: wireless, wire, optical cable, RF, etc., or any suitable combination of the above.

[0159] The flowcharts and block diagrams in the accompanying drawings illustrate the possible architectures, functions, and operations of systems, methods, and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagram can represent a module, a program segment, or a part of code, and the above module, program segment, or part of code contains one or more executable instructions for implementing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the blocks can occur in a different order than marked in the accompanying drawings. For example, two consecutive blocks shown can actually be executed substantially in parallel, and they can sometimes be executed in the reverse order, depending on the functions involved. It should also be noted that each block in the block diagram or flowchart, as well as the combination of blocks in the block diagram or flowchart, can be implemented by a dedicated hardware-based system for performing the specified functions or operations, or can be implemented by a combination of dedicated hardware and computer instructions.

[0160] The modules involved in the embodiments of the present invention can be implemented in software or in hardware. The described modules can also be provided in a processor. For example, it can be described as: a processor includes a text module, a sending module, and an optimization module. In some cases, the names of these modules do not constitute a limitation on the module itself.

[0161] As another aspect, the present invention also provides a computer-readable medium, which can be included in the device described in the above embodiments; or can exist alone without being assembled into the device. The above computer-readable medium carries one or more programs. When the one or more programs are executed by the device, the device includes: generating corresponding operation text according to the operation flow obtained from the user's operations on the page; where each operation flow includes multiple element information and the order between the element information; generating an operation use case based on the operation flow, and sending an instruction to execute the operation use case; receiving the execution result of the operation use case, and optimizing the operation flow according to the execution result and the operation text.

[0162] According to the technical solution of the embodiments of the present invention, since the technical means of generating corresponding operation text according to the operation flow obtained from the user's operations on the page, generating an operation use case based on the operation flow, and optimizing the operation flow according to the execution result of the operation use case and the operation text are adopted, the technical problems of unstable use case execution and non-intelligent manual code segment update are overcome. The embodiments of the present invention generate corresponding operation text based on the operation flow, that is, optimize the operation flow through natural language processing, improve the execution stability of the operation use case during the execution process through iteration, and at the same time, due to the ability to understand text information, when the element information of the page to be tested changes, it can understand and infer the execution scenario, automatically repair the use case, and make the automated execution more intelligent.

[0163] The above specific embodiments do not constitute a limitation on the protection scope of the present invention. Those skilled in the art should understand that various modifications, combinations, sub-combinations, and substitutions can occur depending on design requirements and other factors. Any modifications, equivalent replacements, and improvements made within the spirit and principles of the present invention shall be included within the protection scope of the present invention.

Claims

1. An automated testing method, characterized in that, it includes: generating corresponding operation text according to the operation flow obtained from the user's operations on the page; wherein, each operation flow includes multiple element information and the order between each element information; generating test cases based on the operation flow, and sending an instruction to execute the test cases; receiving the execution results of the test cases, and locating the abnormal results in the execution results; matching the target text information and its corresponding target operation text in the semantic library according to the abnormal results; using the synonyms of the target text information to replace the position of the target text information in the target operation text, so as to optimize the operation flow.

2. The method according to claim 1, characterized in that, before generating the corresponding operation text according to the operation flow of the user on the page, it further includes: recording the operations of the user on the page, so as to obtain an operation flow set; wherein, the operation flow set includes at least one operation flow; screening the N most frequently occurring element information from the operation flow set, obtaining the element information groups combined in pairs according to the operation flows where the N element information are located, and configuring the optimization rules of the element information groups as transaction processing; wherein, N is a positive integer.

3. The method according to claim 1, characterized in that, generating corresponding operation text according to the operation flow obtained from the user's operations on the page, including: obtaining the text information corresponding to each element information in the operation flow obtained from the user's operations on the page, and obtaining the operation text according to the order between each element information; wherein, the operation text includes multiple text information and the order between each text information; saving the operation flow and its corresponding operation text to the semantic library.

4. The method according to claim 3, characterized in that, generating test cases based on the operation flow, and sending an instruction to execute the test cases, including: generating test cases based on the operation flow, and repeatedly sending an instruction to execute the test cases until the number of received failed test cases is zero or a fixed value; wherein, for each test case: generating operation instructions respectively according to each element information in the operation flow corresponding to the test case, and sending the operation instructions one by one according to the order between each element information.

5. The method according to claim 1, characterized in that, using the synonyms of the target text information to replace the position of the target text information in the target operation text, so as to optimize the operation flow, including: finding each synonym that matches the target text information in the synonym set; respectively replacing the position of the target text information in the target operation text with each synonym, and respectively obtaining multiple synonym operation texts; respectively calculating the similarity between the multiple synonym operation texts and the target operation text, and taking the operation flow corresponding to the synonym operation text with a similarity greater than the preset threshold as the optimized operation flow.

6. An automated testing device, characterized in that, it includes: A text module for generating corresponding operation texts according to the operation flows obtained from the user's operations on the page; wherein each operation flow includes multiple element information and the order between the respective element information; A sending module for generating operation test cases based on the operation flows and sending instructions to execute the operation test cases; An optimization module for receiving the execution results of the operation test cases, locating the abnormal results in the execution results; matching the target text information and its location in the target operation text in the semantic library according to the abnormal results; and replacing the position of the target text information in the target operation text with the synonyms of the target text information, so as to optimize the operation flow.

7. The apparatus according to claim 6, wherein, the text module is further configured to: record the operations of the user on the page, so as to obtain an operation flow set; wherein the operation flow set includes at least one operation flow; screen the N element information with the highest occurrence frequency from the operation flow set, obtain the element information groups in pairwise combination according to the operation flows where the N element information are located, and configure the optimization rules of the element information groups as transaction processing; wherein N is a positive integer.

8. The apparatus according to claim 6, wherein, the text module is configured to: obtain the text information corresponding to each element information in the operation flow obtained from the user's operation on the page, and obtain the operation text according to the order between the respective element information; wherein the operation text includes multiple text information and the order between the respective text information; save the operation flow and its corresponding operation text to the semantic library.

9. The apparatus according to claim 8, wherein, the sending module is configured to: generate operation test cases based on the operation flows, and repeatedly send instructions to execute the operation test cases until the number of received operation test cases with failed execution results is zero or a fixed value; wherein, for each operation test case: generate operation instructions respectively according to the respective element information in the operation flow corresponding to the operation test case, and send the operation instructions item by item according to the order between the respective element information.

10. The apparatus according to claim 6, wherein, replacing the position of the target text information in the target operation text with the synonyms of the target text information, so as to optimize the operation flow, includes: finding each synonym that matches the target text information in the synonym set; respectively replacing the position of the target text information in the target operation text with the respective synonyms to obtain multiple synonym operation texts; respectively calculating the similarity between the multiple synonym operation texts and the target operation text, and using the operation flow corresponding to the synonym operation text with a similarity greater than the preset threshold as the optimized operation flow.

11. An electronic device, wherein, comprises: one or more processors; a storage device for storing one or more programs, when the one or more programs are executed by the one or more processors, enabling the one or more processors to implement the method according to any one of claims 1-5.

12. A computer-readable medium having a computer program stored thereon, wherein, when the program is executed by a processor, it implements the method according to any one of claims 1-5.

Citation Information

Patent Citations

  • Highly automatic software testing method based on UML diagram

    CN105022691A

  • Development method and terminal equipment of automated test cases

    CN109062780A