CN113360414A - Software testing method, device, readable storage medium and computer program product - Google Patents

Software testing method, device, readable storage medium and computer program product Download PDF

Info

Publication number
CN113360414A
CN113360414A CN202110823309.0A CN202110823309A CN113360414A CN 113360414 A CN113360414 A CN 113360414A CN 202110823309 A CN202110823309 A CN 202110823309A CN 113360414 A CN113360414 A CN 113360414A
Authority
CN
China
Prior art keywords
target
interface data
current
page
screenshot
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202110823309.0A
Other languages
Chinese (zh)
Inventor
石宏彬
黄文凯
文琦
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
WeBank Co Ltd
Original Assignee
WeBank Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by WeBank Co Ltd filed Critical WeBank Co Ltd
Priority to CN202110823309.0A priority Critical patent/CN113360414A/en
Publication of CN113360414A publication Critical patent/CN113360414A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3684Test management for test design, e.g. generating new test cases
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3688Test management for test execution, e.g. scheduling of test suites

Abstract

The invention discloses a software testing method, a device, a readable storage medium and a computer program product, wherein the software testing method comprises the following steps: acquiring a page screenshot of software to be tested in a current testing process, and carrying out image recognition on the page screenshot to obtain image characteristics; acquiring current interface data of the software to be tested, wherein the current interface data is data returned to the software to be tested by a server corresponding to the software to be tested, and the current interface data is data corresponding to the page screenshot; and determining whether the current test process passes the test based on the image characteristics and the current interface data. The invention improves the flexibility of automatic testing.

Description

