CN115562993A - Test script recording method and device, electronic equipment and storage medium - Google Patents

Test script recording method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN115562993A
CN115562993A CN202211247592.8A CN202211247592A CN115562993A CN 115562993 A CN115562993 A CN 115562993A CN 202211247592 A CN202211247592 A CN 202211247592A CN 115562993 A CN115562993 A CN 115562993A
Authority
CN
China
Prior art keywords
script
target
control
recording
interface
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202211247592.8A
Other languages
Chinese (zh)
Inventor
李宵宵
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Ping An Life Insurance Company of China Ltd
Original Assignee
Ping An Life Insurance Company of China Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Ping An Life Insurance Company of China Ltd filed Critical Ping An Life Insurance Company of China Ltd
Priority to CN202211247592.8A priority Critical patent/CN115562993A/en
Publication of CN115562993A publication Critical patent/CN115562993A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3688Test management for test execution, e.g. scheduling of test suites

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The application provides a test script recording method and device, electronic equipment 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 interface layout detection process to obtain an interface layout script; extracting information of the interface layout data to obtain candidate control information, and recording the information extraction process to obtain a control information script; performing control query based on an event response mechanism, candidate control information and a current operation event to obtain target control information, and recording a control query process to obtain a query information script; classifying 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 recording efficiency can be improved.

Description

