CN117873899B - Automatic testing method and device for UI interface, terminal equipment and storage medium - Google Patents

Automatic testing method and device for UI interface, terminal equipment and storage medium

Info

Publication number
CN117873899B
CN117873899B CN202410140060.7A CN202410140060A CN117873899B CN 117873899 B CN117873899 B CN 117873899B CN 202410140060 A CN202410140060 A CN 202410140060A CN 117873899 B CN117873899 B CN 117873899B
Authority
CN
China
Prior art keywords
test
result
tested
expected
interface
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN202410140060.7A
Other languages
Chinese (zh)
Other versions
CN117873899A (en
Inventor
张少华
万正勇
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Jiuke Information Technology Shenzhen Co ltd
Original Assignee
Jiuke Information Technology Shenzhen Co ltd
Filing date
Publication date
Application filed by Jiuke Information Technology Shenzhen Co ltd filed Critical Jiuke Information Technology Shenzhen Co ltd
Priority to CN202410140060.7A priority Critical patent/CN117873899B/en
Publication of CN117873899A publication Critical patent/CN117873899A/en
Application granted granted Critical
Publication of CN117873899B publication Critical patent/CN117873899B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Abstract

The application is suitable for the technical field of automatic testing, and provides an automatic testing method and device for a UI (user interface), terminal equipment and a storage medium. The automatic testing method of the UI interface comprises the following steps: acquiring a screenshot about a UI interface; carrying out image recognition on the screenshot, and recognizing attribute information of an element to be tested; determining a unique element to be tested based on the attribute information; designing a test case based on the element to be tested; executing the test case by using an RPA tool to obtain a test result; and analyzing the test result to obtain an analysis report. According to the embodiment of the application, the screenshot of the UI interface is subjected to image recognition, so that the attribute information of the element to be tested is obtained, a user does not need to manually search the attribute information of the element to be tested, errors caused by manual operation are avoided, and the automatic test efficiency is improved. Meanwhile, the embodiment of the application can automatically design the test case, and further improves the test efficiency.

Description

Automatic testing method and device for UI interface, terminal equipment and storage medium
Technical Field
The application belongs to the technical field of automatic testing, and particularly relates to an automatic testing method and device for a UI (user interface), terminal equipment and a storage medium.
Background
The automatic test means that a robot process automation (Robotic Process Automation, RPA) tool is utilized to automatically execute test cases to obtain test results, so that the automatic test is realized. The technique is applicable to scenarios requiring a large number of repeated tests. In automatically testing a UI interface, it is particularly necessary to automatically test elements (e.g., buttons, text boxes, etc.) in the UI interface. However, in the related art, a user is required to manually search attribute information of various elements and manually design corresponding test cases, which is prone to error and has low test efficiency.
Disclosure of Invention
The embodiment of the application provides an automatic testing method, an automatic testing device, terminal equipment and a storage medium for a UI (user interface), which can solve the problems that in the related art, errors are easy to occur and the testing efficiency is low when the UI is automatically tested.
In a first aspect, an embodiment of the present application provides an automatic testing method for a UI interface, including:
Acquiring a screenshot about a UI interface;
carrying out image recognition on the screenshot, and recognizing attribute information of an element to be tested;
Determining a unique element to be tested based on the attribute information;
designing a test case based on the element to be tested;
executing the test case by using an RPA tool to obtain a test result;
and analyzing the test result to obtain an analysis report.
In a second aspect, an embodiment of the present application provides an automatic testing apparatus for a UI interface, including:
the acquisition module is used for acquiring screenshot about the UI interface;
the identification module is used for carrying out image identification on the screenshot and identifying attribute information of the element to be tested;
A determining module, configured to determine a unique element to be tested based on the attribute information;
the design module is used for designing a test case based on the element to be tested;
the execution module is used for executing the test case by utilizing an RPA tool to obtain a test result;
and the analysis module is used for analyzing the test result to obtain an analysis report.
In a third aspect, an embodiment of the present application provides a terminal device, including a memory, a processor, and a computer program stored in the memory and capable of running on the processor, where the processor implements the steps of the automatic testing method for a UI interface described above when the processor executes the computer program.
In a fourth aspect, embodiments of the present application provide a computer readable storage medium storing a computer program which, when executed by a processor, implements the steps of the above-described UI interface automatic test method.
In a fifth aspect, an embodiment of the present application provides a computer program product, which when run on a terminal device, causes the terminal device to execute the automatic testing method of the UI interface.
Compared with the prior art, the embodiment of the application has the beneficial effects that: according to the embodiment of the application, the screenshot about the UI interface is obtained, the screenshot is subjected to image recognition, the attribute information of the element to be tested is identified, the unique element to be tested is determined based on the attribute information, the test case is designed based on the element to be tested, the test case is executed by using an RPA tool, the test result is obtained, and the analysis report is obtained by analyzing the test result. According to the embodiment of the application, the screenshot of the UI interface is subjected to image recognition, so that the attribute information of the element to be tested is obtained, a user does not need to manually search the attribute information of the element to be tested, errors caused by manual operation are avoided, and the automatic test efficiency is improved. Meanwhile, the embodiment of the application can automatically design the test case, and further improves the test efficiency.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings that are needed in the embodiments or the description of the prior art will be briefly described below, it being obvious that the drawings in the following description are only some embodiments of the present application, and that other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
Fig. 1 is a schematic implementation flow diagram of an automatic testing method for a UI according to an embodiment of the present application;
fig. 2 is a schematic structural diagram of an automatic testing device for UI according to an embodiment of the present application;
fig. 3 is a schematic structural diagram of a terminal device according to an embodiment of the present application.
Detailed Description
The present application will be described in further detail with reference to the drawings and examples, in order to make the objects, technical solutions and advantages of the present application more apparent. It should be understood that the specific embodiments described herein are for purposes of illustration only and are not intended to limit the scope of the application. All other embodiments, which can be made by a person skilled in the art without any inventive effort, are intended to be protected by the present application based on the embodiments of the present application.
It is noted that the terms "comprising," "including," and "having," and any variations thereof, in the description and claims of the application and in the foregoing figures, are intended to cover non-exclusive inclusions. For example, a process, method, terminal, article, or apparatus that comprises a list of steps or elements is not limited to only those listed steps or elements but may include other steps or elements not listed or inherent to such process, method, article, or apparatus. In the claims, specification, and drawings of the present application, relational terms such as "first" and "second", and the like are used solely to distinguish one entity/operation/object from another entity/operation/object without necessarily requiring or implying any such real-time relationship or order between such entities/operations/objects.
Reference herein to "an embodiment" means that a particular feature, structure, or characteristic described in connection with the embodiment may be included in at least one embodiment of the application. The appearances of such phrases in various places in the specification are not necessarily all referring to the same embodiment, nor are separate or alternative embodiments mutually exclusive of other embodiments. Those of skill in the art will explicitly and implicitly appreciate that the embodiments described herein may be combined with other embodiments.
The automatic test means that a robot process automation (Robotic Process Automation, RPA) tool is utilized to automatically execute test cases to obtain test results, so that the automatic test is realized. The technique is applicable to scenarios requiring a large number of repeated tests. In automatically testing a UI interface, it is particularly necessary to automatically test elements (e.g., buttons, text boxes, etc.) in the UI interface. However, in the related art, a user is required to manually search attribute information of various elements and manually design corresponding test cases, which is prone to error and has low test efficiency.
Therefore, according to the embodiment of the application, the screenshot of the UI interface is subjected to image recognition, so that the attribute information of the element to be tested is obtained, a user does not need to manually search the attribute information of the element to be tested, errors caused by manual operation are avoided, and the automatic test efficiency is improved. Meanwhile, the embodiment of the application can automatically design the test case, and further improves the test efficiency.
In order to illustrate the technical scheme of the application, the following description is made by specific examples.
Fig. 1 shows a schematic implementation flow diagram of an automatic testing method for a UI according to an embodiment of the present application, where the method may be applied to a terminal device. The terminal device may be a mobile phone, tablet computer, notebook computer, ultra-mobile personal computer (UMPC), netbook, etc.
Specifically, the automatic test method for UI interface may include the following steps S101 to S106.
Step S101, a screenshot about the UI interface is acquired.
In the embodiment of the application, for the UI interface needing to be automatically tested, the terminal equipment can directly screen-capture the UI interface containing the attribute information, or can screen-capture the UI interface containing the attribute information in advance and then store the screen-capture in the memory of the terminal equipment, and when the screen-capture is needed, the terminal equipment can call the screen-capture from the memory.
Step S102, performing image recognition on the screenshot, and recognizing attribute information of the element to be tested.
The element to be tested is an element to be automatically tested in the UI interface, for example, a button, a text box, a drop-down box, etc. The attribute information is used to characterize various attributes of the element to be tested.
In the embodiment of the application, after the UI screenshot containing the attribute information is obtained, the terminal equipment can utilize an image recognition algorithm, such as a CNN algorithm, a perceptron algorithm and the like, to perform image recognition on the screenshot, and recognize and extract the attribute information of the element to be tested from the screenshot, such as the character size, skip link, display text, other xpath paths, css patterns and the like of the element to be tested.
Step S103, determining a unique element to be tested based on the attribute information.
In the embodiment of the application, after the attribute information of the element to be tested is identified, the terminal equipment can find the appointed element to be tested through the attribute information, so that the accuracy and the uniqueness of the element to be tested are ensured.
Step S104, designing a test case based on the element to be tested.
In the embodiment of the application, after the unique element to be tested is determined, the terminal equipment can design the corresponding test case according to the attribute information and the corresponding function of the element to be tested so as to verify whether the function of the element to be tested is normal.
Step S105, executing the test case by using the RPA tool to obtain a test result.
The test result is a result obtained after the RPA tool executes the test case, and specifically may be an interface screenshot after the test case is executed.
In the embodiment of the application, after the test case is designed, the terminal equipment can execute the test case by utilizing the RPA tool, operate according to a certain sequence and rule, simulate the real operation behavior of a user and finally obtain a test result.
And S106, analyzing the test result to obtain an analysis report.
In the embodiment of the application, after the test result is obtained, the terminal equipment can analyze the test result according to the test result and the expected result, for example, whether the automatic test passes or not, and the final analysis report is obtained.
Compared with the prior art, the embodiment of the application has the beneficial effects that: according to the embodiment of the application, the screenshot about the UI interface is obtained, the screenshot is subjected to image recognition, the attribute information of the element to be tested is identified, the unique element to be tested is determined based on the attribute information, the test case is designed based on the element to be tested, the test case is executed by using an RPA tool, the test result is obtained, and the analysis report is obtained by analyzing the test result. According to the embodiment of the application, the screenshot of the UI interface is subjected to image recognition, so that the attribute information of the element to be tested is obtained, a user does not need to manually search the attribute information of the element to be tested, errors caused by manual operation are avoided, and the automatic test efficiency is improved. Meanwhile, the embodiment of the application can automatically design the test case, and further improves the test efficiency.
In some embodiments of the present application, the designing the test case based on the element to be tested may specifically include steps S401 to S404.
Step S401, obtaining a requirement document corresponding to an element to be tested.
Wherein the requirements document describes the functions that the element to be tested needs to implement.
In the embodiment of the application, for each element to be tested, a user can edit a requirement document corresponding to the element in advance and store the requirement document in a memory of the terminal equipment. After the element to be tested is determined, the terminal device can acquire the corresponding requirement document from the memory according to the element to be tested.
Step S402, analyzing the demand document by using a natural language processing technology, and extracting a first test environment, a first test step, a first expected result and a data requirement.
The test environment is used for limiting the environment for testing the element to be tested, the test step is used for limiting the step for testing the element to be tested, the expected result is the expected result after the element to be tested is tested, and the data requirement is the requirement of input data about the element to be tested.
In the embodiment of the application, after the required document is obtained, the terminal equipment can analyze the required document by utilizing a natural language processing technology, specifically using an NLP tool or software, and extracting a first test environment, a first test step, a first expected result and a data requirement from the required document.
It should be appreciated that in the requirements document, the user typically does not give explicit test data, but rather gives the relevant requirements of the test data.
Step S403, generating corresponding first test data by using the regular expression according to the data requirement.
The test data are input data of the test case.
In the embodiment of the application, after the data requirement is extracted, the terminal equipment can generate corresponding first test data according to the data requirement by using the regular expression.
For example, in order to test the login function in the UI interface, the requirement document may record a data requirement that "the user name is a mobile phone number, the mobile phone number input box is limited to only inputting numbers, character input is unsuccessful except numbers, and the mobile phone number is limited to inputting 11 digits". Based on the data requirements, the terminal device may generate first test data using the regular expression "+\d {11} $". Specifically, "≡" in the regular expression indicates the start of a character string, "\d" indicates a numeric character, "{11}" indicates the preceding character (here a number) repeated 11 times, "$" indicates the end of a character string, and according to the regular expression, a cell phone number of 11 bits (i.e., first test data) such as "12345678901, 98765432100, 54321098765" or the like can be randomly generated.
Step S404, a test case is designed according to the first test environment, the first test step, the first expected result and the first test data.
In the embodiment of the application, after the first test environment, the first test step, the first expected result and the first test data are obtained, the terminal device can design the test case according to the first test environment, the first test step, the first expected result and the first test data.
According to the embodiment of the application, the test case can be automatically designed according to the element to be tested, so that the degree of automation of automatic test of the element to be tested is further improved, the test efficiency is further improved, and the occurrence of manual errors can be avoided.
In some embodiments of the present application, the analyzing the test result to obtain the analysis report may specifically include steps S501 to S505.
Step S501, comparing the test result of each test case with the corresponding expected result to obtain a comparison result.
The comparison result comprises passing or failing, the failing can indicate that the automatic test of the element to be tested corresponding to the test case fails, and the passing can indicate that the automatic test of the element to be tested corresponding to the test case fails. The expected results are the expected results recorded in the test cases.
It will be appreciated that when automatically testing a UI interface, it is often necessary to test a plurality of elements to be tested. Therefore, the embodiment of the application can automatically test a plurality of elements to be tested, and a corresponding test result can be obtained by automatically testing each element to be tested.
In the embodiment of the application, the terminal equipment can compare the test result of each test case with the corresponding expected result, specifically can capture the test result and capture the expected result, and can obtain the comparison result by comparing the similarity between the two captures.
Specifically, in some embodiments of the present application, the comparing the test result of each test case with the corresponding expected result to obtain the comparison result may specifically include steps S601 to S608.
Step S601, capturing an interface corresponding to the test result to obtain a test image.
In the embodiment of the application, when the RPA tool executes the test case and the interface of the test result is displayed, the terminal equipment can capture the interface corresponding to the test result to obtain a capture, and the capture is the test image.
Step S602, obtaining an expected image corresponding to the expected result.
It can be understood that, for the expected result, the terminal device may perform screenshot on the interface corresponding to the expected result in advance, so as to obtain the expected image. The expected image may then be recorded in the test case.
In the embodiment of the application, the terminal equipment can acquire the expected image from the test case.
Step S603, performing text recognition on the test image to obtain a test result text corresponding to the test result.
Wherein the test result text corresponds to the text recorded on the test image.
In the embodiment of the application, the terminal equipment can utilize a character recognition program, such as an OCR recognition algorithm, to perform character recognition on the test image so as to obtain a test result text corresponding to the test result.
Step S604, performing word recognition on the expected image to obtain an expected result text corresponding to the expected result.
Wherein the expected result text corresponds to text recorded on the expected image.
In the embodiment of the application, the terminal equipment can also utilize a character recognition program, such as an OCR recognition algorithm, to perform character recognition on the expected image so as to obtain an expected result text corresponding to the expected result.
Step S605, comparing the test result text with the expected result text to obtain a text comparison result, wherein the text comparison result comprises consistency or inconsistency.
In the embodiment of the application, after the test result text and the expected result text are obtained, the terminal equipment can compare the test result text with the expected result text one by one, so that a text comparison result is obtained. Specifically, when the test result text is completely consistent with the expected result text, the corresponding text comparison result is consistent. When the test result text is not completely consistent with the expected result text, the corresponding text comparison result is inconsistent.
Step S606, when the text comparison result is consistent, calculating the similarity between the test image and the expected image by using a similarity algorithm.
It should be understood that, for the element to be tested in the UI interface, besides the text in the test result needs to be consistent with the text in the expected result, the appearance features of the element in the test result, such as size, shape, color, etc., also need to be consistent with the expected result, so that the test result can be considered to be consistent with the expected result.
In the embodiment of the application, when the text comparison results are consistent, the terminal equipment can calculate the similarity between the test image and the expected image through a similarity algorithm, such as a histogram similarity algorithm, a matrix decomposition similarity algorithm, a feature extraction similarity algorithm and the like.
In step S607, when the similarity exceeds a preset similarity threshold, a first comparison result is obtained.
Wherein the first comparison result is a pass.
In the embodiment of the application, the similarity threshold value can be set according to the experience of the user, for example, can be set to be 95%. When the similarity exceeds a preset similarity threshold, the test result can be considered to be consistent with the expected result, and the terminal equipment can obtain a first comparison result, wherein the first comparison result is passed.
In step S608, when the similarity does not exceed the similarity threshold, a second comparison result is obtained.
Wherein the second comparison result is not passed.
In the embodiment of the application, when the similarity does not exceed the preset similarity threshold, the test result is not consistent with the expected result, and the terminal equipment can obtain a second comparison result, wherein the second comparison result is passed.
According to the embodiment of the application, the test result and the expected result are firstly subjected to character recognition, and when the character recognition results of the test result and the expected result are consistent, the similarity calculation is performed on the test image corresponding to the test result and the expected image corresponding to the expected result, so that whether the test result and the expected result are consistent is further judged according to the similarity. According to the embodiment of the application, the test result is compared with the expected result from multiple dimensions, so that the accuracy of the comparison result is ensured.
In addition, in other embodiments of the present application, after comparing the test result text with the expected result text to obtain the text comparison result, the method further includes the following steps:
and when the text comparison results are inconsistent, obtaining a third comparison result, wherein the third comparison result is not passed.
In the embodiment of the application, when the text comparison result is inconsistent, the terminal equipment can directly obtain a third comparison result, and the third comparison result is not passed.
It should be noted that when the comparison result is not passing, there may be two reasons, one is that the function of the element to be tested is problematic, and one is that the function of the element to be tested is not problematic, but the expected result in the test case is problematic. It can be understood that the UI interface has the characteristics of strong interactivity, uncontrollable style, faster version iteration, etc., so that there may be a scenario, specifically, when making an expected result of a certain element to be tested, an element to be tested in a low version is used. After two days, the version is updated and the element to be tested is updated. At this time, according to the test case designed by the updated element to be tested, the comparison result will not pass after execution, and at this time, the problem is not caused by the function of the current element to be tested, but caused by the fact that the expected result is not updated.
In view of this, in some embodiments of the present application, after comparing the test result of each test case with the corresponding expected result to obtain the comparison result, the method may further include steps S701 to S705.
And step S701, if the comparison result is not passed, sending the test result and the expected result to the user terminal.
In the embodiment of the application, if the comparison result is not passed, the terminal equipment can send the test result and the expected result to the user terminal. Specifically, a screenshot corresponding to the test result and a screenshot corresponding to the expected result are sent to the user terminal, and the type of each screenshot is marked.
It will be appreciated that the user terminal may be a different terminal than the terminal device, for example the terminal device may be a computer and the user terminal may be a mobile terminal of the user. Of course, the user terminal may be the same terminal as the terminal device, for example, the user terminal and the terminal device are both computers, the user may automatically test the element to be tested on the terminal device, and when the comparison result fails, the terminal device may send the screenshot corresponding to the test result and the screenshot corresponding to the expected result to the application program corresponding to the terminal device (i.e. the user terminal at this time).
Step S702, receiving a replacement instruction sent by the user terminal, and replacing the content of the expected result with the content of the test result to obtain an updated expected result.
The replacement instruction is used for indicating the terminal equipment to replace the content of the expected result with the content of the test result.
In the embodiment of the application, after the user terminal receives the test result and the expected result, the user can check and judge the reason that the comparison result does not pass on the user terminal. If the user judges that the comparison result is not passed because the expected result is not updated in time, the user can send a replacement instruction to the terminal equipment through the user terminal. After receiving the replacement instruction, the terminal device can replace the content of the expected result with the content of the test result, namely delete the screenshot corresponding to the original expected result, and use the screenshot corresponding to the test result as the screenshot corresponding to the updated expected result to obtain the updated expected result.
Step S703, generating an update test case based on the update expected result.
In the embodiment of the application, after obtaining the updated expected result, the terminal equipment can replace the original expected result by using the updated expected result, and generate the updated test case by using the updated expected result, the test environment, the test step and the test data.
Step S704, the RPA tool is utilized to execute the update test case, and the update test result is obtained.
In the embodiment of the application, the terminal equipment can execute the update test case again by utilizing the RPA tool, so as to obtain the update test result. For a specific implementation process, reference may be made to step S105, which is not described herein.
Step S705, analyzing the updated test result to obtain an updated analysis report.
In the embodiment of the application, the terminal equipment can analyze the updated test result so as to obtain an updated analysis report. For a specific analysis process, reference may be made to step S106, which is not described herein.
According to the embodiment of the application, the outdated expected result can be updated by utilizing the test result according to the replacement instruction sent by the user, and the expected result can be updated in time, so that the test efficiency is improved, and the method is very suitable for a scene with a UI interface and a version with a faster iteration. And the updated test case can be designed again according to the updated expected result, so that whether the updated test case is accurate or not is verified.
Step S502, calculating the passing rate of the test cases according to the number of the test cases passing through the comparison result and the total number of the test cases.
In the embodiment of the application, the terminal equipment can count the number of the test cases passing the comparison result in all the test cases, and acquire the total number of the test cases. And dividing the number of the passed test cases by the total number of the test cases to obtain the passing rate of the test cases in the test.
In step S503, a start execution time and an end execution time of each test case are obtained.
In the embodiment of the application, the terminal equipment can count the time of starting executing each test case per se to obtain the starting execution time. And the time for executing each test case per se can be counted to obtain the execution ending time.
Step S504, calculating the execution time of each test case according to the start execution time and the end execution time.
In the embodiment of the application, the terminal equipment can subtract the ending execution time and the starting execution time of each test case, so that the execution time of each test case can be obtained.
Step S505, according to the comparison result, the test case passing rate and the execution time, generating an analysis report.
In the embodiment of the application, after the comparison result, the test case passing rate and the execution time are obtained, the terminal equipment can fill the comparison result, the test case passing rate and the execution time to the corresponding positions of the blank templates according to the preset templates to obtain a final analysis report.
In the embodiment of the application, the analysis report is generated based on the data such as the comparison result, the passing rate of the test case, the execution time and the like, and the reference can be provided for software development and maintenance.
In addition to automatically designing test exceptions according to the elements to be tested, in some scenarios unsuitable for automatically designing test cases, the embodiments of the present application may design test cases according to information provided by a user, thereby covering more use scenarios.
Specifically, in other embodiments of the present application, the designing the test case based on the element to be tested may specifically include step S801 and step S802.
Step S801, a second test environment, second test data, a second test step, and a second expected result corresponding to the element to be tested are obtained.
The second test environment, the second test data, the second test step and the second expected result are all data input by the user.
In the embodiment of the application, the user can input the second test environment, the second test data, the second test step and the second expected result corresponding to the element to be tested to the terminal equipment. The terminal device may receive the data.
Step S802, designing a test case according to the second test environment, the second test data, the second test step and the second expected result.
In the embodiment of the application, after the second test environment, the second test data, the second test step and the second expected result are obtained, the terminal device can design and obtain the test case according to the second test environment, the second test data, the second test step and the second expected result.
Fig. 2 is a schematic structural diagram of an automatic testing apparatus for a UI according to an embodiment of the present application, where the automatic testing apparatus 2 for a UI may be configured on a terminal device, and specifically, the automatic testing apparatus 2 for a UI may include:
an acquisition module 201, configured to acquire a screenshot about a UI interface;
the identification module 202 is configured to perform image identification on the screenshot, and identify attribute information of an element to be tested;
a determining module 203, configured to determine a unique element to be tested based on the attribute information;
a design module 204, configured to design a test case based on the element to be tested;
an execution module 205, configured to execute the test case by using an RPA tool, to obtain a test result;
and the analysis module 206 is used for analyzing the test result to obtain an analysis report.
Compared with the prior art, the embodiment of the application has the beneficial effects that: according to the embodiment of the application, the screenshot about the UI interface is obtained, the screenshot is subjected to image recognition, the attribute information of the element to be tested is identified, the unique element to be tested is determined based on the attribute information, the test case is designed based on the element to be tested, the test case is executed by using an RPA tool, the test result is obtained, and the analysis report is obtained by analyzing the test result. According to the embodiment of the application, the screenshot of the UI interface is subjected to image recognition, so that the attribute information of the element to be tested is obtained, a user does not need to manually search the attribute information of the element to be tested, errors caused by manual operation are avoided, and the automatic test efficiency is improved. Meanwhile, the embodiment of the application can automatically design the test case, and further improves the test efficiency.
In some embodiments of the present application, the design module 204 described above may also be used to: acquiring a requirement document corresponding to the element to be tested; analyzing the demand document by using a natural language processing technology, and extracting a first test environment, a first test step, a first expected result and a data requirement; generating corresponding first test data by using a regular expression according to the data requirement; and designing the test case according to the first test environment, the first test step, the first expected result and the first test data.
In some embodiments of the present application, the analysis module 206 described above may also be used to: comparing the test result of each test case with a corresponding expected result to obtain a comparison result, wherein the comparison result comprises passing or failing; calculating the passing rate of the test cases according to the number of the test cases passing through the comparison result and the total number of the test cases; acquiring the start execution time and the end execution time of each test case; calculating the execution time of each test case according to the start execution time and the end execution time; and generating the analysis report according to the comparison result, the test case passing rate and the execution time.
In some embodiments of the present application, the analysis module 206 described above may also be used to: the interface screenshot corresponding to the test result is taken, and a test image is obtained; acquiring an expected image corresponding to the expected result; performing character recognition on the test image to obtain a test result text corresponding to the test result; performing word recognition on the expected image to obtain an expected result text corresponding to the expected result; comparing the test result text with the expected result text to obtain a text comparison result, wherein the text comparison result comprises consistency or inconsistency; when the text comparison results are consistent, calculating the similarity between the test image and the expected image by using a similarity algorithm; when the similarity exceeds a preset similarity threshold, a first comparison result is obtained, and the first comparison result is passed; and when the similarity does not exceed the similarity threshold, obtaining a second comparison result, wherein the second comparison result is not passed.
In some embodiments of the present application, the analysis module 206 described above may also be used to: and when the text comparison results are inconsistent, obtaining a third comparison result, wherein the third comparison result is not passed.
In some embodiments of the present application, the automatic test equipment 2 of the UI interface may further include an update module for: if the comparison result is not passed, the test result and the expected result are sent to a user terminal; receiving a replacement instruction sent by the user terminal, and replacing the content of the expected result with the content of the test result to obtain an updated expected result; generating an update test case based on the update expected result; executing the updated test case by using an RPA tool to obtain an updated test result; and analyzing the updated test result to obtain an updated analysis report.
In some embodiments of the present application, the design module 204 described above may also be used to: acquiring a second test environment, second test data, a second test step and a second expected result corresponding to the element to be tested; and designing the test case according to the second test environment, the second test data, the second test step and the second expected result.
Fig. 3 is a schematic diagram of a terminal device according to an embodiment of the present application. The terminal device 3 may include: a processor 301, a memory 302 and a computer program 303, e.g. an automatic test program of a UI interface, stored in said memory 302 and executable on said processor 301. The processor 301 executes the computer program 303 to implement the steps in the above-described embodiments of the automatic test method for each UI interface, for example, steps S101 to S106 shown in fig. 1. Or the processor 301 may perform the functions of the modules/units in the above-described apparatus embodiments when executing the computer program 303, for example, the obtaining module 201, the identifying module 202, the determining module 203, the designing module 204, the executing module 205, and the analyzing module 206 shown in fig. 2.
The computer program may be divided into one or more modules/units, which are stored in the memory 302 and executed by the processor 301 to accomplish the present application. The one or more modules/units may be a series of computer program instruction segments capable of performing the specified functions, which instruction segments are used for describing the execution of the computer program in the terminal device.
The terminal device may include, but is not limited to, a processor 301, a memory 302. It will be appreciated by those skilled in the art that fig. 3 is merely an example of a terminal device and is not limiting of the terminal device, and may include more or fewer components than shown, or may combine some components, or different components, e.g., the terminal device may also include input-output devices, network access devices, buses, etc.
The Processor 301 may be a central processing unit (Central Processing Unit, CPU), but may also be other general purpose processors, digital signal processors (DIGITAL SIGNAL Processor, DSP), application SPECIFIC INTEGRATED Circuit (ASIC), off-the-shelf Programmable gate array (Field-Programmable GATE ARRAY, FPGA) or other Programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, or the like. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
The memory 302 may be an internal storage unit of the terminal device, such as a hard disk or a memory of the terminal device. The memory 302 may also be an external storage device of the terminal device, such as a plug-in hard disk, a smart memory card (SMART MEDIA CARD, SMC), a Secure Digital (SD) card, a flash memory card (FLASH CARD) or the like, which are provided on the terminal device. Further, the memory 302 may also include both an internal storage unit and an external storage device of the terminal device. The memory 302 is used for storing the computer program and other programs and data required by the terminal device. The memory 302 may also be used to temporarily store data that has been output or is to be output.
It should be noted that, for convenience and brevity of description, the structure of the above terminal device may also refer to a specific description of the structure in the method embodiment, which is not repeated herein.
It will be apparent to those skilled in the art that, for convenience and brevity of description, only the above-described division of the functional units and modules is illustrated, and in practical application, the above-described functional distribution may be performed by different functional units and modules according to needs, i.e. the internal structure of the apparatus is divided into different functional units or modules to perform all or part of the above-described functions. The functional units and modules in the embodiment may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit, where the integrated units may be implemented in a form of hardware or a form of a software functional unit. In addition, the specific names of the functional units and modules are only for distinguishing from each other, and are not used for limiting the protection scope of the present application. The specific working process of the units and modules in the above system may refer to the corresponding process in the foregoing method embodiment, which is not described herein again.
The embodiment of the application also provides a computer readable storage medium, wherein the computer readable storage medium stores a computer program, and the computer program can realize the steps in the automatic testing method of the UI interface when being executed by a processor.
The embodiment of the application provides a computer program product which can realize the steps in the automatic testing method of the UI interface when being executed by a mobile terminal when the computer program product runs on the mobile terminal.
In the foregoing embodiments, the descriptions of the embodiments are emphasized, and in part, not described or illustrated in any particular embodiment, reference is made to the related descriptions of other embodiments.
Those of ordinary skill in the art will appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
In the embodiments provided in the present application, it should be understood that the disclosed apparatus/terminal device and method may be implemented in other manners. For example, the apparatus/terminal device embodiments described above are merely illustrative, e.g., the division of the modules or units is merely a logical function division, and there may be additional divisions in actual implementation, e.g., multiple units or components may be combined or integrated into another system, or some features may be omitted or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection via interfaces, devices or units, which may be in electrical, mechanical or other forms.
The units described as separate units may or may not be physically separate, and units shown as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
In addition, each functional unit in the embodiments of the present application may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit. The integrated units may be implemented in hardware or in software functional units.
The integrated modules/units, if implemented in the form of software functional units and sold or used as stand-alone products, may be stored in a computer readable storage medium. Based on such understanding, the present application may implement all or part of the flow of the method of the above embodiment, or may be implemented by a computer program to instruct related hardware, where the computer program may be stored in a computer readable storage medium, and when the computer program is executed by a processor, the computer program may implement the steps of each of the method embodiments described above. Wherein the computer program comprises computer program code which may be in source code form, object code form, executable file or some intermediate form etc. The computer readable medium may include: any entity or device capable of carrying the computer program code, a recording medium, a U disk, a removable hard disk, a magnetic disk, an optical disk, a computer Memory, a Read-Only Memory (ROM), a random access Memory (Random Access Memory, RAM), an electrical carrier signal, a telecommunications signal, a software distribution medium, and so forth. It should be noted that the computer readable medium contains content that can be appropriately scaled according to the requirements of jurisdictions in which such content is subject to legislation and patent practice, such as in certain jurisdictions in which such content is subject to legislation and patent practice, the computer readable medium does not include electrical carrier signals and telecommunication signals.
The above embodiments are only for illustrating the technical solution of the present application, and not for limiting the same; although the application has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical scheme described in the foregoing embodiments can be modified or some technical features thereof can be replaced by equivalents; such modifications and substitutions do not depart from the spirit and scope of the technical solutions of the embodiments of the present application, and are intended to be included in the scope of the present application.

Claims (7)

1. An automatic testing method for a UI interface is characterized by comprising the following steps:
Acquiring a screenshot about a UI interface;
Carrying out image recognition on the screenshot to identify attribute information of an element to be tested, wherein the attribute information of the element to be tested comprises one or more of character size, skip link, display text, other xpath paths and css patterns of the element to be tested;
Determining a unique element to be tested based on the attribute information;
designing a test case based on the element to be tested;
executing the test case by using an RPA tool to obtain a test result;
Analyzing the test result to obtain an analysis report;
The design of the test case based on the element to be tested includes:
acquiring a requirement document corresponding to the element to be tested;
Analyzing the demand document by using a natural language processing technology, and extracting a first test environment, a first test step, a first expected result and a data requirement;
generating corresponding first test data by using a regular expression according to the data requirement;
designing the test case according to the first test environment, the first test step, the first expected result and the first test data;
wherein, the analyzing the test result to obtain an analysis report includes:
comparing the test result of each test case with a corresponding expected result to obtain a comparison result, wherein the comparison result comprises passing or failing;
calculating the passing rate of the test cases according to the number of the test cases passing through the comparison result and the total number of the test cases;
acquiring the start execution time and the end execution time of each test case;
Calculating the execution time of each test case according to the start execution time and the end execution time;
Generating the analysis report according to the comparison result, the test case passing rate and the execution time;
The comparing the test result of each test case with the corresponding expected result to obtain a comparison result includes:
The interface screenshot corresponding to the test result is taken, and a test image is obtained;
Acquiring an expected image corresponding to the expected result;
performing character recognition on the test image to obtain a test result text corresponding to the test result;
performing word recognition on the expected image to obtain an expected result text corresponding to the expected result;
Comparing the test result text with the expected result text to obtain a text comparison result, wherein the text comparison result comprises consistency or inconsistency, and when the text comparison result is consistent, the size, shape and color requirements of elements in the test result are consistent with the size, shape and color of the expected result elements;
When the text comparison results are consistent, calculating the similarity between the test image and the expected image by using a similarity algorithm;
when the similarity exceeds a preset similarity threshold, a first comparison result is obtained, and the first comparison result is passed;
And when the similarity does not exceed the similarity threshold, obtaining a second comparison result, wherein the second comparison result is not passed.
2. The method for automatically testing a UI interface according to claim 1, wherein after said comparing the test result text with the expected result text to obtain a text comparison result, the method further comprises:
And when the text comparison results are inconsistent, obtaining a third comparison result, wherein the third comparison result is not passed.
3. The method for automatically testing a UI interface according to claim 1, wherein after comparing the test result of each test case with a corresponding expected result, the method further comprises:
if the comparison result is not passed, the test result and the expected result are sent to a user terminal;
receiving a replacement instruction sent by the user terminal, and replacing the content of the expected result with the content of the test result to obtain an updated expected result;
Generating an update test case based on the update expected result;
executing the updated test case by using an RPA tool to obtain an updated test result;
and analyzing the updated test result to obtain an updated analysis report.
4. The automatic testing method of UI interface according to claim 1, wherein the designing of test cases based on the element to be tested includes:
Acquiring a second test environment, second test data, a second test step and a second expected result corresponding to the element to be tested;
And designing the test case according to the second test environment, the second test data, the second test step and the second expected result.
5. An automatic testing device for UI interface, which is used for implementing the automatic testing method for UI interface of claim 1, comprising:
the acquisition module is used for acquiring screenshot about the UI interface;
the identification module is used for carrying out image identification on the screenshot and identifying attribute information of the element to be tested;
A determining module, configured to determine a unique element to be tested based on the attribute information;
the design module is used for designing a test case based on the element to be tested;
the execution module is used for executing the test case by utilizing an RPA tool to obtain a test result;
and the analysis module is used for analyzing the test result to obtain an analysis report.
6. A terminal device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, the processor implementing the steps of the automatic test method of a UI interface according to any one of claims 1 to 4 when the computer program is executed.
7. A computer readable storage medium storing a computer program, wherein the computer program when executed by a processor implements the steps of the automatic test method for UI interfaces according to any one of claims 1 to 4.
CN202410140060.7A 2024-01-30 Automatic testing method and device for UI interface, terminal equipment and storage medium Active CN117873899B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202410140060.7A CN117873899B (en) 2024-01-30 Automatic testing method and device for UI interface, terminal equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202410140060.7A CN117873899B (en) 2024-01-30 Automatic testing method and device for UI interface, terminal equipment and storage medium

Publications (2)

Publication Number Publication Date
CN117873899A CN117873899A (en) 2024-04-12
CN117873899B true CN117873899B (en) 2024-07-09

Family

ID=

Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112749077A (en) * 2019-10-31 2021-05-04 博智安全科技股份有限公司 Graphical user interface automatic testing method based on artificial intelligence
CN114116441A (en) * 2020-12-30 2022-03-01 京东数科海益信息科技有限公司 UI (user interface) testing method and device, electronic equipment and storage medium

Patent Citations (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112749077A (en) * 2019-10-31 2021-05-04 博智安全科技股份有限公司 Graphical user interface automatic testing method based on artificial intelligence
CN114116441A (en) * 2020-12-30 2022-03-01 京东数科海益信息科技有限公司 UI (user interface) testing method and device, electronic equipment and storage medium

Similar Documents

Publication Publication Date Title
KR102171220B1 (en) Character recognition method, device, server and storage medium of claim documents
CN107783898B (en) Test method and test equipment for mobile application
CN108090567B (en) Fault diagnosis method and device for power communication system
CN109800320B (en) Image processing method, device and computer readable storage medium
CN109783785B (en) Method and device for generating experiment detection report and computer equipment
CN107491536B (en) Test question checking method, test question checking device and electronic equipment
CN109271315B (en) Script code detection method, script code detection device, computer equipment and storage medium
CN112181835B (en) Automatic test method, device, computer equipment and storage medium
CN110941978B (en) Face clustering method and device for unidentified personnel and storage medium
CN113407536A (en) Method and device for associating table data, terminal equipment and medium
CN113505078B (en) Configuration file updating method, device, equipment and storage medium
CN113010785A (en) User recommendation method and device
CN111290953B (en) Method and device for analyzing test logs
CN117873899B (en) Automatic testing method and device for UI interface, terminal equipment and storage medium
CN103049629A (en) Method and device for detecting noise data
CN116453125A (en) Data input method, device, equipment and storage medium based on artificial intelligence
CN116343230A (en) Text recognition model training method, system, electronic equipment and storage medium
CN117873899A (en) Automatic testing method and device for UI interface, terminal equipment and storage medium
CN111626313A (en) Feature extraction model training method, image processing method and device
CN114860608A (en) Scene construction based system automation testing method, device, equipment and medium
CN114239296A (en) Data processing method and device and electronic equipment
CN115017256A (en) Power data processing method and device, electronic equipment and storage medium
CN113868137A (en) Method, device and system for processing buried point data and server
CN113468076A (en) Application program exception testing method, device, equipment and storage medium
CN108572948A (en) The processing method and processing device of doorplate information

Legal Events

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