Test script recording method and device, electronic device, and storage medium

By acquiring interface layout data, extracting control information, and querying event response mechanisms, a target test recording script is generated, solving the problem of low efficiency in manual recording and achieving efficient test script recording and UI automation testing.

CN115562993BActive Publication Date: 2026-02-06CHINA PING AN LIFE INSURANCE CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202211247592.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-10-12
Publication Date
2026-02-06
Estimated Expiration
2042-10-12

AI Technical Summary

Technical Problem

Existing test script recording methods rely on manual processing, which is cumbersome and results in low recording efficiency.

Method used

By acquiring the target client's interface layout data, extracting candidate control information, performing control query and classification based on the event response mechanism, and integrating the data to generate the target test recording script.

Benefits of technology

It improves the efficiency and convenience of test script recording, simplifies the operation process, and enhances the efficiency of UI automation testing and script reusability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115562993B_ABST
    Figure CN115562993B_ABST
Patent Text Reader

Abstract

The application provides a test script recording method and device, an electronic device and a storage medium, and belongs to the technical field of testing. The method comprises the following steps: performing interface layout detection on a target interface to obtain interface layout data, and recording the process of the interface layout detection to obtain an interface layout script; performing information extraction on the interface layout data to obtain candidate control information, and recording the process of the information extraction to obtain a control information script; performing control query based on an event response mechanism, the candidate control information and a current operation event to obtain target control information, and recording the process of the control query to obtain a query information script; performing classification processing on the current operation event to obtain target operation data, and recording the classification process to obtain an operation classification script; and integrating the interface layout script, the query information script and the operation classification script to obtain a target test recording script. The application can improve the recording efficiency.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of testing, in particular to a test script recording method and device, electronic equipment and storage medium. BACKGROUND

[0002] The current test script recording method often needs to rely on manual processing to realize script recording, which is often tedious and time-consuming, affecting the script recording efficiency. Therefore, how to improve the script recording efficiency has become a technical problem to be solved. SUMMARY

[0003] The main purpose of the embodiments of the present application is to provide a test script recording method and device, electronic equipment and storage medium, which aims to improve the script recording efficiency.

[0004] To achieve the above purpose, the first aspect of the embodiments of the present application provides a test script recording method, which comprises:

[0005] Obtaining a target interface of a target client;

[0006] Performing interface layout detection on the target interface to obtain interface layout data, and recording the process of interface layout detection to obtain an interface layout script;

[0007] Extracting information from the interface layout data to obtain candidate control information, and recording the process of information extraction to obtain a control information script;

[0008] Obtaining an interface operation instruction, wherein the interface operation instruction comprises a current operation event and an operation time;

[0009] Performing control query based on a preset event response mechanism, the candidate control information and the current operation event to obtain a target control and target control information of the target control, wherein the target control is a candidate control that needs to consume the current operation event, and recording the process of control query to obtain a query information script;

[0010] Classifying the current operation event based on the target control information and the operation time to obtain target operation data, wherein the target operation data comprises an operation type of the current operation event, and recording the classification process to obtain an operation classification script;

[0011] Integrating the interface layout script, the query information script and the operation classification script to obtain a target test recording script.

[0012] In some embodiments, the information extraction from the interface layout data to obtain candidate control information comprises:

[0013] traversing a control tree of the target interface to obtain candidate controls of the target interface;

[0014] performing information extraction on the interface layout data to obtain control types and control attributes of the candidate controls;

[0015] generating control numbers of the candidate controls according to the control types and the control attributes, wherein the control numbers of each of the candidate controls are unique;

[0016] obtaining the candidate control information according to the control types, the control numbers and the control attributes.

[0017] In some embodiments, the control query based on the preset event response mechanism, the candidate control information and the current operation event obtains a target control and target control information of the target control, including:

[0018] obtaining a target feature parameter corresponding to the current operation event based on the event response mechanism;

[0019] obtaining a preset relationship mapping table, the relationship mapping table storing a mapping relationship between candidate feature parameters and candidate controls;

[0020] performing control query according to the preset relationship mapping table and the target feature parameter to obtain the target control;

[0021] performing filtering processing on the candidate control information according to the target control to obtain the target control information.

[0022] In some embodiments, the classification processing of the current operation event based on the target control information and the operation time obtains target operation data, including:

[0023] performing first classification processing on the current operation event according to the operation time to obtain initial classification data;

[0024] performing second classification processing on the initial classification data according to a control type in the target control information to obtain intermediate classification data;

[0025] performing type adjustment on the intermediate classification data according to preset reference control information to obtain an operation type of the current operation event;

[0026] performing data integration on the operation type, the operation time, the target control information and the current operation event to obtain the target operation data.

[0027] In some embodiments, the integrating the interface layout script, the query information script, and the operation classification script to obtain a target test recording script comprises:

[0028] The interface layout script, the query information script, and the operation classification script are integrated according to a preset splicing sequence to obtain an initial test recording script.

[0029] The initial test recording script is named to obtain a test case name.

[0030] The target test recording script is generated based on the test case name and the initial test recording script.

[0031] In some embodiments, before the interface layout data is obtained by detecting the target interface, the method comprises:

[0032] A test recording request is obtained.

[0033] The recording switch is turned on according to the test recording request.

[0034] In some embodiments, after the target test recording script is obtained by integrating the interface layout script, the query information script, and the operation classification script, the method further comprises:

[0035] The target test recording script is uploaded to a server side.

[0036] The target test recording script is corrected based on reference case data of the server side to obtain target case data.

