CN113468076A - Application program exception testing method, device, equipment and storage medium - Google Patents

Application program exception testing method, device, equipment and storage medium Download PDF

Info

Publication number
CN113468076A
CN113468076A CN202110952881.7A CN202110952881A CN113468076A CN 113468076 A CN113468076 A CN 113468076A CN 202110952881 A CN202110952881 A CN 202110952881A CN 113468076 A CN113468076 A CN 113468076A
Authority
CN
China
Prior art keywords
script
target
page
application program
preset
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
CN202110952881.7A
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 Puhui Enterprise Management Co Ltd
Original Assignee
Ping An Puhui Enterprise Management Co 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 Puhui Enterprise Management Co Ltd filed Critical Ping An Puhui Enterprise Management Co Ltd
Priority to CN202110952881.7A priority Critical patent/CN113468076A/en
Publication of CN113468076A publication Critical patent/CN113468076A/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
    • 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/3684Test management for test design, e.g. generating new test cases

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)
  • Stored Programmes (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The invention relates to the field of artificial intelligence and discloses an application program abnormity testing method, device, equipment and storage medium. The method comprises the following steps: recording scripts of each page of the application program to obtain an initial script fragment file of each page; determining a plurality of business processes based on business requirements; receiving a script execution instruction, determining a target flow according to the instruction, and acquiring a target script fragment sequence corresponding to the target flow; generating a target script based on the target script fragment sequence and the public script data including the screen capture script data; and executing the target script to obtain a screenshot picture set corresponding to the target process, comparing each screenshot picture in the screenshot picture set with a preset standard picture corresponding to each screenshot picture, and determining an abnormal page in the target application program. According to the invention, the whole testing process is obtained by adding the screen capture logic during the page testing, and the screen capture picture is rapidly compared with the standard picture, so that the testing efficiency is improved.

Description

Application program exception testing method, device, equipment and storage medium
Technical Field
The invention relates to the field of artificial intelligence, in particular to an application program exception testing method, device, equipment and storage medium.
Background
The test script is an important technical means for realizing automatic testing, and a test engineer usually designs a test case by using methods such as an equivalence class division method, a boundary value analysis method and the like according to a service scene of a product, converts the test case into a corresponding test script through a code, and executes the test script to perform abnormal testing on the product so as to improve the quality of a software product.
The existing test scheme has low test efficiency because only the test result can be seen during testing and the whole test process cannot be recorded, thereby quickly positioning the abnormity.
Disclosure of Invention
The invention mainly aims to solve the problem of low accuracy of the existing test scheme.
The invention provides an exception testing method for an application program in a first aspect, which comprises the following steps:
performing script recording on each page in a target application program to obtain an initial script fragment file corresponding to each page, wherein the target application program is an application program to be tested, and each page in the target application program comprises a unique initial page number;
determining a plurality of service processes based on preset service requirements, wherein the service processes correspond to the initial page numbers;
receiving a script execution instruction input by a user, determining a target flow in the business flow according to the script execution instruction, and acquiring a target script fragment sequence corresponding to the target flow;
generating a target script based on the target script fragment sequence and preset public script data, wherein the public script data at least comprises screen capture script data for page screen capture;
and executing the target script to obtain a screenshot picture set corresponding to the target process, comparing each screenshot picture in the screenshot picture set with a preset standard picture corresponding to each screenshot picture, and determining an abnormal page in the target application program.
Optionally, in a first implementation manner of the first aspect of the present invention, the performing script recording on each page in the target application to obtain an initial script fragment file corresponding to each page includes:
performing event monitoring on each page in the target application program to obtain event information in each page, wherein the event information comprises the name of an event and the type of the event;
according to the name of the event, element capturing is carried out on the event, and element information in the event is obtained;
and generating an initial script fragment file corresponding to each page based on the type of the event, the element information and a preset script template.
Optionally, in a second implementation manner of the first aspect of the present invention, the generating an initial script fragment file corresponding to each page based on the type of the event, the element information, and a preset script template includes:
receiving a script recording instruction sent by a terminal, and constructing an initial array according to the script recording instruction;
adding the type of the event and the element information into the initial array to obtain a target array;
and generating an initial script fragment file corresponding to each page based on the target array and a preset script template.
Optionally, in a third implementation manner of the first aspect of the present invention, the determining, based on the preset service requirement, a plurality of service flows includes:
receiving a page layout instruction input by a user, and arranging a plurality of initial page numbers according to the page layout instruction to generate a plurality of page number sequences, wherein the page number sequences comprise a plurality of initial page numbers;
and determining a plurality of service flows according to the page number sequence, wherein the service flows correspond to the page number sequence one to one.
Optionally, in a fourth implementation manner of the first aspect of the present invention, the receiving a script execution instruction input by a user, determining a target process in the business process according to the script execution instruction, and acquiring a target script fragment sequence corresponding to the target process includes:
receiving a script execution instruction input by a user, extracting script execution parameters in the script execution instruction, and determining a target process in the business process according to the script execution parameters;
acquiring an initial page number corresponding to the target process, and searching a plurality of target script fragment files corresponding to the target process according to the initial page number corresponding to the target process;
and sequencing the target script fragment files based on the initial page number corresponding to the target flow to generate a target script fragment sequence.
Optionally, in a fifth implementation manner of the first aspect of the present invention, the generating a target script based on the target script fragment sequence and preset public script data includes:
performing data analysis on the target script fragment sequence to obtain a plurality of standard script data corresponding to the target script fragment sequence;
and writing the standard script data into a preset blank script, and writing preset public script data into the tail of each standard script data to obtain a target script.
Optionally, in a sixth implementation manner of the first aspect of the present invention, the comparing each screenshot picture in the screenshot picture set with a preset standard picture corresponding to each screenshot picture, and determining an abnormal page in the target application program includes:
calling a preset convolutional neural network, and respectively extracting the characteristics of each screenshot picture and a preset standard picture corresponding to each screenshot picture to obtain a first characteristic vector corresponding to each screenshot picture and a second characteristic vector corresponding to each preset standard picture;
calculating the distance between a first feature vector corresponding to each screen capture picture and a second feature vector corresponding to each preset standard picture based on an Euclidean distance algorithm, calculating the similarity between each screen capture picture and each preset standard picture based on the distance, and determining that a page corresponding to a target picture is an abnormal page in the target application program, wherein the similarity is smaller than a preset threshold value.
A second aspect of the present invention provides an exception testing apparatus for an application, including:
the script fragment recording module is used for performing script recording on each page in a target application program to obtain an initial script fragment file corresponding to each page, wherein the target application program is an application program to be tested, and each page in the target application program comprises a unique initial page number;
the flow determining module is used for determining a plurality of service flows based on preset service requirements, wherein the service flows correspond to the initial page numbers;
the sequence acquisition module is used for receiving a script execution instruction input by a user, determining a target flow in the business flow according to the script execution instruction, and acquiring a target script fragment sequence corresponding to the target flow;
the script generation module is used for generating a target script based on the target script fragment sequence and preset public script data, wherein the public script data at least comprises screen capture script data for page screen capture;
and the application testing module is used for executing the target script to obtain a screenshot picture set corresponding to the target process, comparing each screenshot picture in the screenshot picture set with a preset standard picture corresponding to each screenshot picture, and determining an abnormal page in the target application program.
Optionally, in a first implementation manner of the second aspect of the present invention, the script fragment recording module specifically includes:
the event monitoring unit is used for monitoring an event on each page in the target application program to obtain event information in each page, wherein the event information comprises the name of the event and the type of the event;
the element capturing unit is used for capturing the elements of the event according to the name of the event to obtain element information in the event;
and the generating unit is used for generating an initial script fragment file corresponding to each page based on the type of the event, the element information and a preset script template.
Optionally, in a second implementation manner of the second aspect of the present invention, the generating unit is specifically configured to:
receiving a script recording instruction sent by a terminal, and constructing an initial array according to the script recording instruction;
adding the type of the event and the element information into the initial array to obtain a target array;
and generating an initial script fragment file corresponding to each page based on the target array and a preset script template.
Optionally, in a third implementation manner of the second aspect of the present invention, the flow determining module specifically includes:
the layout unit is used for receiving a page layout instruction input by a user, and performing layout on a plurality of initial page numbers according to the page layout instruction to generate a plurality of page number sequences, wherein the page number sequences comprise a plurality of initial page numbers;
and the first determining unit is used for determining a plurality of service flows according to the page number sequence, wherein the service flows correspond to the page number sequence one to one.
Optionally, in a fourth implementation manner of the second aspect of the present invention, the sequence acquiring module specifically includes:
the second determining unit is used for receiving a script execution instruction input by a user, extracting script execution parameters in the script execution instruction, and determining a target process in the business process according to the script execution parameters;
the searching unit is used for acquiring an initial page number corresponding to the target process and searching a plurality of target script fragment files corresponding to the target process according to the initial page number corresponding to the target process;
and the sequencing unit is used for sequencing the target script fragment file based on the initial page number corresponding to the target flow to generate a target script fragment sequence.
Optionally, in a fifth implementation manner of the second aspect of the present invention, the script generating module specifically includes:
the data analysis unit is used for carrying out data analysis on the target script fragment sequence to obtain a plurality of standard script data corresponding to the target script fragment sequence;
and the data writing unit is used for writing the standard script data into a preset blank script and writing preset public script data into the tail of each standard script data to obtain a target script.
Optionally, in a sixth implementation manner of the second aspect of the present invention, the application test module specifically includes:
the characteristic extraction unit is used for calling a preset convolutional neural network, and respectively extracting the characteristics of each screenshot picture and a preset standard picture corresponding to each screenshot picture to obtain a first characteristic vector corresponding to each screenshot picture and a second characteristic vector corresponding to each preset standard picture;
and the similarity calculation unit is used for calculating the distance between a first feature vector corresponding to each screen capture picture and a second feature vector corresponding to each preset standard picture based on an Euclidean distance algorithm, calculating the similarity between each screen capture picture and each preset standard picture based on the distance, and determining a page corresponding to a target picture as an abnormal page in the target application program, wherein the target picture is the screen capture picture of which the similarity is smaller than a preset threshold value.
A third aspect of the present invention provides an exception testing apparatus for an application program, including: a memory and at least one processor, the memory having instructions stored therein; the at least one processor calls the instructions in the memory to cause the exception testing device of the application program to execute the exception testing method of the application program.
A fourth aspect of the present invention provides a computer-readable storage medium having stored therein instructions, which, when run on a computer, cause the computer to execute the above-described anomaly testing method for an application program.
In the technical scheme provided by the invention, each page in an application program is taken as a unit, script fragment files corresponding to each page are recorded, each script fragment file corresponds to the page number of each page one by one, then a plurality of service flows are determined based on service requirements, then an execution instruction input by a user is received, a service flow to be tested is determined, a script fragment sequence corresponding to the service flow to be tested is obtained, finally a script to be executed is generated according to the script fragment sequence and public script data containing screen capture logic, a corresponding screen capture picture is obtained by executing the script, and the screen capture picture is compared with a standard picture, so that an abnormal page in the application program is determined. According to the invention, the whole testing process is obtained by adding the screen capture logic during the page testing, and the screen capture picture is rapidly compared with the standard picture, so that the testing efficiency is improved.
Drawings
FIG. 1 is a diagram of a first embodiment of an exception testing method for an application program according to an embodiment of the present invention;
FIG. 2 is a diagram of a second embodiment of an exception testing method for an application according to an embodiment of the present invention;
FIG. 3 is a diagram of a third embodiment of an exception testing method for an application according to an embodiment of the present invention;
FIG. 4 is a diagram of a fourth embodiment of an exception testing method for an application according to the embodiment of the present invention;
FIG. 5 is a diagram of an embodiment of an exception testing apparatus for an application according to an embodiment of the present invention;
FIG. 6 is a diagram of another embodiment of an exception testing apparatus for an application according to an embodiment of the present invention;
fig. 7 is a schematic diagram of an embodiment of an exception testing apparatus for an application program according to an embodiment of the present invention.
Detailed Description
The embodiment of the invention provides an application program exception testing method, device, equipment and storage medium, and the testing efficiency is higher.
The terms "first," "second," "third," "fourth," and the like in the description and in the claims, as well as in the drawings, if any, are used for distinguishing between similar elements and not necessarily for describing a particular sequential or chronological order. It will be appreciated that the data so used may be interchanged under appropriate circumstances such that the embodiments described herein may be practiced otherwise than as specifically illustrated or described herein. Furthermore, the terms "comprises," "comprising," or "having," and any variations thereof, are intended to cover non-exclusive inclusions, 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.
For convenience of understanding, a detailed flow of an embodiment of the present invention is described below, and referring to fig. 1, an embodiment of an exception testing method for an application program in an embodiment of the present invention includes:
101. performing script recording on each page in a target application program to obtain an initial script fragment file corresponding to each page, wherein the target application program is an application program to be tested, and each page in the target application program comprises a unique initial page number;
it can be understood that the server records the script of the application program (software product) to be tested in units of each page, so as to obtain the script fragment file (composed of the code of the test logic) corresponding to each page. The server may be an independent server, or may be a cloud server that provides basic cloud computing services such as a cloud service, a cloud database, cloud computing, a cloud function, cloud storage, a Network service, cloud communication, a middleware service, a domain name service, a security service, a Content Delivery Network (CDN), and a big data and artificial intelligence platform.
Specifically, the recording of the script can be performed based on a script recording tool (e.g., Badboy), and each page has a unique page number, the server stores each script segment file in a preset database (object storage database), and adds an attribute corresponding to the page number to the script segment file, for example, the page number corresponding to the script segment file a is 1, the page number corresponding to the script segment file B is 2, and the page number corresponding to the script segment file C is 3; the script fragment file is used for recording relevant operation events (such as click events, scroll events, keyboard typing events, or more specific operation events) performed by a user on a page in the application program according to a preset test case. Specifically, for example, the application to be tested includes a login page, and for the login page, the script fragment file to be recorded needs to include a plurality of login-related events, such as a keyboard entry event (for inputting an account password), a click event (for submitting a form), and the like.
102. Determining a plurality of service flows based on preset service requirements, wherein the service flows correspond to the initial page numbers;
it can be understood that the business requirement is a functional requirement of a product, for example, a commodity ordering function, and the corresponding business process is a commodity ordering process T, where the commodity ordering process T includes a shopping cart page, a bill settlement page, and a payment page, and if the page number corresponding to the shopping cart page is 5, the page number corresponding to the bill settlement page is 6, and the page number corresponding to the payment page is 7, the commodity ordering process T is determined to be (5, 6, 7).
103. Receiving a script execution instruction input by a user, determining a target flow in a business flow according to the script execution instruction, and acquiring a target script fragment sequence corresponding to the target flow;
it can be understood that the script execution instruction is entered into a page or a command line in the terminal by the user according to the requirement, and the script execution instruction includes a script execution parameter, and the parameter is used for representing the service flow that the script needs to execute. The server receives the script execution instruction and determines the current business process, namely the target process, which needs to be executed according to the script execution parameters. Each business process is composed of pages in a plurality of application programs, and for each page in each application program, the server records scripts, namely each page corresponds to an initial script fragment file. The server firstly determines a plurality of page numbers corresponding to the current business process (target process) to be executed; next, the target script fragment files corresponding to each page number are obtained from the database, and then the initial script fragment files are sequenced in the order of the page numbers from small to large to generate a target script fragment sequence corresponding to the target process, for example, according to the target script fragment file a (the corresponding initial page number is 1), the target script fragment file b (the corresponding initial page number is 2), the target script fragment file c (the corresponding initial page number is 3), and the target script fragment file d (the corresponding initial page number is 4), the generated target script fragment sequence T is (a, b, c, d) in the order of the page numbers.
104. Generating a target script based on the target script fragment sequence and preset public script data, wherein the public script data at least comprises screen capture script data for page screen capture;
it can be understood that the target script fragment sequence includes a plurality of target script fragment files, the server first performs data parsing on the target script fragment sequence to obtain contents (i.e., code fragments) in each target script fragment file, then newly creates a blank script file, fills each code fragment obtained by parsing into the blank script file according to the sequence in the target script fragment sequence to obtain a standard script file, and finally adds common script data (code fragments corresponding to common script logic) into the standard script file, i.e., adds a code fragment corresponding to common script logic at the end of each code fragment in the standard script file. In order to improve the positioning efficiency of the problem, the common script logic at least comprises screen capture logic, and can also comprise other common script logic, such as time-consuming statistical logic. Specifically, for example, a, b, c, and d of the standard script file T are code segments corresponding to the target script segment file, a is a first code segment in the standard script file T, b is a second code segment in the standard script file T, and so on, and a code segment corresponding to the screen capture logic is e, then the common script logic is added to the standard script file T to obtain a target script T (a, e, b, e, c, e, d, and e), which means that after the execution of each page script is finished, page screen capture is performed once.
105. And executing the target script to obtain a screenshot picture set corresponding to the target process, comparing each screenshot picture in the screenshot picture set with a preset standard picture corresponding to each screenshot picture, and determining an abnormal page in the target application program.
It can be understood that, the server executes the target script, executes the test operation on each page of the target flow according to the recorded script logic according to the sequence of the page numbers, and after the recorded script logic is executed on each page, captures the execution result, and stores the captured image in the local storage of the terminal, for example, stores the captured image in the folder a, then obtains the standard picture (used for representing the correct execution result of the page) in the folder B, compares the two pictures, if the two pictures are the same, it is indicated that the current page in the target flow is not abnormal, and if the two pictures are different, it is indicated that the current page in the target flow is abnormal, thereby quickly locating the abnormal point of the software product, and improving the test efficiency.
It can be understood that the embodiment can perform image recognition on the screenshot picture and the standard picture based on the artificial intelligence technology, so as to perform quick comparison. 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.
In the embodiment, the screen capture logic is added during the page test, so that the whole test process is obtained, the screen capture picture is rapidly compared with the standard picture, and the test efficiency is improved.
Referring to fig. 2, a second embodiment of the exception testing method for an application program according to the embodiment of the present invention includes:
201. performing event monitoring on each page in a target application program to obtain event information in each page, wherein the target application program is an application program to be tested, each page in the target application program comprises a unique initial page number, and the event information comprises an event name and an event type;
it can be understood that the server performs event monitoring on each page in the application to be tested based on event driving, so as to obtain event information in each page. For each operation behavior which triggers a certain event, recording as an effective operation, and recording a series of operation behaviors, namely recording a series of event behaviors. For example, the information modification behavior of the user requires the user to click on the text box to generate a cursor, i.e., a click event, and also requires the user to manually input information (new password, confirm new password, etc.), i.e., a key-in (keyDown) event, and after the information is filled in, the user needs to click on a submit button, which is a click event, wherein in the case of a large form field, a scroll (scroll) event is also involved. The event information includes the name of the event, i.e., the name of the method called by the current document object model node (DOM node), which is usually defined by the developer, and the type of the event, i.e., a mouse event (clicking a left mouse button, double clicking a left mouse button, etc.), a keyboard event (typing, releasing, etc.), and the like.
202. According to the name of the event, performing element capture on each event to obtain element information in each event;
it is understood that the server performs positioning based on the document object model, and in particular, element information is mainly captured by a cascading style Selector (CSS Selector), and mainly includes a tag (tag), an attribute (attribute), text content (text), and a value (value).
203. Receiving a script recording instruction sent by a terminal, and constructing an initial array according to the script recording instruction;
it should be understood that the terminal sends a script recording instruction to the server based on the WebSocket communication protocol, and the server receives the script recording instruction and starts to record the script. The server initializes a blank array (initial array), i.e., a record queue, for recording information of the event object and element information.
204. Adding the type and element information of the event into the initial array to obtain a target array;
it will be appreciated that the server adds the type information and element information of the event to the initial array, thereby generating a target array for building the script file.
205. Generating an initial script fragment file corresponding to each page based on the target array and a preset script template;
it can be understood that, the data type and the filling position of the data to be used are pre-configured in the script model, and the server acquires the elements in the target array and fills the elements to the corresponding positions in the script template, thereby generating the initial script fragment file.
206. Determining a plurality of service flows based on preset service requirements, wherein the service flows correspond to the initial page numbers;
207. receiving a script execution instruction input by a user, determining a target flow in a business flow according to the script execution instruction, and acquiring a target script fragment sequence corresponding to the target flow;
208. generating a target script based on the target script fragment sequence and preset public script data, wherein the public script data at least comprises screen capture script data for page screen capture;
209. and executing the target script to obtain a screenshot picture set corresponding to the target process, comparing each screenshot picture in the screenshot picture set with a preset standard picture corresponding to each screenshot picture, and determining an abnormal page in the target application program.
Wherein, the steps 206-207 are similar to the steps 102-105 described above, and detailed description thereof is omitted here.
In this embodiment, a script fragment file recording process corresponding to a page is described in detail, and scripts are recorded on each page, so that a product is tested at a finer granularity, and the test precision is improved.
Referring to fig. 3, a third embodiment of the exception testing method for an application program according to the embodiment of the present invention includes:
301. performing script recording on each page in a target application program to obtain an initial script fragment file corresponding to each page, wherein the target application program is an application program to be tested, and each page in the target application program comprises a unique initial page number;
302. determining a plurality of service flows based on preset service requirements, wherein the service flows correspond to the initial page numbers;
wherein, the steps 301-302 are similar to the steps 101-102 described above, and detailed description thereof is omitted here.
303. Receiving a script execution instruction input by a user, extracting script execution parameters in the script execution instruction, and determining a target flow in a business flow according to the script execution parameters;
it is understood that, the user inputs a script execution instruction in the terminal, the script execution instruction includes an execution parameter of the script (such as a flow type of execution, an execution time, a storage location of a script log, etc.), and the server selects, according to the execution parameter, a service flow to be executed (i.e., a target flow) from the plurality of service flows.
304. Acquiring an initial page number corresponding to a target process, and searching a plurality of target script fragment files corresponding to the target process according to the initial page number corresponding to the target process;
it can be understood that the target process corresponds to a plurality of page numbers, each script fragment file also has a unique corresponding page number, and the server queries the corresponding initial script fragment file in the database according to the plurality of page numbers corresponding to the target process to obtain a plurality of target script fragment files.
305. Sequencing the target script fragment files based on the initial page numbers corresponding to the target process to generate a target script fragment sequence;
it is understood that the server sorts these initial script fragment files in the order of the page numbers in the target flow to generate a target script fragment sequence corresponding to the target flow, for example, the target flow a is (1,3,5), the target script fragment file a (corresponding to the initial page number of 3), the target script fragment file b (corresponding to the initial page number of 5), and the target script fragment file c (corresponding to the initial page number of 1), and the generated target script fragment sequence T is (c, a, b) in the order of the page numbers in the target flow a.
306. Performing data analysis on the target script fragment sequence to obtain a plurality of standard script data corresponding to the target script fragment sequence;
it can be understood that the target script fragment sequence includes a plurality of target script fragment files, and the server performs data analysis on the target script fragment sequence to obtain standard script data (i.e., code fragments) in each target script fragment file, where each script data is a test logic of each page in the target flow.
307. Writing the standard script data into a preset blank script, and writing preset public script data into the tail of each standard script data to obtain a target script, wherein the public script data at least comprises screen capture script data for page screen capture;
it can be understood that the common script data is not related to the test logic of the service, and is generally used to implement auxiliary functions in the test process, such as test time consumption statistics, test page counting, test page screenshot, and the like. The server sequentially writes a plurality of standard script data obtained by data analysis into a preset blank script, and then writes a piece of common script data at the end of each standard script data to obtain a target script, for example, there are standard script data a, standard script data B and standard script data C, after the blank script is written into the target script, a standard script T is obtained as (a, B, C), if the screen capture script data is e, after the screen capture script data is written into the standard script T, an obtained target script F is obtained as (a, e, B, e, C, e), that is, when each page test is finished, screen capture of a page is performed.
308. And executing the target script to obtain a screenshot picture set corresponding to the target process, comparing each screenshot picture in the screenshot picture set with a preset standard picture corresponding to each screenshot picture, and determining an abnormal page in the target application program.
Step 308 is similar to the step 105, and is not described herein again.
In this embodiment, a generation process of the target script is described in detail, and a screen capture logic is added after the target process corresponds to each script fragment file data, so that a screen capture process is performed once after each page is tested, and thus the whole process of the test is obtained.
Referring to fig. 4, a fourth embodiment of the exception testing method for an application program according to the embodiment of the present invention includes:
401. performing script recording on each page in a target application program to obtain an initial script fragment file corresponding to each page, wherein the target application program is an application program to be tested, and each page in the target application program comprises a unique initial page number;
402. determining a plurality of service flows based on preset service requirements, wherein the service flows correspond to the initial page numbers;
403. receiving a script execution instruction input by a user, determining a target flow in a business flow according to the script execution instruction, and acquiring a target script fragment sequence corresponding to the target flow;
404. generating a target script based on the target script fragment sequence and preset public script data, wherein the public script data at least comprises screen capture script data for page screen capture;
wherein, the steps 401-404 are similar to the steps 101-104 described above, and detailed description thereof is omitted here.
405. Executing a target script to obtain a screenshot picture set corresponding to a target process, calling a preset convolutional neural network, and respectively performing feature extraction on each screenshot picture in the screenshot picture set and a preset standard picture corresponding to each screenshot picture to obtain a first feature vector corresponding to each screenshot picture and a second feature vector corresponding to each preset standard picture;
it can be understood that after the target script is executed, each page is tested in sequence, and the test result of each page is subjected to screen capture, so that the screen capture picture set is generated and stored in the specified file directory. Each screenshot picture in the screenshot picture set has a corresponding preset standard picture, the two preset standard pictures correspond to the same page, namely the screenshot picture is an actual test result, and the preset standard picture is an ideal result.
Further, before feature extraction is carried out on the pictures, the server carries out binarization processing on each screen capture picture and a preset standard picture, so that only black pixels (marked by a number of '1') and white pixels (marked by a number of '0') are reserved in each picture. Preferably, the preset convolutional neural network includes two convolution kernels, the first convolution kernel is 1 × 1 in size and is used for performing dimensionality reduction processing on the feature vector, and the second convolution kernel is 3 × 3 in size and is used for amplifying the local feature. The server firstly adopts convolution kernels with the size of 3 × 3 to respectively perform convolution processing on each screen capture picture and the preset standard picture corresponding to each screen capture picture so as to obtain two corresponding high-dimensional feature vectors, secondly adopts convolution kernels with the size of 1 × 1 to perform convolution on the two high-dimensional feature vectors so as to reduce the dimensions of the two high-dimensional feature vectors, and obtains a first feature vector corresponding to each screen capture picture and a second feature vector corresponding to each preset standard picture.
406. Calculating the distance between a first characteristic vector corresponding to each screen capture picture and a second characteristic vector corresponding to each preset standard picture based on an Euclidean distance algorithm, calculating the similarity between each screen capture picture and each preset standard picture based on the distance, and determining that a page corresponding to a target picture is an abnormal page in a target application program, wherein the target picture is the screen capture picture of which the similarity is smaller than a preset threshold value.
It should be understood that the euclidean distance algorithm is used to calculate the distance between two locations in n-dimensional space (euclidean distance), and the calculation formula of euclidean distance refers to formula one:
Figure BDA0003219210720000121
for example, the first eigenvector corresponding to the screenshot picture A is (X: {10, 10, 2, 2, 10, 10, 2, 2, 10, 10}, Y: {8, 8, 6,6,6, 6,6,8,8}), the second eigenvector corresponding to the preset standard picture B is (X: {10, 10, 2, 2, 9, 10, 2, 2, 10, 10}, Y: {7, 8, 6,6,6, 6,6,6, 6,8,8}), and the Euclidean distance between the first eigenvector and the second eigenvector is calculated according to the Euclidean distance algorithm
Figure BDA0003219210720000125
Figure BDA0003219210720000122
The magnitude of the similarity is inversely proportional to the vector distance, and specifically, the formula for calculating the similarity refers to formula two:
Figure BDA0003219210720000123
according to the second formula, the similarity between the screenshot picture A and the preset standard picture B can be calculated
Figure BDA0003219210720000124
If the similarity s is smaller than a preset threshold (such as 0.5), determining that the two pictures are different, namely the real test result does not reach the expected ideal result, and determining that the page corresponding to the screenshot picture A is an abnormal page in the product.
In this embodiment, a process of comparing the screenshot picture with a preset standard picture and determining an abnormal page is described in detail, and whether the test result reaches an ideal test result is directly determined by calculating the similarity between the pictures. The process does not need manual supervision, reduces resource waste and errors caused by artificial subjective judgment, and improves the testing efficiency.
With reference to fig. 5, the method for testing the application program exception in the embodiment of the present invention is described above, and an exception testing apparatus for an application program in the embodiment of the present invention is described below, where an embodiment of the exception testing apparatus for an application program in the embodiment of the present invention includes:
the script fragment recording module 501 is configured to perform script recording on each page in a target application program to obtain an initial script fragment file corresponding to each page, where the target application program is an application program to be tested, and each page in the target application program includes a unique initial page number;
a flow determining module 502, configured to determine a plurality of service flows based on preset service requirements, where the service flows correspond to the plurality of initial page numbers;
a sequence obtaining module 503, configured to receive a script execution instruction input by a user, determine a target process in the business process according to the script execution instruction, and obtain a target script fragment sequence corresponding to the target process;
a script generating module 504, configured to generate a target script based on the target script fragment sequence and preset public script data, where the public script data at least includes screen capture script data for page screen capture;
and the application test module 505 is configured to execute the target script to obtain a screenshot picture set corresponding to the target process, compare each screenshot picture in the screenshot picture set with a preset standard picture corresponding to each screenshot picture, and determine an abnormal page in the target application program.
In the embodiment, the screen capture logic is added during the page test, so that the whole test process is obtained, the screen capture picture is rapidly compared with the standard picture, and the test efficiency is improved.
Referring to fig. 6, another embodiment of the exception testing apparatus for an application according to the embodiment of the present invention includes:
the script fragment recording module 501 is configured to perform script recording on each page in a target application program to obtain an initial script fragment file corresponding to each page, where the target application program is an application program to be tested, and each page in the target application program includes a unique initial page number;
a flow determining module 502, configured to determine a plurality of service flows based on preset service requirements, where the service flows correspond to the plurality of initial page numbers;
a sequence obtaining module 503, configured to receive a script execution instruction input by a user, determine a target process in the business process according to the script execution instruction, and obtain a target script fragment sequence corresponding to the target process;
a script generating module 504, configured to generate a target script based on the target script fragment sequence and preset public script data, where the public script data at least includes screen capture script data for page screen capture;
and the application test module 505 is configured to execute the target script to obtain a screenshot picture set corresponding to the target process, compare each screenshot picture in the screenshot picture set with a preset standard picture corresponding to each screenshot picture, and determine an abnormal page in the target application program.
The script fragment recording module 501 includes:
the event monitoring unit 5011 is configured to perform event monitoring on each page in the target application to obtain event information in each page, where the event information includes a name of an event and a type of the event;
the element capturing unit 5012 is configured to perform element capturing on the event according to the name of the event, so as to obtain element information in the event;
the generating unit 5013 is configured to generate an initial script fragment file corresponding to each page based on the type of the event, the element information, and a preset script template.
The generating unit 5013 is specifically configured to:
receiving a script recording instruction sent by a terminal, and constructing an initial array according to the script recording instruction;
adding the type of the event and the element information into the initial array to obtain a target array;
and generating an initial script fragment file corresponding to each page based on the target array and a preset script template.
The flow determining module 502 specifically includes:
the arranging unit 5021 is configured to receive a page arranging instruction input by a user, arrange a plurality of initial page numbers according to the page arranging instruction, and generate a plurality of page number sequences, where the page number sequences include the plurality of initial page numbers;
a first determining unit 5022, configured to determine multiple service flows according to the page number sequence, where the service flows correspond to the page number sequence one to one.
The sequence acquiring module 503 specifically includes:
a second determining unit 5031, configured to receive a script execution instruction input by a user, extract a script execution parameter in the script execution instruction, and determine a target process in the business process according to the script execution parameter;
a searching unit 5032, configured to obtain an initial page number corresponding to the target process, and search, according to the initial page number corresponding to the target process, a plurality of target script fragment files corresponding to the target process;
a sorting unit 5033, configured to sort the target script fragment file based on the initial page number corresponding to the target process, so as to generate a target script fragment sequence.
The script generating module 504 specifically includes:
a data analysis unit 5041, configured to perform data analysis on the target script fragment sequence to obtain multiple standard script data corresponding to the target script fragment sequence;
and the data writing unit 5042 is configured to write the standard script data into a preset blank script, and write preset public script data into the end of each standard script data to obtain a target script.
The application test module 505 specifically includes:
the feature extraction unit 5051 is configured to call a preset convolutional neural network, and perform feature extraction on each screenshot picture and a preset standard picture corresponding to each screenshot picture respectively to obtain a first feature vector corresponding to each screenshot picture and a second feature vector corresponding to each preset standard picture;
the similarity calculation unit 5052 is configured to calculate, based on an euclidean distance algorithm, a distance between a first feature vector corresponding to each screenshot picture and a second feature vector corresponding to each preset standard picture, calculate, based on the distance, a similarity between each screenshot picture and each preset standard picture, and determine that a page corresponding to a target picture is an abnormal page in the target application program, where the target picture is the screenshot picture of which the similarity is smaller than a preset threshold.
In the embodiment of the invention, the modularized design ensures that hardware of each part of the abnormality testing device of the application program is concentrated on realizing a certain function, the performance of the hardware is realized to the maximum extent, and meanwhile, the modularized design also reduces the coupling among the modules of the device, thereby being more convenient to maintain.
Fig. 5 and fig. 6 describe the exception testing apparatus of the application program in the embodiment of the present invention in detail from the perspective of the modular functional entity, and the exception testing apparatus of the application program in the embodiment of the present invention is described in detail from the perspective of hardware processing.
Fig. 7 is a schematic structural diagram of an exception testing apparatus 700 for an application according to an embodiment of the present invention, where the exception testing apparatus 700 for an application may have a relatively large difference due to different configurations or performances, and may include one or more processors (CPUs) 710 (e.g., one or more processors) and a memory 720, and one or more storage media 730 (e.g., one or more mass storage devices) for storing an application 733 or data 732. Memory 720 and storage medium 730 may be, among other things, transient storage or persistent storage. The program stored in the storage medium 730 may include one or more modules (not shown), each of which may include a series of instruction operations in the abnormality testing apparatus 700 for the application program. Further, the processor 710 may be configured to communicate with the storage medium 730 to execute a series of instruction operations in the storage medium 730 on the exception testing device 700 of the application program.
The exception testing apparatus 700 for an application may also include one or more power supplies 740, one or more wired or wireless network interfaces 750, one or more input-output interfaces 760, and/or one or more operating systems 731, such as Windows Server, Mac OS X, Unix, Linux, FreeBSD, etc. Those skilled in the art will appreciate that the application exception test facility configuration shown in FIG. 7 does not constitute a limitation of the application exception test facility and may include more or fewer components than those shown, or some components may be combined, or a different arrangement of components.
The invention further provides an exception testing device for an application program, which comprises a memory and a processor, wherein computer readable instructions are stored in the memory, and when the computer readable instructions are executed by the processor, the processor executes the steps of the exception testing method for the application program in the embodiments.
The present invention also provides a computer-readable storage medium, which may be a non-volatile computer-readable storage medium, and which may also be a volatile computer-readable storage medium, having stored therein instructions, which, when run on a computer, cause the computer to perform the steps of the anomaly testing method for the application program.
It is clear to those skilled in the art that, for convenience and brevity of description, the specific working processes of the above-described systems, apparatuses and units may refer to the corresponding processes in the foregoing method embodiments, and are not described herein again.
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 invention may be embodied in the form of a software product, which is stored in a storage medium and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: various media capable of storing program codes, 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 above-mentioned embodiments are only used for illustrating the technical solutions of the present invention, and not for limiting the same; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and such modifications or substitutions do not depart from the spirit and scope of the corresponding technical solutions of the embodiments of the present invention.

Claims (10)

1. An exception testing method for an application program, the exception testing method for the application program comprising:
performing script recording on each page in a target application program to obtain an initial script fragment file corresponding to each page, wherein the target application program is an application program to be tested, and each page in the target application program comprises a unique initial page number;
determining a plurality of service processes based on preset service requirements, wherein the service processes correspond to the initial page numbers;
receiving a script execution instruction input by a user, determining a target flow in the business flow according to the script execution instruction, and acquiring a target script fragment sequence corresponding to the target flow;
generating a target script based on the target script fragment sequence and preset public script data, wherein the public script data at least comprises screen capture script data for page screen capture;
and executing the target script to obtain a screenshot picture set corresponding to the target process, comparing each screenshot picture in the screenshot picture set with a preset standard picture corresponding to each screenshot picture, and determining an abnormal page in the target application program.
2. The method for testing the application program exception according to claim 1, wherein the script recording is performed on each page in the target application program, and obtaining an initial script fragment file corresponding to each page comprises:
performing event monitoring on each page in the target application program to obtain event information in each page, wherein the event information comprises the name of an event and the type of the event;
according to the name of the event, element capturing is carried out on the event, and element information in the event is obtained;
and generating an initial script fragment file corresponding to each page based on the type of the event, the element information and a preset script template.
3. The method for testing the application program exception according to claim 2, wherein the generating an initial script fragment file corresponding to each page based on the type of the event, the element information and a preset script template comprises:
receiving a script recording instruction sent by a terminal, and constructing an initial array according to the script recording instruction;
adding the type of the event and the element information into the initial array to obtain a target array;
and generating an initial script fragment file corresponding to each page based on the target array and a preset script template.
4. The method for testing the application program for the abnormality according to claim 1, wherein the determining a plurality of business processes based on the preset business requirements includes:
receiving a page layout instruction input by a user, and arranging a plurality of initial page numbers according to the page layout instruction to generate a plurality of page number sequences, wherein the page number sequences comprise a plurality of initial page numbers;
and determining a plurality of service flows according to the page number sequence, wherein the service flows correspond to the page number sequence one to one.
5. The method for testing the application program exception according to claim 1, wherein the receiving a script execution instruction input by a user, determining a target flow in the business flow according to the script execution instruction, and acquiring a target script fragment sequence corresponding to the target flow comprises:
receiving a script execution instruction input by a user, extracting script execution parameters in the script execution instruction, and determining a target process in the business process according to the script execution parameters;
acquiring an initial page number corresponding to the target process, and searching a plurality of target script fragment files corresponding to the target process according to the initial page number corresponding to the target process;
and sequencing the target script fragment files based on the initial page number corresponding to the target flow to generate a target script fragment sequence.
6. The method for testing the application program for the exception as claimed in claim 1, wherein the generating the object script based on the object script fragment sequence and the preset common script data comprises:
performing data analysis on the target script fragment sequence to obtain a plurality of standard script data corresponding to the target script fragment sequence;
and writing the standard script data into a preset blank script, and writing preset public script data into the tail of each standard script data to obtain a target script.
7. The method for testing the abnormality of the application program according to any one of claims 1 to 6, wherein the step of comparing each screenshot picture in the screenshot picture set with a preset standard picture corresponding to each screenshot picture to determine the abnormal page in the target application program includes:
calling a preset convolutional neural network, and respectively extracting the characteristics of each screenshot picture and a preset standard picture corresponding to each screenshot picture to obtain a first characteristic vector corresponding to each screenshot picture and a second characteristic vector corresponding to each preset standard picture;
calculating the distance between a first feature vector corresponding to each screen capture picture and a second feature vector corresponding to each preset standard picture based on an Euclidean distance algorithm, calculating the similarity between each screen capture picture and each preset standard picture based on the distance, and determining that a page corresponding to a target picture is an abnormal page in the target application program, wherein the similarity is smaller than a preset threshold value.
8. An exception testing apparatus for an application program, the exception testing apparatus comprising:
the script fragment recording module is used for performing script recording on each page in a target application program to obtain an initial script fragment file corresponding to each page, wherein the target application program is an application program to be tested, and each page in the target application program comprises a unique initial page number;
the flow determining module is used for determining a plurality of service flows based on preset service requirements, wherein the service flows correspond to the initial page numbers;
the sequence acquisition module is used for receiving a script execution instruction input by a user, determining a target flow in the business flow according to the script execution instruction, and acquiring a target script fragment sequence corresponding to the target flow;
the script generation module is used for generating a target script based on the target script fragment sequence and preset public script data, wherein the public script data at least comprises screen capture script data for page screen capture;
and the application testing module is used for executing the target script to obtain a screenshot picture set corresponding to the target process, comparing each screenshot picture in the screenshot picture set with a preset standard picture corresponding to each screenshot picture, and determining an abnormal page in the target application program.
9. An abnormality testing device of an application program, characterized in that the abnormality testing device of the application program comprises: a memory and at least one processor, the memory having instructions stored therein;
the at least one processor invoking the instructions in the memory to cause the application program exception testing apparatus to perform the application program exception testing method of any of claims 1-7.
10. A computer-readable storage medium having instructions stored thereon, wherein the instructions, when executed by a processor, implement a method for anomaly testing of an application program according to any one of claims 1-7.
CN202110952881.7A 2021-08-19 2021-08-19 Application program exception testing method, device, equipment and storage medium Pending CN113468076A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110952881.7A CN113468076A (en) 2021-08-19 2021-08-19 Application program exception testing method, device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110952881.7A CN113468076A (en) 2021-08-19 2021-08-19 Application program exception testing method, device, equipment and storage medium

Publications (1)

Publication Number Publication Date
CN113468076A true CN113468076A (en) 2021-10-01

Family

ID=77866736

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110952881.7A Pending CN113468076A (en) 2021-08-19 2021-08-19 Application program exception testing method, device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN113468076A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114153726A (en) * 2021-11-25 2022-03-08 麒麟软件有限公司 Login test method and device based on linux desktop operating system

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112306893A (en) * 2020-11-27 2021-02-02 平安普惠企业管理有限公司 UI page testing method and device, computer equipment and storage medium
CN112597016A (en) * 2020-12-17 2021-04-02 平安普惠企业管理有限公司 Recording method, device and equipment of automatic test script and storage medium
CN112988578A (en) * 2021-03-10 2021-06-18 中国建设银行股份有限公司 Automatic testing method and device

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112306893A (en) * 2020-11-27 2021-02-02 平安普惠企业管理有限公司 UI page testing method and device, computer equipment and storage medium
CN112597016A (en) * 2020-12-17 2021-04-02 平安普惠企业管理有限公司 Recording method, device and equipment of automatic test script and storage medium
CN112988578A (en) * 2021-03-10 2021-06-18 中国建设银行股份有限公司 Automatic testing method and device

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114153726A (en) * 2021-11-25 2022-03-08 麒麟软件有限公司 Login test method and device based on linux desktop operating system
CN114153726B (en) * 2021-11-25 2024-05-17 麒麟软件有限公司 Login test method and device based on linux desktop operating system

Similar Documents

Publication Publication Date Title
EP3588279B1 (en) Automated extraction of rules embedded in software application code using machine learning
CN109062780B (en) Development method of automatic test case and terminal equipment
CN110471945B (en) Active data processing method, system, computer equipment and storage medium
CN111552633A (en) Interface abnormal call testing method and device, computer equipment and storage medium
CN109241014B (en) Data processing method and device and server
CN113626241B (en) Abnormality processing method, device, equipment and storage medium for application program
US20230004979A1 (en) Abnormal behavior detection method and apparatus, electronic device, and computer-readable storage medium
CN109285024B (en) Online feature determination method and device, electronic equipment and storage medium
CN111783415B (en) Template configuration method and device
US11822578B2 (en) Matching machine generated data entries to pattern clusters
CN113468076A (en) Application program exception testing method, device, equipment and storage medium
CN112395182A (en) Automatic testing method, device, equipment and computer readable storage medium
CN112416800A (en) Intelligent contract testing method, device, equipment and storage medium
CN112711678A (en) Data analysis method, device, equipment and storage medium
CN110716778A (en) Application compatibility testing method, device and system
CN115203057B (en) Low code test automation method, device, equipment and storage medium
CN111770080A (en) Method and device for recovering device fingerprint
CN113722203A (en) Program testing method and device, electronic device and computer readable storage medium
CN113159951B (en) Financial data clearing method, device, equipment and storage medium
CN110705382A (en) Electronic invoice management method, device, equipment and medium based on invoice categories
CN113535594B (en) Method, device, equipment and storage medium for generating service scene test case
CN117873899B (en) Automatic testing method and device for UI interface, terminal equipment and storage medium
US11507728B2 (en) Click to document
CN114943212A (en) Parameter report generation method and related equipment thereof
CN116205450A (en) Demand analysis method, device, 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