Disclosure of Invention
In view of the above, the embodiments of the present application provide a method, an apparatus, a computer device, and a storage medium for detecting an application page, so as to solve the problems of time and effort waste and easy error in the conventional manual testing method.
In a first aspect, an embodiment of the present application provides a method for detecting an application page, where the method includes:
receiving an application test task, wherein the application test task carries application information of a target application to be tested, and the target application is an application deployed on test equipment;
starting the target application based on the application information, and jumping to at least one target page of the target application;
acquiring a page image set, and splicing each page image in the page image set to obtain a target image, wherein the page image set comprises: a plurality of page images corresponding to each target page are sequentially intercepted on a display interface of the test equipment;
and acquiring a current application version of the target application, and storing the current application version and the target image in a correlated manner.
In an alternative embodiment, the acquiring the set of page images includes:
displaying the target page based on a display interface of the test equipment, and detecting whether the target page is completely displayed on the display interface;
under the condition that the target page is not completely displayed on the display interface, intercepting the first page image, and adding the first page image to a page image set, wherein the first page image is a page of the target page currently displayed on the display interface;
detecting a first termination element in the first page image, and determining a first element coordinate of the first termination element on the target page;
sliding the target page based on the display interface, intercepting a second page image, and adding the second page image to a page image set, wherein a second element coordinate of a starting element of the second page image is adjacent to the first element coordinate and smaller than the first element coordinate;
and based on the display interface, sliding the target page, detecting whether the display position of the second termination element in the second page image after sliding is changed, and continuously sliding the target page under the condition of the change until the display position of the termination element of the screenshot page image after sliding is not changed, and adding the intercepted page image to a page image set.
In an alternative embodiment, the method further comprises:
detecting a plurality of elements in each page image in the page image set;
and taking the page image with the abnormal element as an abnormal page image, and triggering alarm information.
In an optional embodiment, the stitching each page image in the set of page images to obtain a target image includes:
ordering each page image based on element coordinates of a start element or a stop element of each page image in the page image set to obtain an ordering result;
and splicing the page images according to the sequencing result to obtain the target image.
In an alternative embodiment, the associating the current application version with the target image includes:
storing the target image to a cloud end to obtain a resource identifier of the target image in the cloud end;
acquiring page information corresponding to the target page;
and storing the current application version, the page information and the resource identifier in an associated mode.
In an alternative embodiment, the method further comprises:
acquiring a query request, wherein the query request carries at least one historical application version;
querying a history resource identifier corresponding to the history application version, and extracting a history image by utilizing the history resource identifier;
comparing the historical image with the target image to obtain image difference information;
and generating a test report corresponding to the current application version based on the historical image, the target image and the image difference information.
In an optional embodiment, the generating the test report corresponding to the current application version based on the image difference information includes:
obtaining a visual display demand;
determining a visualization mode of the target image and the historical image based on the visualization display requirements;
and displaying the target image and the historical image on a test report template according to the visual mode, and marking the image difference information on the target image and the historical image to obtain the test report.
In a second aspect, an embodiment of the present application provides a device for detecting an application page, where the device includes:
the receiving module is used for receiving an application test task, wherein the application test task carries application information of a target application to be tested, and the target application is an application deployed on test equipment;
the jump module is used for starting the target application based on the application information and jumping to at least one target page of the target application;
the acquisition module is used for acquiring a page image set and splicing all page images in the page image set to obtain a target image, wherein the page image set comprises: a plurality of page images corresponding to each target page are sequentially intercepted on a display interface of the test equipment;
and the storage module is used for acquiring the current application version of the target application and storing the application version and the target image in a correlated mode.
In a third aspect, an embodiment of the present application provides a computer apparatus, including: the memory and the processor are in communication connection, the memory stores computer instructions, and the processor executes the computer instructions to perform the method of the first aspect or any implementation manner corresponding to the first aspect.
In a fourth aspect, an embodiment of the present application provides a computer readable storage medium having stored thereon computer instructions for causing a computer to perform the method of the first aspect or any of its corresponding embodiments.
Detailed Description
For the purpose of making the objects, technical solutions and advantages of the embodiments of the present application more apparent, the technical solutions of the embodiments of the present application will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present application, and it is apparent that the described embodiments are some embodiments of the present application, but not all embodiments of the present application. All other embodiments, which can be made by those skilled in the art based on the embodiments of the application without making any inventive effort, are intended to be within the scope of the application.
According to embodiments of the present application, there is provided a method, apparatus, computer device and storage medium for detecting an application page, it should be noted that, the steps illustrated in the flowchart of the drawings may be performed in a computer system such as a set of computer executable instructions, and, although a logical order is illustrated in the flowchart, in some cases, the steps illustrated or described may be performed in an order different from that herein.
In this embodiment, a method for detecting an application page is provided, and fig. 1 is a flowchart of a method for detecting an application page according to an embodiment of the present application, as shown in fig. 1, where the flowchart includes the following steps:
step S11, receiving an application test task, wherein the application test task carries application information of a target application to be tested, and the target application is an application deployed on test equipment.
The method provided by the embodiment of the application is applied to the testing equipment, the target application to be tested is deployed on the testing equipment, and the target application can be a client of different service types, for example: social type clients, office type clients, transaction type clients, and the like. Specifically, the test equipment is in communication connection with the server, and the server can send application test tasks to the test equipment at regular time or send test tasks according to test requirements.
Specifically, before the server issues the application test task, firstly, in the pre-test preparation, the DesiredCAPABILIs complete the configuration information setting of the test equipment and the target application to be tested, and the Apium service in the server is started by the start () method of the Apium driver LocalService so that the Apium service establishes connection with the test equipment, and then an android driver of the test equipment is initialized, so that the test command from the server can be conveniently received and executed. After the pre-test preparation is completed, the server may send an application test task to the test device, where the application test task carries application information of the target application to be tested, where the application information may be a version number of the target application and a page corresponding to the function to be tested needs to be captured, and so on.
In the embodiment of the application, after receiving the application test task, the test equipment can start a series of operations such as target application, logging in the target application, cycle skip and screenshot, exiting and the like according to the application test task.
And step S12, starting the target application based on the application information, and jumping to at least one target page of the target application.
In the embodiment of the application, after receiving an application test task, the test equipment starts and operates a corresponding target application according to a version number carried in application information, and then jumps to a corresponding target page according to a function to be tested carried by the test task, wherein the function to be tested can be a user personal function or a product display function and the like, the target page corresponding to the user personal function is a user personal page, and the target page corresponding to the product display function is a product display page.
Step S13, acquiring a page image set, and splicing all page images in the page image set to obtain a target image, wherein the page image set comprises: and sequentially intercepting a plurality of page images corresponding to each target page on a display interface of the test equipment.
In the embodiment of the application, the acquisition of the page image set comprises the following steps A1-A5:
and A1, displaying a target page based on a display interface of the test equipment, and detecting whether the target page is completely displayed on the display interface.
In the embodiment of the application, after jumping to the corresponding target page, displaying the target page on the display interface of the test equipment, and detecting whether the target page is completely displayed on the display interface, for example: and detecting whether page elements of the target page are displayed completely or not, or whether the target page can slide after being displayed on the display interface, and if the page elements of the target page are not displayed completely or can slide, indicating that the target page is not displayed completely on the interface. And on the contrary, the target page is completely displayed on the display interface. If the target page is completely displayed on the display interface, the screen capturing is directly performed on the display interface.
And step A2, under the condition that the target page is not completely displayed on the display interface, intercepting a first page image, and adding the first page image to the page image set, wherein the first page image is a page of the target page currently displayed on the display interface.
In the embodiment of the application, under the condition that the target page is not completely displayed on the display interface, a first page image of the target page is firstly intercepted on the display interface, and then the first page is added to the page image set. Note that, for example: the target page is displayed with 20 pieces of product information, the display interface can only display 5 pieces of product information, at the moment, a first page image can be obtained by screenshot of the display interface, and at the moment, the first page image comprises 5 pieces of product information displayed by the display interface.
And step A3, detecting a first termination element in the first page image, and determining first element coordinates of the first termination element in the target page.
In the embodiment of the application, the first termination element in the first page image is detected, the termination element can be understood as the last first element in the first page image, and the element can be characters, pictures, animation, audio and the like. The first element coordinates are the positions of the elements on the target page, and it is to be noted that after the page is rendered, the element coordinates of each element are fixed.
And step A4, sliding the target page based on the display interface, intercepting a second page image, and adding the second page image to the page image set, wherein a second element coordinate of a starting element of the second page image is adjacent to the first element coordinate and smaller than the first element coordinate.
In the embodiment of the application, after the first page image is intercepted, the target page is automatically slid on the display interface, the second page image is intercepted, and the second page image is added to the page image set. In the process of automatically selecting the target page, first, adjacent element coordinates of first element coordinates of a first termination element are determined, so that a next page element of the first termination element in the target page is determined, and the page element is used as a starting element of a second page image.
And step A5, based on the sliding target page of the display interface, detecting whether the display position of the second termination element in the second page image after sliding is changed, and continuing to slide the target page until the display position of the termination element in the screenshot page image after sliding is unchanged under the condition of the change, and adding the intercepted page image to the page image set.
In the embodiment of the application, after the second page image is captured, the target page is continuously slid on the display interface, whether the display position of the second termination element of the second page image after sliding (the display position is the coordinate of the termination element on the display interface and can be understood as the screen coordinate) is changed or not is detected, and if the display position is not changed, the target page is completely displayed. If the screen shot page image is changed, indicating that the target page has undisplayed content, continuing to slide the target page until the display position of the termination element of the screen shot page image is unchanged after sliding, and adding the intercepted page image to the page image set.
It should be noted that, through accurate calculation point position, coordinate, screenshot, sliding, etc. after the target application jumps to the target page, a plurality of pictures are spliced together seamlessly and accurately. The screenshot method provided by the app ium service can save the picture locally by default, so that the picture needs to be saved as a byte stream format, and then the byte stream is converted into the picture for splicing.
In an embodiment of the present application, the method further comprises the following steps: detecting a plurality of elements in each page image in a page image set; and taking the page image with the abnormal element as an abnormal page image, and triggering alarm information.
It should be noted that, after each capturing of a page image, the page image is detected, for example: sensitive information detection, display content correctness detection, display content integrity detection and the like, when abnormal elements of a page are captured, error reporting information is generated, and at the moment, page information, error reporting information and the like are packaged and sent to send mails for alarming, so that quick response can be obtained after the occurrence of the abnormality, the bug influence time is shortened, and the testing working efficiency can be improved.
In the embodiment of the application, the target image is obtained by splicing each page image in the page image set, which comprises the following steps: ordering the page images based on element coordinates of a start element or a stop element of each page image in the page image set to obtain an ordering result; and splicing the page images according to the sequencing result to obtain a target image. Therefore, the page sequence of each page can be determined by determining the element coordinates of the starting element or the ending element of each page, so that the pages are spliced according to the page sequence finally, and a final target image is generated.
Step S14, the current application version of the target application is obtained, and the current application version and the target image are stored in a correlated mode.
In the embodiment of the application, the current application version and the target image are stored in a correlated manner, and the method comprises the following steps of B1-B3:
and B1, storing the target image to a cloud end to obtain a resource identifier of the target image in the cloud end.
And step B2, obtaining page information corresponding to the target page.
And step B3, storing the current application version, the page information and the resource identifier in an associated mode.
In the embodiment of the application, the problem of slow speed caused by occupation of server space is solved by uploading the pictures to the Qiuyun. The cloud terminal returns the picture url, the information of the current page and the app version data to the database, the visual service platform is connected with the background service, and the screenshot is checked through the oriented version number, so that the page of a certain historical version can be quickly checked, and the problems that the demand is filed frequently, the archiving is complicated and not standard, the complete change record is traced, and the page service logic divergence cannot be quickly confirmed are solved.
In an embodiment of the present application, the method further comprises the following steps C1-C4:
and C1, acquiring a query request, wherein the query request carries at least one historical application version.
And step C2, inquiring a history resource identifier corresponding to the history application version, and extracting a history image by utilizing the history resource identifier.
Step C3, comparing the historical image with the target image to obtain image difference information;
and step C4, generating a test report corresponding to the current application version based on the historical image, the target image and the image difference information.
In the embodiment of the application, the generation of the test report corresponding to the current application version based on the image difference information comprises the following steps: obtaining a visual display demand; determining a visual mode of the target image and the historical image based on the visual display requirement; and displaying the target image and the historical image on a test report template in a visual mode, and marking the image difference information on the target image and the historical image to obtain a test report.
In the embodiment of the application, the test result of the page can be marked on the platform, the requirements of quick test and page walking by project related personnel are met, and the final result can generate an html-format test report mail which is well known to related personnel. In addition, the operations of searching, clicking, jumping, sliding and the like of the page elements in the screenshot process can also achieve the purpose of rapid regression of page interaction;
the embodiment also provides a detection device for an application page, which is used for implementing the foregoing embodiments and preferred embodiments, and is not described in detail. As used below, the term "module" may be a combination of software and/or hardware that implements a predetermined function. While the means described in the following embodiments are preferably implemented in software, implementation in hardware, or a combination of software and hardware, is also possible and contemplated. As shown in fig. 2, the apparatus includes:
the receiving module 21 is configured to receive an application testing task, where the application testing task carries application information of a target application to be tested, and the target application is an application deployed on the testing device;
a skip module 22, configured to start a target application based on the application information, and skip to at least one target page of the target application;
the acquiring module 23 is configured to acquire a page image set, and stitch each page image in the page image set to obtain a target image, where the page image set includes: a plurality of page images corresponding to each target page are sequentially intercepted on a display interface of the test equipment;
the storage module 24 is configured to obtain a current application version of the target application, and associate the stored application version with the target image.
In the embodiment of the present application, the obtaining module 23 is configured to display a target page based on a display interface of the test device, and detect whether the target page is completely displayed on the display interface; under the condition that the target page is not completely displayed on the display interface, a first page image is intercepted, and the first page image is added to the page image set, wherein the first page image is a page of the target page currently displayed on the display interface; detecting a first termination element in the first page image, and determining a first element coordinate of the first termination element in the target page; sliding a target page based on a display interface, intercepting a second page image, and adding the first page image to a page image set, wherein a second element coordinate of a starting element of the second page image is adjacent to the first element coordinate and smaller than the first element coordinate; based on the display interface sliding target page, detecting whether the display position of the second termination element in the second page image after sliding is changed, and continuing to slide the target page under the condition of the change until the display position of the termination element of the screenshot page image after sliding is unchanged, and adding the intercepted page image to the page image set.
In the embodiment of the application, the device further comprises: the alarm module is used for detecting a plurality of elements in each page image in the page image set; and taking the page image with the abnormal element as an abnormal page image, and triggering alarm information. Should be
In the embodiment of the present application, the obtaining module 23 is configured to sort each page image based on the element coordinates of the start element or the end element of each page image in the page image set, so as to obtain a sorting result; and splicing the page images according to the sequencing result to obtain a target image.
In the embodiment of the present application, the storage module 24 is configured to store the target image to the cloud end, so as to obtain a resource identifier of the target image at the cloud end; acquiring page information corresponding to a target page; the association stores the current application version, page information, and resource identifier.
In the embodiment of the application, the device further comprises: the query module is used for acquiring a query request, wherein the query request carries at least one historical application version; querying a history resource identifier corresponding to the history application version, and extracting a history image by using the history resource identifier; comparing the historical image with the target image to obtain image difference information; and generating a test report corresponding to the current application version based on the historical image, the target image and the image difference information.
In the embodiment of the application, the query module is used for acquiring the visual display requirement; determining a visual mode of the target image and the historical image based on the visual display requirement; and displaying the target image and the historical image on a test report template in a visual mode, and marking the image difference information on the target image and the historical image to obtain a test report.
The detection means of the application page in this embodiment are presented in the form of functional units, where a unit refers to an ASIC circuit, a processor and a memory executing one or more software or fixed programs, and/or other devices that can provide the above described functionality.
Further functional descriptions of the above respective modules and units are the same as those of the above corresponding embodiments, and are not repeated here.
Referring to fig. 3, fig. 3 is a schematic structural diagram of a computer device according to an alternative embodiment of the present application, and as shown in fig. 3, the computer device includes: one or more processors 10, memory 20, and interfaces for connecting the various components, including high-speed interfaces and low-speed interfaces. The various components are communicatively coupled to each other using different buses and may be mounted on a common motherboard or in other manners as desired. The processor may process instructions executing within the computer device, including instructions stored in or on memory to display graphical information of the GUI on an external input/output device, such as a display device coupled to the interface. In some alternative embodiments, multiple processors and/or multiple buses may be used, if desired, along with multiple memories and multiple memories. Also, multiple computer devices may be connected, each providing a portion of the necessary operations (e.g., as a server array, a set of blade servers, or a multiprocessor system). One processor 10 is illustrated in fig. 3.
The processor 10 may be a central processor, a network processor, or a combination thereof. The processor 10 may further include a hardware chip, among others. The hardware chip may be an application specific integrated circuit, a programmable logic device, or a combination thereof. The programmable logic device may be a complex programmable logic device, a field programmable gate array, a general-purpose array logic, or any combination thereof.
Wherein the memory 20 stores instructions executable by the at least one processor 10 to cause the at least one processor 10 to perform the methods shown in implementing the above embodiments.
The memory 20 may include a storage program area that may store an operating system, at least one application program required for functions, and a storage data area; the storage data area may store data created from the use of the computer device of the presentation of a sort of applet landing page, and the like. In addition, the memory 20 may include high-speed random access memory, and may also include non-transitory memory, such as at least one magnetic disk storage device, flash memory device, or other non-transitory solid-state storage device. In some alternative embodiments, memory 20 may optionally include memory located remotely from processor 10, which may be connected to the computer device via a network. Examples of such networks include, but are not limited to, the internet, intranets, local area networks, mobile communication networks, and combinations thereof.
Memory 20 may include volatile memory, such as random access memory; the memory may also include non-volatile memory, such as flash memory, hard disk, or solid state disk; the memory 20 may also comprise a combination of the above types of memories.
The computer device also includes a communication interface 30 for the computer device to communicate with other devices or communication networks.
The embodiments of the present application also provide a computer readable storage medium, and the method according to the embodiments of the present application described above may be implemented in hardware, firmware, or as a computer code which may be recorded on a storage medium, or as original stored in a remote storage medium or a non-transitory machine readable storage medium downloaded through a network and to be stored in a local storage medium, so that the method described herein may be stored on such software process on a storage medium using a general purpose computer, a special purpose processor, or programmable or special purpose hardware. The storage medium can be a magnetic disk, an optical disk, a read-only memory, a random access memory, a flash memory, a hard disk, a solid state disk or the like; further, the storage medium may also comprise a combination of memories of the kind described above. It will be appreciated that a computer, processor, microprocessor controller or programmable hardware includes a storage element that can store or receive software or computer code that, when accessed and executed by the computer, processor or hardware, implements the methods illustrated by the above embodiments.
Although embodiments of the present application have been described in connection with the accompanying drawings, various modifications and variations may be made by those skilled in the art without departing from the spirit and scope of the application, and such modifications and variations fall within the scope of the application as defined by the appended claims.