[0037] To achieve the above object, a second aspect of the embodiment of the application provides a test script recording device, which comprises:

[0038] An interface obtaining module is configured to obtain a target interface of a target client.

[0039] A layout detecting module is configured to detect the target interface to obtain interface layout data, and record a process of the interface layout detection to obtain an interface layout script.

[0040] An information extracting module is configured to extract information from the interface layout data to obtain candidate control information, and record a process of the information extraction to obtain a control information script.

[0041] An instruction obtaining module is configured to obtain an interface operation instruction, wherein the interface operation instruction comprises a current operation event and an operation time.

[0042] The control query module is configured to perform control query based on the preset event response mechanism, the candidate control information and the current operation event, to obtain a target control and target control information of the target control, and to record a process of the control query to obtain query information script, wherein the target control is a candidate control that needs to consume the current operation event.

[0043] The operation classification module is configured to perform classification processing on the current operation event based on the target control information and the operation time, to obtain target operation data, and to record a process of the classification to obtain operation classification script, wherein the target operation data includes an operation type of the current operation event.

[0044] The script integration module is configured to perform integration processing on the interface layout script, the query information script and the operation classification script to obtain a target test recording script.

[0045] To achieve the above object, a third aspect of embodiments of the present application provides an electronic device, which comprises a memory and a processor, the memory stores a computer program, and the processor implements the method of the first aspect when executing the computer program.

[0046] To achieve the above object, a fourth aspect of embodiments of the present application provides a computer readable storage medium, which stores a computer program, and the computer program is executed by a processor to implement the method of the first aspect.

[0047] The test script recording method, device, electronic equipment, and storage medium proposed in this application acquire the target interface of the target client; perform interface layout detection on the target interface to obtain interface layout data; and record the interface layout detection process to obtain an interface layout script. This process allows for convenient monitoring of layout changes on the target interface, and based on the detected layout changes, generates interface layout data and records it to the interface layout script, improving the efficiency of script generation. Furthermore, information extraction is performed on the interface layout data to obtain candidate control information, and the information extraction process is recorded to obtain a control information script, improving the efficiency of acquiring candidate control information. Further, interface operation instructions are acquired, including the current operation event and operation time; based on a preset event response mechanism, candidate control information, and the current operation event, control queries are performed to obtain the target control and its target control information, and the control query process is recorded to obtain a query information script, improving the efficiency and accuracy of control queries. Furthermore, based on the target control information and operation time, the current operation events are categorized to obtain target operation data. The categorization process is recorded to obtain an operation categorization script, which facilitates automated testing of operation categorization, determines the correspondence between target controls and operation events, and improves the convenience of script recording by recording the operation categorization process. Finally, the interface layout script, information query script, and operation categorization script are integrated to obtain the target test recording script. This allows test recording scripts belonging to the same case to be combined into a single target test recording script, improving the efficiency of test script recording. Attached Figure Description

[0048] Figure 1 This is a flowchart of the test script recording method provided in the embodiments of this application;

[0049] Figure 2 This is another flowchart of the test script recording method provided in the embodiments of this application;

[0050] Figure 3 yes Figure 1 The flowchart of step S103 in the process;

[0051] Figure 4 yes Figure 1 The flowchart of step S105 in the process;

[0052] Figure 5 yes Figure 1 The flowchart of step S106 in the process;

[0053] Figure 6 yes Figure 1 The flowchart of step S107 in the process;

[0054] Figure 7 is another flowchart of the test script recording method provided by the embodiment of the present application;

[0055] Figure 8 is a structural schematic diagram of the test script recording device provided by the embodiment of the present application;

[0056] Figure 9 is a hardware structural schematic diagram of the electronic device provided by the embodiment of the present application. DETAILED DESCRIPTION

[0057] In order to make the purpose, technical scheme and advantages of the present application clearer, the present application is further described in detail below in combination with the drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application, and are not used to limit the present application.

[0058] It should be noted that although the functional modules are divided in the device schematic diagram, and the logical order is shown in the flowchart, in some cases, the steps shown or described can be executed in a manner different from the module division in the device or the order in the flowchart. The terms "first", "second", etc. in the specification, claims and above-described drawings are used to distinguish similar objects, and do not necessarily describe a specific order or sequence.

[0059] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which the present application belongs. The terms used herein are only for the purpose of describing the embodiments of the present application, and are not intended to limit the present application.

[0060] First, the several terms involved in the present application are analyzed:

[0061] Software Development Kit (SDK): A collection of development tools that software engineers use to create applications for a specific software package, software framework, hardware platform, operating system, etc. A software development kit is a collection of development tools that software engineers use to create applications for a specific software package, software framework, hardware platform, operating system, etc. Generally speaking, SDK is the SDK used to develop applications on the Windows platform. It facilitates the creation of applications through compilers, debuggers, software frameworks, etc. It can simply provide some files of application program interface API for a certain programming language, but it can also include complex hardware that can communicate with some embedded systems. Common tools include utilities for debugging and other purposes. SDKs also often include sample code, supporting technical notes, or other supporting documents that clarify doubts for basic reference materials.

[0062] User Interface (UI): The medium for interaction and information exchange between the system and the user, which realizes the conversion between the internal form of information and the form acceptable by humans. The user interface is the software that mediates the interaction between the user and the hardware. The purpose is to enable the user to conveniently and efficiently operate the hardware to achieve two-way interaction.