Test script recording method and device, electronic equipment and storage medium
Technical Field
The present application relates to the field of test technologies, and in particular, to a method and an apparatus for recording a test script, an electronic device, and a storage medium.
Background
The existing test script recording method often needs to rely on a manual processing mode to realize script recording, and the mode is often complex to operate, consumes more time and affects script recording efficiency, so how to improve the script recording efficiency becomes a technical problem to be solved urgently.
Disclosure of Invention
The embodiment of the application mainly aims to provide a test script recording method and device, electronic equipment and a storage medium, and aims to improve script recording efficiency.
In order to achieve the above object, a first aspect of the embodiments of the present application provides a method for recording a test script, where the method includes:
acquiring a target interface of a target client;
performing interface layout detection on the target interface to obtain interface layout data, and recording the interface layout detection process to obtain an interface layout script;
extracting information from the interface layout data to obtain candidate control information, and recording the information extraction process to obtain a control information script;
acquiring an interface operating instruction, wherein the interface operating instruction comprises a current operating event and operating time;
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, and recording a control query process to obtain a query information script, wherein the target control is a candidate control which needs to consume the current operation event;
classifying the current operation event based on the target control information and the operation time to obtain target operation data, and recording a classification process to obtain an operation classification script, wherein the target operation data comprises the operation type of the current operation event;
and integrating the interface layout script, the query information script and the operation classification script to obtain a target test recording script.
In some embodiments, the extracting information from the interface layout data to obtain candidate control information includes:
traversing the control tree of the target interface to obtain a candidate control of the target interface;
extracting information from the interface layout data to obtain the control type and control attribute of the candidate control;
generating control numbers of the candidate controls according to the control types and the control attributes, wherein the control number of each candidate control is unique;
and obtaining the candidate control information according to the control type, the control number and the control attribute.
In some embodiments, the performing a 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 includes:
acquiring a target characteristic parameter corresponding to the current operation event based on the event response mechanism;
acquiring a preset relational mapping table, wherein the relational mapping table stores the mapping relation between candidate characteristic parameters and candidate controls;
performing control query according to a preset relation mapping table and the target characteristic parameters to obtain the target control;
and screening the candidate control information according to the target control to obtain the target control information.
In some embodiments, the classifying the current operation event based on the target control information and the operation time to obtain target operation data includes:
performing first classification processing on the current operation event according to the operation time to obtain initial classification data;
performing second classification processing on the initial classification data according to the control type in the target control information to obtain intermediate classification data;
performing type adjustment on the intermediate classification data according to preset reference control information to obtain an operation type of the current operation event;
and 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.
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 includes:
integrating the interface layout script, the query information script and the operation classification script according to a preset splicing sequence to obtain an initial test recording script;
case naming is carried out on the initial test recording script to obtain a test case name;
and generating the target test recording script based on the test case name and the initial test recording script.
In some embodiments, before performing interface layout detection on the target interface and obtaining interface layout data, the method includes:
acquiring a test recording request;
and starting a recording switch according to the test recording request.
In some embodiments, after the integrating the interface layout script, the query information script, and the operation classification script to obtain a target test recording script, the method further includes:
uploading the target test recording script to a server side;
and performing data correction on the target test recording script based on the reference case data of the server side to obtain target case data.
In order to achieve the above object, a second aspect of the embodiments of the present application provides a test script recording apparatus, including:
the interface acquisition module is used for acquiring a target interface of a target client;
the layout detection module is used for carrying out interface layout detection on the target interface to obtain interface layout data, and recording the interface layout detection process to obtain an interface layout script;
the information extraction module is used for extracting information from the interface layout data to obtain candidate control information, and recording the information extraction process to obtain a control information script;
the instruction acquisition module is used for acquiring an interface operation instruction, wherein the interface operation instruction comprises a current operation event and operation time;
the control query module is used for 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, and recording a control query process to obtain a query information script, wherein the target control is a candidate control which needs to consume the current operation event;
the operation classification module is used for classifying the current operation event based on the target control information and the operation time to obtain target operation data, and recording a classification process to obtain an operation classification script, wherein the target operation data comprises the operation type of the current operation event;
and the script integration module is used for integrating the interface layout script, the query information script and the operation classification script to obtain a target test recording script.
In order to achieve the above object, a third aspect of the embodiments of the present application provides an electronic device, which includes a memory and a processor, where the memory stores a computer program, and the processor implements the method of the first aspect when executing the computer program.
To achieve the above object, a fourth aspect of the embodiments of the present application proposes a computer-readable storage medium storing a computer program, which when executed by a processor implements the method of the first aspect.
According to the test script recording method, the test script recording device, the electronic equipment and the storage medium, the target interface of the target client is obtained; the interface layout detection is carried out on the target interface to obtain interface layout data, the interface layout detection process is recorded to obtain an interface layout script, the layout change of the target interface can be monitored conveniently through the process, the interface layout data are generated and the interface layout script is recorded based on the detected layout change, and the generation efficiency of the recorded script is improved. Furthermore, information extraction is carried out on the interface layout data to obtain candidate control information, the information extraction process is recorded to obtain a control information script, and the acquisition efficiency of the candidate control information of the candidate control is improved. Further, an interface operation instruction is obtained, wherein the interface operation instruction comprises a current operation event and operation time; and performing control query based on a preset event response mechanism, candidate control information and a current operation event to obtain a target control and target control information of the target control, recording the control query process to obtain a query information script, and improving the efficiency and the accuracy of control query. Furthermore, the current operation event is classified based on the target control information and the operation time to obtain target operation data, and the classification process is recorded to obtain the operation classification script, so that the automatic test of operation classification can be conveniently realized, the corresponding relation between the target control and the operation event is determined, the operation classification script is formed by recording the operation classification process, and the convenience of script recording is improved. And finally, integrating the interface layout script, the query information script and the operation classification script to obtain a target test recording script, so that the test recording scripts belonging to the same case can be integrated together to form the target test recording script, and the recording efficiency of the test scripts is improved.
Drawings
Fig. 1 is a flowchart of a test script recording method according to an embodiment of the present disclosure;
fig. 2 is another flowchart of a test script recording method according to an embodiment of the present disclosure;
FIG. 3 is a flowchart of step S103 in FIG. 1;
fig. 4 is a flowchart of step S105 in fig. 1;
FIG. 5 is a flowchart of step S106 in FIG. 1;
fig. 6 is a flowchart of step S107 in fig. 1;
FIG. 7 is another flowchart of a test script recording method according to an embodiment of the present disclosure;
fig. 8 is a schematic structural diagram of a test script recording apparatus according to an embodiment of the present application;
fig. 9 is a schematic hardware structure diagram of an electronic device according to an embodiment of the present application.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application.
It should be noted that although functional blocks are partitioned in a schematic diagram of an apparatus and a logical order is shown in a flowchart, in some cases, the steps shown or described may be performed in a different order than the partitioning of blocks in the apparatus or the order in the flowchart. The terms first, second and the like in the description and in the claims, as well as in the drawings described above, are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order.
Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this application belongs. The terminology used herein is for the purpose of describing embodiments of the present application only and is not intended to be limiting of the application.
First, several terms referred to in the present application are resolved:
software Development Kit (SDK): is a collection of development tools used by some software engineers to build application software for a particular software package, software framework, hardware platform, operating system, etc. A software development tool broadly refers to a collection of related documents, paradigms, and tools that assist in developing a certain class of software. A software development kit is a collection of development tools used by software engineers to create application software for a particular software package, software framework, hardware platform, operating system, etc., and in general, an SDK is an SDK used to develop applications on a Windows platform. It facilitates the creation of applications through compilers, debuggers, software frameworks, and the like. It may simply be a file that provides an application program interface API for a certain programming language, but may also include complex hardware that can communicate with a certain embedded system. Typical tools include utility tools for debugging and other purposes. SDKs also often include example code, supporting technical notes, or other supporting documentation to clarify suspicions for basic reference.
User Interface (User Interface, UI): is a medium for interaction and information exchange between the system and the user, which realizes the conversion between the internal form of the information and the human acceptable form. The user interface is designed to interact and communicate with the related software between the user and the hardware, so that the user can conveniently and efficiently operate the hardware to achieve bidirectional interaction.
Control refers to the packaging of data and methods. The control may have its own properties and methods, where properties are simple access to control data and methods are some simple and visible functions of the control. The widget creation process includes Design (Design), development (development), debugging (Debug), and then the use of the widget. The control comprises a user interface control, wherein the user interface control is used for developing and constructing the control of the user interface and helping to complete development of interface elements such as windows, text boxes, buttons, pull-down menus and the like in software development.
The existing test script recording method often needs to rely on a manual processing mode to realize script recording, and the mode is often complex to operate, consumes more time and affects script recording efficiency, so how to improve the script recording efficiency becomes a technical problem to be solved urgently.
Based on this, the embodiment of the application provides a test script recording method, a test script recording device, an electronic device and a storage medium, and aims to improve script recording efficiency.
The test script recording method, the test script recording apparatus, the electronic device, and the storage medium provided in the embodiments of the present application are specifically described in the following embodiments, and first, the test script recording method in the embodiments of the present application is described.
The embodiment of the application can acquire and process related data based on an artificial intelligence technology. Among them, artificial Intelligence (AI) is a theory, method, technique and application system that simulates, extends and expands human Intelligence using a digital computer or a machine controlled by a digital computer, senses the environment, acquires knowledge and uses the knowledge to obtain the best result.
The embodiment of the application provides a test script recording method, and relates to the technical field of artificial intelligence. The test script recording method provided by the embodiment of the application can be applied to a terminal, a server side and software running in the terminal or the server side. In some embodiments, the terminal may be a smartphone, tablet, laptop, desktop computer, or the like; the server side can be configured into an independent physical server, a server cluster or a distributed system formed by a plurality of physical servers, and cloud servers for providing basic cloud computing services such as cloud service, a cloud database, cloud computing, cloud functions, cloud storage, network service, cloud communication, middleware service, domain name service, security service, CDN (content delivery network) and big data and artificial intelligence platforms; the software may be an application that implements a test script recording method, etc., but is not limited to the above form.
The application is operational with numerous general purpose or special purpose computing system environments or configurations. For example: personal computers, server computers, hand-held or portable devices, tablet-type devices, multiprocessor systems, microprocessor-based systems, set top boxes, programmable consumer electronics, network PCs, minicomputers, mainframe computers, distributed computing environments that include any of the above systems or devices, and the like. The application may be described in the general context of computer-executable instructions, such as program modules, being executed by a computer. Generally, program modules include routines, programs, objects, components, data structures, etc. that perform particular tasks or implement particular abstract data types. The application may also be practiced in distributed computing environments where tasks are performed by remote processing devices that are linked through a communications network. In a distributed computing environment, program modules may be located in both local and remote computer storage media including memory storage devices.
Fig. 1 is an optional flowchart of a test script recording method according to an embodiment of the present application, where the method in fig. 1 may include, but is not limited to, steps S101 to S107.
Step S101, acquiring a target interface of a target client;
step S102, interface layout detection is carried out on a target interface to obtain interface layout data, and the interface layout detection process is recorded to obtain an interface layout script;
step S103, extracting information of the interface layout data to obtain candidate control information, and recording the information extraction process to obtain a control information script;
step S104, obtaining an interface operation instruction, wherein the interface operation instruction comprises a current operation event and operation time;
step S105, performing control query based on a preset event response mechanism, candidate control information and a current operation event to obtain a target control and target control information of the target control, and recording a control query process to obtain a query information script, wherein the target control is a candidate control which needs to consume the current operation event;
step S106, classifying the current operation event based on the target control information and the operation time to obtain target operation data, and recording the classification process to obtain an operation classification script, wherein the target operation data comprises the operation type of the current operation event;
and S107, integrating the interface layout script, the query information script and the operation classification script to obtain a target test recording script.
In steps S101 to S107 illustrated in the embodiment of the present application, a target interface of a target client is obtained; the interface layout detection is carried out on the target interface to obtain interface layout data, the interface layout detection process is recorded to obtain an interface layout script, the layout change of the target interface can be monitored conveniently, the interface layout data are generated and the interface layout script is recorded based on the detected layout change, and the generation efficiency of the recorded script is improved. The information extraction is carried out on the interface layout data to obtain the candidate control information, and the information extraction process is recorded to obtain the control information script, so that the acquisition efficiency of the candidate control information of the candidate control is improved. Obtaining a current operation event and operation time; and performing control query based on a preset event response mechanism, candidate control information and a current operation event to obtain a target control and target control information of the target control, recording the control query process to obtain a query information script, and improving the efficiency and the accuracy of control query. The current operation event is classified based on the target control information and the operation time to obtain target operation data, and the classification process is recorded to obtain the operation classification script, so that the automatic test of operation classification can be conveniently realized, the corresponding relation between the target control and the operation event is determined, the operation classification script is formed by recording the operation classification process, and the convenience of script recording is improved. And finally, integrating the interface layout script, the query information script and the operation classification script to obtain a target test recording script, so that the test recording scripts belonging to the same case can be integrated together to form the target test recording script, and the script recording efficiency is improved.
It should be noted that the test script recording method can be applied to common recording tools, such as recording SDKs and the like. And the recording SDK is imported to the target client by one key, so that the recording SDK can be integrated in the target client in a component form, the recording SDK is low-coupled with the target client, the integration process is simple and convenient, and the operation time can be saved. The target client can comprise Android mobile equipment such as an Android mobile phone and an Android tablet.
Referring to fig. 2, before step S101 in some embodiments, the test script recording method may include, but is not limited to, steps S201 to S202:
step S201, obtaining a test recording request;
and step S202, starting a recording switch according to the test recording request.
In step S201 of some embodiments, a test recording request may be directly obtained, and the test recording request may be issued by a target object operating on an operating platform, where the target object includes a user, a worker, and the like.
In step S202 of some embodiments, the recording SDK turns on the recording switch according to the test recording request.
Through the steps S201 to S202, the test recording request can be conveniently received, and the recording switch is turned on according to the test recording request, so that the recording operation can be conveniently carried out in the interface automatic test process, the working state of recording the SDK can be well adjusted, and the working energy consumption of recording the SDK is reduced.
In step S101 of some embodiments, a target interface of the target client may be obtained by the shooting component of the recording SDK, where the target interface may be a user interface currently displayed by the target client.
In step S102 of some embodiments, after the target interface of the target client is obtained, interface layout detection is performed on the target interface, a layout change of the target interface is monitored, whether a new addition of a control or a deletion of the control occurs on the target interface is identified, so as to obtain interface layout data, and a process of the interface layout detection is recorded, so as to obtain an interface layout script. Through the process, the layout change of the target interface can be monitored conveniently, the interface layout data is generated and the interface layout script is recorded based on the detected layout change, and the generation efficiency of the test recording script is improved.
Referring to fig. 3, in some embodiments, step S103 may include, but is not limited to, step S301 to step S304:
step S301, traversing a control tree of the target interface to obtain a candidate control of the target interface;
step S302, extracting information of the interface layout data to obtain control types and control attributes of the candidate controls;
step S303, generating control numbers of candidate controls according to the control types and the control attributes, wherein the control number of each candidate control is unique;
and step S304, obtaining candidate control information according to the control type, the control number and the control attribute.
In step S301 of some embodiments, when a control addition or a control deletion occurs on a target interface, traversing a control tree of the target interface to obtain a candidate control of the target interface, where the control tree includes all candidate controls added to a target page, and the candidate controls in the control tree include multiple hierarchies, that is, the candidate controls are divided into a primary control, a secondary control subordinate to the primary control, a tertiary control subordinate to the secondary control, and so on.
In step S302 of some embodiments, information extraction is directly performed on the interface layout data to obtain a control type and control attributes of a candidate control, where the control type of the candidate control includes a text view control TextView, a form control recycleview, a Button, an editable control EditView, and the like, and the control attributes of the candidate control include an XML path language XPath, a control positioning identifier accessibistyid, control coordinates, and a control view name viewName, and the like, where the XML path language XPath is used to determine a language of a certain position of the candidate control in an XML document, and the form control recycleview is a container used to display list-form (list) or grid-form (grid) data, such as a text or a photo.
In step S303 of some embodiments, since the control positioning identifier in the control attribute has uniqueness, a character string is generated based on the control type of the candidate control, the control positioning identifier, and the hierarchy of the candidate control in the control tree, and the character string is used as the control number of the candidate control, where the generated character string has uniqueness, that is, the control number of each candidate control is unique.
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.
Through the steps S301 to S304, control traversal and information extraction can be conveniently performed on the control tree of the target interface, candidate control information of each candidate control is obtained, the acquisition efficiency of the candidate control information of the candidate control is improved, and compared with the traditional technology, the control attribute is manually captured on the UI automation test, so that the operation process is simplified, the operation time is saved, and the efficiency of the UI automation test is improved.
In step S104 of some embodiments, an interface operation instruction may be directly obtained, and the interface operation instruction may be issued by a target user through operation on an operation platform, where the interface operation instruction includes operation information such as a current operation event and operation time.
Referring to fig. 4, in some embodiments, step S105 may include, but is not limited to, step S401 to step S404:
step S401, acquiring a target characteristic parameter corresponding to a current operation event based on an event response mechanism;
step S402, acquiring a preset relational mapping table, wherein the relational mapping table stores the mapping relation between the candidate characteristic parameters and the candidate controls;
step S403, inquiring a control according to a preset relational mapping table and a target characteristic parameter to obtain a target control;
and S404, screening the candidate control information according to the target control to obtain target control information.
In step S401 of some embodiments, the event response mechanism indicates that each candidate control has a candidate feature parameter to record a click event of the current candidate control, and after a click event is set for a certain candidate control in the business logic, the candidate control that needs to respond to the click event may be queried based on the candidate feature and the click event. Therefore, the candidate characteristic parameter corresponding to the current operation event can be conveniently acquired based on the event response mechanism, and the candidate characteristic is taken as the target characteristic parameter.
In step S402 of some embodiments, a pre-stored mapping table may be directly called, where the mapping table stores a mapping relationship between a candidate feature parameter and a candidate control, where the candidate feature parameter may be a preset variable parameter.
In step S403 in some embodiments, when the control query is performed according to the preset relationship mapping table and the target feature parameter, the candidate feature parameter corresponding to the target feature parameter is extracted, the candidate control corresponding to the candidate feature parameter is extracted, and the candidate control is used as the target control, which is the candidate control that needs to consume the current operation event.
In step S404 in some embodiments, the candidate control information is filtered according to the target control, so as to obtain a candidate control corresponding to the target control and candidate control information of the candidate control, and the candidate control information is used as the target control information.
Through the 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, and compared with the connection between the mobile phone and a computer in the traditional technology, the test mode of the control information of the specified control is grabbed at the computer terminal, so that the efficiency of UI automatic test can be better improved.
Referring to fig. 5, in some embodiments, step S106 may include, but is not limited to, step S501 to step S504:
step S501, performing first classification processing on the current operation event according to the operation time to obtain initial classification data;
step S502, according to the control type in the target control information, carrying out second classification processing on the initial classification data to obtain intermediate classification data;
step S503, performing type adjustment on the intermediate classification data according to preset reference control information to obtain the operation type of the current operation event;
step S504, data integration is carried out on the operation type, the operation time, the target control information and the current operation event, and target operation data are obtained.
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 slide operation according to a magnitude relationship between the operation time and the time threshold, where the time threshold includes a first threshold and a second threshold, and the first threshold is smaller than the second threshold. When the operation time is less than a first threshold value, classifying the current operation event as click operation, when the operation time is between the first threshold value and a second threshold value, namely the operation time is greater than or equal to the first threshold value and the operation time is less than or equal to the second threshold value, classifying the current operation event as sliding operation, when the operation time is greater than the second threshold value, classifying the current operation event as long press operation, and based on the classification rule, performing first classification processing on the current operation event more conveniently to obtain initial classification data.
In step S502 of some embodiments, when the initial classification data indicates that the current operation event is a click operation, performing second classification processing on the initial classification data according to a control type in the target control information, and if the control type is an editable control, classifying the initial classification data as an input operation, that is, the current operation event is an input operation; and if the control type is a button, classifying the initial classification data as click operation. Based on the division rule, the initial classification data can be conveniently subjected to second classification processing to obtain intermediate classification data.
In step S503 of some embodiments, the reference control information includes an operation type to which the target control should respond, and 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 characterized by the intermediate classification data is used as the final operation type of the current operation event, and if the operation type in the intermediate classification data is not consistent with the operation type to which the target control should respond, the operation type to which the target control should respond is used as the final operation type of the current operation event.
In step S504 of some embodiments, data integration is performed on the operation type, the operation time, the target control information, and the current operation event to form an operation file, so as to obtain target operation data.
Through the steps S501 to S504, the automatic test of operation classification can be conveniently realized, the corresponding relation between the target control and the operation event is determined, the target operation data is generated, the operation classification process is recorded to form the operation classification script, and the convenience of script recording is improved.
Referring to fig. 6, in some embodiments, step S107 includes, but is not limited to, step S601 to step S603:
step S601, integrating the interface layout script, the query information script and the operation classification script according to a preset splicing sequence to obtain an initial test recording script;
step S602, naming the initial test recording script to obtain a test case name;
and step S603, generating a target test recording script based on the test case name and the initial test recording script.
In step S601 in some embodiments, the preset splicing sequence may be a common step sequence of the UI test, or may be other, without limitation. And sequentially splicing the interface layout script, the query information script and the operation classification script according to the splicing sequence to form a complete test script and obtain an initial test recording script.
In step S602 of some embodiments, case naming may be performed on the initial test recording scripts according to a preset naming rule to obtain a test case name of each initial test recording script, where the test case name may include letters, numbers, chinese characters, or character strings.
In step S603 of some embodiments, the test case name and the initial test recording script are associated and matched to obtain target test recording scripts, where 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.
Through the steps S601 to S603, scripts can be conveniently recorded in the test process of each test step, test recording scripts corresponding to each test step are 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 scripts is improved, the target test recording scripts can be used in the subsequent test analysis and other processes, and the efficiency and the convenience of automatic testing are improved.
Referring to fig. 7, after step S107 in some embodiments, the test script recording method may include, but is not limited to, steps S701 to S702:
step S701, uploading a target test recording script to a server;
step S702, data correction is carried out on the target test recording script based on the reference case data of the server side, and target case data are obtained.
In step S701 of some embodiments, the target test recording script may be uploaded to a target file directory of the server end through wired communication or wireless communication, so as to store the target test recording script.
In step S702 of some embodiments, the server may view the detailed content of the target test recording script in a form of case maintenance, and modify the step type, the control name, the operation name, and the like of the target test recording script according to the reference case data to obtain the target case data. For example, in the case correction process, content adjustment is performed on the target test recording script according to the error reporting information until the target test recording script can normally run. During modification, the original reference case data can be referred to for modification according to the actual execution condition of the target test recording script.
It should be noted that, under normal conditions, if the target test recording script recorded according to the recording specification is not changed in the target interface, the data content of the target test recording script does not need to be modified.
In addition, because the target space corresponding to each operation event has a unique control number, when the script data needs to be modified due to the change of the interface, the operation recording script only needs to be modified once, and the target test recording script related to the operation step can be synchronously updated. For example, interface a has a "confirm" button, and when recording case1, clicking the "confirm" button will generate a number: 123456, this number indicates the "ok" button of interface a is clicked; when recording other case caseX, clicking the "confirm" button of interface A, the operation data with number 123456 will be directly reused. Thus, no matter how many cases are recorded, as long as the "confirm" button of the interface a is clicked, the corresponding operation number will be 123456. If the "confirm" button of a phase interface a becomes the "complete" button, we can number: 123456, directly changes "confirm" to "complete" in the operational data, so that all the following are numbered: 123456 the operation data obtained will be "complete". By the method, the content of all target test recording scripts related to the operation step can be synchronously updated by modifying one operation, and compared with the conventional technology in which the recorded scripts are required to be completely rewritten when the UI interface changes, the method can improve the reusability and modification convenience of the test scripts, thereby improving the efficiency of UI automatic testing.
The target test recording script can be uploaded to the server through the steps S701 to S702, so that a worker can analyze and modify the target test recording script, when the target test recording script needs to be modified, a plurality of test recording scripts belonging to the same case can be adjusted based on one-time modification, and convenience in script maintenance and efficiency of automatic testing are improved.
According to the test script recording method provided by the embodiment of the application, a target interface of a target client is obtained; the interface layout detection is carried out on the target interface to obtain interface layout data, the interface layout detection process is recorded to obtain an interface layout script, the layout change of the target interface can be monitored conveniently through the process, the interface layout data are generated and the interface layout script is recorded based on the detected layout change, and the generation efficiency of the test recording script is improved. Furthermore, information extraction is carried out on the interface layout data to obtain candidate control information, the information extraction process is recorded to obtain a control information script, the acquisition efficiency of the candidate control information of the candidate control is improved, and compared with the traditional technology that the control attribute is manually captured on the UI automation test, the operation process is simplified, the operation time is saved, and the UI automation test efficiency is improved. Further, an interface operation instruction is obtained, wherein the interface operation instruction comprises a current operation event and operation time; and performing control query 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, and recording the control query process to obtain a query information script, wherein the target control is the candidate control which needs to consume the current operation event, so that the efficiency and the query accuracy of the control query can be improved. Furthermore, the current operation event is classified 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 comprises the operation type of the current operation event, so that the automatic test of operation classification can be conveniently realized, the corresponding relation between the target control and the operation event is determined, the target operation data is generated, the operation classification script is formed by recording the operation classification process, and the convenience of script recording is improved. And finally, integrating the interface layout script, the query information script and the operation classification script to obtain a target test recording script, wherein the target test recording script can be formed by integrating the test recording scripts belonging to the same case, so that the target test recording script can be used in the subsequent test analysis and other processes, and the efficiency and convenience of the interface automatic test are improved.
Referring to fig. 8, an embodiment of the present application further provides a test script recording apparatus, which can implement the above test script recording method, and the apparatus includes:
an interface obtaining module 801, configured to obtain a target interface of a target client;
the layout detection module 802 is configured to perform interface layout detection on a target interface to obtain interface layout data, and record an interface layout detection process to obtain an interface layout script;
the information extraction module 803 is configured to perform information extraction on the interface layout data to obtain candidate control information, and record an information extraction process to obtain a control information script;
an instruction obtaining module 804, configured to obtain an interface operation instruction, where the interface operation instruction includes a current operation event and operation time;
the control query module 805 is configured to perform control query based on a preset event response mechanism, candidate control information, and a current operation event to obtain a target control and target control information of the target control, and record a control query process to obtain a query information script, where the target control is a candidate control that needs to consume the current operation event;
an operation classification module 806, configured to classify a current operation event based on the target control information and the operation time to obtain target operation data, and record a classification process to obtain an operation classification script, where the target operation data includes an operation type of the current operation event;
the script integration module 807 is configured to integrate the interface layout script, the query information script, and the operation classification script to obtain a target test recording script.
The specific implementation of the test script recording apparatus is substantially the same as the specific implementation of the test script recording method, and is not described herein again.
An embodiment of the present application further provides an electronic device, where the electronic device includes: the test script recording method comprises a memory, a processor, a program which is stored on the memory and can run on the processor, and a data bus for realizing connection communication between the processor and the memory, wherein the program realizes the test script recording method when being executed by the processor. The electronic equipment can be any intelligent terminal including a tablet computer, a vehicle-mounted computer and the like.
Referring to fig. 9, fig. 9 illustrates a hardware structure of an electronic device according to another embodiment, where the electronic device includes:
the processor 901 may be implemented by a general-purpose CPU (central processing unit), a microprocessor, an Application Specific Integrated Circuit (ASIC), or one or more integrated circuits, and is configured to execute a relevant program to implement the technical solution provided in the embodiment of the present application;
the memory 902 may 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). The memory 902 may store an operating system and other application programs, and when the technical solution provided by the embodiments of the present disclosure is implemented by software or firmware, the relevant program codes are stored in the memory 902, and the processor 901 calls to execute the test script recording method according to the embodiments of the present disclosure;
an input/output interface 903 for implementing information input and output;
a communication interface 904, configured to implement communication interaction between the device and another device, where communication may be implemented in a wired manner (e.g., USB, network cable, etc.), or in a wireless manner (e.g., mobile network, WIFI, bluetooth, etc.);
a bus 905 that transfers information between various components of the device (e.g., the processor 901, the memory 902, the input/output interface 903, and the communication interface 904);
wherein the processor 901, the memory 902, the input/output interface 903 and the communication interface 904 are communicatively connected to each other within the device via a bus 905.
The embodiment of the application also provides a computer-readable storage medium, which stores one or more programs, and the one or more programs can be executed by one or more processors to implement the test script recording method.
The memory, which is a non-transitory computer readable storage medium, may be used to store non-transitory software programs as well as non-transitory computer executable programs. Further, the memory may include high speed random access memory, and may also include non-transitory memory, such as at least one disk storage device, flash memory device, or other non-transitory solid state storage device. In some embodiments, the memory optionally includes memory located remotely from the processor, and these remote memories may be connected to the processor through a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
According to the test script recording method, the test script recording device, the electronic equipment and the computer readable storage medium, a target interface of a target client is obtained; the interface layout detection is carried out on the target interface to obtain interface layout data, the interface layout detection process is recorded to obtain an interface layout script, the layout change of the target interface can be monitored conveniently through the process, the interface layout data are generated and the interface layout script is recorded based on the detected layout change, and the generation efficiency of the test recording script is improved. Furthermore, information extraction is carried out on the interface layout data to obtain candidate control information, the information extraction process is recorded to obtain a control information script, the acquisition efficiency of the candidate control information of the candidate control is improved, and compared with the traditional technology that the control attribute is manually captured on the UI automation test, the operation process is simplified, the operation time is saved, and the UI automation test efficiency is improved. Further, an interface operation instruction is obtained, wherein the interface operation instruction comprises a current operation event and operation time; and performing control query based on a preset event response mechanism, candidate control information and a current operation event to obtain a target control and target control information of the target control, and recording a control query process to obtain a query information script, wherein the target control is the candidate control needing to consume the current operation event, so that the efficiency and the accuracy of control query can be improved. Furthermore, the current operation event is classified 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 comprises the operation type of the current operation event, so that the automatic test of operation classification can be conveniently realized, the corresponding relation between the target control and the operation event is determined, the target operation data is generated, the operation classification script is formed by recording the operation classification process, and the convenience of script recording is improved. And finally, integrating the interface layout script, the query information script and the operation classification script to obtain a target test recording script, wherein the target test recording script can be formed by integrating the test recording scripts belonging to the same case, so that the target test recording script can be used in the subsequent test analysis and other processes, and the efficiency and convenience of the interface automatic test are improved.
The embodiments described in the embodiments of the present application are for more clearly illustrating the technical solutions of the embodiments of the present application, and do not constitute a limitation to the technical solutions provided in the embodiments of the present application, and it is obvious to those skilled in the art that the technical solutions provided in the embodiments of the present application are also applicable to similar technical problems with the evolution of technology and the emergence of new application scenarios.
It will be appreciated by those skilled in the art that the solutions shown in fig. 1-7 are not intended to limit the embodiments of the present application and may include more or fewer steps than those shown, or some of the steps may be combined, or different steps may be included.
The above-described embodiments of the apparatus are merely illustrative, wherein the units illustrated as separate components may or may not be physically separate, i.e. may be located in one place, or may also be distributed over a plurality of network elements. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the present embodiment.
One of ordinary skill in the art will appreciate that all or some of the steps of the methods, systems, functional modules/units in the devices disclosed above may be implemented as software, firmware, hardware, and suitable combinations thereof.
The terms "first," "second," "third," "fourth," and the like in the description of the application and the above-described figures, if any, are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It should be understood that the data so used may be interchanged under appropriate circumstances such that embodiments of the application described herein may be implemented in sequences other than those illustrated or described herein. Moreover, the terms "comprises," "comprising," and "having," and any variations thereof, are intended to cover a non-exclusive inclusion, such that a process, method, system, article, or apparatus that comprises a list of steps or elements is not necessarily limited to those steps or elements expressly listed, but may include other steps or elements not expressly listed or inherent to such process, method, article, or apparatus.
It should be understood that in the present application, "at least one" means one or more, "a plurality" means two or more. "and/or" for describing an association relationship of associated objects, indicating that there may be three relationships, e.g., "a and/or B" may indicate: only A, only B and both A and B are present, wherein A and B may be singular or plural. The character "/" generally indicates that the former and latter associated objects are in an "or" relationship. "at least one of the following" or similar expressions refer to any combination of these items, including any combination of single item(s) or plural items. For example, at least one (one) of a, b, or c, may represent: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", wherein a, b, c may be single or plural.
In the several embodiments provided in the present application, it should be understood that the disclosed apparatus and method may be implemented in other ways. For example, the above-described apparatus embodiments are merely illustrative, and for example, the above-described division of units is only one type of division of logical functions, and other divisions may be realized in practice, for example, a plurality of units or components may be combined or integrated into another system, or some features may be omitted, or not executed. In addition, the shown or discussed mutual coupling or direct coupling or communication connection may be an indirect coupling or communication connection through some interfaces, devices or units, and may be in an electrical, mechanical or other form.
The units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be 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 solution of the embodiment.
In addition, functional units in the embodiments of the present application may be integrated into one processing unit, or each unit may exist alone physically, or two or more units are integrated into one unit. The integrated unit can be realized in a form of hardware, and can also be realized in a form of a software functional unit.
The integrated unit, if implemented in the form of a software functional unit and sold or used as a stand-alone product, may be stored in a computer readable storage medium. Based on such understanding, the technical solution of the present application may be substantially implemented or contributed to by the prior art, or all or part of the technical solution may be embodied in a software product, which is stored in a storage medium and includes multiple instructions for causing a computer device (which may be a personal computer, a server, or a network device) to perform all or part of the steps of the method of the embodiments of the present application. And the aforementioned storage medium includes: various media capable of storing programs, such as a usb disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk, or an optical disk.
The preferred embodiments of the present application have been described above with reference to the accompanying drawings, and the scope of the claims of the embodiments of the present application is not limited thereto. Any modifications, equivalents and improvements that may occur to those skilled in the art without departing from the scope and spirit of the embodiments of the present application are intended to be within the scope of the claims of the embodiments of the present application.