Software testing method, device, readable storage medium and computer program product
Technical Field
The present invention relates to the field of automated testing technologies, and in particular, to a software testing method, a software testing device, a readable storage medium, and a computer program product.
Background
With the rapid development of technology, more and more software products are emerging. In the software development process, many errors will occur, for example, the alignment of the front and back end interfaces requires developers to correctly understand the meaning of each field, and the software page is realized according to the visual draft, which belongs to an error-prone link, so that the software needs to be tested to avoid errors.
At present, an interface automatic test method can only verify whether a background service logic is normal or not, and cannot verify whether a front end can correctly display page elements under the service logic or not. Although the interface automatic test method can verify whether the front-end page is correctly displayed, the interface automatic test method cannot verify whether the interface data returned to the front end by the back end meets the expectation. Therefore, it is necessary to separately perform the interface automation test and the interface automation test, which results in low flexibility of the automation test.
Disclosure of Invention
The invention mainly aims to provide a software testing method, a device, a readable storage medium and a computer program product, aiming at improving the flexibility of automatic testing.
In order to achieve the above object, the present invention provides a software testing method, which comprises the following steps:
acquiring a page screenshot of software to be tested in a current testing process, and carrying out image recognition on the page screenshot to obtain image characteristics;
acquiring current interface data of the software to be tested, wherein the current interface data is data returned to the software to be tested by a server corresponding to the software to be tested, and the current interface data is data corresponding to the page screenshot;
and determining whether the current test process passes the test based on the image characteristics and the current interface data.
Optionally, the step of determining whether the current testing process passes the test based on the image feature and the current interface data includes:
determining a plurality of target elements corresponding to the page screenshot, and sequentially determining whether the current interface data comprises target interface data corresponding to one current target element in the plurality of target elements;
if the current interface data comprises the target interface data, determining whether the current target element is displayed correctly based on the image characteristics;
if the current target element is correctly displayed, returning to the step of sequentially determining whether the current interface data comprises target interface data corresponding to a current target element in the plurality of target elements until the plurality of target elements are correctly displayed so as to determine that the current test process passes the test or until a target element in the plurality of target elements is wrongly displayed;
and if the current target element is wrong in display, determining that the current test process fails.
Optionally, the step of sequentially determining whether the current interface data includes target interface data corresponding to a current target element of the plurality of target elements includes:
sequentially acquiring a current target element in the plurality of target elements;
based on the current target element, searching corresponding target interface data from a preset mapping set, wherein the preset mapping set comprises the target elements and the corresponding target interface data;
and judging whether the current interface data contains the target interface data.
Optionally, before the step of searching for corresponding target interface data from a preset mapping set based on the current target element, the method further includes:
determining a target page screenshot corresponding to the page screenshot;
acquiring a page element screenshot set corresponding to the target page screenshot, and acquiring a target interface data set corresponding to the target page screenshot;
and mapping the page element screenshot set and the target interface data set to obtain the preset mapping set.
Optionally, the step of obtaining the page element screenshot set corresponding to the target page screenshot includes:
intercepting the target page screenshot to obtain a plurality of page element screenshots needing to be verified;
and obtaining a page element screenshot set corresponding to the target page screenshot based on the plurality of page element screenshots.
Optionally, the step of obtaining the target interface data set corresponding to the target page screenshot includes:
acquiring an interface data set corresponding to the target page screenshot, wherein the interface data set comprises interface data returned by an interface request initiated by the target page screenshot;
performing data extraction on the interface data set to obtain a plurality of element interface data needing to be verified;
and obtaining a target interface data set corresponding to the target page screenshot based on the plurality of element interface data.
Optionally, the step of determining whether the current target element exhibits correctness based on the image feature comprises:
acquiring target image characteristics corresponding to the current target elements;
judging whether the image features contain the target image features;
if the image features comprise the target image features, the current target element is displayed correctly;
and if the image features do not comprise the target image features, displaying the current target element in error.
In addition, to achieve the above object, the present invention also provides a software testing apparatus, including: a memory, a processor and a software test program stored on the memory and executable on the processor, the software test program when executed by the processor implementing the steps of the software testing method as described above.
In addition, to achieve the above object, the present invention also provides a computer readable storage medium having a software testing program stored thereon, which when executed by a processor implements the steps of the software testing method as described above.
Furthermore, to achieve the above object, the present invention also provides a computer program product comprising a computer program which, when being executed by a processor, realizes the steps of the software testing method as described above.
The invention provides a software testing method, a device, a readable storage medium and a computer program product, which are used for acquiring a page screenshot of software to be tested in the current testing process and carrying out image recognition on the page screenshot to obtain image characteristics; acquiring current interface data of the software to be tested, wherein the current interface data is data returned to the software to be tested by a server corresponding to the software to be tested, and the current interface data is data corresponding to a page screenshot; and determining whether the current test process passes the test or not based on the image characteristics and the current interface data. By the method, the image recognition is carried out on the page screenshot of the software to be tested to obtain the image characteristics, the current interface data of the software to be tested is obtained, the current interface data is response data corresponding to the page screenshot, whether the current test process passes the test is determined based on the image characteristics and the current interface data, whether the returned current interface data meets the expectation is judged based on the image characteristics of the page screenshot of the current test process, whether the page screenshot is displayed correctly is judged based on the current interface data, and therefore the automatic interface test and the automatic interface test are achieved simultaneously, and the flexibility of the automatic test is improved.
Drawings
Fig. 1 is a schematic terminal structure diagram of a hardware operating environment according to an embodiment of the present invention;
FIG. 2 is a flowchart illustrating a software testing method according to a first embodiment of the present invention;
fig. 3 is a schematic diagram of a system architecture according to an embodiment of the present invention.
The implementation, functional features and advantages of the objects of the present invention will be further explained with reference to the accompanying drawings.
Detailed Description
It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
Referring to fig. 1, fig. 1 is a schematic terminal structure diagram of a hardware operating environment according to an embodiment of the present invention.
The terminal in the embodiment of the present invention is a software testing device, and the software testing device may be a terminal device having a processing function, such as a PC (personal computer), a microcomputer, a notebook computer, and a server.
As shown in fig. 1, the terminal may include: a processor 1001, such as a CPU (Central Processing Unit), a communication bus 1002, a user interface 1003, a network interface 1004, and a memory 1005. Wherein a communication bus 1002 is used to enable connective communication between these components. The user interface 1003 may include a Display screen (Display), an input unit such as a Keyboard (Keyboard), and the optional user interface 1003 may also include a standard wired interface, a wireless interface. The network interface 1004 may optionally include a standard wired interface, a wireless interface (e.g., WI-FI interface). The memory 1005 may be a high-speed RAM memory or a non-volatile memory (e.g., a magnetic disk memory). The memory 1005 may alternatively be a storage device separate from the processor 1001.
Those skilled in the art will appreciate that the terminal structure shown in fig. 1 is not intended to be limiting and may include more or fewer components than those shown, or some components may be combined, or a different arrangement of components.
As shown in fig. 1, a memory 1005, which is a kind of computer storage medium, may include therein an operating system, a network communication module, a user interface module, and a software test program.
In the terminal shown in fig. 1, the processor 1001 may be configured to call a software test program stored in the memory 1005 and perform the following operations:
acquiring a page screenshot of software to be tested in a current testing process, and carrying out image recognition on the page screenshot to obtain image characteristics;
acquiring current interface data of the software to be tested, wherein the current interface data is data returned to the software to be tested by a server corresponding to the software to be tested, and the current interface data is data corresponding to the page screenshot;
and determining whether the current test process passes the test based on the image characteristics and the current interface data.
Further, the processor 1001 may be configured to call the software test program stored in the memory 1005, and further perform the following operations:
determining a plurality of target elements corresponding to the page screenshot, and sequentially determining whether the current interface data comprises target interface data corresponding to one current target element in the plurality of target elements;
if the current interface data comprises the target interface data, determining whether the current target element is displayed correctly based on the image characteristics;
if the current target element is correctly displayed, returning to the step of sequentially determining whether the current interface data comprises target interface data corresponding to a current target element in the plurality of target elements until the plurality of target elements are correctly displayed so as to determine that the current test process passes the test or until a target element in the plurality of target elements is wrongly displayed;
and if the current target element is wrong in display, determining that the current test process fails.
Further, the processor 1001 may be configured to call the software test program stored in the memory 1005, and further perform the following operations:
sequentially acquiring a current target element in the plurality of target elements;
based on the current target element, searching corresponding target interface data from a preset mapping set, wherein the preset mapping set comprises the target elements and the corresponding target interface data;
and judging whether the current interface data contains the target interface data.
Further, the processor 1001 may be configured to call the software test program stored in the memory 1005, and further perform the following operations:
determining a target page screenshot corresponding to the page screenshot;
acquiring a page element screenshot set corresponding to the target page screenshot, and acquiring a target interface data set corresponding to the target page screenshot;
and mapping the page element screenshot set and the target interface data set to obtain the preset mapping set.
Further, the processor 1001 may be configured to call the software test program stored in the memory 1005, and further perform the following operations:
intercepting the target page screenshot to obtain a plurality of page element screenshots needing to be verified;
and obtaining a page element screenshot set corresponding to the target page screenshot based on the plurality of page element screenshots.
Further, the processor 1001 may be configured to call the software test program stored in the memory 1005, and further perform the following operations:
acquiring an interface data set corresponding to the target page screenshot, wherein the interface data set comprises interface data returned by an interface request initiated by the target page screenshot;
performing data extraction on the interface data set to obtain a plurality of element interface data needing to be verified;
and obtaining a target interface data set corresponding to the target page screenshot based on the plurality of element interface data.
Further, the processor 1001 may be configured to call the software test program stored in the memory 1005, and further perform the following operations:
acquiring target image characteristics corresponding to the current target elements;
judging whether the image features contain the target image features;
if the image features comprise the target image features, the current target element is displayed correctly;
and if the image features do not comprise the target image features, displaying the current target element in error.
Based on the hardware structure, the invention provides various embodiments of the software testing method.
The invention provides a software testing method.
Referring to fig. 2, fig. 2 is a flowchart illustrating a software testing method according to a first embodiment of the present invention.
In this embodiment, the software testing method includes:
step S10, acquiring a page screenshot of the software to be tested in the current testing process, and carrying out image recognition on the page screenshot to obtain image characteristics;
in this embodiment, a page screenshot of the software to be tested in the current testing process is obtained, and image recognition is performed on the page screenshot to obtain image characteristics. The software to be tested may include software with page display, such as a mobile phone APP (Application), a computer client, and a web page.
It should be noted that the whole software testing process includes a plurality of testing processes, each testing process corresponds to one page to be tested, and the screenshot of the page to be tested is obtained to determine the current page screenshot of the test.
Further, before the step S10, the software testing method further includes:
and opening software to be tested, and controlling the software to be tested to enter a page to be tested so as to perform screenshot on the page to be tested to obtain a page screenshot of the software to be tested in the current testing process.
In an embodiment, the software testing method is applied to a software testing system, the software testing system includes a UI automation driving service and an image feature extraction and identification service, and the step of opening the software to be tested and controlling the software to be tested to enter a page to be tested includes:
driving terminal equipment to open software to be tested through the UI automatic driving service, and controlling the software to be tested to enter a page to be tested; capturing the page to be tested through the UI automation driving service to obtain a page capture of the software to be tested in the current testing process; and transmitting the page screenshot from the UI automation driving service to the image feature extraction and identification service so that the image feature extraction and identification service can perform image identification on the page screenshot to obtain image features.
It should be noted that the image feature extraction and identification service module and the UI automation driving service module are deployed in the same network, and the image feature extraction and identification service module can receive a page screenshot of the UI automation driving service module in the UI automation running process, and perform feature analysis and identification.
In some embodiments, the page shot includes several elements, and the step of performing image recognition on the page shot to obtain the image features includes:
respectively carrying out image recognition on the plurality of elements to obtain a plurality of element image characteristics; and obtaining image characteristics based on the plurality of element image characteristics. The page screenshot is composed of a plurality of elements or modules, and when the data states returned by the interface requests are different, the display of the elements or modules is changed.
Step S20, acquiring current interface data of the software to be tested, wherein the current interface data is data returned to the software to be tested by the server corresponding to the software to be tested, and the current interface data is data corresponding to the page screenshot;
in this embodiment, the current interface data of the software to be tested is obtained, where the current interface data is data returned to the software to be tested by the server corresponding to the software to be tested, and the current interface data is data corresponding to the page screenshot. It should be noted that the current interface data is interface data corresponding to the current test process, that is, interface data corresponding to the current page screenshot, and the current interface data is used to determine page display content of the software to be tested, so as to obtain the page screenshot, that is, the page screenshot already includes the content displayed by the current interface data.
For ease of understanding, for example, the current interface data includes { "isVIP": 1, if the field isVIP is 1, showing the medal VIP on the page; the current interface data includes { "isVIP": 0} and field isVIP is 0, then the page does not show medal of VIP, shows medal of common user. Therefore, when the current interface data is different, the display of an element or module in the page changes, that is, the page display is dynamically changed according to the actual interface data.
It should be noted that, after the software to be tested sends the interface request, the server corresponding to the software to be tested returns response data (interface data) to the software to be tested in response to the interface request, and at this time, the response data is recorded and extracted to obtain the interface data of all the interface requests, so as to obtain the current interface data of the software to be tested.
In one embodiment, the software to be tested sends an interface request through the HTTP proxy service module, the HTTP proxy service module forwards the request to a real service application server interface, obtains a request response result, returns the request response result to the software to be tested, and records and extracts a response data field set, thereby obtaining current interface data of the software to be tested.
In some embodiments, the screenshot includes a plurality of target elements, and the step S20 includes:
and acquiring a plurality of element interface data corresponding to the target elements in the software to be tested, and taking the element interface data as current interface data.
Step S30, determining whether the current testing process passes the test based on the image features and the current interface data.
In the embodiment, whether the current test process passes the test is determined based on the image characteristics and the current interface data. Specifically, the image characteristics are compared with the current interface data, and whether page display is correct or not is judged, so that whether the current test process passes the test or not is determined.
Further, the step of comparing the image characteristics with the current interface data and judging whether the page display is correct comprises:
and judging whether the returned current interface data is in accordance with expectations or not based on the image characteristics of the page screenshot in the current testing process, and judging whether the page screenshot is displayed correctly or not based on the current interface data, so as to determine that the current testing process passes the test after the page screenshot and the current interface data meet the requirements.
In an embodiment, the screenshot includes a plurality of target elements, and the step S30 includes:
determining whether the current test procedure passes the test based on the number of element image features and the number of element interface data. Specifically, under the same page element, comparing the element image feature of the page element with the element interface data of the page element to obtain a comparison result, determining whether the current page element passes the test based on the comparison result, determining that the current test process passes the test until all the page elements pass the test, and determining that the current test process does not pass the test if one of the page elements does not pass the test.
Further, under the same page element, whether returned element interface data of the page element is in accordance with expectation is judged based on the element image features of the page element, whether the page element is displayed correctly is judged based on the element interface data of the page element, the page element is determined to pass the test after the page element and the page element both meet the requirements, the current test process is determined to pass the test until all the page elements pass the test, and if one page element does not pass the test, the current test process is determined not to pass the test.
In one embodiment, the step S30 includes:
determining a plurality of target elements corresponding to the page screenshot, and sequentially determining whether the current interface data comprises target interface data corresponding to one current target element in the plurality of target elements; if the current interface data comprises the target interface data, determining whether the current target element is displayed correctly based on the image characteristics; if the current target element is correctly displayed, returning to the step of sequentially determining whether the current interface data comprises target interface data corresponding to a current target element in the plurality of target elements until the plurality of target elements are correctly displayed so as to determine that the current test process passes the test or until a target element in the plurality of target elements is wrongly displayed; and if the current target element is wrong in display, determining that the current test process fails. Specific execution flow may refer to the following second embodiment.
In another embodiment, the step S30 includes:
comparing the image characteristics with target image characteristics to obtain a first comparison result; comparing the current interface data with target interface data to obtain a second comparison result; determining whether the current test process passes the test based on the first comparison result and the second comparison result. The method for acquiring the target image features comprises the following steps: and determining a target page screenshot corresponding to the page screenshot, and performing image recognition on the target page screenshot to obtain the target image characteristics. The acquisition mode of the target interface data is as follows: determining a target page screenshot corresponding to the page screenshot; and acquiring target interface data corresponding to the screenshot of the target page.
The embodiment of the invention provides a software testing method, which comprises the steps of obtaining a page screenshot of software to be tested in the current testing process, and carrying out image recognition on the page screenshot to obtain image characteristics; acquiring current interface data of the software to be tested, wherein the current interface data is data returned to the software to be tested by a server corresponding to the software to be tested, and the current interface data is data corresponding to a page screenshot; and determining whether the current test process passes the test or not based on the image characteristics and the current interface data. By the method, the image recognition is carried out on the page screenshot of the software to be tested to obtain the image characteristics, the current interface data of the software to be tested is obtained, the current interface data is response data corresponding to the page screenshot, whether the current test process passes the test is determined based on the image characteristics and the current interface data, whether the returned current interface data meets the expectation is judged based on the image characteristics of the page screenshot of the current test process, whether the page screenshot is displayed correctly is judged based on the current interface data, and therefore the automatic interface test and the automatic interface test are achieved simultaneously, and the flexibility of the automatic test is improved.
Further, based on the first embodiment, a second embodiment of the software testing method of the present invention is provided.
In this embodiment, the step S30 includes:
step A31, determining a plurality of target elements corresponding to the page screenshot, and sequentially determining whether the current interface data includes target interface data corresponding to a current target element in the plurality of target elements;
in this embodiment, a plurality of target elements corresponding to the page screenshot are determined, and whether the current interface data includes target interface data corresponding to a current target element of the plurality of target elements is sequentially determined. Specifically, a plurality of target elements in the page screenshot are determined, then the plurality of target elements are circularly acquired to obtain the current target element, and whether the current interface data comprises target interface data corresponding to one current target element in the plurality of target elements is sequentially determined.
The target elements can be elements needing verification in the page screenshot, for example, the VIP medal in the page screenshot is an element needing verification, the page position where the VIP medal is located is a target element, and the target elements can also be elements which are currently shown in the page screenshot. The target interface data is the interface data expected by the current target element, and can be preset according to the requirement.
In an embodiment, the target elements are elements that need to be verified in the page screenshot, and the step of determining the target elements corresponding to the page screenshot includes:
and searching a plurality of corresponding target elements from a preset mapping set based on the page screenshot, wherein the preset mapping set comprises the page screenshot and the plurality of corresponding target elements. The preset mapping set can be preset according to actual needs.
For understanding, for example, setting and storing the target page screenshots, and sequencing the target page screenshots according to the sequence needing verification as follows: { P1、P2、...、PnRecording as ListP; then, screenshot P is taken on the target page in the order of ListPiIntercepting the element screenshot needing to be verified to obtain a page element screenshot set { P }iE1、PiE2、...、PiEmRecord as List (P)iE),PiE.g. ListP and i.e. 1, n]In which elements in the same position but representing different states (e.g. for different purposes)Switch on/off state), should also be recorded separately; then, according to the sequence of ListP, respectively capturing the target page screenshots PiExtracting and recording the key fields returned by the initiated data query interface to obtain a target interface data set { P }iD1、PiD2、...、PiDqRecord as List (P)iD),i∈[1,n]And different return results of the same interface field are recorded in a distinguishing way. Based on this, the target interface data is an interface data in the target interface data set, such as PiD1The target interface data PiD1Data returned by one or more interfaces can be included, that is, one target element can correspond to a plurality of interface requests and interface responses.
In an embodiment, the step a31, sequentially determining whether the current interface data includes target interface data corresponding to a current target element of the target elements includes:
step A311, sequentially obtaining a current target element from the plurality of target elements;
in this embodiment, a current target element of a plurality of target elements is sequentially obtained. Specifically, the plurality of target elements are circularly acquired to obtain a current target element. For ease of understanding, e.g., a List of screenshot of page elements (P) based on index iiE) Circularly obtaining the current target element PiEj
Step A312, based on the current target element, searching a preset mapping set for corresponding target interface data, where the preset mapping set includes the target elements and corresponding target interface data;
in this embodiment, based on the current target element, the corresponding target interface data is searched from a preset mapping set, where the preset mapping set includes a plurality of target elements and a plurality of corresponding target interface data. The preset mapping set is used for representing an expected mapping relationship between the page element and the interface data, and the preset mapping set may be a mapping table or a mapping set, which is not limited herein.
For ease of understanding, for example, the preset mapping set is:
RelationList=[{PiE1:List(PiD1)}...{PiEm:List(PiDm)}]denoted as relationship List, where, { PiEm:List(PiDm) Indicates that the current interface data contains a List (P)iDm) Time, page screenshot PiWill show the element PiEm. Specifically, the current target element P is found from the relationship ListiEjCorresponding target interface data List (P)iDj)。
Further, before the step a312, the software testing method further includes:
step A314, determining a target page screenshot corresponding to the page screenshot;
in this embodiment, a target page screenshot corresponding to the page screenshot is determined. In particular, the target page screen shots are set and stored, e.g., the target page screen shots are ordered into { P } in the order that they need to be verified1、P2、...、PnAnd recording as a target page screenshot ListP. The target page screenshot is a page needing to be verified, and the page screenshot is also a page needing to be verified, so that the corresponding target page screenshot can be determined based on the page screenshot.
Step A315, acquiring a page element screenshot set corresponding to the target page screenshot, and acquiring a target interface data set corresponding to the target page screenshot;
in this embodiment, a page element screenshot set corresponding to a target page screenshot is obtained, and a target interface data set corresponding to the target page screenshot is obtained. The page element screenshot set is a screenshot set obtained by intercepting a target page screenshot, and comprises a plurality of page element screenshots, wherein the page element screenshot sets comprise 1 or more page element screenshots. The target interface data set is interface data returned by an interface request initiated by the screenshot of the target page, the target interface data set comprises a plurality of target interface data, and the plurality of target interface data comprise 1 or more interface data.
For example, the target page shots P are ordered in the target page shot set ListPiIntercepting the element screenshot to obtain a page element screenshot set { P }iE1、PiE2、...、PiEmRecord as List (P)iE),PiE.g. ListP and i.e. 1, n]Elements that are in the same position but represent different states (e.g., switch on/off states) should also be recorded separately. And respectively capturing the target page screenshots P according to the sequence of ListPiExtracting and recording the key fields returned by the initiated data query interface to obtain a target interface data set { P }iD1、PiD2、...、PiDqRecord as List (P)iD),i∈[1,n]And different return results of the same interface field are recorded in a distinguishing way.
Specifically, in step a315, obtaining a page element screenshot set corresponding to the target page screenshot includes:
a3151, intercepting the target page screenshot to obtain a plurality of page element screenshots needing to be verified;
and A3152, obtaining a page element screenshot set corresponding to the target page screenshot based on the plurality of page element screenshots.
In the embodiment, a target page screenshot is intercepted to obtain a plurality of page element screenshots needing to be verified; and then, based on the plurality of page element screenshots, obtaining a page element screenshot set corresponding to the target page screenshot. The target page screenshot comprises a plurality of page elements, the page element screenshots are screenshots of elements needing to be verified in the target element screenshot, and the number of the page elements can be smaller than or equal to the number of the page elements. The set of page element screenshots includes a number of page element screenshots.
For example, the target page shots P are ordered in the target page shot set ListPiIntercepting the element screenshot to obtain a page element screenshot set { P }iE1、PiE2、...、PiEm}, record as List(PiE),PiE.g. ListP and i.e. 1, n]Elements that are in the same position but represent different states (e.g., switch on/off states) should also be recorded separately.
Specifically, in step a315, obtaining a target interface data set corresponding to the target page screenshot includes:
step A3153, obtaining an interface data set corresponding to the target page screenshot, where the interface data set includes interface data returned by an interface request initiated by the target page screenshot;
in this embodiment, an interface data set corresponding to the target page screenshot is obtained, where the interface data set includes interface data returned by an interface request initiated by the target page screenshot. It should be noted that the interface request of the target page screenshot may include several interface requests, where the several interface requests include 1 or more interface requests, and correspondingly, the returned interface data may include several interface data, where the several interface data include 1 or more interface requests.
For example, the target page screen shots P are respectively arranged according to the sequence of the target page screen shot set ListPiExtracting and recording the key fields returned by the initiated data query interface to obtain a target interface data set { P }iD1、PiD2、...、PiDqRecord as List (P)iD),i∈[1,n]And different return results of the same interface field are recorded in a distinguishing way.
Step A3154, extracting data of the interface data set to obtain a plurality of element interface data needing to be verified;
and A3155, obtaining a target interface data set corresponding to the target page screenshot based on the plurality of element interface data.
In this embodiment, data extraction is performed on the interface data set to obtain a plurality of element interface data to be verified, and then, based on the plurality of element interface data, a target interface data set corresponding to the target page screenshot is obtained. Specifically, based on a plurality of page element screenshots needing to be verified, data extraction is performed on an interface data set to extract a plurality of element interface data corresponding to the plurality of page element screenshots, wherein one page element screenshot can correspond to the plurality of interface data, and the plurality of interface data comprise 1 or more interface data, that is, one page element screenshot can correspond to 1 or more interface requests, and correspondingly, one page element screenshot corresponds to 1 or more returned interface data. The target interface dataset includes a number of element interface data.
For example, the target page screen shots P are respectively arranged according to the sequence of the target page screen shot set ListPiExtracting and recording the key fields returned by the initiated data query interface to obtain a target interface data set { P ] needing to be verifiediD1、PiD2、...、PiDqRecord as List (P)iD),i∈[1,n]And different return results of the same interface field are recorded in a distinguishing way.
Step A316, mapping the page element screenshot set and the target interface data set to obtain the preset mapping set.
In this embodiment, the page element screenshot set and the target interface data set are mapped to obtain a preset mapping set. Specifically, each page element screenshot in the page element screenshot set is mapped with corresponding target interface data, and the target interface data is target interface data in the target interface data set. It is to be understood that the target interface data may include 1 or more interface data, that is, one page element screenshot may correspond to several interface data, and the several interface data includes 1 or more interface data.
For example, List (P) in terms of the page element screenshot setiE) In the order of (2), screenshot P of the page elementiThe corresponding target interface data is designated by the element screenshot to be verified, namely the preset mapping set is as follows:
RelationList=[{PiE1:List(PiD1)}...{PiEm:List(PiDm)}]denoted as relationship List, where, { PiEm:List(PiDm) Indicates the current interface data packetContaining List (P)iDm) Time, page screenshot PiWill show the element PiEm
Step a313, determining whether the current interface data includes the target interface data.
In this embodiment, it is determined whether the current interface data includes the target interface data. For example, the current interface data is { P }iD1、PiD2、...、PiDqRecord as List (P)iDR),i∈[1,n]Then, based on
Figure BDA0003172064410000151
Judgment target interface data List (P)iDj) Whether it belongs to the current interface data List (P)iDR)。
In one embodiment, the software to be tested sends an interface request through the HTTP proxy service module, the HTTP proxy service module forwards the request to a real business application server interface, obtains a request response result, returns the request response result to the software to be tested, records and extracts a response data field set, and therefore current interface data { P } of the software to be tested is obtainediD1、PiD2、...、PiDqRecord as List (P)iDR),i∈[1,n]。
Step A32, if the current interface data includes the target interface data, determining whether the current target element is shown correctly based on the image features;
in this embodiment, if the current interface data includes the target interface data, it is determined whether the current target element is correctly displayed based on the image feature. It should be noted that, if the current interface data includes target interface data, it indicates that the target interface data returned by the current target element is in accordance with expectations, so as to further determine whether the current target element is correctly displayed based on the image features of the page screenshot, and determine whether the current target element is correctly displayed after both of the current target element and the target interface data meet requirements.
In one embodiment, the step a32, determining whether the current target element is correctly shown based on the image feature, includes:
step A321, obtaining target image characteristics corresponding to the current target element;
in this embodiment, a target image feature corresponding to a current target element is obtained. Specifically, a page element screenshot corresponding to a current target element is obtained, and then image recognition is performed on the page element screenshot to obtain target image characteristics.
For example, the target page shots P are ordered in the target page shot set ListPiIntercepting the element screenshot to obtain a page element screenshot set { P }iE1、PiE2、...、PiEmRecord as List (P)iE),PiE.g. ListP and i.e. 1, n]In which elements that are in the same position but represent different states (e.g. switch on/off states) should also be recorded separately, and then a List (P) of the collection of page element screenshotsiE) And carrying out image recognition on the screenshot of each page element to obtain the target image characteristics corresponding to the current target element.
Step A322, determining whether the image feature includes the target image feature;
step A323, if the image feature includes the target image feature, the current target element is displayed correctly;
in step a324, if the image feature does not include the target image feature, the current target element is displayed incorrectly.
In this embodiment, whether the image features of the page screenshot contain the target image features is judged, if the image features of the page screenshot contain the target image features, the current target element is correctly displayed, and if the image features of the page screenshot do not contain the target image features, the current target element is incorrectly displayed.
In an embodiment, the software testing method is applied to a software testing system, the software testing system includes an image feature extraction and recognition service, and the step of determining whether the image feature includes the target image feature includes:
extracting identification through the image characteristicAnd the other service is used for detecting whether the image characteristics of the current target element can be extracted or not. For example, screenshot P of the page in the currently executing processiWhether the current target element P can be extracted through an interface in the image feature extraction and identification serviceiEjThe image feature of (1).
In another embodiment, the step a32, determining whether the current target element is correctly shown based on the image feature, includes:
determining an element image feature of the current target element based on the image feature and the current target element; acquiring target image characteristics of the current target elements, and comparing the element image characteristics with the target image characteristics; and determining whether the current target element is correctly displayed or not based on the comparison result. Specifically, based on a current target element, extracting corresponding element image features from image features of a page screenshot, then obtaining the page element screenshot corresponding to the current target element, then performing image recognition on the page element screenshot to obtain target image features, then further performing feature extraction on the target image features to obtain target image features of the current target element, if the element image features are the same as the target image features or the similarity distance is smaller than a preset threshold value, judging whether the current target element is displayed correctly, and if the element image features are not the same as the target image features or the similarity distance is larger than the preset threshold value, judging whether the current target element is displayed incorrectly.
Further, after the step a31, the software testing method further includes:
and if the current interface data does not contain the target interface data, returning to the step of sequentially determining whether the current interface data contains the target interface data corresponding to a current target element in the plurality of target elements. Or if the current interface data does not contain the target interface data, judging that the target interface data returned by the current target element is not in accordance with the expectation, and determining that the current target element is displayed incorrectly.
Step A33, if the current target element is correctly displayed, returning to the step of sequentially determining whether the current interface data includes target interface data corresponding to a current target element in the plurality of target elements until the plurality of target elements are correctly displayed, so as to determine that the current test process passes the test, or until a target element in the plurality of target elements is incorrectly displayed;
step A34, if the current target element shows an error, determining that the current testing process fails.
In this embodiment, if the current target element is correctly displayed, the step of sequentially determining whether the current interface data includes target interface data corresponding to a current target element of the plurality of target elements is returned until the plurality of target elements are correctly displayed, so as to determine that the current test process passes the test, or until a target element of the plurality of target elements is incorrectly displayed; and if the current target element is displayed wrongly, determining that the current test process fails.
In the embodiment, a plurality of target elements corresponding to a page screenshot of the page screenshot are determined, and whether the current interface data of the page screenshot comprises the target interface data corresponding to one current target element in the plurality of target elements of the page screenshot is determined in sequence; if the current interface data of the page screenshot contains the target interface data of the page screenshot, determining whether the current target element of the page screenshot is displayed correctly or not based on the image characteristics of the page screenshot; if the current target element of the page screenshot is correctly displayed, returning to the step of sequentially determining whether the current interface data of the page screenshot comprises target interface data corresponding to one current target element of a plurality of target elements of the page screenshot until the plurality of target elements of the page screenshot are correctly displayed so as to determine that the current test process of the page screenshot passes the test or until one target element of the plurality of target elements of the page screenshot is wrongly displayed; and if the current target element of the page screenshot shows an error, determining that the current test process of the page screenshot fails. By the method, whether the page screenshot is displayed correctly is judged based on the current interface data, whether the returned current interface data meets the expectation is judged based on the image characteristics of the page screenshot in the current testing process, so that the interface automatic testing and the interface automatic testing are realized simultaneously, and the flexibility of the automatic testing is improved. Meanwhile, the page screenshot is further divided to obtain a plurality of target elements, and whether the target elements are consistent with expected display of interface return data or not is automatically compared, so that the granularity of automatic testing is improved.
The invention also provides a software testing device.
In this embodiment, the software testing apparatus includes:
the identification module is used for acquiring a page screenshot of the software to be tested in the current testing process and carrying out image identification on the page screenshot to obtain image characteristics;
an obtaining module, configured to obtain current interface data of the software to be tested, where the current interface data is data returned to the software to be tested by a server corresponding to the software to be tested, and the current interface data is data corresponding to the page screenshot;
and the testing module is used for determining whether the current testing process passes the test or not based on the image characteristics and the current interface data.
Each virtual function module of the software testing apparatus is stored in the memory 1005 of the software testing device shown in fig. 1, and is used for implementing all functions of a software testing program; when executed by the processor 1001, the modules may implement software testing functions.
Further, the test module includes:
the element determining unit is used for determining a plurality of target elements corresponding to the page screenshot and sequentially determining whether the current interface data comprises target interface data corresponding to one current target element in the plurality of target elements;
an element judgment unit, configured to determine whether the current target element is correctly displayed based on the image feature if the current interface data includes the target interface data;
a step returning unit, configured to, if the current target element is correctly displayed, return to a step of sequentially determining whether the current interface data includes target interface data corresponding to a current target element of the multiple target elements until the multiple target elements are correctly displayed, so as to determine that the current test process passes the test, or until a target element of the multiple target elements is incorrectly displayed;
and the test determining unit is used for determining that the current test process fails if the current target element shows an error.
Further, the element determining unit is further configured to sequentially obtain a current target element from the plurality of target elements; based on the current target element, searching corresponding target interface data from a preset mapping set, wherein the preset mapping set comprises the target elements and the corresponding target interface data; and judging whether the current interface data contains the target interface data.
Further, the element determining unit is further configured to determine a target page screenshot corresponding to the page screenshot; acquiring a page element screenshot set corresponding to the target page screenshot, and acquiring a target interface data set corresponding to the target page screenshot; and mapping the page element screenshot set and the target interface data set to obtain the preset mapping set.
Further, the element determination unit is further configured to intercept the target page screenshot to obtain a plurality of page element screenshots that need to be verified; and obtaining a page element screenshot set corresponding to the target page screenshot based on the plurality of page element screenshots.
Further, the element determining unit is further configured to obtain an interface data set corresponding to the target page screenshot, where the interface data set includes interface data returned by an interface request initiated by the target page screenshot; performing data extraction on the interface data set to obtain a plurality of element interface data needing to be verified; and obtaining a target interface data set corresponding to the target page screenshot based on the plurality of element interface data.
Further, the element judgment unit is further configured to obtain a target image feature corresponding to the current target element; judging whether the image features contain the target image features; if the image features comprise the target image features, the current target element is displayed correctly; and if the image features do not comprise the target image features, displaying the current target element in error.
The function implementation of each module in the software testing apparatus corresponds to each step in the software testing method embodiment, and the function and implementation process thereof are not described in detail herein.
The present invention also provides a software testing system, comprising: a memory, a processor and a software test program stored on the memory and executable on the processor, the software test program, when executed by the processor, implementing the steps of the software testing method as described in any one of the above embodiments.
The specific embodiment of the software testing system of the present invention is basically the same as the embodiments of the software testing method described above, and is not described herein again.
In an embodiment, referring to fig. 3, fig. 3 is a schematic diagram of a system architecture related to an embodiment of the present invention, where the software testing system includes a UI automation driving service, an image feature extraction and identification service, an HTTP proxy service, and a service application server, and the software to be tested is an App client. Specifically, the APP client is driven to open through the UI automation driving service, and the APP client is controlled to enter a page needing to be tested; capturing the page to be tested through the UI automation driving service to obtain an APP page capture of the APP client in the current testing process; and transmitting the APP page screenshot from the UI automation driving service to the image feature extraction and identification service so that the image feature extraction and identification service can perform image identification on the APP page screenshot to obtain image features. The method comprises the steps that an interface request of an APP client side is sent through HTTP proxy service, the HTTP proxy service forwards the request to a real business application server, a request response result is obtained and returned to the APP client side, a response data field set is recorded and extracted, interface data are obtained and transmitted to image feature extraction and identification service, and whether the current test process passes the test or not is determined based on an APP page screenshot and interface data.
The mobile equipment is connected with a UI automation driving service module (Apium), and the App client is driven by the Apium to run a UI automation step. The mobile equipment is accessed to the HTTP proxy service module, all requests of the App client are received and sent through the HTTP proxy, and the HTTP proxy service module is communicated with the service application server to complete real service data request and response forwarding. While the HTTP proxy service will record and process all requests and responses. The image feature extraction and identification service module and the UI automation driving service module are deployed in the same network, and the image feature extraction and identification service module and the UI automation driving service module can receive the interface screenshot of the UI automation driving service module in the UI automation operation process and perform feature analysis and identification.
The invention also provides a computer readable storage medium having stored thereon a software test program which, when executed by a processor, implements the steps of the software testing method as described in any one of the above embodiments.
The specific embodiment of the computer-readable storage medium of the present invention is substantially the same as the embodiments of the software testing method described above, and is not described herein again.
The invention also provides a computer program product comprising a computer program which, when executed by a processor, implements the steps of the software testing method as described in any one of the above embodiments.
The specific embodiment of the computer program product of the present invention is substantially the same as the embodiments of the software testing method described above, and will not be described herein again.
It should be noted that, in this document, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or system that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or system. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other like elements in a process, method, article, or system that comprises the element.
The above-mentioned serial numbers of the embodiments of the present invention are merely for description and do not represent the merits of the embodiments.
Through the above description of the embodiments, those skilled in the art will clearly understand that the method of the above embodiments can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware, but in many cases, the former is a better implementation manner. Based on such understanding, the technical solution of the present invention may be embodied in the form of a software product, which is stored in a storage medium (e.g., ROM/RAM, magnetic disk, optical disk) as described above and includes instructions for enabling a terminal device (e.g., a mobile phone, a computer, a server, or a network device) to execute the method according to the embodiments of the present invention.
The above description is only a preferred embodiment of the present invention, and not intended to limit the scope of the present invention, and all modifications of equivalent structures and equivalent processes, which are made by using the contents of the present specification and the accompanying drawings, or directly or indirectly applied to other related technical fields, are included in the scope of the present invention.