[0063] Control: refers to the encapsulation of data and methods. Controls can have their own properties and methods, where properties are simple access to control data, and methods are some simple and visible functions of the control. The control creation process includes design (Design), development (Develop), debugging (Debug), and then the use of the control. Among them, the control includes user interface controls, which are used to develop user interface controls to help complete the development of window, text box, button, drop-down menu and other interface elements in software development.

[0064] The current test script recording method often needs to rely on manual processing to realize script recording, which is often tedious and time-consuming, affecting the script recording efficiency. Therefore, how to improve the script recording efficiency has become a technical problem to be solved.

[0065] Based on this, the embodiments of the present application provide a test script recording method, a test script recording device, an electronic device and a storage medium, aiming to improve the script recording efficiency.

[0066] The test script recording method and device, the electronic device and the storage medium provided by the embodiments of the present application are described in detail as follows. First, the test script recording method in the embodiments of the present application is described.

[0067] The embodiments of the present application can acquire and process related data based on artificial intelligence technology. Artificial intelligence (AI) is a theory, method, technology and application system for simulating, extending and expanding human intelligence by using a digital computer or a machine controlled by a digital computer, perceiving an environment, acquiring knowledge and using the knowledge to obtain optimal results.

[0068] The test script recording method provided by the embodiments of the present application relates to the field of artificial intelligence technology. The test script recording method provided by the embodiments of the present application can be applied in a terminal, can be applied in a server end, and can also be software running in a terminal or a server end. In some embodiments, the terminal can be a smart phone, a tablet computer, a notebook computer, a desktop computer, etc.; the server end can be configured as a separate physical server, can be configured as a server cluster or a distributed system composed of multiple physical servers, can also be configured as a cloud server providing basic cloud computing services such as cloud service, cloud database, cloud computing, cloud function, cloud storage, network service, cloud communication, middleware service, domain name service, security service, CDN, and big data and artificial intelligence platform; and the software can be an application for implementing the test script recording method, but is not limited to the above forms.

[0069] The present application can be used in many general or special computer system environments or configurations. For example: personal computers, server computers, handheld devices or portable devices, tablet devices, multi-processor systems, microprocessor-based systems, set-top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, distributed computing environments including any of the above systems or devices, etc. The present application can be described in the general context of computer-executable instructions executed by a computer, such as program modules. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform specific tasks or implement specific abstract data types. The present application can also be practiced in a distributed computing environment in which tasks are performed by remote processing devices connected by a communication network. In a distributed computing environment, program modules can be located in local and remote computer storage media, including storage devices.

[0070] Figure 1 is an optional flowchart of the test script recording method provided by the embodiments of the present application, Figure 1 The method in can include but is not limited to steps S101 to S107.

[0071] Step S101, obtaining a target interface of a target client;

[0072] Step S102, performing interface layout detection on the target interface to obtain interface layout data, and recording a process of the interface layout detection to obtain an interface layout script;

[0073] Step S103, performing information extraction on the interface layout data to obtain candidate control information, and recording a process of the information extraction to obtain a control information script;

[0074] Step S104, obtaining an interface operation instruction, wherein the interface operation instruction includes a current operation event and an operation time;

[0075] Step S105, performing control query based on a preset event response mechanism, the candidate control information and the current operation event to obtain a target control and target control information of the target control, wherein the target control is a candidate control that needs to consume the current operation event, and recording a process of the control query to obtain a query information script;

[0076] Step S106, classifying the current operation event based on the target control information and the operation time to obtain target operation data, wherein the target operation data includes an operation type of the current operation event, and recording a process of the classification to obtain an operation classification script;

[0077] Step S107, performing integration processing on the interface layout script, the query information script and the operation classification script to obtain a target test recording script.

[0078] The steps S101 to S107 shown in the embodiments of the present application can obtain the target interface of the target client, perform interface layout detection on the target interface to obtain interface layout data, record the process of interface layout detection to obtain an interface layout script, conveniently monitor the layout change of the target interface, generate interface layout data and record the interface layout script based on the detected layout change, and improve the generation efficiency of the recorded script. The information extraction is performed on the interface layout data to obtain candidate control information, the process of information extraction is recorded to obtain a control information script, and the acquisition efficiency of the candidate control information of the candidate control is improved. The current operation event and operation time are obtained, the target control and target control information of the target control are obtained by performing control query based on the preset event response mechanism, candidate control information and current operation event, the process of control query is recorded to obtain a query information script, and the efficiency and accuracy of control query can be improved. The current operation event is classified and processed based on the target control information and operation time to obtain target operation data, the classification process is recorded to obtain an operation classification script, the automation test of operation classification can be conveniently realized, the corresponding relationship between the target control and operation event is determined, the process of operation classification is recorded to form an operation classification script, and the convenience of script recording is improved. Finally, the interface layout script, query information script and operation classification script are integrated and processed to obtain a target test recording script, so that the test recording scripts belonging to the same case can be integrated together to form a target test recording script, and the efficiency of script recording is improved.

[0079] It should be noted that the test script recording method can be applied to common recording tools, such as recording SDK and the like. The recording SDK is imported into the target client by one key, so that the recording SDK can be integrated in the target client in the form of a component, the recording SDK is low-coupled with the target client, the integration process is relatively simple, and the operation time can be saved. The target client can include an Android mobile device, such as an Android mobile phone and an Android tablet.

[0080] Please refer to Figure 2 Before step S101 of some embodiments, the test script recording method can include but is not limited to steps S201 to S202:

[0081] In step S201, a test recording request is obtained.

[0082] In step S202, a recording switch is started according to the test recording request.

