CN113986767A - Automated testing method, system, device and computer readable storage medium - Google Patents
Automated testing method, system, device and computer readable storage medium Download PDFInfo
- Publication number
- CN113986767A CN113986767A CN202111433134.9A CN202111433134A CN113986767A CN 113986767 A CN113986767 A CN 113986767A CN 202111433134 A CN202111433134 A CN 202111433134A CN 113986767 A CN113986767 A CN 113986767A
- Authority
- CN
- China
- Prior art keywords
- control
- test
- target
- identification function
- label
- 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
Links
- 238000012360 testing method Methods 0.000 title claims abstract description 240
- 230000006870 function Effects 0.000 claims abstract description 153
- 238000013515 script Methods 0.000 claims abstract description 52
- 238000012545 processing Methods 0.000 claims abstract description 16
- 238000010998 test method Methods 0.000 claims abstract description 15
- 238000007306 functionalization reaction Methods 0.000 claims description 12
- 238000004422 calculation algorithm Methods 0.000 claims description 8
- 230000003044 adaptive effect Effects 0.000 claims description 5
- 238000000034 method Methods 0.000 abstract description 28
- 230000008569 process Effects 0.000 abstract description 14
- 230000007246 mechanism Effects 0.000 abstract description 13
- 238000005516 engineering process Methods 0.000 abstract description 12
- 238000011161 development Methods 0.000 description 9
- 238000004891 communication Methods 0.000 description 6
- 238000012423 maintenance Methods 0.000 description 6
- 238000004590 computer program Methods 0.000 description 5
- 230000005540 biological transmission Effects 0.000 description 4
- 230000008859 change Effects 0.000 description 4
- 238000010586 diagram Methods 0.000 description 4
- 230000009471 action Effects 0.000 description 3
- 238000004364 calculation method Methods 0.000 description 3
- 230000007547 defect Effects 0.000 description 2
- 238000011022 operating instruction Methods 0.000 description 2
- 230000008439 repair process Effects 0.000 description 2
- 230000002159 abnormal effect Effects 0.000 description 1
- 238000004458 analytical method Methods 0.000 description 1
- 238000013459 approach Methods 0.000 description 1
- 238000013473 artificial intelligence Methods 0.000 description 1
- 238000012790 confirmation Methods 0.000 description 1
- 238000012986 modification Methods 0.000 description 1
- 230000004048 modification Effects 0.000 description 1
- 230000003287 optical effect Effects 0.000 description 1
- 230000003068 static effect Effects 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Preventing errors by testing or debugging software
- G06F11/3668—Software testing
- G06F11/3672—Test management
- G06F11/3684—Test management for test design, e.g. generating new test cases
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Preventing errors by testing or debugging software
- G06F11/3668—Software testing
- G06F11/3672—Test management
- G06F11/3688—Test management for test execution, e.g. scheduling of test suites
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Computer Hardware Design (AREA)
- Quality & Reliability (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Debugging And Monitoring (AREA)
Abstract
The invention relates to the technical field of financial technology (Fintech). The invention discloses an automatic test method, a system, equipment and a computer readable storage medium.A general identification mechanism is formulated, firstly, the related control to be tested is subjected to functional processing according to an adaptability principle and a control identification function is predefined, and then, in the actual test process, the control identification function is called according to the specific control parameter in the actual operation instruction, so that the control identification function can identify the target operation control which needs to execute the operation instruction in a page, and does not depend on a tedious object library, thereby removing the huge workload of continuously maintaining the traditional object library; finally, corresponding test operation is carried out on the target operation control according to the operation instruction, the professional requirement on automatic testers can be reduced, and manual testers can write the automatic test scripts by using a mode of learning and editing the operation instruction, so that the labor cost of the automatic testers is greatly reduced.
Description
Technical Field
The invention relates to the technical field of financial technology (Fintech), in particular to an automatic testing method, system, equipment and a computer readable storage medium.
Background
With the development of computer technology, more and more technologies (big data, distributed, Blockchain, artificial intelligence, etc.) are applied to the financial field, and the traditional financial industry is gradually changing to financial technology (Fintech), but because of the requirements of security and real-time performance of the financial industry, higher requirements are also put forward on the automatic testing technology.
Among the WEB tests in the current market, the most common automated test method is as follows: and storing the page object to an object library set, finding a control in the test page through the object library attribute, and implementing test operation according to test instruction input, clicking and selection. However, with the increase of software complexity, the development technology is continuously updated iteratively, and the workload and difficulty of maintaining the automatic test script are also continuously increased. Specifically, the maintenance cost of the automated object library is very high, and when the attribute of a test page changes due to defect repair, version release, and the like, a failed object needs to be updated again to the scanning library, and when the test page is in the face of a huge amount of spatial data, a large amount of labor cost needs to be consumed for updating, and the generation frequency of the phenomenon is very high. Therefore, if a software program wants to maintain a set of continuously available automatic test case reference libraries, the labor cost is enormous. The problem that the labor cost for maintaining the existing automatic test scripts is high is reflected.
Disclosure of Invention
The invention mainly aims to provide an automatic test method, an automatic test system, automatic test equipment and a computer readable storage medium, and aims to solve the technical problem of high labor cost of the conventional automatic test script maintenance.
In order to achieve the above object, the present invention provides an automatic testing method, which includes:
acquiring a test script associated with a target test page, and accessing the target test page based on the test script, wherein the test script comprises an operation instruction for indicating test content;
calling a preset control identification function according to the control parameters in the operation instruction so as to identify a target operation control matched with the control parameters in the target test page, wherein each control in the target test page is subjected to functionalization processing adaptive to the control identification function;
and executing the specified test operation in the operation instruction on the target operation control by executing the operation instruction.
Optionally, the control identification function comprises a first identification function and a second identification function, the control parameters comprise a control label,
the step of calling a preset control identification function according to the control parameter in the operation instruction to identify the target operation control matched with the control parameter in the target test page comprises the following steps:
calling a first recognition function and a second recognition function according to the control label in the operation instruction;
identifying all operation controls and label type controls corresponding to the control labels from the target test page by calling the first identification function, wherein the first identification function is matched with all the operation controls and the label type controls;
and determining the operation control which is closest to the label type control in all the operation controls by using a preset control identification algorithm through calling the second identification function to serve as the target operation control.
Optionally, the step of determining, by calling the second recognition function and using a preset control recognition algorithm, an operation control closest to the label type control in all the operation controls as the target operation control includes:
acquiring label pixel positioning coordinates of the label type control and a plurality of operation pixel positioning coordinates of the operation control set by calling the second identification function;
obtaining the pixel bit distance of each operation control to the label type control according to the absolute value of the difference between each operation pixel positioning coordinate and the label pixel positioning coordinate;
finding out a minimum value from the pixel bit distances, and taking an operation control corresponding to the minimum value as the target operation control.
Optionally, the first identification function comprises a label identification function and an operation identification function, the target test page comprises a plurality of operation controls,
the step of identifying all the operation controls and the label type controls corresponding to the control labels from the target test page by calling the first identification function comprises:
identifying a label type control with label content consistent with the label of the control from the target test page by calling the label identification function, wherein the function initialization attribute of the label type control corresponds to a basic main parameter of the label identification function;
and identifying a plurality of operation controls contained in the target test page as an operation control set by calling an operation identification function, wherein the function initialization attribute of the operation control corresponds to a basic main parameter of the operation identification function.
Optionally, before the step of obtaining the test script associated with the target test page, the method further includes:
constructing a basic control class, and defining a plurality of control types in the basic control class, wherein the control types cover the types of the controls in the target test page;
and initializing the control attribute of each control type to finish the functionalization processing of the control.
Optionally, the specified test operation comprises an input operation, the target operation control comprises an input box control,
the step of executing the specified test operation in the operation instruction on the target operation control by executing the operation instruction comprises:
executing the operation instruction to write the control value in the operation instruction into the input box control.
Optionally, before the step of obtaining the test script associated with the target test page, the method further includes:
and acquiring test content information, and converting the test content information into the operation instruction according to a preset operation instruction specification.
In addition, to achieve the above object, the present invention further provides an automated testing system, including:
the target page access module is used for acquiring a test script associated with a target test page and accessing the target test page based on the test script, wherein the test script comprises an operation instruction for indicating test content;
the target control identification module is used for calling a preset control identification function according to the control parameters in the operation instruction so as to identify the target operation control matched with the control parameters in the target test page, wherein each control in the target test page is subjected to functionalization treatment adaptive to the control identification function;
and the test operation execution module is used for executing the specified test operation in the operation instruction on the target operation control by executing the operation instruction.
In addition, to achieve the above object, the present invention also provides an automated test apparatus, including: the system comprises a memory, a processor and an automated test program stored on the memory and executable on the processor, wherein the automated test program when executed by the processor implements the steps of the automated test method as described above.
In addition, to achieve the above object, the present invention further provides a computer readable storage medium having an automated testing program stored thereon, which, when executed by a processor, implements the steps of the automated testing method as described above.
Furthermore, to achieve the above object, the present invention also provides a computer program product comprising a computer program, which when executed by a processor, performs the steps of the automated testing method as described above.
According to the method, a universal identification mechanism is formulated, firstly, the control related to the test is subjected to functional processing according to an adaptability principle, a control identification function is predefined, then, in the actual test process, a preset control identification function is called according to specific control parameters in an actual operation instruction, so that the control identification function can identify a target operation control needing to execute the operation instruction in a page, even if the attribute of the control in the page changes, the control is subjected to functional processing, the identification mechanism is not affected, a complicated object library is not relied on, and the huge workload of continuously maintaining the traditional object library is eliminated; finally, corresponding test operation is carried out on the target operation control according to the operation instruction, so that a test script task for testing the control of the target test page is completed, the professional requirements on automatic testers are reduced, the automatic testers do not need to be test technicians, the traditional manual testers can complete writing of the automatic test script by using a mode of learning and editing the operation instruction (grammar is simpler) even though the traditional manual testers cannot test the development technology, and the function of general identification only needs to be maintained by individual high-level test development technicians, so that the labor cost of the automatic testers is greatly reduced, and the technical problem of high labor cost of maintenance of the automatic test script for the page control in the prior art is solved.
Drawings
FIG. 1 is a schematic diagram of an apparatus architecture of a hardware operating environment according to an embodiment of the present invention;
FIG. 2 is a schematic flow chart of a first embodiment of an automated testing method according to the present invention;
FIG. 3 is a schematic diagram of a test page in an embodiment of the automated testing method of the present invention;
FIG. 4 is a flow chart of the preamble steps of a third embodiment of the automated testing method of the present invention;
FIG. 5 is a functional block diagram of an automated test system according to the present invention.
The implementation, functional features and advantages of the objects of the present invention will be further explained with reference to the accompanying drawings.
Detailed Description
It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
Among the WEB tests in the current market, the most common automated test method is as follows: and storing the page object to an object library set, finding a control in the test page through the object library attribute, and implementing test operation according to test instruction input, clicking and selection. However, with the increase of software complexity, the development technology is continuously updated iteratively, and the workload and difficulty of maintaining the automatic test script are also continuously increased. Specifically, the maintenance cost of the automated object library is very high, and when the attribute of a test page changes due to defect repair, version release, and the like, a failed object needs to be updated again to the scanning library, and when the test page is in the face of a huge amount of spatial data, a large amount of labor cost needs to be consumed for updating, and the generation frequency of the phenomenon is very high. Therefore, if a software program wants to maintain a set of continuously available automatic test case reference libraries, the labor cost is enormous. The problem that the labor cost for maintaining the existing automatic test scripts is high is reflected.
In order to solve the problems, the invention provides an automatic test method, namely, a universal identification mechanism is formulated, firstly, a control related to the test is subjected to functional processing according to an adaptability principle and a control identification function is predefined, then, in the actual test process, a preset control identification function is called according to specific control parameters in an actual operation instruction, so that the control identification function can identify a target operation control needing to execute the operation instruction in a page, even if the attribute of the control in the page changes, the control is subjected to functional processing, so that the identification mechanism is not influenced, a complicated object library is not relied on, and huge workload for continuously maintaining the traditional object library is removed; finally, corresponding test operation is carried out on the target operation control according to the operation instruction, so that a test script task for testing the control of the target test page is completed, the professional requirements on automatic testers are reduced, the automatic testers do not need to be test technicians, the traditional manual testers can complete writing of the automatic test script by using a mode of learning and editing the operation instruction (grammar is simpler) even though the traditional manual testers cannot test the development technology, and the function of general identification only needs to be maintained by individual high-level test development technicians, so that the labor cost of the automatic testers is greatly reduced, and the technical problem of high labor cost of maintenance of the automatic test script for the page control in the prior art is solved.
As shown in fig. 1, fig. 1 is a schematic device structure diagram of a hardware operating environment according to an embodiment of the present invention.
As shown in fig. 1, the automated test system may include: a processor 1001, such as a CPU, a user interface 1003, a network interface 1004, a memory 1005, a communication bus 1002. Wherein a communication bus 1002 is used to enable connective communication between these components. The user interface 1003 may include a Display screen (Display), an input unit such as a Keyboard (Keyboard), and the optional user interface 1003 may also include a standard wired interface, a wireless interface. The network interface 1004 may optionally include a standard wired interface, a wireless interface (e.g., WI-FI interface). The memory 1005 may be a high-speed RAM memory or a non-volatile memory (e.g., a magnetic disk memory). The memory 1005 may alternatively be a storage device separate from the processor 1001.
Those skilled in the art will appreciate that the configuration of the apparatus shown in fig. 1 is not intended to be limiting of the apparatus and may include more or fewer components than those shown, or some components may be combined, or a different arrangement of components.
As shown in fig. 1, a memory 1005, which is one type of computer storage medium, may include therein an operating system, a network communication module, a user interface module, and an automation test program.
In the device shown in fig. 1, the network interface 1004 is mainly used for connecting to a backend server and performing data communication with the backend server; the user interface 1003 is mainly used for connecting a client (programmer's end) and performing data communication with the client; and the processor 1001 may be configured to invoke the automated test program stored in the memory 1005 and perform the operations of the automated test method described below.
Based on the hardware structure, the embodiment of the automatic testing method is provided.
Referring to fig. 2, fig. 2 is a flowchart illustrating an automated testing method according to a first embodiment of the present invention. The automatic test method comprises the following steps of;
step S10, obtaining a test script associated with a target test page, and accessing the target test page based on the test script, wherein the test script comprises an operation instruction for indicating test content;
in the present embodiment, the present invention is applied to a terminal device. The target test page refers to a WEB page of a software project aimed at by the current WEB test task. The test script refers to a series of instructions for performing corresponding test operations on a target test page, which may be executed by an automated test tool. The test scripts can be created (recorded) or automatically generated using a test automation tool, or can be implemented using programming language programming, or can be implemented by combining the first three approaches. The operation instruction refers to an instruction in the test script for instructing what kind of test operation is performed on the operation control in the page, and needs to be written according to a certain format specification, one test script usually includes a plurality of operation instructions, and each operation instruction is usually executed according to a sequence specified by the script. The test script may be associated with a target test page to which the test script is directed after being generated, for example, an address of a software project where the test script is located is specified in the test script, or a unique identifier of the software project is added to a correlation of the test script, and the like.
Specifically, after the terminal generates and stores the test script, if an automation test instruction is received, the software item address pointed by the automation test instruction is determined, and then the test script associated with the software item address is called from the memory area of the test script. The terminal firstly opens the browser through the test script, and then opens the associated project website (for example, the uniform resource locator address of the software project) on the browser to access the target test page corresponding to the website.
Step S20, calling a preset control identification function according to the control parameters in the operation instruction to identify a target operation control matched with the control parameters in the target test page, wherein each control in the target test page is subjected to functionalization adaptive to the control identification function;
and step S30, executing a specified test operation in the operation instruction on the target operation control by executing the operation instruction.
In this embodiment, the control refers to a front-end language generation object of the browser presentation. Control parameters refer to incoming parameters in the operating instructions that are related to the control. The control identification function is a predefined function used for identifying a target control in the page, and the definition mode of the function is matched with the functionalization mode of the control. The target operation control refers to an operation control corresponding to an operation instruction in a target test page, and different operation instructions may respectively correspond to different target operation controls or may correspond to the same target operation control. The operation control refers to a control corresponding to a control parameter in the page, and has operability, for example, when the control parameter is a name tag, the operation control is a text box control capable of inputting content. The functionalization processing of the control refers to the definition of a function module for the control. The specified test operation refers to an operation, such as a write operation, a click operation and the like, which is performed on the target operation control and is indicated by the operation instruction.
Specifically, the terminal calls a control identification function according to a control parameter in the operation instruction, so as to identify and position a target operation control matched with the control parameter in a current target test page based on the control identification function, and after the target operation control is positioned, the test operation indicated by the operation instruction can be executed on the target operation control. If a plurality of operation instructions with the execution sequence are recorded in the test script, the terminal calls the control identification function in sequence to position a plurality of target operation controls corresponding to each operation instruction in the target test page, and then executes corresponding test operations on the plurality of target operation controls in sequence according to the sequence. After the test operation is executed, the terminal can detect the page change so as to judge whether the function of the test software is in accordance with the expectation or not and generate a test result so as to finish the automatic test.
The embodiment provides an automatic testing method. The automatic test method comprises the steps of formulating a universal identification mechanism, firstly carrying out functional processing on a control related to test according to an adaptability principle and predefining a control identification function, and then calling a preset control identification function according to specific control parameters in an actual operation instruction in an actual test process, so that the control identification function can identify a target operation control needing to execute the operation instruction in a page, and even if the attribute of the control in the page changes, the control is subjected to functional processing, so that the identification mechanism is not influenced, a complicated object library is not relied on, and huge workload for continuously maintaining the traditional object library is removed; finally, corresponding test operation is carried out on the target operation control according to the operation instruction, so that a test script task for testing the control of the target test page is completed, the professional requirements on automatic testers are reduced, the automatic testers do not need to be test technicians, the traditional manual testers can complete writing of the automatic test script by using a mode of learning and editing the operation instruction (grammar is simpler) even though the traditional manual testers cannot test the development technology, and the function of general identification only needs to be maintained by individual high-level test development technicians, so that the labor cost of the automatic testers is greatly reduced, and the technical problem of high labor cost of maintenance of the automatic test script for the page control in the prior art is solved.
Further, based on the first embodiment shown in fig. 2, a second embodiment of the automated testing method of the present invention is provided. In this embodiment, the control identification function includes a first identification function and a second identification function, the control parameter includes a control label, and step S20 includes:
step S21, calling a first recognition function and a second recognition function according to the control label in the operation instruction;
step S22, identifying all operation controls and label type controls corresponding to the control labels from the target test page by calling the first identification function, wherein the first identification function is adapted to all operation controls and the label type controls;
step S23, determining, by calling the second recognition function, an operation control closest to the label type control in all the operation controls by using a preset control recognition algorithm, so as to serve as the target operation control.
In this embodiment, the first identification function refers to a functional module that identifies a control in the target test page. The second recognition function refers to a functional block that performs pixel calculation on the recognition result. The first identification function and the second identification function are both public functions.
The terminal calls a first identification function through a control label in the operation instruction, and locates a label type control uniquely corresponding to the control label in the page and all operation controls (such as input frame type controls) corresponding to the control label in the page, wherein the number of the operation controls may be one or more. After the control is identified, the terminal continues to call the second identification function so as to determine one operation control which is closest to the label type control and serves as a target operation control of the operation instruction.
According to the embodiment, the attribute of the control is functionalized according to a set of universal control identification mechanism, a tedious object library is not required, and huge workload for continuously maintaining the traditional object library is eliminated.
Further, step S22 includes:
step S221, acquiring label pixel positioning coordinates of the label type control and a plurality of operation pixel positioning coordinates of the operation control set by calling the second identification function;
step S222, obtaining the pixel bit distance of each operation control to the label type control according to the absolute value of the difference between each operation pixel positioning coordinate and the label pixel positioning coordinate;
step S223, finding out a minimum value from the pixel bit distances, and taking the operation control corresponding to the minimum value as the target operation control.
In this embodiment, the tag pixel location coordinate includes a tag pixel abscissa and a tag pixel ordinate, and similarly, the operation pixel location coordinate also includes an operation pixel abscissa and an operation pixel ordinate. The coordinates all use the same point in the WEB page as the origin of coordinates, for example, the upper left edge focus of the WEB page.
As a specific embodiment, according to the identification process of the name input box type control in the WEB page shown in fig. 3, the operation instruction is: the SetKey refers to a specific execution action "input", the "name" refers to a control identification Label (i.e., the control Label), and "zhang san" is a specific control input value. The second identification function is a predefined specifiyobject public function, and is used for further identifying the operation control with the minimum pixel position difference value of the label type control as the target operation control. The basic main parameters of the SpecifyObject public function are Parent, ClassName, TextView and Assignment, wherein the 'Parent' is the basic main version type for distinguishing the identified page, such as IE and other client-side application programs; the ClassName is the operation control type distinguished and identified, and the function mainly plays a role in reference transmission and has no defined logic; the TextView is used for distinguishing the label content when the control is specifically identified, and takes the transmission reference of the operation instruction as the standard, specifically, the operation instruction is a name label in the embodiment, and the function mainly plays a transmission reference role and has no defined logic.
According to an operation control set (namely, each input box control in the figure) identified by a first identification function, acquiring pixel bit abs _ x and abs _ y numerical values (namely, numerical values of abscissa and ordinate of the operation pixel) of each operation control in the set, caching the numerical values, and then calculating logic according to the pixel bits, namely: taking an absolute value of a difference between Abs _ x (the abscissa of the label pixel) of the label type control (i.e., the name label in the figure) and Abs _ x of each operation control, and multiplying the absolute value of a difference between Abs _ y of the label type control and Abs _ y of each operation control to obtain a set of set values, i.e., set values of pixel bit distances between the name label control and each input box control, wherein the input box control corresponding to the minimum value in the set values is the operation control closest to the name label according to a basic principle that two points are closest to a straight line and the closest distance value is the smallest. In addition, the function also calls a private function ThrowError for exception error throwing.
The embodiment further discloses a specific implementation logic of pixel position calculation, so that the system can position the target operation control corresponding to each operation instruction according to the logic, the positioning of the target control can be completed quickly and accurately without burdening a huge object library and a heavy work task of updating the object library, and meanwhile, the influence of the change of the control attribute is avoided.
Further, the first identification function includes a tag identification function and an operation identification function, the target test page includes a plurality of operation controls, and step S21 includes:
step S211, identifying a label type control with label content consistent with the label of the control from the target test page by calling the label identification function, wherein the function initialization attribute of the label type control corresponds to a basic main parameter of the label identification function;
step S212, identifying a plurality of operation controls included in the target test page as an operation control set by calling an operation identification function, where a function initialization attribute of the operation control corresponds to a basic main parameter of the operation identification function.
In this embodiment, fig. 3 is still used as an example. Before step S10, a GetOb common function is defined as a tag identification function, and the unique identification of the first layer of the control is mainly made according to the tag, and the basic main parameters are Parent, ClassName, and TextView, where "Parent" is the basic main version type for distinguishing the identified page, such as IE, other client application programs; "ClassName" is to distinguish the operation control type that is discerned, this embodiment takes the input box as an example, the case branch of ClassName only defines the input box type EditType, and at the same time defines the value of the attribute "webclass" as "Static"; the "TextView" is a Label tag parameter for distinguishing a specific identification control, and the value of the attribute "text" is defined as "TextView", that is, a name, based on the reference of the operation instruction, that is, the name tag of the embodiment. The function is mainly applied to sorting sets when a page has a plurality of visible labels, and if necessary, a new index parameter can be added through an extended parameter for identification. Besides basic parameters, basic attribute visible is defined as True in the function, namely the visible control of the page, and according to the conventional manual test, the invisible control of the page does not need to be tested manually, namely, the automatic test is not needed. When a name tag is recognized on a page, the control information is temporarily stored in a subclass object of a cache function oWeb, so that a second recognition function recognizes a Label tag of a name according to a function GetOb, the object is stored in an oLabel cache object, when the recognized number is less than 1, error rejection exception checking is carried out, when the recognized object is greater than 1, confirmation can be carried out according to the specification of the index parameter, in the embodiment, one name Label tag is taken as an explanation, when the recognized object is equal to 1, the values of Abs _ x and Abs _ y of the object Label, namely the pixel coordinate value of the Label tag with the focus of the upper left edge of the WEB page as the origin, are obtained, and the values are stored in Abs _ x and Abs _ y of the oLabel cache object.
A GetObS public function is further defined as the operation identification function, when a plurality of operation controls are mainly identified, a plurality of objects identified by the page are defined as a set, an identified control set is provided for pixel calculation of the second identification function, and basic main parameters are Parent, ClassName and TextView, wherein the 'Parent' is a basic main version type for distinguishing the identified page, such as IE and other client application programs; the "ClassName" is to distinguish the identified operation control type, in this embodiment, taking an input box as an example, the case branch of the ClassName only defines the type EditType of the input box, and at the same time defines the value of the attribute "webclass" as "WebEdit"; the 'TextView' is a Label parameter for distinguishing a specific identification control, is generally used for identification of Button buttons by taking the transmission parameter of an operation instruction as a reference, and is identified by a WebEdit control, and the parameter is not used. According to the ClassName, when a control (namely an input frame control) of the WebEdit is identified on a page, the control information is temporarily stored in a subclass object of a cache function oWeb, and a set is ordered according to the identified sequence so as to be transmitted to the second identification function.
According to the embodiment, the two predefined public functions are utilized, so that the system can position the label control and the operation control in the page only by calling the two public functions when executing the identification task, and the influence of the change of the control attribute is avoided, so that the identification efficiency is improved, and the daily workload of technicians is reduced.
Further, based on the first embodiment shown in fig. 2, a third embodiment of the automated testing method of the present invention is provided. In this embodiment, before step S10, the method further includes:
a1, constructing a basic control class, and defining a plurality of control types in the basic control class, wherein the control types cover the types of the controls in the target test page;
step A2, initializing the control attribute of each control type to complete the functionalization processing of the control.
In this embodiment, before step S10, the control needs to be functionalized, and first, a basic control Class needs to be constructed, and a basic control type, such as a common WEB page control type, e.g., a LabelType (tag type), an EditType (edit type), a button type, etc., is defined; then, the attribute category of the control type, such as LabelType ═ Text ", EditType ═ WebEdit", and buttertype ═ WebButton, is initialized.
Specifically, fig. 3 is taken as an example. The method comprises the steps of constructing a basic control Class, initializing the attribute Class of the control, defining a privatization function Class _ Initialize by taking a name input box to be input in a drawing as an example, and initializing an 'EditType' type for an EditType parameter of the input box. In addition, a privatization function Throwwerror can be defined for error throwing processing when abnormal is executed, and an error log is used for problem analysis.
The existing object library identification technology can only record the control of the current WEB page, but the embodiment increases the flexibility of an identification mechanism by carrying out functional processing on the control in advance, so that the corresponding control in the page can be found according to the control parameter of the operation instruction even if the attribute of the control changes, and the influence of attribute change on the identification process of the control is eliminated.
Further, the specified test operation includes an input operation, the target operation control includes an input box control, and step S30 includes:
step S31, executing the operation instruction to write the control value in the operation instruction into the input box control.
In this embodiment, as shown in fig. 3, if the operation command is specifically: if the terminal is configured to perform a first operation, the terminal may perform a second identification function on the target input frame identified by the second identification function (i.e., the input frame on the right side of the "name" label in the drawing) to perform the operation indicated by the operation instruction.
According to the embodiment, the operation instruction is executed after the target operation control to which the operation instruction is directed is positioned, so that an automatic test process for the control in the target test page is completed, manual intervention is not required in the whole process, and therefore the test efficiency is greatly improved.
Further, before step S10, the method further includes:
and step B1, acquiring test content information, and converting the test content information into the operation instruction according to a preset operation instruction specification.
In this embodiment, the operation instruction has a unified format specification, for example, the format of the specification is "control identification Label ═ control value ═ control identification Label" ("operation category" is a specific execution action, such as input, click, selection, "control identification Label" is a control Label to be searched for, "identification name of the control, such as" name, certificate number, "and" control value "is specific data input or selected during operation, such as" zhang san, "and may be omitted, i.e., there is no" control value "when the control operation is a click or a click type of button.
Before step S10, in addition to the control being functionalized and the operating instruction specification being made, other initialization steps may be performed. As a specific example, as shown in fig. 4.
S01: and constructing a basic control Class, and defining basic control types such as LabelType, EditType, ButtonType and other common WEB page control types.
S02: the attribute category of the control type is initialized, such as LabelType ═ Text ", EditType ═ WebEdit", ButtonType ═ WebButton ".
S03: initializing an operation type function, such as Set, for an input operation; click is used for clicking operation; select, for selection operations, etc.
S04: initializing a control object identification algorithm, defaulting part of normalized attributes, such as visible value of "true", html tag of EditType value of "TD", and searching logic, performing uniqueness identification on a first layer of a control according to a Label Label, defining a plurality of objects identified by a page as a set when a plurality of operation controls are identified, numbering according to the identified sequence, and performing logic of calculating pixel bits by a second layer for further identification.
S05: and initializing other command algorithms for simulating keyboard operation on the basis of other commands, such as tab, space, backspace, F1-F9 and the like.
S06: an operation instruction specification is formulated, the format of the specification is that the operation type is the control identification Label and the control value, and the operation type is a specific execution action.
S07: and compiling the operation instruction according to the automatic test case. If "zhang san" is input in the WEB page name input box, the operation instruction is edited as: SetKey is named and three is named.
After the seven initial steps are completed, the actual automated testing process is performed, i.e., S08: accessing a WEB page, executing an operation instruction, identifying a control on the WEB page according to an operation instruction parameter, identifying the control through a Label Label of the control type, executing an operation type instruction on the control, and writing a control value 'Zhang III'.
The embodiment specifically describes the preamble steps required for implementing control identification, and the initialization steps of the preambles provide an implementation basis for the control identification mechanism, so that the system can identify the target operation control in the page according to the identification mechanism with universality based on the preamble steps, and then, the automatic and efficient automatic test process can be performed on the control of the page based on the identification mechanism with universality. In addition, it should be noted that, the above is not limited to the control identification of the WEB page, and a set of function library of the control identification mechanism of the application program can be established by using other application programs to functionalize the control.
As shown in fig. 5, the present invention further provides an automated testing system, which includes:
a target page access module 10, configured to obtain a test script associated with a target test page, and access the target test page based on the test script, where the test script includes an operation instruction for indicating test content;
the target control identification module 20 is configured to call a preset control identification function according to the control parameter in the operation instruction to identify a target operation control matched with the control parameter in the target test page, where each control in the target test page is subjected to functionalization adapted to the control identification function;
and the test operation executing module 30 is configured to execute a specified test operation in the operation instruction on the target operation control by executing the operation instruction.
Optionally, the control identification function includes a first identification function and a second identification function, the control parameter includes a control label, and the target control identification module 20 includes:
the identification function calling unit is used for calling a first identification function and a second identification function according to the control label in the operation instruction;
the first function identification unit is used for identifying all operation controls and label type controls corresponding to the control labels from the target test page by calling the first identification function, wherein the first identification function is matched with all the operation controls and the label type controls;
and the second function identification unit is used for determining the operation control which is closest to the label type control in all the operation controls by using a preset control identification algorithm through calling the second identification function, so as to serve as the target operation control.
Optionally, the second function identification unit is further configured to:
acquiring label pixel positioning coordinates of the label type control and a plurality of operation pixel positioning coordinates of the operation control set by calling the second identification function;
obtaining the pixel bit distance of each operation control to the label type control according to the absolute value of the difference between each operation pixel positioning coordinate and the label pixel positioning coordinate;
finding out a minimum value from the pixel bit distances, and taking an operation control corresponding to the minimum value as the target operation control.
Optionally, the first identification function includes a tag identification function and an operation identification function, the target test page includes a plurality of operation controls, and the first function identification unit is further configured to:
identifying a label type control with label content consistent with the label of the control from the target test page by calling the label identification function, wherein the function initialization attribute of the label type control corresponds to a basic main parameter of the label identification function;
and identifying a plurality of operation controls contained in the target test page as an operation control set by calling an operation identification function, wherein the function initialization attribute of the operation control corresponds to a basic main parameter of the operation identification function.
Optionally, the automated testing system further comprises:
the control type definition module is used for constructing a basic control class and defining a plurality of control types in the basic control class, wherein the control types cover the types of the controls in the target test page;
and the control attribute initialization module is used for initializing the control attribute of each control type so as to complete the functionalization processing of the control.
Optionally, the specified test operation includes an input operation, the target operation control includes an input box control, and the test operation executing module 30 includes:
and the writing operation execution unit is used for executing the operation instruction so as to write the control value in the operation instruction into the input box control.
Optionally, the automated testing system further comprises:
and the operation instruction generating module is used for acquiring the test content information and converting the test content information into the operation instruction according to a preset operation instruction specification.
The invention also provides automatic test equipment.
The automated test equipment comprises a processor, a memory and an automated test program stored on the memory and capable of running on the processor, wherein the automated test program, when executed by the processor, implements the steps of the automated test method as described above.
The method for implementing the automatic test program when executed may refer to various embodiments of the automatic test method of the present invention, and details thereof are not repeated herein.
The invention also provides a computer readable storage medium.
The computer readable storage medium of the present invention has stored thereon an automated test program which, when executed by a processor, implements the steps of the automated test method described above.
The method for implementing the automatic test program when executed may refer to various embodiments of the automatic test method of the present invention, and will not be described herein again.
The invention also provides a computer program product comprising a computer program which, when executed by a processor, carries out the steps of the automated testing method as described above.
The method implemented when the computer program is executed may refer to each embodiment of the automated testing method of the present invention, and details thereof are not repeated herein.
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or system that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or system. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or system that comprises the element.
The above-mentioned serial numbers of the embodiments of the present invention are merely for description and do not represent the merits of the embodiments.
Through the above description of the embodiments, those skilled in the art will clearly understand that the method of the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but in many cases, the former is a better implementation manner. 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 (e.g., ROM/RAM, magnetic disk, optical disk) as described above and includes instructions for enabling a terminal device (e.g., a mobile phone, a computer, a server, or a network device) to execute the method according to the embodiments of the present invention.
The above description is only a preferred embodiment of the present invention, and not intended to limit the scope of the present invention, and all modifications of equivalent structures and equivalent processes, which are made by using the contents of the present specification and the accompanying drawings, or directly or indirectly applied to other related technical fields, are included in the scope of the present invention.
Claims (10)
1. An automated testing method, comprising:
acquiring a test script associated with a target test page, and accessing the target test page based on the test script, wherein the test script comprises an operation instruction for indicating test content;
calling a preset control identification function according to the control parameters in the operation instruction so as to identify a target operation control matched with the control parameters in the target test page, wherein each control in the target test page is subjected to functionalization processing adaptive to the control identification function;
and executing the specified test operation in the operation instruction on the target operation control by executing the operation instruction.
2. The automated testing method of claim 1, wherein the control identification function comprises a first identification function and a second identification function, the control parameters comprise a control label,
the step of calling a preset control identification function according to the control parameter in the operation instruction to identify the target operation control matched with the control parameter in the target test page comprises the following steps:
calling a first recognition function and a second recognition function according to the control label in the operation instruction;
identifying all operation controls and label type controls corresponding to the control labels from the target test page by calling the first identification function, wherein the first identification function is matched with all the operation controls and the label type controls;
and determining the operation control which is closest to the label type control in all the operation controls by using a preset control identification algorithm through calling the second identification function to serve as the target operation control.
3. The automated testing method according to claim 2, wherein the step of determining, by calling the second recognition function, an operation control closest to the label type control among all the operation controls by using a preset control recognition algorithm, as the target operation control, comprises:
acquiring label pixel positioning coordinates of the label type control and a plurality of operation pixel positioning coordinates of the operation control set by calling the second identification function;
obtaining the pixel bit distance of each operation control to the label type control according to the absolute value of the difference between each operation pixel positioning coordinate and the label pixel positioning coordinate;
finding out a minimum value from the pixel bit distances, and taking an operation control corresponding to the minimum value as the target operation control.
4. The automated testing method of claim 2, wherein the first recognition function comprises a tag recognition function and an operational recognition function, the target test page including a plurality of operational controls,
the step of identifying all the operation controls and the label type controls corresponding to the control labels from the target test page by calling the first identification function comprises:
identifying a label type control with label content consistent with the label of the control from the target test page by calling the label identification function, wherein the function initialization attribute of the label type control corresponds to a basic main parameter of the label identification function;
and identifying a plurality of operation controls contained in the target test page as an operation control set by calling an operation identification function, wherein the function initialization attribute of the operation control corresponds to a basic main parameter of the operation identification function.
5. The automated testing method of claim 1, wherein the step of obtaining a test script associated with a target test page is preceded by:
constructing a basic control class, and defining a plurality of control types in the basic control class, wherein the control types cover the types of the controls in the target test page;
and initializing the control attribute of each control type to finish the functionalization processing of the control.
6. The automated testing method of claim 1, wherein the specified testing operation comprises an input operation, the target operation control comprises an input box control,
the step of executing the specified test operation in the operation instruction on the target operation control by executing the operation instruction comprises:
executing the operation instruction to write the control value in the operation instruction into the input box control.
7. The automated testing method of any of claims 1-6, wherein the step of obtaining a test script associated with the target test page is preceded by:
and acquiring test content information, and converting the test content information into the operation instruction according to a preset operation instruction specification.
8. An automated test system, comprising:
the target page access module is used for acquiring a test script associated with a target test page and accessing the target test page based on the test script, wherein the test script comprises an operation instruction for indicating test content;
the target control identification module is used for calling a preset control identification function according to the control parameters in the operation instruction so as to identify the target operation control matched with the control parameters in the target test page, wherein each control in the target test page is subjected to functionalization treatment adaptive to the control identification function;
and the test operation execution module is used for executing the specified test operation in the operation instruction on the target operation control by executing the operation instruction.
9. An automated test equipment, comprising: memory, a processor and an automated test program stored on the memory and executable on the processor, the automated test program when executed by the processor implementing the steps of the automated test method of any one of claims 1 to 7.
10. A computer-readable storage medium, having an automated test program stored thereon, which when executed by a processor implements the steps of the automated test method of any of claims 1 to 7.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111433134.9A CN113986767A (en) | 2021-11-29 | 2021-11-29 | Automated testing method, system, device and computer readable storage medium |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202111433134.9A CN113986767A (en) | 2021-11-29 | 2021-11-29 | Automated testing method, system, device and computer readable storage medium |
Publications (1)
Publication Number | Publication Date |
---|---|
CN113986767A true CN113986767A (en) | 2022-01-28 |
Family
ID=79732450
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202111433134.9A Pending CN113986767A (en) | 2021-11-29 | 2021-11-29 | Automated testing method, system, device and computer readable storage medium |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN113986767A (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN114670200A (en) * | 2022-03-30 | 2022-06-28 | 上海擎朗智能科技有限公司 | Automatic testing method applied to robot, computer storage medium and robot |
-
2021
- 2021-11-29 CN CN202111433134.9A patent/CN113986767A/en active Pending
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN114670200A (en) * | 2022-03-30 | 2022-06-28 | 上海擎朗智能科技有限公司 | Automatic testing method applied to robot, computer storage medium and robot |
CN114670200B (en) * | 2022-03-30 | 2024-04-26 | 上海擎朗智能科技有限公司 | Automatic test method applied to robot, computer storage medium and robot |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US9064056B2 (en) | Completing functional testing | |
US11074162B2 (en) | System and a method for automated script generation for application testing | |
CN112182468A (en) | Positioning and analyzing method compatible with client interface element and webpage element | |
US20110035729A1 (en) | Generating and resolving component names in an integrated development environment | |
US8745727B2 (en) | Graphical user interface tester | |
CN108710571B (en) | Method and device for generating automatic test code | |
CN104182335A (en) | Software testing method and device | |
CN109614325B (en) | Method and device for determining control attribute, electronic equipment and storage medium | |
CN111462811A (en) | Automatic testing method and device, storage medium and electronic equipment | |
CN112506778A (en) | WEB user interface automatic test method, device, equipment and storage medium | |
CN112231206A (en) | Script editing method for application program test, computer readable storage medium and test platform | |
JP7380714B2 (en) | Operation log acquisition device and operation log acquisition method | |
CN113094625A (en) | Page element positioning method and device, electronic equipment and storage medium | |
CN111679976A (en) | Method and device for searching page object | |
CN113986767A (en) | Automated testing method, system, device and computer readable storage medium | |
CN109144871B (en) | Automatic test element identification method and device | |
US8739146B2 (en) | Systems and methods for generating and distributing executable procedures for technical desk-side support | |
CN116719736A (en) | Test case generation method and device for testing software interface | |
CN116820996A (en) | Automatic generation method and device for integrated test cases based on artificial intelligence | |
CN115481025A (en) | Script recording method and device for automatic test, computer equipment and medium | |
CN112003647B (en) | Detection method, device and equipment for recycled optical modem and storage medium | |
CN109117176B (en) | Version automatic deployment method and system based on host | |
CN113805861A (en) | Code generation method based on machine learning, code editing system and storage medium | |
KR20220022383A (en) | Method and system for multimedia device | |
CN112181809B (en) | Graphic user interface automatic test method based on multiple positioning methods |
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 |