Claims (10)

1. A method for recording a test script, the method comprising:
acquiring a target interface of a target client;
performing interface layout detection on the target interface to obtain interface layout data, and recording the interface layout detection process to obtain an interface layout script;
extracting information from the interface layout data to obtain candidate control information, and recording the information extraction process to obtain a control information script;
acquiring an interface operating instruction, wherein the interface operating instruction comprises a current operating event and operating time;
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, and recording a control query process to obtain a query information script, wherein the target control is a candidate control which needs to consume the current operation event;
classifying the current operation event based on the target control information and the operation time to obtain target operation data, and recording a classification process to obtain an operation classification script, wherein the target operation data comprises the operation type of the current operation event;
and integrating the interface layout script, the query information script and the operation classification script to obtain a target test recording script.
2. The method of claim 1, wherein the extracting information from the interface layout data to obtain candidate control information comprises:
traversing the control tree of the target interface to obtain a candidate control of the target interface;
extracting information from the interface layout data to obtain the control type and the control attribute of the candidate control;
generating control numbers of the candidate controls according to the control types and the control attributes, wherein the control number of each candidate control is unique;
and obtaining the candidate control information according to the control type, the control number and the control attribute.
3. The method according to claim 1, wherein the performing a 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 comprises:
acquiring a target characteristic parameter corresponding to the current operation event based on the event response mechanism;
acquiring a preset relational mapping table, wherein the relational mapping table stores the mapping relation between candidate characteristic parameters and candidate controls;
performing control query according to a preset relation mapping table and the target characteristic parameters to obtain the target control;
and screening the candidate control information according to the target control to obtain the target control information.
4. The method of claim 1, wherein the classifying the current operation event based on the target control information and the operation time to obtain target operation data comprises:
performing first classification processing on the current operation event according to the operation time to obtain initial classification data;
performing second classification processing on the initial classification data according to the control type in the target control information to obtain intermediate classification data;
performing type adjustment on the intermediate classification data according to preset reference control information to obtain an operation type of the current operation event;
and 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.
5. The method according to claim 1, wherein the integrating the interface layout script, the query information script, and the operation classification script to obtain a target test recording script comprises:
integrating the interface layout script, the query information script and the operation classification script according to a preset splicing sequence to obtain an initial test recording script;
case naming is carried out on the initial test recording script to obtain a test case name;
and generating the target test recording script based on the test case name and the initial test recording script.
6. The method of claim 1, wherein before performing interface layout detection on the target interface to obtain interface layout data, the method comprises:
acquiring a test recording request;
and starting a recording switch according to the test recording request.
7. The method according to any one of claims 1 to 6, wherein after the integrating process is performed on the interface layout script, the query information script, and the operation classification script to obtain a target test recording script, the method further comprises:
uploading the target test recording script to a server side;
and performing data correction on the target test recording script based on the reference case data of the server side to obtain target case data.
8. An apparatus for recording a test script, the apparatus comprising:
the interface acquisition module is used for acquiring a target interface of a target client;
the layout detection module is used for carrying out interface layout detection on the target interface to obtain interface layout data, and recording the interface layout detection process to obtain an interface layout script;
the information extraction module is used for extracting information from the interface layout data to obtain candidate control information, and recording the information extraction process to obtain a control information script;
the instruction acquisition module is used for acquiring an interface operation instruction, wherein the interface operation instruction comprises a current operation event and operation time;
the control query module is used for 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, and recording a control query process to obtain a query information script, wherein the target control is a candidate control which needs to consume the current operation event;
the operation classification module is used for classifying the current operation event based on the target control information and the operation time to obtain target operation data, and recording a classification process to obtain an operation classification script, wherein the target operation data comprises the operation type of the current operation event;
and the script integration module is used for integrating the interface layout script, the query information script and the operation classification script to obtain a target test recording script.
9. An electronic device, comprising a memory storing a computer program and a processor implementing the test script recording method according to any one of claims 1 to 7 when the computer program is executed by the processor.
10. A computer-readable storage medium, in which a computer program is stored, which computer program, when being executed by a processor, carries out a test script recording method according to any one of claims 1 to 7.
CN202211247592.8A 2022-10-12 2022-10-12 Test script recording method and device, electronic equipment and storage medium Pending CN115562993A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211247592.8A CN115562993A (en) 2022-10-12 2022-10-12 Test script recording method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211247592.8A CN115562993A (en) 2022-10-12 2022-10-12 Test script recording method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN115562993A true CN115562993A (en) 2023-01-03