[0083] In step S201 of some embodiments, a test recording request can be directly obtained, which can be issued by a target object operating on an operation platform, wherein the target object includes a user, a staff, and the like.

[0084] In step S202 of some embodiments, according to the test recording request, the recording SDK can start a recording switch.

[0085] Through the above steps S201 to S202, the test recording request can be conveniently received, and the recording switch can be started according to the test recording request, so as to record the process of the interface automation test, which can better adjust the working state of the recording SDK and reduce the working energy consumption of the recording SDK.

[0086] In step S101 of some embodiments, a target interface of a target client can be obtained through a shooting component of a recording SDK, and the target interface can be a user interface currently displayed by the target client.

[0087] In step S102 of some embodiments, after obtaining the target interface of the target client, interface layout detection is performed on the target interface, the layout change of the target interface is listened to, whether the addition of a control or the deletion of a control occurs in the target interface is identified, so as to obtain interface layout data, and the process of the interface layout detection is recorded to obtain an interface layout script. Through this process, the layout change of the target interface can be conveniently listened to, and based on the detected layout change, the interface layout data and the recording to the interface layout script are generated, which improves the generation efficiency of the test recording script.

[0088] Please refer to Figure 3 In some embodiments, step S103 can include but is not limited to steps S301 to S304:

[0089] Step S301: traversing a control tree of the target interface to obtain candidate controls of the target interface;

[0090] Step S302: performing information extraction on the interface layout data to obtain a control type and a control attribute of the candidate controls;

[0091] Step S303: generating a control number of the candidate controls according to the control type and the control attribute, wherein the control number of each candidate control is unique;

[0092] Step S304: obtaining candidate control information according to the control type, the control number, and the control attribute.

[0093] In step S301 of some embodiments, when the target interface appears control addition or control deletion, the control tree of the target interface is traversed to obtain candidate controls of the target interface, wherein the control tree includes all candidate controls added to the target page, and the candidate controls in the control tree include multiple levels, i.e., the candidate controls are divided into first-level controls, second-level controls subordinate to the first-level controls, third-level controls subordinate to the second-level controls, and so on.

[0094] In step S302 of some embodiments, information extraction is directly performed on the interface layout data to obtain the control type and the control attribute of the candidate control, wherein the control type of the candidate control includes a text view control TextView, a table control RecyclerView, a button Button, an editable control EditView, and the like, and the control attribute of the candidate control includes an xml path language XPath, a control positioning identifier accessibisityId, a control coordinate, and a control view name viewName, and the like, wherein the xml path language XPath is used to determine the language of a certain position of the candidate control in an XML document, the table control RecyclerView is a container used to display data in a list form or a grid form, such as text or photos.

[0095] In step S303 of some embodiments, since the control positioning identifier in the control attribute has uniqueness, a string is generated based on the control type of the candidate control, the control positioning identifier, and the level of the candidate control in the control tree, and the string is used as the control number of the candidate control, wherein the generated string has uniqueness, i.e., the control number of each candidate control is unique.

[0096] In step S304 of some embodiments, the control type, the control number, and the control attribute of each candidate control are integrated to obtain candidate control information of the candidate control.

[0097] Through the above steps S301 to S304, the control tree of the target interface can be conveniently traversed and information extracted to obtain the candidate control information of each candidate control, thereby improving the acquisition efficiency of the candidate control information of the candidate control. Compared with the manual control attribute grabbing in the UI automatic test of the traditional technology, the operation process is simplified, the operation time is saved, and the efficiency of the UI automatic test is improved.

[0098] In step S104 of some embodiments, the interface operation instruction can be directly obtained, and the interface operation instruction can be operated and issued by a target user on an operation platform, wherein the interface operation instruction includes operation information such as a current operation event and an operation time.

[0099] Please refer toFigure 4 In some embodiments, step S105 can include, but is not limited to, steps S401 to S404:

[0100] In step S401, a target feature parameter corresponding to a current operation event is obtained based on an event response mechanism.

[0101] In step S402, a preset relationship mapping table is obtained, and the relationship mapping table stores a mapping relationship between a candidate feature parameter and a candidate control.

[0102] In step S403, a target control is obtained by querying the candidate control according to the preset relationship mapping table and the target feature parameter.

[0103] In step S404, target control information is obtained by filtering candidate control information according to the target control.

[0104] In step S401 of some embodiments, the event response mechanism means that each candidate control has a candidate feature parameter recording a click event of the current candidate control. When a click event is set for a candidate control in the business logic, the candidate control that needs to respond to the click event can be queried based on the candidate feature and the click event. Therefore, the candidate feature parameter corresponding to the current operation event can be obtained based on the event response mechanism, and the candidate feature is taken as the target feature parameter.

[0105] In step S402 of some embodiments, a pre-stored relationship mapping table can be directly called, and the relationship mapping table stores a mapping relationship between a candidate feature parameter and a candidate control. The candidate feature parameter can be a preset variable parameter.

[0106] In step S403 of some embodiments, when the candidate control is queried according to the preset relationship mapping table and the target feature parameter, the candidate feature parameter corresponding to the target feature parameter is extracted, and the candidate control corresponding to the candidate feature parameter is extracted. The candidate control is taken as the target control, and the target control is the candidate control that needs to consume the current operation event.

[0107] In step S404 of some embodiments, the candidate control corresponding to the target control and the candidate control information of the candidate control are obtained by filtering the candidate control information according to the target control, and the candidate control information is taken as the target control information.

