Canvas-based testing method, device, computer equipment and storage medium

By recording and deserializing user operation information and performing comparison and testing, the problem of Canvas page automation testing is solved, which improves testing efficiency and code robustness, and reduces development risks.

CN113468050BActive Publication Date: 2024-12-03HANGZHOU QUNHE INFORMATION TECHNOLOGIES CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202110733854.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-06-30
Publication Date
2024-12-03
Estimated Expiration
2041-06-30

AI Technical Summary

Technical Problem

The existing technology is difficult to achieve automated testing of Canvas-based pages, which leads to developers facing huge risk of recession when developing new functions. The testing efficiency is low, and the problem cannot be discovered in time, and a lot of time is wasted for troubleshooting.

Method used

By recording user operation information, deserialization process, obtain the running results of the test script, and compare it with the expected results, output test results, realize local tests on the canvas, and reduce the search for operation problems in a large number of code necessity.

Benefits of technology

Improves testing efficiency, reduces waste of manpower and time, improves code robustness, realizes automated regression testing of Canvas pages, and reduces development risks.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN113468050B_ABST
    Figure CN113468050B_ABST
Patent Text Reader

Abstract

The present application discloses a canvas-based testing method, apparatus, computer equipment and storage medium, and relates to the field of computer application technology. The method comprises recording a script to be tested of user operation information from a canvas, and replaying the script to be tested, so that it is not necessary to perform regression testing on all codes before each code submission and during integration testing, thereby saving a lot of manpower and time; deserializing the script to be tested to obtain a test script, and obtaining the running result of the test script, and comparing the running result with the expected result of the user operation information to output the test result, that is, by reconstructing the object of the script to be tested and executing the test, a local test of the canvas can be achieved, so that it is not necessary to find and locate the operation problem of the canvas in a large amount of code, effectively improving the test efficiency, and further improving the robustness of the code.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer application technology, and in particular to a canvas-based testing method, apparatus, computer equipment and storage medium. Background Art

[0002] As a Canvas-based Web software, since it often involves many operations and editing states, especially three-dimensional software, the amount and complexity of its code are often much higher than that of general Web pages. Since automated testing can effectively improve the robustness of the code, facilitate programmers to quickly find problems, improve development efficiency, and improve program quality, it is often used in system testing and operation and maintenance.

[0003] However, most of the current front-end automated testing is based on searching and comparing Dom (Document Object Model) or has clear input and output data to implement testing. For example, automated testing can be a commonly used interactive page based on Dom nodes or a function with clear input and output, but for Canvas, there is no testable structure inside. Canvas is a single DOM. Most of the current front-end automation requires clicks between different DOMs, so automated testing cannot be implemented for Canvas pages. In the absence of a mature automated regression testing framework, developers are accompanied by a huge risk of regression every time they develop a new function. Sometimes they cannot be discovered in time, and they have to waste a lot of time to investigate the causes of the regression, which greatly affects the testing efficiency. Summary of the invention

[0004] The purpose of the embodiments of the present application is to propose a canvas-based testing method to solve the problem of low testing efficiency.

[0005] In order to solve the above technical problems, the present application provides a canvas-based testing method, comprising the following steps:

[0006] The script to be tested that records user operation information from the canvas;

[0007] Deserialize the script to be tested to obtain the test script;

[0008] Get the running results of the test script;

[0009] Compare the running results with the expected results of the user operation information to output the test results.

[0010] Furthermore, the script to be tested that records user operation information from the canvas includes:

[0011] Get user operation information from the canvas;

[0012] Classifying and processing the operation information to obtain an initial script, wherein the initial script includes commands and events;

[0013] The initial script is serialized to obtain the script to be tested.

[0014] Furthermore, after the operation information is classified and processed to obtain the initial script, the canvas-based testing method further includes:

[0015] According to the command and the event, a selection set identifier corresponding to the operation information is determined, wherein the selection set identifier is used to indicate a selector.

[0016] Furthermore, the expected result includes the expected result of the selector corresponding to the selection set identifier, and the operation result is compared with the expected result of the user operation information to output the test result including:

[0017] Run commands or events in a test script;

[0018] If there is no error in the running result, compare the running result with the expected result of the selector;

[0019] If the comparison results are consistent and the script to be tested has not finished replaying, the reverse test process of the script to be tested will continue.

[0020] Furthermore, the canvas-based testing method further includes:

[0021] If the running result reports an error or the comparison result is inconsistent, it is determined that the current test script has failed.

[0022] Furthermore, the embodiment of the present application provides a canvas-based testing device, comprising:

[0023] The recording module is used to record the user operation information from the canvas to the script under test;

[0024] The deserialization module is used to deserialize the script to be tested to obtain the test script;

[0025] The acquisition module is used to obtain the running results of the test script;

[0026] The test module is used to compare the running results with the expected results of the user operation information to output the test results.

[0027] Furthermore, the recording module includes:

[0028] An acquisition unit, used to obtain user operation information from the canvas;

[0029] A classification unit, used for classifying the operation information to obtain an initial script, wherein the initial script includes commands and events;

[0030] The serialization unit is used to serialize the initial script to obtain the script to be tested.

[0031] Furthermore, the canvas-based testing device further includes:

[0032] The selector module is used to determine the selection set identifier corresponding to the operation information according to the command and the event, wherein the selection set identifier is used to indicate the selector.

[0033] Furthermore, the test module includes:

[0034] Run unit, used to run commands or events in the test script;

[0035] The comparison unit is used to compare the running result with the expected result of the selector if there is no error in the running result;

[0036] The execution unit is used to continue to execute the reverse test process of the script to be tested if the comparison results are consistent and the playback of the script to be tested has not been completed.

[0037] Furthermore, the canvas-based testing device further includes:

[0038] The test failure module is used to determine that the current test script has failed if the running result reports an error or the comparison result is inconsistent.

[0039] In order to solve the above technical problems, an embodiment of the present application further provides a computer device, including a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the computer program, the steps of the above canvas-based testing method are implemented.

[0040] In order to solve the above technical problems, an embodiment of the present application further provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the steps of the above canvas-based testing method are implemented.

[0041] Compared with the prior art, the embodiments of the present application have the following beneficial effects:

[0042] By recording the user operation information of the script to be tested in the canvas, the script to be tested can be replayed, so that there is no need to perform regression testing on all codes before each code submission and integration testing, thereby saving a lot of manpower and time; the script to be tested is deserialized to obtain the test script, and the running result of the test script is obtained, and the running result is compared with the expected result of the user operation information to output the test result. That is, by reconstructing the object of the script to be tested and executing the test, local testing of the canvas can be achieved, so that there is no need to find and locate the operation problems of the canvas one by one in a large amount of code, which effectively improves the test efficiency and thus improves the robustness of the code. BRIEF DESCRIPTION OF THE DRAWINGS

[0043] In order to more clearly illustrate the scheme in the present application, a brief introduction is given below to the drawings required for use in the description of the embodiments of the present application. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0044] Figure 1 is an exemplary system architecture diagram to which the present application may be applied;

[0045] Figure 2 is a schematic diagram of a canvas-based testing system provided by the present application;

[0046] Figure 3 is a flowchart of an embodiment of a canvas-based testing method provided by the present application

[0047] Figure 4 is a structural schematic diagram of an embodiment of a canvas-based testing device provided by the present application;

[0048] Figure 5 It is a structural diagram of an embodiment of a computer device provided by the present application. DETAILED DESCRIPTION

[0049] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by technicians in the technical field of the present application; the terms used in the specification of the application herein are only for the purpose of describing specific embodiments and are not intended to limit the present application; the terms "including" and "having" and any variations thereof in the specification and claims of the present application and the above-mentioned drawings are intended to cover non-exclusive inclusions. The terms "first", "second", etc. in the specification and claims of the present application or the above-mentioned drawings are used to distinguish different objects, not to describe a specific order.

[0050] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.

[0051] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the accompanying drawings.

[0052] like Figure 1 As shown, the system architecture 100 may include terminal devices 101, 102, 103, a network 104 and a server 105. The network 104 is used to provide a medium for communication links between the terminal devices 101, 102, 103 and the server 105. The network 104 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.