Claims (10)

1. A software testing method is characterized by comprising the following steps:
acquiring a page screenshot of software to be tested in a current testing process, and carrying out image recognition on the page screenshot to obtain image characteristics;
acquiring current interface data of the software to be tested, wherein the current interface data is data returned to the software to be tested by a server corresponding to the software to be tested, and the current interface data is data corresponding to the page screenshot;
and determining whether the current test process passes the test based on the image characteristics and the current interface data.
2. The software testing method of claim 1, wherein the step of determining whether the current testing process passed the test based on the image features and the current interface data comprises:
determining a plurality of target elements corresponding to the page screenshot, and sequentially determining whether the current interface data comprises target interface data corresponding to one current target element in the plurality of target elements;
if the current interface data comprises the target interface data, determining whether the current target element is displayed correctly based on the image characteristics;
if the current target element is correctly displayed, returning to the step of sequentially determining whether the current interface data comprises target interface data corresponding to a current target element in the plurality of target elements until the plurality of target elements are correctly displayed so as to determine that the current test process passes the test or until a target element in the plurality of target elements is wrongly displayed;
and if the current target element is wrong in display, determining that the current test process fails.
3. The method for software testing according to claim 2, wherein the step of sequentially determining whether the current interface data includes target interface data corresponding to a current target element of the plurality of target elements comprises:
sequentially acquiring a current target element in the plurality of target elements;
based on the current target element, searching corresponding target interface data from a preset mapping set, wherein the preset mapping set comprises the target elements and the corresponding target interface data;
and judging whether the current interface data contains the target interface data.
4. The software testing method of claim 3, wherein prior to the step of finding corresponding target interface data from a preset mapping set based on the current target element, further comprising:
determining a target page screenshot corresponding to the page screenshot;
acquiring a page element screenshot set corresponding to the target page screenshot, and acquiring a target interface data set corresponding to the target page screenshot;
and mapping the page element screenshot set and the target interface data set to obtain the preset mapping set.
5. The software testing method of claim 4, wherein the step of obtaining the set of page element screenshots corresponding to the target page screenshot comprises:
intercepting the target page screenshot to obtain a plurality of page element screenshots needing to be verified;
and obtaining a page element screenshot set corresponding to the target page screenshot based on the plurality of page element screenshots.
6. The software testing method of claim 4, wherein the step of obtaining the target interface data set corresponding to the target page screenshot comprises:
acquiring an interface data set corresponding to the target page screenshot, wherein the interface data set comprises interface data returned by an interface request initiated by the target page screenshot;
performing data extraction on the interface data set to obtain a plurality of element interface data needing to be verified;
and obtaining a target interface data set corresponding to the target page screenshot based on the plurality of element interface data.
7. The software testing method of claim 2, wherein the step of determining whether the current target element is exhibiting correctness based on the image feature comprises:
acquiring target image characteristics corresponding to the current target elements;
judging whether the image features contain the target image features;
if the image features comprise the target image features, the current target element is displayed correctly;
and if the image features do not comprise the target image features, displaying the current target element in error.
8. A software testing device, characterized in that the software testing device comprises: memory, a processor and a software test program stored on the memory and executable on the processor, the software test program, when executed by the processor, implementing the steps of the software testing method according to any one of claims 1 to 7.
9. A computer-readable storage medium, characterized in that the computer-readable storage medium has stored thereon a software test program which, when executed by a processor, implements the steps of the software testing method according to any one of claims 1 to 7.
10. A computer program product, characterized in that the computer program product comprises a computer program which, when being executed by a processor, carries out the steps of the software testing method according to any one of claims 1 to 7.
CN202110823309.0A 2021-07-20 2021-07-20 Software testing method, device, readable storage medium and computer program product Pending CN113360414A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110823309.0A CN113360414A (en) 2021-07-20 2021-07-20 Software testing method, device, readable storage medium and computer program product

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110823309.0A CN113360414A (en) 2021-07-20 2021-07-20 Software testing method, device, readable storage medium and computer program product