[0108] Through the above steps S401 to S404, the basic information of the test control can be automatically recorded by operating the Android mobile terminal such as an Android mobile phone. Compared with the traditional technology of connecting a mobile phone to a computer and grabbing the control information of a specified control on the computer, the efficiency of UI automatic testing can be improved.

[0109] Referring to Figure 5 In some embodiments, step S106 can include, but is not limited to, steps S501-S504:

[0110] Step S501, performing first classification processing on the current operation event according to the operation time to obtain initial classification data;

[0111] Step S502, performing second classification processing on the initial classification data according to the control type in the target control information to obtain intermediate classification data;

[0112] Step S503, performing type adjustment on the intermediate classification data according to the preset reference control information to obtain the operation type of the current operation event;

[0113] Step S504, integrating the operation type, the operation time, the target control information, and the current operation event to obtain target operation data.

[0114] In step S501 of some embodiments, the operation time of the current operation time is compared with a preset time threshold, and the current operation event is classified as a click operation, a long press operation, or a sliding operation according to the size relationship between the operation time and the time threshold, wherein the time threshold includes a first threshold and a second threshold, and the first threshold is less than the second threshold. When the operation time is less than the first threshold, the current operation event is classified as a click operation; when the operation time is between the first threshold and the second threshold, i.e., the operation time is greater than or equal to the first threshold and less than or equal to the second threshold, the current operation event is classified as a sliding operation; and when the operation time is greater than the second threshold, the current operation event is classified as a long press operation. Based on this division rule, the initial classification data can be obtained by first classifying the current operation event.

[0115] In step S502 of some embodiments, when the initial classification data indicates that the current operation event is a click operation, the initial classification data is second classified according to the control type in the target control information. If the control type is an editable control, the initial classification data is classified as an input operation, i.e., the current operation event is an input operation; if the control type is a button, the initial classification data is classified as a click operation. Based on this division rule, the intermediate classification data can be obtained by second classifying the initial classification data.

[0116] In step S503 of some embodiments, the reference control information includes an operation type to which the target control should respond. When the operation type in the intermediate classification data is consistent with the operation type to which the target control should respond, the operation type represented by the intermediate classification data is taken as the final operation type of the current operation event. If the operation type in the intermediate classification data is inconsistent with the operation type to which the target control should respond, the operation type to which the target control should respond is taken as the final operation type of the current operation event.

[0117] In step S504 of some embodiments, the operation type, operation time, target control information, and current operation event are integrated to form an operation file, so as to obtain target operation data.

[0118] Through the above steps S501 to S504, the automation testing of operation classification can be conveniently realized, the correspondence between the target control and the operation event is determined, the target operation data is generated, and the process of operation classification is recorded to form an operation classification script, thereby improving the convenience of script recording.

[0119] Please refer to Figure 6 In some embodiments, step S107 includes but is not limited to steps S601 to S603.

[0120] In step S601, the interface layout script, the query information script, and the operation classification script are integrated according to a preset splicing order to obtain an initial test recording script.

[0121] In step S602, the initial test recording script is named to obtain a test case name.

[0122] In step S603, the target test recording script is generated based on the test case name and the initial test recording script.

[0123] In step S601 of some embodiments, the preset splicing order can be a common UI test step order or other orders, which is not limited. According to the splicing order, the interface layout script, the query information script, and the operation classification script are spliced in sequence to form a complete test script, and the initial test recording script is obtained.

[0124] In step S602 of some embodiments, the initial test recording script can be named according to a preset naming rule to obtain a test case name of each initial test recording script. The test case name can include letters, numbers, Chinese characters, or strings, etc.

[0125] In step S603 of some embodiments, the test case name and the initial test recording script are associated and matched to obtain a target test recording script, wherein each target test recording script has a test case name and a case number, and the case number of each target test recording script is unique.

[0126] Through the above steps S601 to S603, the test process of each test step can be conveniently recorded by script, and the test recording script corresponding to each test step is generated, so that the test recording scripts belonging to the same case can be integrated together to form a target test recording script, the recording efficiency of the test script is improved, and the target test recording script can be used in subsequent test analysis process, etc., thereby improving the efficiency and convenience of the automated test.

[0127] Please refer to Figure 7 After step S107 of some embodiments, the test script recording method can include but is not limited to steps S701 to S702:

[0128] In step S701, the target test recording script is uploaded to the server side.

[0129] In step S702, the target test recording script is data corrected based on the reference case data on the server side to obtain target case data.

[0130] In step S701 of some embodiments, the target test recording script can be uploaded to the target file directory on the server side through wired communication or wireless communication, etc., to realize the storage of the target test recording script.

[0131] In step S702 of some embodiments, the detailed content of the target test recording script can be viewed in the form of case maintenance on the server side, and the step type, control name, operation name, etc. of the target test recording script are modified according to the reference case data to obtain the target case data. For example, in the case correction process, the content of the target test recording script is adjusted according to the error information until the target test recording script can run normally. When modifying, the actual execution of the target test recording script can be referred to to modify the original reference case data.

[0132] It should be noted that, under normal circumstances, if the target test recording script is recorded according to the recording specification, and the target interface does not change, the data content of the target test recording script does not need to be modified.