[0053] Users can use terminal devices 101, 102, 103 to interact with server 105 through network 104 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 101, 102, 103, such as web browser applications, shopping applications, search applications, instant messaging tools, email clients, social platform software, etc.

[0054] Terminal devices 101, 102, 103 can be various electronic devices with display screens and supporting web browsing, including but not limited to smart phones, tablet computers, e-book readers, MP3 players (Moving Picture Experts Group Audio Layer III), MP4 (Moving Picture Experts Group Audio Layer IV) players, laptop computers, desktop computers, etc.

[0055] The server 105 may be a server that provides various services, such as a background server that provides support for web pages displayed on the terminal devices 101 , 102 , and 103 .

[0056] It should be noted that the canvas-based testing method provided in the embodiment of the present application is generally executed by a server / terminal device, and accordingly, the canvas-based testing device is generally arranged in the server / terminal device.

[0057] It should be understood that Figure 1The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.

[0058] Specifically, Canvas is like a curtain on which you can draw various charts, animations, etc. using JavaScript (a lightweight, interpreted or just-in-time compiled programming language with function priority). Canvas is a new tag in HTML5 (HyperText Markup Language 5, a language description method for building Web content) that can be used to generate images in real time on web pages and manipulate image content. Basically, it is a bitmap that can be manipulated with JavaScript. The Canvas object represents an HTML canvas element - <canvas>, it has no behavior of its own, but can define an API (interface) to support scripted client-side drawing operations. Therefore, Canvas often involves many operations and editing states, especially three-dimensional software, the number and complexity of its code are often much higher than general Web pages. However, the existing automatic testing methods based on interactive pages of Dom nodes or functional functions with clear input and output are powerless for Canvas-based pages. In the absence of a mature automated regression testing framework, every time developers develop new functions, they are accompanied by a huge risk of regression, which sometimes cannot be discovered in time, and a lot of time is wasted to investigate the causes of the regression, which greatly affects development efficiency. For testers, every time they go online, they also spend a lot of time to manually perform regression testing, especially for software that is deployed and released frequently, the time spent on regression testing will be even greater.

[0059] Therefore, in the embodiment of the present application, the problem of automated regression testing of Canvas-based Web applications is solved, an automatic recording function is provided to record and generate the script to be tested, and then the script to be tested is read and played back to compare the selector changes, the number of elements and the attribute changes in the same actual operation process, that is, to compare whether the operation process is consistent with the actual change state, so as to achieve the purpose of automated testing, so that the Web version does not need to spend huge human resources to do regression testing each time it is modified during the continuous iteration process, and problems can be discovered in time, thereby improving the efficiency of traffic testing, thereby effectively improving development efficiency and ensuring code quality.

[0060] Continue to refer Figure 2 , shows a flowchart of an embodiment of a canvas-based testing method of the present application. The canvas-based testing method comprises the following steps:

[0061] S201: A script to be tested that records user operation information from the canvas.

[0062] The user operation information includes click / double-click / long press on the canvas element, such as a mouse click, or a shortcut key trigger operation, for example, simultaneously controlling the Ctrl key and the letter "A" key as an operation to quickly select an element.

[0063] Furthermore, user operation information can be abstracted into commands and events. In the embodiment of the present application, a command refers to a trigger instruction of a user in the canvas, that is, an action instruction, such as a click command, a drag command, a shortcut key command, etc.; an event refers to all objects triggered by a command and the corresponding description information, for example, the object pointed to by a click command is a mouse click event.

[0064] Furthermore, commands and events are processed in sequence, that is, serialization processing is to convert user operation information into a byte stream that can be stored or transmitted. For example, JavaScript objects are converted into JSON (JavaScript Object Notation, a data exchange format). The byte stream saves the object status and description information in the commands and events, and is saved as the script to be tested. That is, the script to be tested is script information that has been serialized, which is beneficial to ensure the integrity and transferability of the script to be tested when transmitting and saving the script to be tested, and also facilitates the subsequent playback of the script to be tested.

[0065] S202: Deserialize the script to be tested to obtain a test script.

[0066] In an embodiment of the present application, the commands and events in the script to be tested are deserialized, that is, the objects of the commands or events are reconstructed through deserialization, and the byte stream is converted into the original object state and description information. For example, JSON is deserialized into a JavaScript object, and the information such as the events, commands, and attributes, elements controlled by each event or command in the original canvas is restored to use the information as a test script.

[0067] S203: Obtain the running result of the test script.

[0068] Specifically, the iterative version code of the current Web terminal is used to run the test script to output the running result of the test script, wherein the iterative version code is the logic code after the original code on the Web terminal is modified and iterated. The test script is run through the iterative version code to test whether the current iterative version code has any changes to the current canvas.

[0069] S204: Compare the running result with the expected result of the user operation information to output the test result.

[0070] In the embodiment of the present application, the expected result refers to the state information and number of elements of each element and attribute when the canvas is running normally without changing the original code of the Web end. The test result includes whether the operation reports an error, whether the comparison results are consistent, etc.

[0071] In an embodiment of the present application, by recording the script to be tested of the user operation information from the canvas, the playback of the script to be tested is realized, so that there is no need to perform regression testing on all codes before each code submission and during integration testing, thereby saving a lot of manpower and time; the script to be tested is deserialized to obtain the test script, and the running result of the test script is obtained, and the running result is compared with the expected result of the user operation information to output the test result, that is, by reconstructing the object of the script to be tested and executing the test, the canvas can be partially tested, so that there is no need to find and locate the operation problems of the canvas one by one in a large amount of code, which effectively improves the test efficiency and thus improves the robustness of the code.

[0072] Furthermore, the script to be tested that records user operation information from the canvas includes:

[0073] Get user operation information from the canvas;

[0074] Classifying and processing the operation information to obtain an initial script, wherein the initial script includes commands and events;

[0075] The initial script is serialized to obtain the script to be tested.

[0076] Specifically, user operation information in the canvas is monitored from the terminal device interface, for example, the user clicks the text in the main navigation bar in the canvas with the mouse, uses shortcut keys to trigger a login confirmation button, or drags components in the canvas.

[0077] The command contains the operation logic of the button. For example, the user operation information is clicking any UI (User Interface) button on the web page, or pressing a shortcut key, which can be considered to trigger one or more commands. The event can be a mouse down event, that is, when the mouse pointer moves over an element and the mouse button is pressed, or it can be a mouse up event, that is, when the mouse button is released on an element, or a mouse move event, that is, when the mouse moves over an element. The event can also be a keyboard event triggered on the canvas. Commands and events are pre-saved in the operation form, that is, the operation form specifies the command or event to which each user operation information points.

[0078] Therefore, by monitoring user operation information, corresponding commands or events can be found, that is, the user operation information is converted into an initial scripting language of commands or events in the operation form. The initial scripting language is a dynamic language used to control software applications, or can be interpreted or compiled when called.

[0079] In the embodiments of the present application, in order to enable the initial script to be reused repeatedly during the testing process, the initial script needs to be pre-stored in a temporary or persistent storage area. Serialization processing is to convert the initial script into a form that can be stored or transmitted. Therefore, after converting the user operation information into the initial script, performing serialization processing on it to obtain the script to be tested, and recording and storing it in a temporary or persistent storage area can realize the playback and use of the user operation information.

[0080] Further, after classifying the operation information to obtain the initial script, the canvas-based testing method further includes:

[0081] Determining a selection set identifier corresponding to the operation information according to commands and events, where the selection set identifier is used to indicate a selector.

[0082] Among them, the selection set identifier is a selector identifier, and the selector can be a CSS (Cascading Style Sheets) selector, such as an intersection selector, a union selector, a descendant selector, a child element selector, a pseudo selector, a simple selector, an attribute selector, etc. The simple selector includes a class selector and an ID selector.

[0083] The class selector is used to describe the styles of a group of tags. A class selector can be used on multiple tags. For example, define the name of a class selector as.class_name, {property: property value;}, that is, there must be a dot "." in front of the class selector, which is essential and is the sign of the class selector. The name class_name of the class selector is user-defined, that is, the class selector name is essentially the selection set identifier. Use the defined class style through the class attribute on the HTML tag, and the format is: <tag name class = "class name"> tag content < / tag name>. The class selector can be used on multiple HTML tags on the same page with the same class selector.

[0084] Further, the use of the ID selector and the class selector is basically the same. The sign of the ID selector is defined starting with a hash "#". The ID selector can be used through the ID attribute in HTML. An ID selector can only appear once on the same page and is unique. While the class selector can appear multiple times on the same page, so the ID selector is more targeted. Therefore, on the same page, the same ID selector is not allowed to appear, but the same class selector is allowed. Define an ID selector through #, which can be expressed as #ID name {property: property value;}, for example, the property is the page background color and the property value is pink.

[0085] Therefore, according to the selector pointed to by the command and event, the selection set identifier corresponding to the operation information can be determined. The selection set identifier indicates that the current CSS style setting is implemented by the specified selector. By classifying commands or events according to the selection set identifier, it is possible to quickly determine that the same selector can be used for different instructions or events on multiple HTML tags in the same page.

[0086] Further, the expected result includes the expected result of the selector corresponding to the selection set identifier. As shown in step S204, the operation result is compared with the expected result of the user operation information to output the test result including:

[0087] Run commands or events in a test script;

[0088] If there is no error in the running result, compare the running result with the expected result of the selector;

[0089] If the comparison results are consistent and the script to be tested has not finished replaying, the reverse test process of the script to be tested will continue.

[0090] In the real-time example of the present application, the command or event of the test script is run in the iterative version code of the current Web end. At this time, the command or event is reconstructed by deserializing the script to be tested.

[0091] The expected result of the selector is the state information of the selector corresponding to the user operation information when the iterative version code of the Web end is not tested. The state information of the selector can be the attribute value of the attribute. The reverse test process refers to the process of deserializing the script to be tested to obtain the test script and testing the test script.

[0092] If the program in the running result does not report an error, it means that there is no syntax or code format problem in the iterative version code, and further compare whether the status information of the selector presented in the current running result is consistent with the expected result of the selector. If they are consistent, it means that the iterative version code test of the current Web end is successful, and continue to read the script to be tested, and deserialize the script to be tested before testing, and loop in sequence until the test is stopped when the script to be tested is read.

[0093] Furthermore, combined with Figure 3 , Figure 3 This is a schematic diagram of the test comparison process in the embodiment of the present application. By reading the pre-recorded script to be tested, it is determined whether the script to be tested is an instruction; if it is an instruction, the command in the script to be tested is deserialized, otherwise the event is deserialized, that is, the object of the command or event is rebuilt through deserialization to serve as a test script; the command or event is run based on the iterative version code of the current Web end; if no program error occurs during the running process, further compare the current selector with the selector of the last non-iterative version code to see if there is any change. For example, when the last selector operation is to click on object A and object B in sequence, when testing the current selector, if object A and / or object B is not clicked, it is possible that object A and / or object B does not exist, or the position of object A and / or object B has changed, indicating that the current selector is not clicked. The executed program is different from the last executed program, but the program hopes that the test result line is consistent with the last save to determine that there is no regression; if the selector changes or the program reports an error, that is, the running result reports an error or the comparison result is inconsistent, it is determined that the current test script has failed, that is, the current iteration version code test has failed; if the selector has not changed, it is further determined whether the script to be tested has completed the playback; if the playback has not ended, the test process of the script to be tested continues until all the scripts to be tested are read and the test is completed. There is no need to perform a new round of overall testing on all the codes in the current Web canvas after each test failure. Instead, by replaying the scripts to be tested one by one, that is, replaying the user operation information one by one, a lot of test troubleshooting time is reduced, thereby improving test efficiency.

[0094] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program, and the computer program can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, the aforementioned storage medium can be a non-volatile storage medium such as a disk, an optical disk, a read-only memory (ROM), or a random access memory (RAM).

[0095] It should be understood that, although the steps in the flowchart of the accompanying drawings are displayed in sequence as indicated by the arrows, these steps are not necessarily executed in sequence in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least a part of the steps in the flowchart of the accompanying drawings may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and their execution order is not necessarily sequential, but can be executed in turn or alternately with other steps or at least a part of the sub-steps or stages of other steps.

[0096] Further references Figure 4 , as a response to the above Figure 2 The present application provides an embodiment of a canvas-based testing device, which is similar to Figure 2 Corresponding to the method embodiment shown, the device can be specifically applied to various electronic devices.

[0097] like Figure 4 As shown, Figure 4 This is a schematic diagram of the structure of an embodiment of a canvas-based test device provided by the present application, wherein the canvas-based test device further includes: a recording module 401, a deserialization module 402, an acquisition module 403 and a testing module 404. Among them:

[0098] Recording module 401, used for recording the script to be tested of user operation information from the canvas;

[0099] The deserialization module 402 is used to deserialize the script to be tested to obtain a test script;

[0100] The acquisition module 403 is used to obtain the running result of the test script;

[0101] The test module 404 is used to compare the operation result with the expected result of the user operation information to output the test result.

[0102] Furthermore, the recording module 401 includes:

[0103] The acquisition unit 4011 is used to acquire user operation information from the canvas;

[0104] The classification unit 4012 is used to classify the operation information to obtain an initial script, wherein the initial script includes commands and events;

[0105] The serialization unit 4013 is used to serialize the initial script to obtain the script to be tested.

[0106] Furthermore, the canvas-based testing device further includes:

[0107] The selector module 405 is used to determine the selection set identifier corresponding to the operation information according to the command and the event, wherein the selection set identifier is used to indicate the selector.

[0108] Furthermore, the testing module 404 includes:

[0109] The running unit 4041 is used to run the commands or events in the test script;

[0110] The comparison unit 4042 is used to compare the running result with the expected result of the selector if there is no error in the running result;

[0111] The execution unit 4043 is used to continue to execute the reverse test process of the script to be tested if the comparison results are consistent and the playback of the script to be tested has not ended.

[0112] Furthermore, the canvas-based testing device further includes:

[0113] The test failure module 406 is used to determine that the current test script test has failed if the running result reports an error or the comparison result is inconsistent.

[0114] Regarding the canvas-based testing device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.

[0115] To solve the above technical problems, the present application also provides a computer device. Figure 5 , Figure 5 This is a basic structural block diagram of the computer device in this embodiment.

[0116] The computer device 5 includes a memory 51, a processor 52, and a network interface 53 that are interconnected through a system bus. It should be noted that the figure only shows a computer device 5 with components 51-53, but it should be understood that it is not required to implement all the components shown, and more or fewer components can be implemented instead. Among them, those skilled in the art can understand that the computer device here is a device that can automatically perform numerical calculations and / or information processing according to pre-set or stored instructions, and its hardware includes but is not limited to microprocessors, application specific integrated circuits (Application Specific Integrated Circuit, ASIC), programmable gate arrays (Field-Programmable Gate Array, FPGA), digital processors (Digital Signal Processor, DSP), embedded devices, etc.

[0117] The computer device may be a computing device such as a desktop computer, a notebook, a PDA, a cloud server, etc. The computer device may interact with a user through a keyboard, a mouse, a remote controller, a touch pad, or a voice control device.

[0118] The memory 51 includes at least one type of readable storage medium, and the readable storage medium includes flash memory, hard disk, multimedia card, card-type memory (for example, SD or D canvas-based test memory, etc.), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, disk, optical disk, etc. In some embodiments, the memory 51 can be an internal storage unit of the computer device 5, such as a hard disk or memory of the computer device 5. In other embodiments, the memory 51 can also be an external storage device of the computer device 5, such as a plug-in hard disk equipped on the computer device 5, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc. Of course, the memory 51 can also include both the internal storage unit of the computer device 5 and its external storage device. In this embodiment, the memory 51 is generally used to store the operating system and various application software installed on the computer device 5, such as the program code of the canvas-based test method, etc. In addition, the memory 51 can also be used to temporarily store various types of data that have been output or are to be output.

[0119] The processor 52 may be a central processing unit (CPU), a controller, a microcontroller, a microprocessor, or other data processing chips in some embodiments. The processor 52 is generally used to control the overall operation of the computer device 5. In this embodiment, the processor 52 is used to run the program code stored in the memory 51 or process data, such as running the program code of the canvas-based testing method.

[0120] The network interface 53 may include a wireless network interface or a wired network interface. The network interface 53 is generally used to establish a communication connection between the computer device 5 and other electronic devices.

[0121] The present application also provides another embodiment, namely, providing a computer-readable storage medium, wherein the computer-readable storage medium stores a canvas-based test program, and the canvas-based test program can be executed by at least one processor so that the at least one processor performs the steps of the canvas-based test method as described above.

[0122] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in each embodiment of the present application.

[0123] Obviously, the embodiments described above are only some embodiments of the present application, rather than all embodiments. The preferred embodiments of the present application are given in the accompanying drawings, but they do not limit the patent scope of the present application. The present application can be implemented in many different forms. On the contrary, the purpose of providing these embodiments is to make the understanding of the disclosure of the present application more thorough and comprehensive. Although the present application is described in detail with reference to the aforementioned embodiments, for those skilled in the art, it is still possible to modify the technical solutions recorded in the aforementioned specific implementation methods, or to perform equivalent replacement of some of the technical features therein. Any equivalent structure made using the contents of the specification and drawings of this application, directly or indirectly used in other related technical fields, is similarly within the scope of patent protection of this application.< / canvas>

Claims

1. A canvas-based testing method, characterized in that: The method comprises: The script to be tested that records user operation information from the canvas; Deserialize the script to be tested to obtain a test script; Obtaining the running result of the test script; Compare the operation result with the expected result of the user operation information to output a test result; The script to be tested that records user operation information from the canvas includes: Obtaining user operation information from the canvas; Classifying and processing the operation information to obtain an initial script, wherein the initial script includes commands and events; Serializing the initial script to obtain a script to be tested; After classifying the operation information to obtain an initial script, the method further includes: According to the command and the event, a selection set identifier corresponding to the operation information is determined, wherein the selection set identifier is used to indicate a selector.

2. The canvas-based testing method according to claim 1, characterized in that: The expected result includes the expected result of the selector corresponding to the selection set identifier, and the comparing the operation result with the expected result of the user operation information to output the test result includes: Run the commands or events in the test script; If the running result does not report an error, then compare the running result with the expected result of the selector; If the comparison results are consistent and the script to be tested has not finished replaying, the reverse test process of the script to be tested continues.

3. The canvas-based testing method according to any one of claims 1-2, characterized in that: The method further comprises: If the running result reports an error or the comparison result is inconsistent, it is determined that the current test script test has failed.

4. A canvas-based testing device, characterized in that: The canvas-based test setup includes: The recording module is used to record the user operation information from the canvas to the script under test; A deserialization module, used for deserializing the script to be tested to obtain a test script; An acquisition module, used to obtain the running result of the test script; A test module, used to compare the operation result with the expected result of the user operation information to output a test result; The recording module comprises: An acquisition unit, used to acquire user operation information from the canvas; a classification unit, configured to classify the operation information to obtain an initial script, wherein the initial script includes commands and events; after classifying the operation information to obtain the initial script, further determining a selection set identifier corresponding to the operation information according to the commands and the events, wherein the selection set identifier is used to indicate a selector; The serialization unit is used to serialize the initial script to obtain a script to be tested.

5. The canvas-based testing device according to claim 4, characterized in that: The test module includes: A running unit, used to run commands or events in the test script; A comparison unit, configured to compare the running result with the expected result of the selector if there is no error in the running result; The execution unit is used to continue to execute the reverse test process of the script to be tested if the comparison results are consistent and the playback of the script to be tested has not ended.

6. A computer device, comprising a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the canvas-based testing method according to any one of claims 1 to 3 when executing the computer program.

7. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the canvas-based testing method according to any one of claims 1 to 3 are implemented.