Publications (1)

Publication Number Publication Date
CN113360414A true CN113360414A (en) 2021-09-07

Family

ID=77540050

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110823309.0A Pending CN113360414A (en) 2021-07-20 2021-07-20 Software testing method, device, readable storage medium and computer program product

Country Status (1)

Country Link
CN (1) CN113360414A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115357501A (en) * 2022-08-24 2022-11-18 中国人民解放军32039部队 Automatic testing method and system for space flight measurement and control software

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115357501A (en) * 2022-08-24 2022-11-18 中国人民解放军32039部队 Automatic testing method and system for space flight measurement and control software
CN115357501B (en) * 2022-08-24 2024-04-05 中国人民解放军32039部队 Automatic testing method and system for aerospace measurement and control software

Similar Documents

Publication Publication Date Title
US9946637B2 (en) Automatic updating of graphical user interface element locators based on dimension comparison
WO2020024412A1 (en) User behavior recognition method and apparatus based on sliding block verification code verification
CN109194689B (en) Abnormal behavior recognition method, device, server and storage medium
US20150370694A1 (en) Automatic updating of graphical user interface element locators based on image comparison
CN111460356B (en) Automatic login method, device, medium and equipment
US20180174288A1 (en) SCORE WEIGHTS FOR USER INTERFACE (ui) ELEMENTS
CN109271762B (en) User authentication method and device based on slider verification code
Villanes et al. What are software engineers asking about android testing on stack overflow?
CN111552633A (en) Interface abnormal call testing method and device, computer equipment and storage medium
US20170017695A1 (en) Question and answer information providing system, information processing device, and non-transitory computer-readable medium
CN110825618A (en) Method and related device for generating test case
CN105320595A (en) Application test method and device
CN110826646A (en) Robot vision testing method and device, storage medium and terminal equipment
CN112306854B (en) Case testing method and device, electronic equipment and storage medium
CN110677506B (en) Network access method, device, computer equipment and storage medium
CN113360414A (en) Software testing method, device, readable storage medium and computer program product
CN113190444B (en) Test method, test device and storage medium
CN112395182A (en) Automatic testing method, device, equipment and computer readable storage medium
CN112633341A (en) Interface testing method and device, computer equipment and storage medium
CN114531340B (en) Log acquisition method and device, electronic equipment, chip and storage medium
US7882205B2 (en) Device setting apparatus, device setting method, information acquiring apparatus, information acquiring method, storage medium, and program
CN116431468A (en) Test method, test device, test processing equipment and storage medium
CN111382383A (en) Method, device, medium and computer equipment for determining sensitive type of webpage content
WO2021121130A1 (en) Method and apparatus for information collection, computer device, and storage medium
CN113836037B (en) Interface interaction testing method, device, equipment and storage medium

Legal Events

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