[0133] In addition, since each operation event corresponds to a target space with a unique control number, when the interface changes and the script data needs to be modified, only one modification of the operation recording script is required, and the target test recording script involving the operation step can be updated synchronously. For example, interface A has a "confirm" button. When recording case 1, the "confirm" button is clicked, and the operation generates a number: 123456, which represents clicking the "confirm" button of interface A. When recording other cases caseX, the "confirm" button of interface A is also clicked, and the operation data with the number 123456 is directly reused. In this way, no matter how many cases are recorded, as long as the "confirm" button of interface A is clicked, the corresponding operation number will be 123456. If the "confirm" button of interface A becomes a "complete" button at a certain stage, we can change "confirm" to "complete" in the operation data by number: 123456. In this way, all operation data obtained by number: 123456 will be "complete". This way can realize that one modification of an operation can update all target test recording scripts involving the operation step. Compared with the traditional technology that requires rewriting all recorded scripts when the UI interface changes, the embodiment of the application can improve the reusability and modification convenience of the test script, thereby improving the efficiency of UI automated testing.

[0134] Through the above steps S701 to S702, the target test recording script can be uploaded to the server end, so that the staff can analyze and modify the target test recording script. When the target test recording script needs to be modified, based on one modification, multiple test recording scripts belonging to the same case can be adjusted, which improves the convenience of script maintenance and the efficiency of automated testing.

[0135] The test script recording method provided by the embodiments of the present application can obtain a target interface of a target client, perform interface layout detection on the target interface to obtain interface layout data, record the process of interface layout detection to obtain an interface layout script, conveniently monitor the layout change of the target interface, generate interface layout data and record the interface layout script based on the detected layout change, and improve the generation efficiency of the test recording script. Further, information extraction is performed on the interface layout data to obtain candidate control information, the process of information extraction is recorded to obtain a control information script, the acquisition efficiency of the candidate control information of the candidate control is improved, compared with the traditional technology of manually capturing control attributes in UI automatic testing, the operation process is simplified, the operation time is saved, and the efficiency of UI automatic testing is improved. Further, an interface operation instruction is obtained, the interface operation instruction includes a current operation event and an operation time, control query is performed based on a preset event response mechanism, candidate control information and the current operation event to obtain a target control and target control information of the target control, the process of control query is recorded to obtain a query information script, the target control is a candidate control that needs to consume the current operation event, and this method can improve the efficiency and accuracy of control query. Further, the current operation event is classified and processed based on the target control information and the operation time to obtain target operation data, the classification process is recorded to obtain an operation classification script, the target operation data includes the operation type of the current operation event, the automation test of operation classification can be conveniently realized, the corresponding relationship between the target control and the operation event is determined, the target operation data is generated, and the process of operation classification is recorded to form an operation classification script, thereby improving the convenience of script recording. Finally, the interface layout script, the query information script and the operation classification script are integrated and processed to obtain a target test recording script, this method can integrate the test recording scripts belonging to the same case together to form the target test recording script, the target test recording script can be used in subsequent test analysis and other processes, and the efficiency and convenience of interface automatic testing are improved.

[0136] Please refer to Figure 8 The embodiments of the present application also provide a test script recording device, which can implement the test script recording method described above, and the device comprises:

[0137] An interface obtaining module 801 is configured to obtain a target interface of a target client.

[0138] An interface layout detection module 802 is configured to perform interface layout detection on the target interface to obtain interface layout data, and record the process of interface layout detection to obtain an interface layout script.

[0139] The information extraction module 803 is configured to extract information from the interface layout data to obtain candidate control information, and record the information extraction process to obtain a control information script.

[0140] The instruction obtaining module 804 is configured to obtain an interface operation instruction, where the interface operation instruction includes a current operation event and an operation time.

[0141] The control querying module 805 is configured to query a target control based on a preset event response mechanism, the candidate control information, and the current operation event, to obtain the target control and target control information of the target control, and record the control querying process to obtain a querying information script, where the target control is a candidate control that needs to consume the current operation event.

[0142] The operation classifying module 806 is configured to classify the current operation event based on the target control information and the operation time to obtain target operation data, and record the classification process to obtain an operation classification script, where the target operation data includes an operation type of the current operation event.

[0143] The script integrating module 807 is configured to integrate the interface layout script, the querying information script, and the operation classification script to obtain a target test recording script.

[0144] The specific implementation of the test script recording apparatus is basically the same as the specific implementation of the test script recording method described above, and thus will not be repeated here.

[0145] The embodiments of the present application further provide an electronic device, which includes a memory, a processor, a program stored in the memory and capable of running on the processor, and a data bus for realizing connection and communication between the processor and the memory, and the program is executed by the processor to realize the test script recording method. The electronic device can be any smart terminal, such as a tablet computer or a vehicle-mounted computer.

[0146] Please refer to Figure 9 , Figure 9 The hardware structure of the electronic device of another embodiment is illustrated, which includes:

[0147] The processor 901 can be implemented in a general-purpose CPU (Central Processing Unit), a microprocessor, an ASIC (Application Specific Integrated Circuit), or one or more integrated circuits, and is configured to execute a related program to implement the technical solutions provided by the embodiments of the present application.

[0148] The memory 902 can be implemented in the form of a read-only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM), etc. The memory 902 can store an operating system and other application programs. When the technical solutions provided by the embodiments of the present specification are implemented by software or firmware, the related program codes are stored in the memory 902 and are invoked by the processor 901 to execute the test script recording method of the embodiments of the present application;

[0149] The input / output interface 903 is configured to realize information input and output.

[0150] The communication interface 904 is configured to realize the communication interaction between the device and other devices. The communication can be realized by a wired manner (for example, a USB, a network cable, etc.) or a wireless manner (for example, a mobile network, WIFI, Bluetooth, etc.).

[0151] The bus 905 is configured to transmit information between various components (for example, the processor 901, the memory 902, the input / output interface 903, and the communication interface 904) of the device.

[0152] The processor 901, the memory 902, the input / output interface 903, and the communication interface 904 are connected to each other through the bus 905 to realize the communication connection between the device.

[0153] The embodiments of the present application also provide a computer readable storage medium. The computer readable storage medium stores one or more programs. The one or more programs can be executed by one or more processors to implement the above test script recording method.

[0154] The memory is a non-transitory computer readable storage medium, which can be used to store non-transitory software programs and non-transitory computer executable programs. In addition, the memory can include a high-speed random access memory and can also include a non-transitory memory, such as at least one magnetic disk storage device, a flash memory device, or other non-transitory solid-state memory device. In some embodiments, the memory can optionally include a memory remotely arranged relative to the processor. These remote memories can be connected to the processor through a network. Examples of the above network include but are not limited to the Internet, an intranet, a local area network, a mobile communication network, and a combination thereof.

[0155] The test script recording method, test script recording device, electronic device and computer readable storage medium provided by the embodiments of the present application can obtain a target interface of a target client, perform interface layout detection on the target interface to obtain interface layout data, and record the process of interface layout detection to obtain an interface layout script. Through this process, the layout changes of the target interface can be conveniently monitored, and based on the detected layout changes, the interface layout data is generated and recorded into the interface layout script, thereby improving the generation efficiency of the test recording script. Further, information extraction is performed on the interface layout data to obtain candidate control information, and the process of information extraction is recorded to obtain a control information script, thereby improving the acquisition efficiency of the candidate control information of the candidate control. Compared with the manual method of capturing control attributes in UI automatic testing in the prior art, the operation process is simplified, the operation time is saved, and the efficiency of UI automatic testing is improved. Further, an interface operation instruction is obtained, wherein the interface operation instruction includes a current operation event and an operation time. Based on a preset event response mechanism, candidate control information and the current operation event, control query is performed to obtain a target control and target control information of the target control, and the process of control query is recorded to obtain a query information script, wherein the target control is a candidate control that needs to consume the current operation event. This method can improve the efficiency and accuracy of control query. Further, the current operation event is classified and processed based on the target control information and the operation time to obtain target operation data, and the classification process is recorded to obtain an operation classification script, wherein the target operation data includes the operation type of the current operation event. This method can conveniently realize automatic testing of operation classification, determine the correspondence between the target control and the operation event, generate target operation data, and record the process of operation classification to form an operation classification script, thereby improving the convenience of script recording. Finally, the interface layout script, the query information script and the operation classification script are integrated and processed to obtain a target test recording script. This method can integrate test recording scripts belonging to the same case together to form a target test recording script, so that the target test recording script can be used in subsequent test analysis and other processes, thereby improving the efficiency and convenience of interface automatic testing.

[0156] The embodiments described in the embodiments of the present application are used to more clearly illustrate the technical solutions of the embodiments of the present application, and do not constitute a limitation on the technical solutions provided by the embodiments of the present application. Those skilled in the art can know that, with the evolution of technology and the appearance of new application scenarios, the technical solutions provided by the embodiments of the present application are also applicable to similar technical problems.

[0157] Those skilled in the art can understand that, Figures 1-7The technical solutions shown in the figures do not constitute a limitation on the embodiments of the present application, and can include more or fewer steps than shown, or combine certain steps, or different steps.

[0158] The apparatus embodiments described above are merely illustrative, and units described as separate components can or can not be physically separate, i.e., can be located in one place, or can be distributed over multiple network units. Some or all of the modules can be selected according to actual needs to achieve the purposes of the embodiments.

[0159] Those skilled in the art can understand that all or some of the steps in the above disclosed method, the functional modules / units in the system and the device can be implemented as software, firmware, hardware and their appropriate combinations.

[0160] The terms "first", "second", "third", "fourth" and the like (if any) in the description and the above drawings of the present application are used to distinguish similar objects, and do not necessarily indicate a specific order or sequence. It should be understood that the data thus used can be interchanged under appropriate circumstances, so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein. In addition, the terms "include" and "have" and any variations thereof are intended to cover non-exclusive inclusion, for example, a process, method, system, product or device that includes a series of steps or units does not necessarily limit to those steps or units clearly listed, but can include other steps or units not clearly listed or inherent to these processes, methods, products or devices.

[0161] It should be understood that in the present application, "at least one" means one or more, and "multiple" means two or more. "And / or" is used to describe the association between the associated objects, which means that there can be three relationships, for example, "A and / or B" can represent three cases: only A, only B, and A and B at the same time, where A and B can be singular or plural. The character " / " generally represents an "or" relationship between the associated objects. "At least one of the following" or similar expressions means any combination of these items, including any combination of single or multiple items. For example, at least one of a, b or c can represent: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, and c can be single or multiple.

[0162] In several embodiments provided in the present application, it should be understood that the disclosed apparatus and method can be implemented by other manners. For example, the apparatus embodiments described above are merely illustrative, for example, the division of the above units is merely a logical function division, and actual implementation can have another division manner, for example, a plurality of units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the coupling or direct coupling or communication connection between the units or components shown or discussed can be indirect coupling or communication connection through some interfaces, apparatuses or units, and can be electrical, mechanical or other forms.

[0163] The units described above as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, i.e., they can be located in one place or distributed on a plurality of network units. Some or all of the units can be selected according to actual needs to achieve the purpose of the embodiment.

