Test script generation method and device and electronic equipment
By determining the target elements in web testing and generating test scripts using artificial intelligence models, the problem of inaccurate generation of complex web test scripts is solved, and efficient and accurate test results are achieved.
Patent Information
- Application Number
- CN202510518634.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-23
- Publication Date
- 2025-08-08
AI Technical Summary
When generating web test scripts in the prior art, it is difficult to accurately reflect the real functions and performance of complex web pages, resulting in inaccurate test results.
By obtaining test instruction information, determining the pending elements in the target page based on the operation information, and using artificial intelligence models to generate target test scripts, reducing the processing of the entire page elements, improving positioning accuracy and generation efficiency.
It improves the accuracy and efficiency of test script generation, reduces the use of data transmission and processing resources, and improves the reliability of test results.
Smart Images

Figure CN120448262A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and more specifically to a method, device and electronic device for generating a test script. Background Art
[0002] With the development of Internet technology, web applications are becoming increasingly complex, and the amount of page data is constantly increasing. To ensure the quality and stability of web pages, web page testing is necessary. Generating test scripts is a relatively important step in web page testing.
[0003] If the web page structure is complex and the generated test script is inaccurate, it will not be able to reflect the actual functions and performance issues of the web page, affecting the accuracy of the web page test results. Summary of the Invention
[0004] In view of this, this application provides the following technical solutions:
[0005] A method for generating a test script, comprising:
[0006] Get test instruction information;
[0007] Determining target elements to be processed in the target page based on operation information of the target page corresponding to the test instruction information; the target elements are part of the elements in the target page;
[0008] A target test script corresponding to the test instruction information is generated according to the target element.
[0009] Optionally, determining a target element to be processed in the target page based on operation information of the target page corresponding to the test instruction information includes:
[0010] Determining a target page corresponding to the test instruction information;
[0011] When the target page is displayed, receiving operation information for the target page;
[0012] Based on the operation information, obtaining element positioning information corresponding to the operation information;
[0013] Based on the element location information and the page feature information of the target page, a target element to be processed is determined in the target page.
[0014] Optionally, the element location information includes element path information, and determining the target element to be processed in the target page based on the element location information and page feature information of the target page includes:
[0015] Determining a structure tree of the target page based on the page feature information of the target page, the structure tree including a plurality of nodes, the nodes including a hierarchical relationship of nodes and element nodes, the element nodes representing elements of the target page;
[0016] A target element to be processed is determined in the structure tree based on the element path information.
[0017] Optionally, the element location information includes element feature description information, and determining the target element to be processed in the target page based on the element location information and page feature information of the target page includes:
[0018] Determining element attribute characteristics of the target page based on page characteristic information of the target page;
[0019] Based on the element feature description information and the element attribute feature, a target element to be processed in the target page is determined.
[0020] Optionally, generating a target test script corresponding to the test instruction information according to the target element includes:
[0021] Determining, based on each test process corresponding to the test instruction information, an association relationship between target elements corresponding to each test process;
[0022] A target test script is generated based on the association relationship between each of the target elements and the test action features corresponding to the target elements.
[0023] Optionally, the target element to be processed represents an element to be transmitted to a target model and processed by the target model, wherein generating a target test script corresponding to the test instruction information according to the target element includes:
[0024] generating target input information based on the test instruction information and at least one target element;
[0025] Processing the target input information based on the target model to obtain a target test script;
[0026] The target model represents an artificial intelligence model that can be converted into a test script based on elements and test instructions.
[0027] Optionally, obtaining test instruction information includes:
[0028] Get user input information;
[0029] Parsing the user input information to obtain test instruction information;
[0030] The target page represents a web page determined based on the page input information in the test instruction information.
[0031] Optionally, it also includes:
[0032] In response to executing the target test script, obtaining an execution result of the target test script;
[0033] Optimization information is determined based on the execution result, and the optimization information is used to optimize the target test script.
[0034] A test script generation device, comprising:
[0035] An acquisition unit, used for obtaining test instruction information;
[0036] a determining unit, configured to determine a target element to be processed in the target page based on operation information of the target page corresponding to the test instruction information; the target element is a portion of elements in the target page;
[0037] A generating unit is used to generate a target test script corresponding to the test instruction information according to the target element.
[0038] An electronic device, comprising:
[0039] A memory, used to store applications and data generated by the execution of the applications;
[0040] A processor, configured to execute the application program to implement:
[0041] Get test instruction information;
[0042] Determining target elements to be processed in the target page based on operation information of the target page corresponding to the test instruction information; the target elements are part of the elements in the target page;
[0043] A target test script corresponding to the test instruction information is generated according to the target element. BRIEF DESCRIPTION OF THE DRAWINGS
[0044] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are merely embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without any creative work.
[0045] Figure 1 A flow chart of a method for generating a test script provided in an embodiment of the present application;
[0046] Figure 2 A flowchart of a method for determining a target element provided in an embodiment of the present application;
[0047] Figure 3 A schematic diagram of a structure tree provided in an embodiment of the present application;
[0048] Figure 4 A schematic diagram of a processing flow for an application scenario provided in an embodiment of the present application;
[0049] Figure 5 A schematic diagram of the structure of a test script generation device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0050] The following will be combined with the drawings in the embodiments of this application to clearly and completely describe the technical solutions in the embodiments of this application. Obviously, the embodiments described are only part of the embodiments of this application, not all of the embodiments. Based on the embodiments in this application, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of this application.
[0051] In this application, the terms "first" and "second" are used to distinguish between different objects, not to describe a specific order. Furthermore, the terms "including" and "having," and any variations thereof, are intended to cover non-exclusive inclusions. For example, a process, method, system, product, or apparatus comprising a series of steps or elements is not limited to the listed steps or elements and may include steps or elements that are not listed.
[0052] The embodiment of the present application provides a method for generating a test script, which is used in the scenario of automatically generating a test script, and can generally be applied to the generation process of a web page test script, which is a code for automatically verifying the functions and performance of a web page. It checks whether the web page elements are displayed normally and whether the functions are correctly implemented by simulating user operations such as clicking, inputting, scrolling, etc. It can also be applied to the scenario of generating a test script for a front-end interface, etc. By using the method for generating a test script in the embodiment of the present application, the efficiency of test script generation can be improved and the occupancy of processing resources in the test script generation process can be reduced.
[0053] See also Figure 1 , is a flow chart of a method for generating a test script provided in an embodiment of the present application, the method may include the following steps:
[0054] S101. Obtain test instruction information.
[0055] In an embodiment of the present application, a test script can be generated through a test platform, and correspondingly, a user can input text or voice information for describing the test content through the front-end interface of the test platform. In the case where the user inputs text information, key information in the text information can be extracted as test instruction information, such as extracting test content information and test-related information in the text instruction. In the case where the user inputs voice information, the voice information can be converted into text information first, and then the test instruction information can be extracted from the text information. Correspondingly, the test instruction information can include information characterizing the test content, and can also include associated information for testing. For example, in an application scenario in which a web page test script is generated, the test instruction information can include test instructions for the functions of a certain web page, as well as address information of the web page, etc.
[0056] In embodiments of the present application, test scripts can be automatically generated by the test platform. To improve the efficiency and accuracy of test script generation, after obtaining test information input by the user, the test information can be preprocessed so that the preprocessed information meets the information processing requirements of the test platform. For example, the test information can be supplemented, cleaned and verified, and formatted uniformly to obtain test instruction information.
[0057] S102: Determine a target element to be processed in the target page based on the operation information of the target page corresponding to the test instruction information.
[0058] The test instruction information may include information about the test content, and may also include information about the target page corresponding to the test content. For example, in an application scenario where a web page test script is generated, the target page may be the web page to be tested. For example, the test instruction information may include the access address information of the target page. The test platform may directly access the address information of the target page to be tested through a target component (such as a browser plug-in or a standalone application), such as https: / / ex**.*****. The target web page will then be displayed on the front end of the test platform, and the user may perform related operations on the target web page, such as selecting elements.
[0059] The user's operation information on the target page may include the user selecting the corresponding elements in the target page through touch operations on the target page, such as the user can select elements in the target page through operations such as mouse clicks or hovering, such as buttons, input boxes and other elements in the page. After detecting these operation information, the target elements to be processed in the target page will be determined based on these operation information. The target elements are some elements in the target page. Among them, the target elements to be processed represent elements that need to be processed by the processing module of the test platform, such as the processing module is a functional module based on an artificial intelligence model, and the target elements represent elements input to the artificial intelligence model.
[0060] In an embodiment of the present application, the target element to be processed can be located by operating information on the target page, and then only the target element can be processed subsequently without having to process all elements corresponding to the target page. This can reduce the resource information required for element transmission and processing, thereby improving processing efficiency. In the process of determining the target element to be processed in the target page based on the operating information, the characteristic information of the element selected by the user can be determined based on the operating information, and then the characteristic information can be analyzed to determine the location information of the element, so that the target element can be determined based on the location information without having to transmit other non-target elements to the corresponding processing module, thereby reducing the data transmission cost.
[0061] S103: Generate a target test script corresponding to the test instruction information according to the target element.
[0062] After obtaining the target element, a target test script can be generated based on the test content and test script framework included in the test instruction information. For example, the execution action for the element included in the test content in the test instruction information can be used, and then the target element can be encapsulated and processed according to the code information corresponding to the execution action, and converted into the corresponding test script format to obtain the target test script. The target test script can be used to execute the test instruction and obtain the test results.
[0063] An embodiment of the present application provides a method for generating a test script. In this method, after obtaining the test instruction information, the target element to be processed in the target page can be determined based on the operation information of the target page corresponding to the test instruction information, thereby realizing the positioning of the target element without passing all elements in the entire target page to the processing module of the test platform for processing. This can reduce the amount of transmitted data. At the same time, in the process of generating the target test script, the target element can be analyzed without analyzing all elements, which reduces the occupancy of processing resources and improves the efficiency and accuracy of target test script generation.
[0064] The following describes the test script generation method of the embodiment of the present application in conjunction with the corresponding application scenario.
[0065] In one embodiment of the present application, a method for determining a target element is also provided. Figure 2 Based on the operation information of the target page corresponding to the test instruction information, the process of determining the target element to be processed in the target page may include the following steps:
[0066] S201: Determine a target page corresponding to the test instruction information.
[0067] S202: When the target page is displayed, receive operation information for the target page.
[0068] S203: Based on the operation information, obtain element positioning information corresponding to the operation information.
[0069] S204: Determine a target element to be processed in the target page based on the element location information and the page feature information of the target page.
[0070] After the test instruction information includes the URL information of the target page, the front end of the test platform will display the target page based on the URL information. In one embodiment, obtaining the test instruction information includes obtaining user input information, parsing the user input information, and obtaining the test instruction information, wherein the target page is guaranteed to be a web page determined based on the page input information in the test instruction information. Then, user operation information for the target page is received, such as information about the user selecting relevant elements in the target page, so that element location information can be determined based on the user operation information. To accurately locate the element, at least one dimension of information can be obtained to determine the location information of the element, such as element path information, attribute information, and feature information. After obtaining the element location information, the target element to be processed is determined based on the page feature information of the target page. The page feature information of the target page can represent the layout information of each element in the target page, such as element structure information, element attribute information, and element layout relationship information. Therefore, based on the element location information of the target element, the target element to be processed can be matched and located in the target page, improving the accuracy and efficiency of target element determination.
[0071] Correspondingly, in one implementation of an embodiment of the present application, the element positioning information may include element path information, wherein, based on the element positioning information and the page feature information of the target page, the target element to be processed is determined in the target page, including: determining the structure tree of the target page based on the page feature information of the target page; and determining the target element to be processed in the structure tree based on the element path information.
[0072] The structure tree includes multiple nodes, including hierarchical relationships of nodes and element nodes, which represent elements of the target page. For example, the structure tree can be a DOM tree. DOM (Document Object Model) is a programming interface for representing HTML or XML documents. It organizes the structure of a document in a tree form, so that the content, structure and style of the document can be accessed and manipulated by programming languages (such as JavaScript). DOM represents an HTML document as a tree structure, called a DOM tree. Each node of the tree represents a part of the document, see Figure 3, the node types can include: Document Node, which is the root node of the tree and represents the entire HTML document; Element Node, which represents an HTML element, such as 、 、 etc.; AttributeNode represents the attributes of an element, such as id, class, href, etc.; CommentNode represents the comments in HTML, such as Figure 3 The "document title", "input box" and "title" shown in the figure have a hierarchical relationship, that is, a superior-subordinate relationship of the nodes.
[0073] In the process of generating web page test scripts by integrating natural language through a large language model, an artificial intelligence model is usually used to load the entire page and parse the DOM structure. If the page structure is complex, it is difficult for the artificial intelligence model to accurately locate the operation object, resulting in the inability to accurately operate the target element when the test script is executed, thereby affecting the accuracy of the test results. In an embodiment of the present application, elements in the DOM tree can be located by element path information. The element path information can be XPath information, wherein XPath (XML Path Language) is a query language for locating nodes in XML / HTML documents. In this way, the target element to be processed can be determined by the element path information and the path of each element in the DOM tree, so that when obtaining the target element to be processed, there is no need to transmit and analyze the complete DOM structure and data, and the target element can be transmitted. This can save the transmission amount of source data and the computing overhead of the processing module, and because the actual complete page content is not transmitted to the processing module, data security is also improved.
[0074] Correspondingly, the element positioning information may also include element feature description information, wherein the target element to be processed is determined in the target page based on the element positioning information and the page feature information of the target page, including: determining the element attribute characteristics of the target page based on the page feature information of the target page; determining the target element to be processed in the target page based on the element feature description information and the element attribute characteristics. The element feature description information may be a description of the attributes, type, etc. of the element, that is, the elements can be distinguished by the feature description information of each element, and the target element to be processed corresponding to the current element feature description information can be determined. For example, the element feature description information may be an element selector virtual, such as Selector information, which finds buttons, input boxes, links, etc. on a web page through specific rules. In this way, feature matching can be performed based on the element feature description information and the element attribute characteristics of the target page, thereby determining the target element to be processed.
[0075] In an embodiment of the present application, element positioning information can be determined through multi-dimensional information, such as element path information, element feature description information, element attribute information and relative positioning information, etc., wherein the relative positioning information can be the position of the reference element, etc., so that the target element to be processed can be obtained more accurately through multi-dimensional information.
[0076] After obtaining the target element, a corresponding target test script can be generated. In one embodiment of the present application, the process of generating a target test script corresponding to the test instruction information based on the target element may include: determining the association relationship between the target elements corresponding to each test process based on each test process corresponding to the test instruction information; and generating the target test script based on the association relationship between each target element and the test action characteristics corresponding to the target element. The test instruction information may include a test process representing the test steps, such as the test instruction information including first testing the "like" function for information and then testing the "cancel" function; or first testing the function of adding an item from an online shopping webpage to a shopping cart and then testing the function of removing the item from the shopping cart. In this way, the association relationship between the target elements corresponding to each process can be determined based on the test process. This association relationship can represent the execution order relationship between the elements and the hierarchical relationship between the elements. In this way, the order of execution logic in each test script can be clearly defined in the test script, so that the generated test script is more consistent with the test instruction information. For example, based on the association relationship between the target elements and the test action characteristics corresponding to the target elements, the execution order of the test actions of each target element can be determined, thereby generating the target test script. Furthermore, after the user inputs the corresponding test instruction and a test script is generated according to the test instruction, when a test instruction related to the previous test instruction is received again, the current test script can be generated again based on the test script corresponding to the previous test instruction, thereby improving the efficiency of test script generation.
[0077] In an embodiment of the present application, after obtaining a target element, the target element can be processed by a target model to automatically generate a corresponding test script. Accordingly, in one embodiment, the target element to be processed represents an element to be transmitted to the target model and processed by the target model. Generating a target test script corresponding to the test instruction information based on the target element includes: generating target input information based on the test instruction information and at least one target element; and processing the target input information based on the target model to obtain a target test script. The target model represents an artificial intelligence model that can convert elements and test instructions into test scripts. The target model can have a natural language understanding function that can be used to parse user input information, such as obtaining the user's test intent. The target model can also dynamically bind the target element to be processed to an operation type (such as click, input, etc.). And, based on the code generator in the target model, an executable script that conforms to the syntax of the target test framework is output. Furthermore, the target model can also have a logic check function to automatically detect the rationality of the test steps. For example, when testing the login function on a web page, if the user directly clicks on login without entering a password, a prompt message will be generated. Furthermore, the target model may be an artificial intelligence model obtained by training based on corresponding training data, wherein the training data may be verified test script information, and the test script information may be annotated with corresponding elements and test instruction information.
[0078] After the target test script is generated in the embodiment of the present application, the target test script can also be executed to obtain the execution result of the target test script; based on the execution result, the optimization information is determined. Among them, the optimization information is used to optimize the target test script. Correspondingly, the execution result of the target test script can be displayed to the user in the form of visual information, so that the user can determine whether the current target test script meets the user's needs based on the execution result. If it does not meet the user's needs, the user can generate feedback information, and generate optimization information through the feedback information. The optimization information can be used by the user to optimize the user's test instructions, or it can be used to optimize the relevant information in the test script so that the optimized test script can meet the user's needs.
[0079] See also Figure 4 , which shows a processing flow diagram of an application scenario provided by an embodiment of the present application. The user can input input information such as test steps / instructions through the test front end, such as the URL information of the web page to be tested, test content, test actions and other information. Then, the corresponding instruction information can be obtained by parsing the input information, such as including the URL information of the input web page as http / / ***; the user clicks a button; the page displays the logo text "XXX". Then, the target page can be displayed according to the user's input information, and the page element information is obtained through the page tool of the page element based on the user's operation information on the target page, and then the corresponding touch element set is determined according to the test step / instruction set. These element sets and the test script method instruction set are then sent to the AI model for parsing to generate a test script. For example, the user enters the test steps / instructions from the business front end; the user loads the target operation page through the page tool provided by the business front end and obtains the page information of the operation object / page element (for example, XPath, Selector and other page element information) through mouse actions (single click, double click, right click, focus suspension, etc.). Based on the content and number of test steps / instructions, the above steps can be executed multiple times to obtain the page information combination of the operation object / page element (i.e. the manipulation object information set). The collected results and the test script method instruction set are sent to AI for parsing to generate the test script.
[0080] In this application scenario, when using natural language to describe the operation steps, the page information of the manipulated object is obtained with the help of the page script tool, so that the manipulation elements can be accurately and quickly obtained when generating the inspection script, without having to transmit and analyze the complete page structure and data. This saves the transmission volume of source data and AI overhead to the greatest extent, improves the hit rate of running script statements and the overall correctness of the script, and since the actual page content is not transmitted to the AI, it also plays a role in protecting data security.
[0081] In the embodiment of the present application, a test script generation device is also provided, see Figure 5 , the device comprises:
[0082] An acquisition unit 501 is used to obtain test instruction information;
[0083] A determining unit 502 is configured to determine a target element to be processed in the target page based on the operation information of the target page corresponding to the test instruction information; the target element is a part of the elements in the target page;
[0084] The generating unit 503 is configured to generate a target test script corresponding to the test instruction information according to the target element.
[0085] Optionally, the determining unit includes:
[0086] A first determining subunit, configured to determine a target page corresponding to the test instruction information;
[0087] a receiving subunit, configured to receive operation information for the target page when the target page is displayed;
[0088] A first acquisition subunit is configured to obtain, based on the operation information, element location information corresponding to the operation information;
[0089] The second determining subunit is configured to determine a target element to be processed in the target page based on the element positioning information and the page feature information of the target page.
[0090] Optionally, the element location information includes element path information, and the second determining subunit is configured to:
[0091] Determining a structure tree of the target page based on the page feature information of the target page, the structure tree including a plurality of nodes, the nodes including a hierarchical relationship of nodes and element nodes, the element nodes representing elements of the target page;
[0092] A target element to be processed is determined in the structure tree based on the element path information.
[0093] Optionally, the element location information includes element feature description information, and the second determining subunit may be further configured to:
[0094] Determining element attribute characteristics of the target page based on page characteristic information of the target page;
[0095] Based on the element feature description information and the element attribute feature, a target element to be processed in the target page is determined.
[0096] Optionally, the generating unit includes:
[0097] A third determining subunit is configured to determine, based on each test process corresponding to the test instruction information, an association relationship between target elements corresponding to each test process;
[0098] The first generating subunit is used to generate a target test script based on the association relationship between each of the target elements and the test action characteristics corresponding to the target elements.
[0099] Optionally, the target element to be processed represents an element to be transmitted to a target model and processed by the target model, wherein the generating unit includes:
[0100] A second generating subunit, configured to generate target input information based on the test instruction information and at least one target element;
[0101] a processing subunit, configured to process the target input information based on a target model to obtain a target test script;
[0102] The target model represents an artificial intelligence model that can be converted into a test script based on elements and test instructions.
[0103] Optionally, the acquiring unit includes:
[0104] The second acquisition subunit is used to obtain user input information;
[0105] The parsing subunit is used to parse the user input information to obtain test instruction information;
[0106] The target page represents a web page determined based on the page input information in the test instruction information.
[0107] Optionally, it also includes:
[0108] an execution result obtaining unit, configured to obtain an execution result of the target test script in response to executing the target test script;
[0109] An optimization information determination unit is used to determine optimization information based on the execution result, where the optimization information is used to optimize the target test script.
[0110] It should be noted that the specific implementation of each unit and sub-unit in this embodiment can refer to the corresponding content in the previous text and will not be described in detail here.
[0111] In another embodiment of the present application, a readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the above-mentioned test script generation method is implemented.
[0112] In another embodiment of the present application, an electronic device is provided, which may include:
[0113] A memory, used to store applications and data generated by the execution of the applications;
[0114] A processor, configured to execute the application program to implement:
[0115] Get test instruction information;
[0116] Determining target elements to be processed in the target page based on operation information of the target page corresponding to the test instruction information; the target elements are part of the elements in the target page;
[0117] A target test script corresponding to the test instruction information is generated according to the target element.
[0118] Optionally, determining a target element to be processed in the target page based on operation information of the target page corresponding to the test instruction information includes:
[0119] Determining a target page corresponding to the test instruction information;
[0120] When the target page is displayed, receiving operation information for the target page;
[0121] Based on the operation information, obtaining element positioning information corresponding to the operation information;
[0122] Based on the element location information and the page feature information of the target page, a target element to be processed is determined in the target page.
[0123] Optionally, the element location information includes element path information, and determining the target element to be processed in the target page based on the element location information and page feature information of the target page includes:
[0124] Determining a structure tree of the target page based on the page feature information of the target page, the structure tree including a plurality of nodes, the nodes including a hierarchical relationship of nodes and element nodes, the element nodes representing elements of the target page;
[0125] A target element to be processed is determined in the structure tree based on the element path information.
[0126] Optionally, the element location information includes element feature description information, and determining the target element to be processed in the target page based on the element location information and page feature information of the target page includes:
[0127] Determining element attribute characteristics of the target page based on page characteristic information of the target page;
[0128] Based on the element feature description information and the element attribute feature, a target element to be processed in the target page is determined.
[0129] Optionally, generating a target test script corresponding to the test instruction information according to the target element includes:
[0130] Determining, based on each test process corresponding to the test instruction information, an association relationship between target elements corresponding to each test process;
[0131] A target test script is generated based on the association relationship between each of the target elements and the test action features corresponding to the target elements.
[0132] Optionally, the target element to be processed represents an element to be transmitted to a target model and processed by the target model, wherein generating a target test script corresponding to the test instruction information according to the target element includes:
[0133] generating target input information based on the test instruction information and at least one target element;
[0134] Processing the target input information based on the target model to obtain a target test script;
[0135] The target model represents an artificial intelligence model that can be converted into a test script based on elements and test instructions.
[0136] Optionally, obtaining test instruction information includes:
[0137] Get user input information;
[0138] Parsing the user input information to obtain test instruction information;
[0139] The target page represents a web page determined based on the page input information in the test instruction information.
[0140] Optionally, it also includes:
[0141] In response to executing the target test script, obtaining an execution result of the target test script;
[0142] Optimization information is determined based on the execution result, and the optimization information is used to optimize the target test script.
[0143] It should be noted that the specific implementation of the processor in this embodiment can refer to the corresponding content in the previous text and will not be described in detail here.
[0144] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. Reference can be made to the common and similar parts between the various embodiments. For the devices disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the description is relatively simple, and the relevant parts can be referred to the method description.
[0145] Professionals may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the above description has generally described the components and steps of each example according to their functions. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0146] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), internal memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
[0147] The above description of the disclosed embodiments is intended to enable one skilled in the art to implement or use the present application. Various modifications to these embodiments will be readily apparent to one skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of the present application. Therefore, the present application is not limited to the embodiments shown herein, but is intended to conform to the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A method for generating a test script, comprising: Get test instruction information; determining a target element to be processed in the target page based on operation information of the target page corresponding to the test instruction information; The target elements are some elements in the target page; A target test script corresponding to the test instruction information is generated according to the target element.
2. The method according to claim 1, wherein determining the target element to be processed in the target page based on the operation information of the target page corresponding to the test instruction information comprises: Determining a target page corresponding to the test instruction information; When the target page is displayed, receiving operation information for the target page; Based on the operation information, obtaining element positioning information corresponding to the operation information; Based on the element location information and the page feature information of the target page, a target element to be processed is determined in the target page.
3. The method according to claim 2, wherein the element location information includes element path information, and determining the target element to be processed in the target page based on the element location information and page feature information of the target page comprises: Determining a structure tree of the target page based on the page feature information of the target page, the structure tree including a plurality of nodes, the nodes including a hierarchical relationship of nodes and element nodes, the element nodes representing elements of the target page; A target element to be processed is determined in the structure tree based on the element path information.
4. The method according to claim 2, wherein the element location information includes element feature description information, and determining the target element to be processed in the target page based on the element location information and page feature information of the target page comprises: Determining element attribute characteristics of the target page based on page characteristic information of the target page; Based on the element feature description information and the element attribute feature, a target element to be processed in the target page is determined.
5. The method according to claim 1, wherein generating a target test script corresponding to the test instruction information according to the target element comprises: Determining, based on each test process corresponding to the test instruction information, an association relationship between target elements corresponding to each test process; A target test script is generated based on the association relationship between each of the target elements and the test action features corresponding to the target elements.
6. The method according to claim 1, wherein the target element to be processed represents an element to be transferred to a target model and processed by the target model, wherein: Generating a target test script corresponding to the test instruction information according to the target element includes: generating target input information based on the test instruction information and at least one target element; Processing the target input information based on the target model to obtain a target test script; The target model represents an artificial intelligence model that can be converted into a test script based on elements and test instructions.
7. The method according to claim 1, wherein obtaining test instruction information comprises: Get user input information; Parsing the user input information to obtain test instruction information; The target page represents a web page determined based on the page input information in the test instruction information.
8. The method according to claim 1, further comprising: In response to executing the target test script, obtaining an execution result of the target test script; Optimization information is determined based on the execution result, and the optimization information is used to optimize the target test script.
9. A test script generation device, comprising: An acquisition unit, used for obtaining test instruction information; a determining unit, configured to determine a target element to be processed in the target page based on operation information of the target page corresponding to the test instruction information; The target elements are some elements in the target page; A generating unit is used to generate a target test script corresponding to the test instruction information according to the target element.
10. An electronic device comprising: A memory, used to store applications and data generated by the execution of the applications; A processor, configured to execute the application program to implement: Get test instruction information; determining a target element to be processed in the target page based on operation information of the target page corresponding to the test instruction information; The target elements are some elements in the target page; A target test script corresponding to the test instruction information is generated according to the target element.
Citation Information
Cited By
DOM (Document Object Model) element and visual element alignment and DOM element mapping method and device
CN121144180A