Family

ID=84744455

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211247592.8A Pending CN115562993A (en) 2022-10-12 2022-10-12 Test script recording method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN115562993A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116401421A (en) * 2023-03-14 2023-07-07 深圳市晶存科技有限公司 Chip test data query method, system, equipment and medium

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN116401421A (en) * 2023-03-14 2023-07-07 深圳市晶存科技有限公司 Chip test data query method, system, equipment and medium
CN116401421B (en) * 2023-03-14 2024-05-07 深圳市晶存科技有限公司 Chip test data query method, system, equipment and medium

Similar Documents

Publication Publication Date Title
CN107317724B (en) Data acquisition system and method based on cloud computing technology
CN109408102B (en) Version comparison method and device, household electrical appliance and network equipment
CN104731589A (en) Automatic generation method and device of user interface (UI)
CN109376069B (en) Method and device for generating test report
US10175954B2 (en) Method of processing big data, including arranging icons in a workflow GUI by a user, checking process availability and syntax, converting the workflow into execution code, monitoring the workflow, and displaying associated information
CN104679500B (en) Method and device for realizing automatic generation of entity class
CN103257852B (en) The method and apparatus that a kind of development environment of distribution application system is built
CN104572072A (en) MVC (model view controller) mode-based language transformation method and equipment for program
CN104461531A (en) Implementing method for self-defined functions of reporting system
CN112817866A (en) Recording playback method, device, system, computer equipment and storage medium
CN110941629A (en) Metadata processing method, device, equipment and computer readable storage medium
CN115562993A (en) Test script recording method and device, electronic equipment and storage medium
CN109063059A (en) User behaviors log processing method, device and electronic equipment
CN115469849B (en) Service processing system, method, electronic equipment and storage medium
CN116339715A (en) Front-end page construction method and device, electronic equipment and storage medium
CN111966725A (en) Data acquisition method and device applied between internal network and external network and electronic equipment
CN113268232A (en) Page skin generation method and device and computer readable storage medium
CN113722337B (en) Service data determination method, device, equipment and storage medium
CN115455006A (en) Data processing method, data processing device, electronic device, and storage medium
CN115454382A (en) Demand processing method and device, electronic equipment and storage medium
CN113515715B (en) Buried point event code generation method, buried point event code processing method and related equipment
US10204106B2 (en) Management method, management device, and management system
CN111813439A (en) Distribution material quality control method, device, equipment and computer storage medium
CN106469086B (en) Event processing method and device
CN117370203B (en) Automatic test method, system, electronic equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination