CN110737573B - Method and device for automatically testing user interface UI - Google Patents
Method and device for automatically testing user interface UI Download PDFInfo
- Publication number
- CN110737573B CN110737573B CN201810789737.4A CN201810789737A CN110737573B CN 110737573 B CN110737573 B CN 110737573B CN 201810789737 A CN201810789737 A CN 201810789737A CN 110737573 B CN110737573 B CN 110737573B
- Authority
- CN
- China
- Prior art keywords
- test
- picture
- instruction
- reading
- sequence
- 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.)
- Active
Links
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
-
- 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/3696—Methods or tools to render software testable
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 discloses a method and a device for automatically testing a user interface UI. The method comprises the following steps: reading the test case from the storage path of the test case; generating a test instruction corresponding to each test picture according to the file name of each test picture in the test case; and finishing the UI automatic test according to the test instruction and the corresponding test picture. The technical scheme realizes the tight coupling of the test case and the test picture based on the modification of the file name of the test picture, is convenient for management and test result investigation, and simultaneously, the code of the automatic test can be automatically generated according to the rule, thereby being convenient for use.
Description
Technical Field
The invention relates to the field of automatic testing, in particular to a method and a device for automatically testing a User Interface (UI).
Background
In the past, the UI (User Interface) test usually adopts manual test, which is time-consuming and labor-consuming. Currently, UI automation tests are well developed, but there are many disadvantages, for example, when a test picture is needed, a test case needs to be compiled for the test picture, the test case is separated from the test picture, which is not convenient for storage management and examination of test results, and is also inconvenient for generation of automation test codes.
Disclosure of Invention
In view of the above, the present invention has been developed to provide a method and apparatus for user interface UI automation testing that overcomes, or at least partially solves, the above-mentioned problems.
According to one aspect of the invention, a method for automatically testing a User Interface (UI) is provided, which comprises the following steps:
reading the test case from the storage path of the test case;
generating a test instruction corresponding to each test picture according to the file name of each test picture in the test case;
and finishing the UI automatic test according to the test instruction and the corresponding test picture.
Optionally, the test case is a folder containing a plurality of test pictures.
Optionally, the file name of the test picture includes a sequence identifier of a test sequence;
the reading of the test case from the storage path of the test case comprises:
reading test pictures from the folder according to the sequence identification, wherein one test picture is read each time, and after the corresponding test is finished according to the test picture, the test picture corresponding to the next sequence identification in the test sequence is read, or a new sequence identification is determined according to the test result, and the test picture corresponding to the new sequence identification is read;
and ending the UI automatic test when the test picture corresponding to the last sequence identifier in the test sequence in the folder is read completely, or ending the UI automatic test when the test result according to one test picture confirms that the test ending condition is met.
Optionally, the file name of the test picture includes a plurality of pieces of test information and an identifier corresponding to each piece of test information;
the test information includes a dummy of the test instruction and/or test data.
Optionally, the generating a test instruction corresponding to each test picture according to the file name of each test picture in the test case includes:
reading the file name of the test picture as a character string, and traversing the character string in sequence to obtain each identifier and test information corresponding to each identifier;
and searching a test instruction mapping table according to the pseudo instructions in the test information, and searching out corresponding test instructions.
Optionally, the test instructions include one or more of:
triggering a user event instruction, judging the instruction, jumping the instruction, and testing the time setting instruction.
Optionally, the completing the UI automation test according to the test instruction and the corresponding test picture includes:
screenshot is conducted on the UI of the application, and identification of a test picture is conducted in the screenshot;
and finishing the UI automatic test according to the image recognition result and the test instruction.
Optionally, the method further comprises:
and storing the test result of the UI automatic test and the corresponding test case into the same directory.
According to another aspect of the present invention, there is provided an apparatus for automated testing of a user interface UI, comprising:
the test case reading unit is suitable for reading the test cases from the storage paths of the test cases;
the test instruction generating unit is suitable for generating test instructions corresponding to the test pictures according to the file names of the test pictures in the test cases;
and the test unit is suitable for completing the UI automatic test according to the test instruction and the corresponding test picture.
Optionally, the test case is a folder containing a plurality of test pictures.
Optionally, the file name of the test picture includes a sequence identifier of a test sequence;
the test case reading unit is suitable for reading test pictures from the folder according to the sequence identifications, wherein one test picture is read each time, and after the corresponding test is finished according to the test picture, the test picture corresponding to the next sequence identification in the test sequence is read, or a new sequence identification is determined according to the test result, and the test picture corresponding to the new sequence identification is read; and ending the UI automatic test when the test picture corresponding to the last sequence identifier in the test sequence in the folder is read, or ending the UI automatic test when the test result according to one test picture confirms that the test ending condition is met.
Optionally, the file name of the test picture includes a plurality of pieces of test information and an identifier corresponding to each piece of test information;
the test information includes pseudo instructions of the test instructions and/or test data.
Optionally, the test instruction generating unit is adapted to read a file name of the test picture as a character string, sequentially traverse the character string, and obtain each identifier and test information corresponding to each identifier; and searching a test instruction mapping table according to the pseudo instruction in the test information, and searching out a corresponding test instruction.
Optionally, the test instructions include one or more of:
triggering a user event instruction, judging the instruction, jumping the instruction, and testing the time setting instruction.
Optionally, the test unit is adapted to perform screenshot on the UI of the application, and identify a test picture in the screenshot; and finishing the UI automatic test according to the image recognition result and the test instruction.
Optionally, the test unit is further adapted to store the test result of the UI automation test and the corresponding test case in the same directory.
In accordance with still another aspect of the present invention, there is provided an electronic apparatus including: a processor; and a memory arranged to store computer executable instructions that, when executed, cause the processor to perform a method as any one of the above.
According to a further aspect of the invention there is provided a computer readable storage medium, wherein the computer readable storage medium stores one or more programs which, when executed by a processor, implement a method as claimed in any preceding claim.
According to the technical scheme, the test cases are read from the storage paths of the test cases, the test instructions corresponding to the test pictures are generated according to the file names of the test pictures in the test cases, and the UI automatic test is completed according to the test instructions and the corresponding test pictures. The technical scheme realizes the tight coupling of the test case and the test picture based on the modification of the file name of the test picture, is convenient for management and test result investigation, and simultaneously, the code of the automatic test can be automatically generated according to the rule, thereby being convenient for use.
The foregoing description is only an overview of the technical solutions of the present invention, and the embodiments of the present invention are described below in order to make the technical means of the present invention more clearly understood and to make the above and other objects, features, and advantages of the present invention more clearly understandable.
Drawings
Various additional advantages and benefits will become apparent to those of ordinary skill in the art upon reading the following detailed description of the preferred embodiments. The drawings are only for purposes of illustrating the preferred embodiments and are not to be construed as limiting the invention. Also, like reference numerals are used to refer to like parts throughout the drawings. In the drawings:
FIG. 1 illustrates a flow diagram of a method for automated testing of a user interface UI in accordance with one embodiment of the invention;
FIG. 2 is a schematic structural diagram of an apparatus for automated testing of a user interface UI according to an embodiment of the invention;
FIG. 3 shows a schematic structural diagram of an electronic device according to one embodiment of the invention;
fig. 4 shows a schematic structural diagram of a computer-readable storage medium according to an embodiment of the invention.
Detailed Description
Exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. While exemplary embodiments of the present disclosure are shown in the drawings, it should be understood that the present disclosure may be embodied in various forms and should not be limited to the embodiments set forth herein. Rather, these embodiments are provided so that this disclosure will be thorough and complete, and will fully convey the scope of the disclosure to those skilled in the art.
FIG. 1 shows a flow diagram of a method for automated testing of a user interface UI according to one embodiment of the invention. As shown in fig. 1, the method includes:
step S110, reading the test case from the storage path of the test case.
The meaning of the test case is generally analyzed in combination with the usage scenario, and in the embodiment of the present invention, the automated test code is separated from the test case, but the test case also contains test logic. That is, the test case contains data used for testing and description information of the test logic, but does not contain specific execution instructions.
Therefore, in step S120, a test command corresponding to each test picture is generated based on the file name of each test picture in the test case.
It can be seen that the file name contains description information of the test logic, for example, the picture content of a test picture describes a control in the application, and the file name describes that the control is to be clicked, so that the test instruction is generated according to the description information.
And step S130, finishing UI automatic test according to the test instruction and the corresponding test picture.
It can be seen that, in the method shown in fig. 1, the test case is read from the storage path of the test case, the test instruction corresponding to each test picture is generated according to the file name of each test picture in the test case, and the UI automation test is completed according to the test instruction and the corresponding test picture. The technical scheme realizes tight coupling of the test case and the test picture based on modification of the file name of the test picture, is convenient for management and test result investigation, and simultaneously codes of automatic test can be automatically generated according to rules and are convenient to use.
In an embodiment of the present invention, in the method, the test case is a folder containing a plurality of test pictures.
Therefore, a folder containing a plurality of test pictures is a test case. Some UI automation tests in the prior art are implemented as follows: and (4) storing the test pictures in a centralized manner, and writing the test pictures and corresponding test logic in another file (such as an Excel document). In this case, the file is generally referred to as a test case, and the test picture is only used as test data used in the test, so that loose coupling is formed. However, it is very inconvenient in the test result viewing and the management of test cases and test data, for example, if a certain control is found to be unsuccessfully tested, a file needs to be opened, a corresponding test picture needs to be determined, and then the test picture needs to be opened, which is very tedious in steps. In the embodiment, the folder containing the test pictures is directly used as the test case, so that the corresponding test pictures can be directly positioned when the test result is back-checked, the basic logic of the test can be quickly known through the file names of the test pictures, and the method is visual and simple.
In an embodiment of the present invention, in the method, the file name of the test picture includes a sequence identifier of a test sequence; reading the test case from the storage path of the test case comprises the following steps: reading test pictures from the folder according to the sequence identification, wherein one test picture is read each time, and after the corresponding test is finished according to the test picture, the test picture corresponding to the next sequence identification in the test sequence is read, or a new sequence identification is determined according to the test result, and the test picture corresponding to the new sequence identification is read; and ending the UI automatic test when the test picture corresponding to the last sequence identifier in the test sequence in the folder is read, or ending the UI automatic test when the test ending condition is determined to be met according to the test result of one test picture.
For example, under the folder, there are 01, 02 \8230; \823010ten test pictures at the beginning as sequence identifiers of the test sequence. During testing, the picture at the beginning of 01 is read first, the testing logic is obtained according to the rest part of the file name of the picture, a corresponding testing instruction is generated, the testing is completed according to the picture, and then the picture at the beginning of 02 is read \8230, 8230, until the testing of the picture at the beginning of 10 is completed. Thus, the test for one test case is completed.
In some cases, it is possible to execute different test logics according to different test results of some test pictures. For example, clicking on a control to jump, another test may be required when the control is not present. It is possible to jump to the test of test picture 08 instead of continuing the test of test picture 04 when test picture 03 fails.
The test instruction generated according to the test picture file name may further include an instruction for directly determining to end the test according to the test result, for example, if a certain picture is not identified, the test is directly ended. The above test process also supports an interference scene picture occurring in the UI automation test process, for example, the test picture 08 may be shielded by a floating window (for example, a system floating window, not a floating window of an application to be tested), and then the test picture 07 corresponding to the floating window may be added before the test picture 08, so that although the floating window 08 does not need to be tested actually, the test picture 08 may be operated due to interference, for example, the floating window is clicked, and a control corresponding to the test picture 08 is exposed after the floating window disappears, so that the UI automation test may be continued. Thus, the execution logic of the test picture 07 becomes to click once, and whether the click is successful or not does not affect the presentation of the test result, because the test is not the purpose of testing.
In an embodiment of the present invention, in the method, the filename of the test picture includes a plurality of pieces of test information and an identifier corresponding to each piece of test information; the test information includes a dummy of the test instruction and/or test data.
Based on one test picture, a plurality of operations may exist, or only one operation may exist; the operation itself may only be to determine whether a control corresponding to a certain test picture exists, or may need to click the control, or the control may be an input box and needs to input some test data. Three examples of file names are given below:
01_click_key_Enter.png;02_exist.png;03_type_value.png。
the method comprises the following steps that (01) a test picture at the beginning needs to click (click) a control, judge a feature item (key) and then execute an operation (Enter) of pressing an Enter key; 02, the first test picture only needs to judge whether the corresponding picture content exists; the test picture at the beginning of 03 requires the entry of the value (value) of the corresponding test data in the control (type). That is, one test picture supports a plurality of test instructions.
It can be seen that there are multiple test information in the file name, separated by "_" or underline. Of course, other identification symbols may be used to identify the test information in other embodiments.
Likewise, it can be seen that the testing may include multiple steps, which may also be in a sequential order. In an embodiment of the present invention, in the method, generating the test instruction corresponding to each test picture according to the file name of each test picture in the test case includes: reading the file name of the test picture as a character string, and traversing the character string in sequence to obtain each identifier and test information corresponding to each identifier; and searching a test instruction mapping table according to the pseudo instruction in the test information, and searching out a corresponding test instruction.
It is clear that click is a pseudo-instruction that can be understood by a tester, not an actual test instruction. In this embodiment, a test instruction mapping table may be preset to set a mapping relationship between the pseudo instruction and the test instruction, so that the test image needs to be set by relying on the test instruction mapping table when being named.
Specifically, in an embodiment of the present invention, in the method, the test instruction includes one or more of the following: triggering a user event instruction, judging the instruction, jumping the instruction, and testing the time setting instruction.
For example, click corresponds to the operation of clicking a screen, enter corresponds to the operation of pressing an Enter key, and all of the operations trigger corresponding user events, and corresponding test instructions belong to judgment instructions; exist belongs to judging whether the picture exists or not, and a corresponding test instruction belongs to a judging instruction; when the test picture does not exist, other test pictures are jumped and tested without the original sequence, the corresponding test instruction belongs to the jump instruction, and the logic corresponding to the if else statement in the code is easy to think in practice; the pictures are searched in the UI interface for different reasons, the response time is different, so that the test time can be set to meet the requirement that the response is slow to wait partially due to the reasons of test environment and the like, and the corresponding test instruction is a test time setting instruction.
In an embodiment of the present invention, in the method, the completing the UI automation test according to the test instruction and the corresponding test picture includes: screenshot is conducted on the UI of the application, and identification of a test picture is conducted in the screenshot; and finishing the UI automatic test according to the image recognition result and the test instruction.
In this embodiment, based on an image recognition technology, the screenshot of the UI is recognized, and whether the screenshot includes the picture content of the test picture is determined, and the subsequent test may refer to several examples of test logic given in the foregoing embodiments, such as clicking a control or inputting test data.
Wherein, based on one test picture, it is possible to identify a plurality of identical parts from the screenshot, e.g. there are two "confirmation" corresponding pictures in the UI interface, which are completely identical. In the embodiment of the invention, all the same pictures can be identified and corresponding operations, such as clicking, only one picture needs to be placed in the test case, and only the corresponding test information in the file name needs to be modified, for example, two identical pictures which are possibly identified are marked, and clicking operation is performed on the two pictures.
In an embodiment of the present invention, the method further includes: and storing the test result of the UI automatic test and the corresponding test case into the same directory.
Therefore, the test result can be quickly checked, the test case can be found immediately after the test result is seen, the corresponding test picture can be found, the checking of testers is greatly facilitated, and the test efficiency is improved.
Fig. 2 is a schematic structural diagram of an apparatus for automated testing of a user interface UI according to an embodiment of the present invention. As shown in fig. 2, the apparatus 200 for automated testing of a user interface UI includes:
the test case reading unit 210 is adapted to read a test case from a storage path of the test case.
The meaning of the test case is generally analyzed in combination with the usage scenario, and in the embodiment of the present invention, the automated test code is separated from the test case, but the test case also contains test logic. That is, the test case contains data used for testing and description information of the test logic, but does not contain specific execution instructions.
The test instruction generating unit 220 is adapted to generate a test instruction corresponding to each test picture according to the file name of each test picture in the test case.
It can be seen that the file name contains description information of the test logic, for example, the picture content of a test picture describes a control in the application, and the file name describes that the control is to be clicked, so that the test instruction is generated according to the description information.
And the test unit 230 is adapted to complete the UI automation test according to the test instruction and the corresponding test picture.
It can be seen that, in the apparatus shown in fig. 2, through the mutual cooperation of the units, the test case is read from the storage path of the test case, the test instruction corresponding to each test picture is generated according to the file name of each test picture in the test case, and the UI automation test is completed according to the test instruction and the corresponding test picture. The technical scheme realizes tight coupling of the test case and the test picture based on modification of the file name of the test picture, is convenient for management and test result investigation, and simultaneously codes of automatic test can be automatically generated according to rules and are convenient to use.
In an embodiment of the present invention, in the apparatus, the test case is a folder containing a plurality of test pictures.
Therefore, a folder containing a plurality of test pictures is a test case. Some UI automation tests in the prior art are implemented as follows: and (4) storing the test pictures in a centralized manner, and writing the test pictures and corresponding test logic in another file (such as an Excel document). In this case, the file is generally referred to as a test case, and the test picture is only used as test data used in the test, so that loose coupling is formed. However, it is very inconvenient in the test result viewing and the management of test cases and test data, for example, if it is found that the test of a certain control is not successful, a file needs to be opened, a corresponding test picture needs to be determined, and then the test picture is opened, which is very tedious in steps. In the embodiment, the folder containing the test pictures is directly used as the test case, so that the corresponding test pictures can be directly positioned when the test result is back-checked, the basic logic of the test can be quickly known through the file names of the test pictures, and the method is visual and simple.
In an embodiment of the present invention, in the above apparatus, the file name of the test picture includes a sequence identifier of the test sequence; a test case reading unit 210 adapted to read test pictures from the folder according to the sequence identifiers, wherein one test picture is read each time, and after a corresponding test is completed according to the test picture, a test picture corresponding to a next sequence identifier in the test sequence is read, or a new sequence identifier is determined according to the test result, and a test picture corresponding to the new sequence identifier is read; and ending the UI automatic test when the test picture corresponding to the last sequence identifier in the test sequence in the folder is read, or ending the UI automatic test when the test ending condition is determined to be met according to the test result of one test picture.
For example, under the folder are 01, 02 \8230 \ 8230; ten test pictures at the beginning of 10, as sequence identifiers for the test sequence. During testing, the picture at the beginning of 01 is read first, the testing logic is obtained according to the rest part of the file name of the picture, a corresponding testing instruction is generated, the testing is completed according to the picture, and then the picture at the beginning of 02 is read \8230, 8230, until the testing of the picture at the beginning of 10 is completed. Thus, the test for one test case is completed.
In some cases, it is possible to execute different test logics according to different test results of some test pictures. For example, clicking on a control to jump, another test may be required when the control is not present. It is possible to jump to the test of test picture 08 instead of continuing the test of test picture 04 when test picture 03 fails.
The test instruction generated according to the file name of the test picture may further include an instruction for directly determining to end the test according to the test result, for example, if a certain picture is not identified, the test is directly ended. The above test process also supports an interference scene picture appearing in the UI automation test process, for example, the test picture 08 may be blocked by a floating window (for example, a system floating window, not a floating window of an application to be tested), and then the test picture 07 corresponding to the floating window may be added before the test picture 08, so that although the floating window 08 is not actually required to be tested, the test picture may be operated due to interference, for example, the floating window is clicked, and after the interference disappears, a control corresponding to the test picture 08 is exposed, so that the UI automation test may be continued. Thus, the execution logic of the test picture 07 becomes to click once, and whether the click is successful or not does not affect the presentation of the test result, because the test is not the purpose of testing.
In an embodiment of the present invention, in the apparatus, the filename of the test picture includes a plurality of pieces of test information and an identifier corresponding to each piece of test information; the test information includes a dummy of the test instruction and/or test data.
There may be multiple operations or only one operation based on one test picture; the operation itself may only be to determine whether a control corresponding to a certain test picture exists, or may need to click the control, or the control may be an input box and needs to input some test data. Three examples of file names are given below:
01_click_key_Enter.png;02_exist.png;03_type_value.png。
the method comprises the following steps that (01) a test picture at the beginning needs to click (click) a control, judge a feature item (key) and then execute an operation (Enter) of pressing an Enter key; 02, the first test picture only needs to judge whether the corresponding picture content exists; the test picture at the beginning of 03 requires the entry of the value (value) of the corresponding test data in the control (type). That is, one test picture supports a plurality of test instructions.
It can be seen that there are multiple test information in the file name, separated by "_" or underline. Of course, other identification symbols may be used to identify the test information in other embodiments.
Likewise, it can be seen that the testing may include multiple steps, which may also be in a sequential order. In an embodiment of the present invention, in the above apparatus, the test instruction generating unit 220 is adapted to read a filename of a test picture as a character string, sequentially traverse the character string, and obtain each identifier and test information corresponding to each identifier; and searching a test instruction mapping table according to the pseudo instructions in the test information, and searching out corresponding test instructions.
It is clear that click is a pseudo-instruction that can be understood by a tester, not an actual test instruction. In this embodiment, a test instruction mapping table may be preset to set a mapping relationship between the pseudo instruction and the test instruction, so that the test image needs to be set by relying on the test instruction mapping table when being named.
Specifically, in an embodiment of the present invention, in the apparatus, the test instruction includes one or more of the following: triggering a user event instruction, judging an instruction, jumping an instruction, and testing a time setting instruction.
For example, click corresponds to the operation of clicking a screen, enter corresponds to the operation of pressing an Enter key, and all of the operations trigger corresponding user events, and corresponding test instructions belong to judgment instructions; exist belongs to judging whether the picture exists or not, and a corresponding test instruction belongs to a judging instruction; when the test picture does not exist, other test pictures are jumped and tested without the original sequence, the corresponding test instruction belongs to the jump instruction, and the logic corresponding to the if else statement in the code is easy to think in practice; the search of pictures in the UI interface can be caused by various reasons and different response time, so that the test time can be set to meet the requirement that the response is slow to wait partially due to the reasons of test environment and the like, and the corresponding test instruction is a test time setting instruction.
In an embodiment of the present invention, in the above apparatus, the testing unit 230 is adapted to perform screenshot on the UI of the application, and identify a test picture in the screenshot; and finishing the UI automatic test according to the image recognition result and the test instruction.
In this embodiment, based on an image recognition technology, the screenshot of the UI is recognized, and whether the screenshot includes the picture content of the test picture is determined, and the subsequent test may refer to several examples of test logic given in the foregoing embodiments, such as clicking a control or inputting test data.
Wherein, based on one test picture, it is possible to identify a plurality of identical parts from the screenshot, e.g. there are two "confirmation" corresponding pictures in the UI interface, which are completely identical. In the embodiment of the invention, all the same pictures can be identified and corresponding operations can be carried out, such as clicking, only one picture needs to be placed in the test case, and only the corresponding test information in the file name is modified, for example, two identical pictures which are possibly identified are marked, and both the two pictures are clicked.
In an embodiment of the present invention, in the above apparatus, the testing unit 230 is further adapted to save the test result of the UI automation test and the corresponding test case into the same directory.
Therefore, the test result can be quickly checked, the test case can be found immediately after the test result is seen, the corresponding test picture can be found, the checking of testers is greatly facilitated, and the test efficiency is improved.
In summary, according to the technical solution of the present invention, the test case is read from the storage path of the test case, the test instruction corresponding to each test picture is generated according to the file name of each test picture in the test case, and the UI automation test is completed according to the test instruction and the corresponding test picture. The technical scheme realizes tight coupling of the test case and the test picture based on modification of the file name of the test picture, is convenient for management and test result investigation, and simultaneously codes of automatic test can be automatically generated according to rules and are convenient to use.
It should be noted that:
the algorithms and displays presented herein are not inherently related to any particular computer, virtual machine, or other apparatus. Various general purpose devices may be used with the teachings herein. The required structure for constructing such a device will be apparent from the description above. Moreover, the present invention is not directed to any particular programming language. It is appreciated that a variety of programming languages may be used to implement the teachings of the present invention as described herein, and any descriptions of specific languages are provided above to disclose the best mode of the invention.
In the description provided herein, numerous specific details are set forth. It is understood, however, that embodiments of the invention may be practiced without these specific details. In some instances, well-known methods, structures and techniques have not been shown in detail in order not to obscure an understanding of this description.
Similarly, it should be appreciated that in the foregoing description of exemplary embodiments of the invention, various features of the invention are sometimes grouped together in a single embodiment, figure, or description thereof for the purpose of streamlining the disclosure and aiding in the understanding of one or more of the various inventive aspects. However, the disclosed method should not be construed to reflect the intent: rather, the invention as claimed requires more features than are expressly recited in each claim. Rather, as the following claims reflect, inventive aspects lie in less than all features of a single foregoing disclosed embodiment. Thus, the claims following the detailed description are hereby expressly incorporated into this detailed description, with each claim standing on its own as a separate embodiment of this invention.
Those skilled in the art will appreciate that the modules in the device in an embodiment may be adaptively changed and disposed in one or more devices different from the embodiment. The modules or units or components of the embodiments may be combined into one module or unit or component, and furthermore they may be divided into a plurality of sub-modules or sub-units or sub-components. All of the features disclosed in this specification (including any accompanying claims, abstract and drawings), and all of the processes or elements of any method or apparatus so disclosed, may be combined in any combination, except combinations where at least some of such features and/or processes or elements are mutually exclusive. Each feature disclosed in this specification (including any accompanying claims, abstract and drawings) may be replaced by alternative features serving the same, equivalent or similar purpose, unless expressly stated otherwise.
Moreover, those skilled in the art will appreciate that although some embodiments described herein include some features included in other embodiments, not others, combinations of features of different embodiments are meant to be within the scope of the invention and form different embodiments. For example, in the following claims, any of the claimed embodiments may be used in any combination.
The various component embodiments of the invention may be implemented in hardware, or in software modules running on one or more processors, or in a combination thereof. It will be appreciated by those skilled in the art that a microprocessor or Digital Signal Processor (DSP) may be used in practice to implement some or all of the functions of some or all of the components of the apparatus for automated testing of a user interface UI according to embodiments of the present invention. The present invention may also be embodied as apparatus or device programs (e.g., computer programs and computer program products) for performing a portion or all of the methods described herein. Such programs implementing the present invention may be stored on computer-readable media or may be in the form of one or more signals. Such a signal may be downloaded from an internet website or provided on a carrier signal or in any other form.
For example, fig. 3 shows a schematic structural diagram of an electronic device according to an embodiment of the invention. The electronic device comprises a processor 310 and a memory 320 arranged to store computer executable instructions (computer readable program code). The memory 320 may be an electronic memory such as a flash memory, an EEPROM (electrically erasable programmable read only memory), an EPROM, a hard disk, or a ROM. The memory 320 has a storage space 330 storing computer readable program code 331 for performing any of the method steps described above. For example, the storage space 330 for storing the computer readable program code may comprise respective computer readable program codes 331 for respectively implementing various steps in the above method. The computer readable program code 331 may be read from or written to one or more computer program products. These computer program products comprise a program code carrier such as a hard disk, a Compact Disc (CD), a memory card or a floppy disk. Such a computer program product is typically a computer readable storage medium such as described in fig. 4. Fig. 4 shows a schematic structural diagram of a computer-readable storage medium according to an embodiment of the present invention. The computer readable storage medium 400, having stored thereon computer readable program code 331 for performing the steps of the method according to the invention, readable by a processor 310 of an electronic device 300, causes the electronic device 300 to perform the steps of the method described above, when the computer readable program code 331 is executed by the electronic device 300, in particular the computer readable program code 331 stored on the computer readable storage medium may perform the method shown in any of the embodiments described above. The computer readable program code 331 may be compressed in a suitable form.
It should be noted that the above-mentioned embodiments illustrate rather than limit the invention, and that those skilled in the art will be able to design alternative embodiments without departing from the scope of the appended claims. In the claims, any reference signs placed between parentheses shall not be construed as limiting the claim. The word "comprising" does not exclude the presence of elements or steps not listed in a claim. The word "a" or "an" preceding an element does not exclude the presence of a plurality of such elements. The invention may be implemented by means of hardware comprising several distinct elements, and by means of a suitably programmed computer. In the unit claims enumerating several means, several of these means may be embodied by one and the same item of hardware. The usage of the words first, second and third, etcetera do not indicate any ordering. These words may be interpreted as names.
The invention provides A1, a method for automatically testing a user interface UI, comprising the following steps:
reading the test case from the storage path of the test case;
generating a test instruction corresponding to each test picture according to the file name of each test picture in the test case;
and finishing the UI automatic test according to the test instruction and the corresponding test picture.
A2, the method as A1, wherein the test case is a folder containing a plurality of test pictures.
A3, the method as A2, wherein the file name of the test picture includes a sequence identifier of a test sequence;
the reading of the test case from the storage path of the test case comprises:
reading test pictures from the folder according to the sequence identification, wherein one test picture is read each time, and after the corresponding test is finished according to the test picture, the test picture corresponding to the next sequence identification in the test sequence is read, or a new sequence identification is determined according to the test result, and the test picture corresponding to the new sequence identification is read;
and ending the UI automatic test when the test picture corresponding to the last sequence identifier in the test sequence in the folder is read, or ending the UI automatic test when the test result according to one test picture confirms that the test ending condition is met.
A4, the method as A1, wherein the file name of the test picture includes a plurality of pieces of test information and an identifier corresponding to each piece of test information;
the test information includes pseudo instructions of the test instructions and/or test data.
The method of A5, as described in A4, wherein the generating a test instruction corresponding to each test picture according to the file name of each test picture in the test case includes:
reading the file name of the test picture as a character string, and traversing the character string in sequence to obtain each identifier and test information corresponding to each identifier;
and searching a test instruction mapping table according to the pseudo instructions in the test information, and searching out corresponding test instructions.
The method of A1, wherein the test instruction comprises one or more of:
triggering a user event instruction, judging an instruction, jumping an instruction, and testing a time setting instruction.
The method of A1, wherein the completing the UI automation test according to the test instruction and the corresponding test picture includes:
screenshot is conducted on the UI of the application, and identification of a test picture is conducted in the screenshot;
and finishing the UI automatic test according to the image recognition result and the test instruction.
The method as in A1, wherein the method further comprises:
and storing the test result of the UI automatic test and the corresponding test case into the same directory.
The invention also provides B9, a device for automatically testing the UI of the user interface, which comprises:
the test case reading unit is suitable for reading the test cases from the storage paths of the test cases;
the test instruction generating unit is suitable for generating test instructions corresponding to the test pictures according to the file names of the test pictures in the test cases;
and the test unit is suitable for completing the UI automatic test according to the test instruction and the corresponding test picture.
The apparatus of B10, as stated in B9, wherein, the said test case is the file folder comprising several test pictures.
The device B11 is the device B10, wherein the file name of the test picture comprises a sequence identifier of a test sequence;
the test case reading unit is suitable for reading test pictures from the folder according to the sequence identifications, wherein one test picture is read each time, and after the corresponding test is finished according to the test picture, the test picture corresponding to the next sequence identification in the test sequence is read, or a new sequence identification is determined according to the test result, and the test picture corresponding to the new sequence identification is read; and ending the UI automatic test when the test picture corresponding to the last sequence identifier in the test sequence in the folder is read, or ending the UI automatic test when the test result according to one test picture confirms that the test ending condition is met.
B12, the device as in B9, wherein the file name of the test picture comprises a plurality of pieces of test information and marks corresponding to the test information;
the test information includes a dummy of the test instruction and/or test data.
B13. The apparatus as claimed in B12, wherein,
the test instruction generating unit is suitable for reading the file name of the test picture as a character string, sequentially traversing the character string and obtaining each identifier and test information corresponding to each identifier; and searching a test instruction mapping table according to the pseudo instruction in the test information, and searching out a corresponding test instruction.
The apparatus of B14, as described in B9, wherein the test instructions include one or more of:
triggering a user event instruction, judging the instruction, jumping the instruction, and testing the time setting instruction.
B15. The device according to B9, wherein,
the test unit is suitable for screenshot of the UI of the application and identification of a test picture in the screenshot; and finishing the UI automatic test according to the image recognition result and the test instruction.
B16. The apparatus of B15, wherein,
the test unit is also suitable for storing the test result of the UI automation test and the corresponding test case into the same directory.
The invention also provides C17, an electronic device, wherein the electronic device comprises: a processor; and a memory arranged to store computer executable instructions that, when executed, cause the processor to perform the method of any of A1-A8.
The invention also provides D18, a computer readable storage medium, wherein the computer readable storage medium stores one or more programs which, when executed by a processor, implement the method as recited in any of A1-A8.
Claims (16)
1. A method of User Interface (UI) automation testing, comprising:
reading the test case from the storage path of the test case; the test case is a folder containing a plurality of test pictures;
generating a test instruction corresponding to each test picture according to the file name of each test picture in the test case;
completing UI automatic test according to the test instruction and the corresponding test picture;
the file name of the test picture comprises a sequence identifier of a test sequence;
the reading of the test case from the storage path of the test case comprises:
and reading the test pictures from the folder according to the sequence identification.
2. The method of claim 1, wherein said reading test pictures from said folder by sequence identification comprises: reading a test picture each time, and after completing a corresponding test according to the test picture, reading the test picture corresponding to the next sequence identifier in the test sequence, or determining a new sequence identifier according to the test result, and reading the test picture corresponding to the new sequence identifier;
and ending the UI automatic test when the test picture corresponding to the last sequence identifier in the test sequence in the folder is read completely, or ending the UI automatic test when the test result according to one test picture confirms that the test ending condition is met.
3. The method as claimed in claim 1, wherein the file name of the test picture includes a plurality of pieces of test information and a mark corresponding to each piece of test information;
the test information includes a dummy of the test instruction and/or test data.
4. The method of claim 3, wherein the generating a test instruction corresponding to each test picture according to the file name of each test picture in the test case comprises:
reading the file name of the test picture as a character string, and traversing the character string in sequence to obtain each identifier and test information corresponding to each identifier;
and searching a test instruction mapping table according to the pseudo instruction in the test information, and searching out a corresponding test instruction.
5. The method of claim 1, wherein the test instructions comprise one or more of:
triggering a user event instruction, judging an instruction, jumping an instruction, and testing a time setting instruction.
6. The method of claim 1, wherein the completing the UI automation test according to the test instructions and the corresponding test pictures comprises:
screenshot is conducted on the UI of the application, and identification of a test picture is conducted in the screenshot;
and finishing the UI automatic test according to the image recognition result and the test instruction.
7. The method of claim 1, wherein the method further comprises:
and storing the test result of the UI automatic test and the corresponding test case into the same directory.
8. An apparatus for User Interface (UI) automation testing, comprising:
the test case reading unit is suitable for reading the test case from the storage path of the test case; the test case is a folder containing a plurality of test pictures;
the test instruction generating unit is suitable for generating test instructions corresponding to the test pictures according to the file names of the test pictures in the test cases;
the test unit is suitable for completing the UI automatic test according to the test instruction and the corresponding test picture;
the file name of the test picture comprises a sequence identifier of a test sequence;
the test case reading unit is suitable for reading the test pictures from the folder according to the sequence identification.
9. The apparatus of claim 8, wherein the test case reading unit is adapted to: reading a test picture each time, and after completing corresponding test according to the test picture, reading the test picture corresponding to the next sequence identifier in the test sequence, or determining a new sequence identifier according to the test result, and reading the test picture corresponding to the new sequence identifier; and ending the UI automatic test when the test picture corresponding to the last sequence identifier in the test sequence in the folder is read completely, or ending the UI automatic test when the test result according to one test picture confirms that the test ending condition is met.
10. The apparatus according to claim 8, wherein the file name of the test picture includes a plurality of pieces of test information and an identifier corresponding to each piece of test information;
the test information includes pseudo instructions of the test instructions and/or test data.
11. The apparatus of claim 9, wherein,
the test instruction generating unit is suitable for reading the file name of the test picture as a character string, traversing the character string in sequence and obtaining each identification and test information corresponding to each identification; and searching a test instruction mapping table according to the pseudo instructions in the test information, and searching out corresponding test instructions.
12. The apparatus of claim 8, wherein the test instructions comprise one or more of:
triggering a user event instruction, judging the instruction, jumping the instruction, and testing the time setting instruction.
13. The apparatus of claim 8, wherein,
the test unit is suitable for screenshot of the UI of the application and identification of a test picture in the screenshot; and finishing the UI automatic test according to the image recognition result and the test instruction.
14. The apparatus of claim 13, wherein,
the test unit is also suitable for storing the test result of the UI automation test and the corresponding test case in the same directory.
15. An electronic device, wherein the electronic device comprises: a processor; and a memory arranged to store computer-executable instructions that, when executed, cause the processor to perform the method of any one of claims 1-7.
16. A computer readable storage medium, wherein the computer readable storage medium stores one or more programs which, when executed by a processor, implement the method of any of claims 1-7.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810789737.4A CN110737573B (en) | 2018-07-18 | 2018-07-18 | Method and device for automatically testing user interface UI |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810789737.4A CN110737573B (en) | 2018-07-18 | 2018-07-18 | Method and device for automatically testing user interface UI |
Publications (2)
Publication Number | Publication Date |
---|---|
CN110737573A CN110737573A (en) | 2020-01-31 |
CN110737573B true CN110737573B (en) | 2023-02-17 |
Family
ID=69235246
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201810789737.4A Active CN110737573B (en) | 2018-07-18 | 2018-07-18 | Method and device for automatically testing user interface UI |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN110737573B (en) |
Families Citing this family (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN112150431B (en) * | 2020-09-21 | 2024-06-18 | 京东科技控股股份有限公司 | UI vision walking method and device, storage medium and electronic device |
CN112597045A (en) * | 2020-12-29 | 2021-04-02 | 福州富昌维控电子科技有限公司 | PLC instruction quality detection method and terminal based on ladder diagram |
CN114323585B (en) * | 2021-12-28 | 2024-04-12 | 梅卡曼德(北京)机器人科技有限公司 | Method for batch calculation of modulation transfer function, electronic device and storage medium |
Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103309797A (en) * | 2012-03-09 | 2013-09-18 | 阿里巴巴集团控股有限公司 | Automatic testing method and device of user interface |
US9075918B1 (en) * | 2014-02-25 | 2015-07-07 | International Business Machines Corporation | System and method for creating change-resilient scripts |
CN107861862A (en) * | 2017-06-27 | 2018-03-30 | 陆金所(上海)科技服务有限公司 | UI automated testing methods, device and computer-readable recording medium |
CN107885665A (en) * | 2017-12-28 | 2018-04-06 | 努比亚技术有限公司 | With case script method of testing, mobile terminal and computer-readable recording medium |
CN107957948A (en) * | 2017-12-07 | 2018-04-24 | 郑州云海信息技术有限公司 | A kind of user interface automatic test device and method |
CN108268373A (en) * | 2017-09-21 | 2018-07-10 | 平安科技(深圳)有限公司 | Automatic test cases management method, device, equipment and storage medium |
-
2018
- 2018-07-18 CN CN201810789737.4A patent/CN110737573B/en active Active
Patent Citations (6)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN103309797A (en) * | 2012-03-09 | 2013-09-18 | 阿里巴巴集团控股有限公司 | Automatic testing method and device of user interface |
US9075918B1 (en) * | 2014-02-25 | 2015-07-07 | International Business Machines Corporation | System and method for creating change-resilient scripts |
CN107861862A (en) * | 2017-06-27 | 2018-03-30 | 陆金所(上海)科技服务有限公司 | UI automated testing methods, device and computer-readable recording medium |
CN108268373A (en) * | 2017-09-21 | 2018-07-10 | 平安科技(深圳)有限公司 | Automatic test cases management method, device, equipment and storage medium |
CN107957948A (en) * | 2017-12-07 | 2018-04-24 | 郑州云海信息技术有限公司 | A kind of user interface automatic test device and method |
CN107885665A (en) * | 2017-12-28 | 2018-04-06 | 努比亚技术有限公司 | With case script method of testing, mobile terminal and computer-readable recording medium |
Also Published As
Publication number | Publication date |
---|---|
CN110737573A (en) | 2020-01-31 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US6986125B2 (en) | Method and apparatus for testing and evaluating a software component using an abstraction matrix | |
US9619373B2 (en) | Method and apparatus to semantically connect independent build and test processes | |
US6941546B2 (en) | Method and apparatus for testing a software component using an abstraction matrix | |
CN110737573B (en) | Method and device for automatically testing user interface UI | |
CN105743736B (en) | Automated testing method and system | |
CN104572463B (en) | The method and device of test interface information | |
JP2015507303A (en) | Code coverage rate determination method and system | |
US9262299B1 (en) | Simulation observability and control of all hardware and software components of a virtual platform model of an electronics system | |
US10162742B2 (en) | System and method for end to end performance response time measurement based on graphic recognition | |
CN110175609A (en) | Interface element detection method, device and equipment | |
CN106776334A (en) | Based on annotation generation method of test example and device | |
CN110287696A (en) | A kind of detection method, device and the equipment of the shell process that rebounds | |
CN111831554B (en) | Code checking method and device | |
CN107820608A (en) | For the method and apparatus for the Debugging message for producing, capture, storing and loading the test script to fail | |
EP2951680B1 (en) | Acquiring identification of an application lifecycle management entity associated with similar code | |
US20130339798A1 (en) | Methods for automated software testing and devices thereof | |
US9563541B2 (en) | Software defect detection identifying location of diverging paths | |
CN107038117B (en) | Web automatic testing method based on definition-reference between event processing functions | |
JP2013218492A (en) | Software test automatic evaluation device and method | |
US20170308379A1 (en) | Evaluating documentation coverage | |
CN112765041B (en) | Game automation testing method and device and electronic equipment | |
US11422696B2 (en) | Representation of user interface interactive regions | |
US10339229B1 (en) | Simulation observability and control of all hardware and software components of a virtual platform model of an electronics system | |
WO2012066635A1 (en) | Test method, test device, and test execution program | |
CN109710305A (en) | A kind of acquisition methods, device, storage medium and terminal device for developing information |
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 | ||
GR01 | Patent grant | ||
GR01 | Patent grant |