[0164] In addition, the functional units in each embodiment of the present application can be integrated in one processing unit, or each unit can be physically present separately, or two or more units can be integrated in one unit. The integrated unit can be realized in the form of hardware or in the form of a software functional unit.

[0165] If the integrated unit is realized in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer readable storage medium. Based on this understanding, the technical solutions of the present application essentially or the part of the prior art that makes a contribution or the whole or part of the technical solutions can be embodied in the form of a software product, which is stored in a storage medium and includes a plurality of instructions for causing a computer device (which can be a personal computer, a server, or a network device, etc.) to execute all or part of the steps of the method of each embodiment of the present application. The foregoing storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, and various program storage media.

[0166] The preferred embodiments of the embodiments of the present application are described above with reference to the accompanying drawings, but this does not limit the scope of the embodiments of the present application. Any modifications, equivalent replacements and improvements made by those skilled in the art without departing from the scope and essence of the embodiments of the present application shall be within the scope of the embodiments of the present application.

Claims

1. A method for recording test scripts, characterized in that, The method includes: Obtain the target interface of the target client; The target interface is subjected to interface layout detection to obtain interface layout data, and the interface layout detection process is recorded to obtain an interface layout script. Information is extracted from the interface layout data to obtain candidate control information, and the information extraction process is recorded to obtain a control information script; Obtain interface operation instructions, wherein the interface operation instructions include the current operation event and the operation time; Based on the preset event response mechanism, the candidate control information, and the current operation event, a control query is performed to obtain the target control and the target control information of the target control. The control query process is recorded to obtain a query information script, wherein the target control is a candidate control that needs to consume the current operation event. The current operation event is classified based on the target control information and the operation time to obtain target operation data. The classification process is recorded to obtain an operation classification script. The target operation data includes the operation type of the current operation event. The interface layout script, the query information script, and the operation classification script are integrated and processed to obtain the target test recording script.

2. The method according to claim 1, characterized in that, The step of extracting information from the interface layout data to obtain candidate control information includes: Traverse the control tree of the target interface to obtain candidate controls for the target interface; Information is extracted from the interface layout data to obtain the control type and control attributes of the candidate controls; Based on the control type and the control attributes, a control number is generated for each candidate control, wherein the control number of each candidate control is unique; The candidate control information is obtained based on the control type, the control number, and the control attributes.

3. The method according to claim 1, characterized in that, The control query based on the preset event response mechanism, the candidate control information, and the current operation event, to obtain the target control and the target control information of the target control, includes: Based on the event response mechanism, the target feature parameters corresponding to the current operation event are obtained; Obtain a preset relationship mapping table, which stores the mapping relationship between candidate feature parameters and candidate controls; The target control is obtained by querying the control according to the preset relationship mapping table and the target feature parameters; The candidate control information is filtered based on the target control to obtain the target control information.

4. The method according to claim 1, characterized in that, The process of classifying the current operation event based on the target control information and the operation time to obtain target operation data includes: The current operation event is classified according to the operation time to obtain initial classification data. Based on the control type in the target control information, the initial classification data is subjected to a second classification process to obtain intermediate classification data; The intermediate classification data is adjusted according to the preset reference control information to obtain the operation type of the current operation event; The target operation data is obtained by integrating the operation type, operation time, target control information, and current operation event.

5. The method according to claim 1, characterized in that, The integration and processing of the interface layout script, the query information script, and the operation classification script to obtain the target test recording script includes: The interface layout script, the query information script, and the operation classification script are integrated and processed according to the preset splicing order to obtain the initial test recording script; The initial test recording script is named according to the test cases to obtain the test case names; Based on the test case name and the initial test recording script, the target test recording script is generated.

6. The method according to claim 1, characterized in that, Before performing interface layout detection on the target interface to obtain interface layout data, the method includes: Get the test recording request; Start the recording switch according to the test recording request.

7. The method according to any one of claims 1 to 6, characterized in that, After integrating the interface layout script, the query information script, and the operation classification script to obtain the target test recording script, the method further includes: Upload the target test recording script to the server. The target test recording script is corrected based on the reference case data on the server side to obtain the target case data.

8. A test script recording device, characterized in that, The device includes: The interface acquisition module is used to acquire the target interface of the target client. The layout detection module is used to perform interface layout detection on the target interface, obtain interface layout data, and record the interface layout detection process to obtain an interface layout script. The information extraction module is used to extract information from the interface layout data, obtain candidate control information, and record the information extraction process to obtain a control information script. The instruction acquisition module is used to acquire interface operation instructions, wherein the interface operation instructions include the current operation event and the operation time; The control query module is used to query controls based on a preset event response mechanism, the candidate control information and the current operation event, to obtain the target control and the target control information of the target control, and to record the control query process to obtain a query information script, wherein the target control is a candidate control that needs to consume the current operation event; An operation classification module is used to classify the current operation event based on the target control information and the operation time to obtain target operation data, and to record the classification process to obtain an operation classification script, wherein the target operation data includes the operation type of the current operation event; The script integration module is used to integrate the interface layout script, the query information script, and the operation classification script to obtain the target test recording script.

9. An electronic device, characterized in that, The electronic device includes a memory and a processor, the memory storing a computer program, and the processor executing the computer program to implement the test script recording method as described in any one of claims 1 to 7.

10. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by the processor, it implements the test script recording method according to any one of claims 1 to 7.

Citation Information

Patent Citations

  • Script recording method and apparatus

    CN107193750A

  • Method and apparatus for recording test scripts

    CN107491386A