CN113238942A - User interface testing method and device, electronic equipment and storage medium - Google Patents

User interface testing method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN113238942A
CN113238942A CN202110523555.4A CN202110523555A CN113238942A CN 113238942 A CN113238942 A CN 113238942A CN 202110523555 A CN202110523555 A CN 202110523555A CN 113238942 A CN113238942 A CN 113238942A
Authority
CN
China
Prior art keywords
image
target
user interface
application
original image
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
CN202110523555.4A
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.)
JD Digital Technology Holdings Co Ltd
Original Assignee
JD Digital Technology Holdings 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 JD Digital Technology Holdings Co Ltd filed Critical JD Digital Technology Holdings Co Ltd
Priority to CN202110523555.4A priority Critical patent/CN113238942A/en
Publication of CN113238942A publication Critical patent/CN113238942A/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
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F18/00Pattern recognition
    • G06F18/20Analysing
    • G06F18/22Matching criteria, e.g. proximity measures
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/451Execution arrangements for user interfaces

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Quality & Reliability (AREA)
  • Computer Hardware Design (AREA)
  • Bioinformatics & Cheminformatics (AREA)
  • Evolutionary Computation (AREA)
  • Evolutionary Biology (AREA)
  • Computer Vision & Pattern Recognition (AREA)
  • Human Computer Interaction (AREA)
  • Bioinformatics & Computational Biology (AREA)
  • Artificial Intelligence (AREA)
  • Life Sciences & Earth Sciences (AREA)
  • User Interface Of Digital Computer (AREA)

Abstract

The embodiment of the invention discloses a user interface testing method, a user interface testing device, electronic equipment and a storage medium, wherein the user interface testing method comprises the following steps: obtaining an original image and a target image of an application, wherein the original image is a page screenshot of the application running in a first running environment, the target image is a page screenshot of the application running in a second running environment, and the application is tested through a user interface in the first running environment in advance; zooming the target image based on the resolution of the original image to obtain a target zoomed image; and acquiring page similarity between the original image and the target zooming image, and determining whether the application passes the user interface test in the second running environment or not based on the page similarity. The embodiment of the invention has the advantage of high user interface testing efficiency.

Description

User interface testing method and device, electronic equipment and storage medium
Technical Field
The invention relates to the technical field of testing, in particular to a user interface testing method and device, electronic equipment and a storage medium.
Background
The variety of hardware products such as electronic devices is increasing, and for example, mobile devices have different models and screens with different resolutions, and even different browsers are used, so that it is difficult to realize compatibility of the same application program when the application program is used in the diversified products.
In the related art, compatibility testing of an application program, such as UI (User Interface) compatibility testing, is performed manually by a tester, and the tester performs the User Interface compatibility testing on applications one by one under the conditions of multi-machine type devices, such as mobile devices, various browsers, multi-resolution devices, and the like. The following technical problems exist:
the types, browsers, screen resolutions and the like of the various types are various, so that the user interface compatibility test is performed on the applications one by one, a large amount of manpower and material resources are consumed, and the test workload is large and the test efficiency is low.
Disclosure of Invention
Based on the problems in the prior art, embodiments of the present invention provide a user interface testing method and apparatus, an electronic device, and a storage medium. The user interface testing method has the advantage of high user interface testing efficiency.
In a first aspect, an embodiment of the present invention provides a user interface testing method, including:
obtaining an original image and a target image of an application, wherein the original image is a page screenshot of the application running in a first running environment, the target image is a page screenshot of the application running in a second running environment, and the application passes a user interface test in the first running environment in advance;
zooming the target image based on the resolution of the original image to obtain a target zoomed image;
and acquiring page similarity between the original image and the target zooming image, and determining whether the application passes the user interface test in the second running environment or not based on the page similarity.
Further, the scaling the target image based on the resolution of the original image to obtain a target scaled image includes:
acquiring the resolution of the original image;
obtaining the width and the height of the original image based on the resolution of the original image;
scaling the target image in an equal proportion based on the width and the height of the original image to obtain an initial scaled image;
and obtaining the target scaling image based on the resolution of the initial scaling image.
Further, the obtaining the target scaled image based on the resolution of the initial scaled image includes:
judging whether the resolution of the initial zooming image is consistent with the resolution of the original image or not;
if the two images are consistent, the initial zooming image is used as the target zooming image;
and if not, adjusting the number of pixel points in the initial zoomed image, and taking the initial zoomed image as the target zoomed image after the resolution of the initial zoomed image is consistent with the resolution of the original image.
Further, the obtaining of the page similarity between the original image and the target zoomed image, and determining whether the application passes the user interface test in the second operating environment based on the page similarity include:
acquiring page similarity between the original image and the target zoomed image;
and if the page similarity is lower than a preset threshold value, determining that the application passes the user interface test in the second running environment, otherwise, determining that the application does not pass the user interface test in the second running environment.
Further, the obtaining of the page similarity between the original image and the target zoomed image includes:
comparing whether the corresponding pixel points in the original image and the target zoomed image are the same or not;
and obtaining the page similarity based on the number of different pixel points in the comparison result.
Further, before the obtaining of the page similarity between the original image and the target zoomed image and determining, based on the page similarity, whether the application passes the user interface test in the second operating environment, the method further includes:
converting the original image and the target zoomed image into a gray scale image, wherein the acquiring of the page similarity between the original image and the target zoomed image comprises: and obtaining the page similarity based on the gray level image of the original image and the gray level image of the target scaling image.
Further, the obtaining of the original image and the target image of the application includes:
starting the application under the first running environment and the second running environment respectively;
and controlling the application to synchronously execute in the first running environment and the second running environment so as to obtain the original image and the target image aiming at the same user interface in the application.
In a second aspect, an embodiment of the present invention provides a user interface testing apparatus, including:
the system comprises an image acquisition module, a display module and a display module, wherein the image acquisition module is used for acquiring an original image and a target image of an application, the original image is a page screenshot of the application running in a first running environment, the target image is a page screenshot of the application running in a second running environment, and the application passes a user interface test in the first running environment in advance;
the zooming module is used for zooming the target image based on the resolution of the original image to obtain a target zoomed image;
and the judging module is used for acquiring the page similarity between the original image and the target zooming image and determining whether the application passes the user interface test in the second running environment or not based on the page similarity.
In a third aspect, an embodiment of the present invention further provides an electronic device, including a memory, a processor, and a computer program stored on the memory and executable on the processor, where the processor executes the computer program to implement the user interface testing method according to the first aspect.
In a fourth aspect, an embodiment of the present invention further provides a non-transitory computer-readable storage medium, on which a computer program is stored, where the computer program, when executed by a processor, implements the user interface testing method according to the first aspect.
It can be known from the foregoing technical solutions that, in the user interface test, the apparatus, the electronic device, and the storage medium provided in the embodiments of the present invention, an original image applied to a user interface obtained in a first operating environment that has passed a test condition and a target image applied to a user interface obtained in a second operating environment that is applying a condition that compatibility is being tested are obtained, and then the target image is scaled according to a resolution of the original image, so that the target scaled image has a resolution identical to that of the original image, and finally, a page similarity between the two is obtained at the same resolution, so that a UI compatibility test applied in the second operating environment can be completed according to a difference between the page similarities.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to these drawings without creative efforts.
FIG. 1 is a flow chart of a method for testing a user interface according to an embodiment of the present invention;
FIG. 2 is a flow chart of a method for testing a user interface according to another embodiment of the present invention;
FIG. 3 is a block diagram of a user interface testing apparatus according to an embodiment of the present invention;
fig. 4 is a schematic structural diagram of an electronic device according to an embodiment of the present invention.
Detailed Description
The following further describes embodiments of the present invention with reference to the accompanying drawings. The following examples are only for illustrating the technical solutions of the present invention more clearly, and the protection scope of the present invention is not limited thereby.
A user interface testing method, apparatus, electronic device, and storage medium according to embodiments of the present invention are described below with reference to the accompanying drawings.
Fig. 1 is a flowchart illustrating a user interface testing method according to an embodiment of the present invention. As shown in fig. 1, a user interface testing method provided by an embodiment of the present invention includes the following steps:
s101: the method comprises the steps of obtaining an original image and a target image of an application, wherein the original image is a page screenshot of the application running in a first running environment, the target image is a page screenshot of the application running in a second running environment, and the application is tested through a user interface in the first running environment in advance.
The application may be a Web application, which is an application accessible through the Web, and for the Web application, a user may access only through a browser, for example, the user may access through multiple browsers on a PC (personal computer) or multiple browsers on a mobile device. Of course, the application may also be an application on a mobile device, and the mobile device may be a device such as a smartphone.
The operating environments such as the first operating environment and the second operating environment may refer to models, resolutions, sizes, browsers, and the like, for example: if an application is used on two different models, different resolutions, different sizes, and/or different browsers, the application may operate in different environments when used on the two different models, different resolutions, different sizes, and/or different browsers. In one embodiment of the invention, the first operating environment is a first browser, and the second operating environment is a second browser, wherein the first browser and the second browser are different in type, and the application passes the user interface test in advance when being accessed in the first browser.
In this example, the User Interface test refers to a User Interface (UI) compatibility test, where the UI compatibility test refers to a test of consistency of UI Interface display on mobile devices of different models, different resolutions, and different sizes, and a test of consistency of UI Interface display in different browsers, and the test of consistency of UI Interface display may be a test of consistency of page layout or picture display ratio.
For the same application, assuming that the first browser is a first running environment and the second browser is a second running environment, the application has been tested in the first browser through the user interface, at this time, the application running in the first browser may be referred to as a reference application, and the application running in the second browser may be referred to as a tested application, that is: the original image is a screenshot of a certain page when the reference application runs in the first browser, and the target image is a screenshot of a certain page when the tested application runs in the second browser.
In this example, the original image and the target image are images for the same user interface in the application. For example: and if the original image is the page screenshot of the login interface when the application runs in the first browser, the target image is the page screenshot of the login interface when the application runs in the second browser.
In a specific application, as shown in fig. 2, after the test has started, the following operations are performed:
s201: the reference application is started.
S202: and starting the application to be tested.
S203: controlling the reference application and the application to be tested to be in a synchronous state, and intercepting a page picture, namely: after the application is started in the first running environment and the second running environment respectively; the control application is executed synchronously in the first operating environment and the second operating environment. Therefore, the screenshot can be synchronously performed on the same user interface, and the original image and the target image aiming at the same user interface can be quickly obtained.
It is understood that the sequence of step S201 and step S202 may be adjusted, that is, the reference application and the application to be tested are started in a non-sequential order, the application to be tested is started first, and then the reference application is started, or both the application to be tested and the reference application are started at the same time.
In practical applications, for starting the reference application and the application to be tested in steps S201 and S202, the corresponding web browser may be started through the WebDriver, and then, the starting of the reference application and the application to be tested is realized using the corresponding integrated development tool or command line tool. For example: if the operating system is iOS (short for mobile operating system), it can be started by Xcode, and if the operating system is android (short for mobile operating system), it can be started by ADB.
Wherein, Xcode is an integrated development tool (IDE) capable of running on an operating system iOS, and the Xcode has functions of developing iOS application programs and the like. The ADB is an Android Debug Bridge (ADB), which is a versatile command line tool that can communicate with devices. The adb command may be used to perform various device operations, such as functions to install and debug applications. Webdrive is an automatic testing framework of a web application, is developed for each browser, is tightly integrated with the browser, and can support the creation of more tests.
In the above description, the purpose of controlling the reference application and the application to be tested to be in a synchronous state is to obtain the original image and the target image synchronously, so as to achieve the purpose of improving the obtaining efficiency of the original image and the target image. Of course, in other examples, the original image and the target image may be obtained asynchronously.
S102: and zooming the target image based on the resolution of the original image to obtain a target zoomed image.
And the target image is zoomed based on the resolution of the original image, and the obtained target zoomed image is obtained by adjusting the resolution of the target image to be consistent with the resolution of the original image according to the resolution of the original image.
In one example, scaling a target image based on a resolution of an original image to obtain a target scaled image includes: acquiring the resolution of the original image; obtaining the width and the height of the original image based on the resolution of the original image; scaling the target image in an equal proportion based on the width and the height of the original image to obtain an initial scaled image; and obtaining the target scaling image based on the resolution of the initial scaling image.
In this example, the unit of width and height may be a pixel, for example: the original image with a resolution of 800 × 600, representing 800 pixels in width and 600 pixels in height, may be automatically adapted to the resolution of the target image by some existing algorithm, as depicted in S204 of fig. 2, taking the original image with a resolution of 800 × 600 as an example, i.e.: the resolution of the target image is automatically adapted based on the resolution of the original image, i.e. the resolution of the target scaled image should also be 800 x 600 after the automatic adaptation of the resolution of the target image by the algorithm.
When the resolution of one image is automatically adapted based on the resolution of another image, some existing algorithms may cause the resolution of the obtained image to slightly differ from the resolution, for example: adapting the resolution of the target image based on the original image with 800 × 600 resolution may be such that the resolution of the scaled target image is 800 × 599, 800 × 601, 799 × 600, 799 × 599, etc., in which case further adjustment of the resolution of the scaled target image to 800 × 600 may be required, which may be achieved by increasing or decreasing pixels.
Specifically, obtaining the target scaled image based on the resolution of the initial scaled image includes: judging whether the resolution of the initial zoomed image is consistent with the resolution of the original image; if the two images are consistent, taking the initial zooming image as the target zooming image; and if not, adjusting the number of pixel points in the initial zoomed image, and taking the initial zoomed image as the target zoomed image after the resolution of the initial zoomed image is consistent with the resolution of the original image. For example: after automatic adaptation of the resolution based on the resolution of 800 × 600, the resolution of the initial scaled image is 800 × 599, i.e.: the resolution of the initial zoomed image is one column of pixels less than the resolution of the original image, and at this time, one column of pixel points may be added to the column specified by the initial zoomed image, where the specified column is usually the rightmost side of the image. As another example, after automatic adaptation of resolution based on a resolution of 800 × 600, the resolution of the initial scaled image is 801 × 600, i.e.: the resolution of the initially zoomed image is one line more than the resolution of the original image, and at this time, one line of pixel points may be reduced on the line designated by the initially zoomed image, where the designated line is usually the lowest side of the image.
It should be noted that, because the attention level generally decreases from the top left to the bottom right when a certain page is viewed, adding or deleting one row or one column of pixels to or from the lowest row or the lowest right column has less difference to be perceived when the page is viewed, that is: the influence on the image is small, and therefore, in the above example, the specified column is set as the rightmost column of the image and the specified row is set as the lowermost row of the image, so that the difference is small for the images before and after modification.
In the above description, the added row of pixels or column of pixels may be black pixels or white pixels.
S103: and acquiring page similarity between the original image and the target zooming image, and determining whether the application passes the user interface test in the second running environment or not based on the page similarity. Namely: and if the original image and the target zoom image are very similar, the user interface of the application is compatible with the second running environment.
In an embodiment of the present invention, acquiring a page similarity between the original image and the target zoomed image, and determining whether the application passes a user interface test in the second operating environment based on the page similarity includes: acquiring page similarity between the original image and the target zoomed image; and if the page similarity is lower than a preset threshold value, determining that the application passes the user interface test in the second running environment, otherwise, determining that the application does not pass the user interface test in the second running environment.
In this example, obtaining the page similarity between the original image and the target zoomed image includes: comparing whether the corresponding pixel points in the original image and the target zoomed image are the same or not; and obtaining the page similarity based on the number of different pixel points in the comparison result.
Specifically, assuming that the resolution of the original image is 800 × 600, the resolution of the target zoomed image is already adjusted to 800 × 600, the pixel points in the N-th row and the M-th column in the original image are compared with the pixel points in the N-th row and the M-th column in the target zoomed image one by one, and finally, the number of different pixel points is counted, and the number is taken as the page similarity. Therefore, a tolerable preset threshold value can be preset, if the threshold value is smaller than the threshold value, the user interface of the application is compatible with the second running environment, otherwise, the user interface of the application is incompatible with the second running environment, and therefore UI compatibility test of the appliance interface is automatically achieved. Where N is any integer from 1 to the number of pixel rows of the image, and M is any integer from 1 to the number of pixel columns of the image.
In the above description, the preset threshold may be determined empirically, for example, set to 100, which indicates that if there are more than 100 pixel point differences between the two, the application does not pass the UI compatibility test in the second operating environment, and otherwise, the application passes the UI compatibility test in the second operating environment.
As shown in FIG. 2, in a specific application, S205, it is determined whether the page displays are consistent, that is: and determining whether the application passes the user interface test in the second running environment according to the page similarity between the original image and the target zooming image, if the page display is consistent, executing S206, otherwise executing S207, and if the test does not pass. In S206, it is determined whether the script is ended, that is: whether each page of the application is tested, if yes, and the test is passed, S208 is executed, that is: the test is passed.
According to the user interface testing method provided by the embodiment of the invention, the original image of the user interface obtained in the first operation environment which passes the testing condition and the target image of the user interface obtained in the second operation environment which applies the condition of testing the compatibility are obtained, then the target image is zoomed according to the resolution of the original image, so that the target zoomed image has the same resolution as the original image, and finally the page similarity between the original image and the target zoomed image is obtained under the same resolution, so that the UI compatibility test applied in the second operation environment can be completed according to the difference condition between the page similarities.
In an embodiment of the present invention, before the obtaining of the page similarity between the original image and the target zoomed image, and determining whether the application passes the user interface test in the second operating environment based on the page similarity, the method further includes: converting the original image and the target zoomed image into a gray scale image, wherein the acquiring of the page similarity between the original image and the target zoomed image comprises: and obtaining the page similarity based on the gray level image of the original image and the gray level image of the target scaling image. Thus, the efficiency of the UI compatibility test can be further improved.
Fig. 3 is a schematic structural diagram of a user interface testing apparatus according to an embodiment of the present invention, and as shown in fig. 3, the user interface testing apparatus according to the embodiment of the present invention includes: an image acquisition module 310, a scaling module 320, and a decision module 330, wherein:
the image obtaining module 310 is configured to obtain an original image and a target image of an application, where the original image is a page screenshot of the application running in a first running environment, the target image is a page screenshot of the application running in a second running environment, and the application passes a user interface test in the first running environment in advance.
The application may be a Web application, which is an application accessible through the Web, and for the Web application, a user may access only through a browser, for example, the user may access through multiple browsers on a PC (personal computer) or multiple browsers on a mobile device. Of course, the application may also be an application on a mobile device, and the mobile device may be a device such as a smartphone.
The operating environments such as the first operating environment and the second operating environment may refer to models, resolutions, sizes, browsers, and the like, for example: if an application is used on two different models, different resolutions, different sizes, and/or different browsers, the application may operate in different environments when used on the two different models, different resolutions, different sizes, and/or different browsers. In one embodiment of the invention, the first operating environment is a first browser, and the second operating environment is a second browser, wherein the first browser and the second browser are different in type, and the application passes the user interface test in advance when being accessed in the first browser.
In this example, the User Interface test refers to a User Interface (UI) compatibility test, where the UI compatibility test refers to a test of consistency of UI Interface display on mobile devices of different models, different resolutions, and different sizes, and a test of consistency of UI Interface display in different browsers, and the test of consistency of UI Interface display may be a test of consistency of page layout or picture display ratio.
For the same application, assuming that the first browser is a first running environment and the second browser is a second running environment, the application has been tested in the first browser through the user interface, at this time, the application running in the first browser may be referred to as a reference application, and the application running in the second browser may be referred to as a tested application, that is: the original image is a screenshot of a certain page when the reference application runs in the first browser, and the target image is a screenshot of a certain page when the tested application runs in the second browser.
In this example, the original image and the target image are images for the same user interface in the application. For example: and if the original image is the page screenshot of the login interface when the application runs in the first browser, the target image is the page screenshot of the login interface when the application runs in the second browser.
In a specific application, as shown in fig. 2, after the test has started, the following operations are performed:
the reference application is started.
And starting the application to be tested.
Controlling the reference application and the application to be tested to be in a synchronous state, and intercepting a page picture, namely: after the application is started in the first running environment and the second running environment respectively; the control application is executed synchronously in the first operating environment and the second operating environment. Therefore, the screenshot can be synchronously performed on the same user interface, and the original image and the target image aiming at the same user interface can be quickly obtained.
It can be understood that the reference application and the application to be tested are started in no sequence, the application to be tested is started first, and then the reference application is started, or the application to be tested and the reference application are started simultaneously.
In actual application, starting a reference application and a tested application, starting a corresponding web browser through the WebDriver, and then starting the reference application and the tested application by using a corresponding integrated development tool or a command line tool. For example: if the operating system is iOS (short for mobile operating system), it can be started by Xcode, and if the operating system is android (short for mobile operating system), it can be started by ADB.
Wherein, Xcode is an integrated development tool (IDE) capable of running on an operating system iOS, and the Xcode has functions of developing iOS application programs and the like. The ADB is an Android Debug Bridge (ADB), which is a versatile command line tool that can communicate with devices. The adb command may be used to perform various device operations, such as functions to install and debug applications. Webdrive is an automatic testing framework of a web application, is developed for each browser, is tightly integrated with the browser, and can support the creation of more tests.
In the above description, the purpose of controlling the reference application and the application to be tested to be in a synchronous state is to obtain the original image and the target image synchronously, so as to achieve the purpose of improving the obtaining efficiency of the original image and the target image. Of course, in other examples, the original image and the target image may be obtained asynchronously.
The scaling module 320 is configured to scale the target image based on the resolution of the original image to obtain a target scaled image.
And the target image is zoomed based on the resolution of the original image, and the obtained target zoomed image is obtained by adjusting the resolution of the target image to be consistent with the resolution of the original image according to the resolution of the original image.
In one example, scaling a target image based on a resolution of an original image to obtain a target scaled image includes: acquiring the resolution of the original image; obtaining the width and the height of the original image based on the resolution of the original image; scaling the target image in an equal proportion based on the width and the height of the original image to obtain an initial scaled image; and obtaining the target scaling image based on the resolution of the initial scaling image.
In this example, the unit of width and height may be a pixel, for example: the original image with a resolution of 800 × 600, representing 800 pixels in width and 600 pixels in height, may be automatically adapted to the resolution of the target image by some existing algorithm, as described in fig. 2, taking the original image with a resolution of 800 × 600 as an example, i.e.: the resolution of the target image is automatically adapted based on the resolution of the original image, i.e. the resolution of the target scaled image should also be 800 x 600 after the automatic adaptation of the resolution of the target image by the algorithm.
When the resolution of one image is automatically adapted based on the resolution of another image, some existing algorithms may cause the resolution of the obtained image to slightly differ from the resolution, for example: adapting the resolution of the target image based on the original image with 800 × 600 resolution may be such that the resolution of the scaled target image is 800 × 599, 800 × 601, 799 × 600, 799 × 599, etc., in which case further adjustment of the resolution of the scaled target image to 800 × 600 may be required, which may be achieved by increasing or decreasing pixels.
Specifically, obtaining the target scaled image based on the resolution of the initial scaled image includes: judging whether the resolution of the initial zoomed image is consistent with the resolution of the original image; if the two images are consistent, taking the initial zooming image as the target zooming image; and if not, adjusting the number of pixel points in the initial zoomed image, and taking the initial zoomed image as the target zoomed image after the resolution of the initial zoomed image is consistent with the resolution of the original image. For example: after automatic adaptation of the resolution based on the resolution of 800 × 600, the resolution of the initial scaled image is 800 × 599, i.e.: the resolution of the initial zoomed image is one column of pixels less than the resolution of the original image, and at this time, one column of pixel points may be added to the column specified by the initial zoomed image, where the specified column is usually the rightmost side of the image. As another example, after automatic adaptation of resolution based on a resolution of 800 × 600, the resolution of the initial scaled image is 801 × 600, i.e.: the resolution of the initially zoomed image is one line more than the resolution of the original image, and at this time, one line of pixel points may be reduced on the line designated by the initially zoomed image, where the designated line is usually the lowest side of the image.
It should be noted that, because the attention level generally decreases from the top left to the bottom right when a certain page is viewed, adding or deleting one row or one column of pixels to or from the lowest row or the lowest right column has less difference to be perceived when the page is viewed, that is: the influence on the image is small, and therefore, in the above example, the specified column is set as the rightmost column of the image and the specified row is set as the lowermost row of the image, so that the difference is small for the images before and after modification.
In the above description, the added row of pixels or column of pixels may be black pixels or white pixels.
The determining module 330 is configured to obtain a page similarity between the original image and the target zoomed image, and determine whether the application passes the user interface test in the second operating environment based on the page similarity.
Namely: and if the original image and the target zoom image are very similar, the user interface of the application is compatible with the second running environment.
In an embodiment of the present invention, acquiring a page similarity between the original image and the target zoomed image, and determining whether the application passes a user interface test in the second operating environment based on the page similarity includes: acquiring page similarity between the original image and the target zoomed image; and if the page similarity is lower than a preset threshold value, determining that the application passes the user interface test in the second running environment, otherwise, determining that the application does not pass the user interface test in the second running environment.
In this example, obtaining the page similarity between the original image and the target zoomed image includes: comparing whether the corresponding pixel points in the original image and the target zoomed image are the same or not; and obtaining the page similarity based on the number of different pixel points in the comparison result.
Specifically, assuming that the resolution of the original image is 800 × 600, the resolution of the target zoomed image is already adjusted to 800 × 600, the pixel points in the N-th row and the M-th column in the original image are compared with the pixel points in the N-th row and the M-th column in the target zoomed image one by one, and finally, the number of different pixel points is counted, and the number is taken as the page similarity. Therefore, a tolerable preset threshold value can be preset, if the threshold value is smaller than the threshold value, the user interface of the application is compatible with the second running environment, otherwise, the user interface of the application is incompatible with the second running environment, and therefore UI compatibility test of the appliance interface is automatically achieved. Where N is any integer from 1 to the number of pixel rows of the image, and M is any integer from 1 to the number of pixel columns of the image.
In the above description, the preset threshold may be determined empirically, for example, set to 100, which indicates that if there are more than 100 pixel point differences between the two, the application does not pass the UI compatibility test in the second operating environment, and otherwise, the application passes the UI compatibility test in the second operating environment.
As shown in fig. 2, in a specific application, it is determined whether the page displays are consistent, that is: determining whether the application passes the user interface test in the second operation environment according to the page similarity between the original image and the target zoom image, if the page display is consistent, then judging whether the script is finished, and if the script is finished and each page of the application passes the test, then the test is passed; if the page shows are not consistent, the test fails.
According to the user interface testing device provided by the embodiment of the invention, the original image of the user interface obtained in the first operation environment which passes the testing condition and the target image of the user interface obtained in the second operation environment which applies the condition of testing the compatibility are obtained, then the target image is zoomed according to the resolution of the original image, so that the target zoomed image has the same resolution as the original image, and finally the page similarity between the original image and the target zoomed image is obtained under the same resolution, so that the UI compatibility test applied in the second operation environment can be completed according to the difference condition between the page similarities.
In an embodiment of the present invention, before acquiring the page similarity between the original image and the target zoomed image, and determining whether the application passes the user interface test in the second operating environment based on the page similarity, the determining module 330 is further configured to: and converting the original image and the target zooming image into gray images, wherein the obtained page similarity between the original image and the target zooming image is obtained based on the gray images of the original image and the target zooming image.
It should be noted that a specific implementation manner of the user interface testing apparatus according to the embodiment of the present invention is similar to a specific implementation manner of the user interface testing method according to the embodiment of the present invention, and please refer to the description of the method part specifically, and details are not described here specifically in order to reduce redundancy.
Based on the same inventive concept, another embodiment of the present invention provides an electronic device, which specifically includes the following components, with reference to fig. 4: a processor 401, a memory 402, a communication interface 403, and a communication bus 404;
the processor 401, the memory 402 and the communication interface 403 complete mutual communication through the communication bus 404; the communication interface 403 is used for implementing information transmission between the devices;
the processor 401 is configured to call the computer program in the memory 402, and the processor implements all the steps of the user interface testing method when executing the computer program, for example, the processor implements the following steps when executing the computer program: obtaining an original image and a target image of an application, wherein the original image is a page screenshot of the application running in a first running environment, the target image is a page screenshot of the application running in a second running environment, and the application passes a user interface test in the first running environment in advance; zooming the target image based on the resolution of the original image to obtain a target zoomed image; and acquiring page similarity between the original image and the target zooming image, and determining whether the application passes the user interface test in the second running environment or not based on the page similarity.
Based on the same inventive concept, yet another embodiment of the present invention provides a non-transitory computer-readable storage medium having stored thereon a computer program, which when executed by a processor implements all the steps of the above-mentioned user interface testing method, for example, the processor implements the following steps when executing the computer program: obtaining an original image and a target image of an application, wherein the original image is a page screenshot of the application running in a first running environment, the target image is a page screenshot of the application running in a second running environment, and the application passes a user interface test in the first running environment in advance; zooming the target image based on the resolution of the original image to obtain a target zoomed image; and acquiring page similarity between the original image and the target zooming image, and determining whether the application passes the user interface test in the second running environment or not based on the page similarity.
In addition, the logic instructions in the memory may be implemented in the form of software functional units and may be stored in a computer readable storage medium when sold or used as a stand-alone product. 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 and includes instructions for causing a computer device (which may be a personal computer, a server, or a network device) to execute all or part of the steps of the method according to the embodiments of the present invention. And the aforementioned storage medium includes: a U-disk, a removable hard disk, a Read-Only Memory (ROM), a Random Access Memory (RAM), a magnetic disk or an optical disk, and other various media capable of storing program codes.
The above-described embodiments of the apparatus are merely illustrative, and the units described as separate parts may or may not be physically separate, and parts displayed as units may or may not be physical units, may be located in one place, or may be distributed on a plurality of network units. Some or all of the modules may be selected according to actual needs to achieve the purpose of the solution of the embodiment of the present invention. One of ordinary skill in the art can understand and implement it without inventive effort.
Through the above description of the embodiments, those skilled in the art will clearly understand that each embodiment can be implemented by software plus a necessary general hardware platform, and certainly can also be implemented by hardware. Based on such understanding, the above technical solutions may be essentially or partially implemented in the form of software products, which may be stored in a computer-readable storage medium, such as ROM/RAM, magnetic disk, optical disk, etc., and include instructions for causing a computer device (which may be a personal computer, a server, or a network device, etc.) to execute the index monitoring method according to the embodiments or some parts of the embodiments.
In addition, in the present invention, terms such as "first" and "second" are used for descriptive purposes only and are not to be construed as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include at least one such feature. In the description of the present invention, "a plurality" means at least two, e.g., two, three, etc., unless specifically limited otherwise.
Moreover, in the present invention, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus 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 apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
Furthermore, in the description herein, reference to the description of the term "one embodiment," "some embodiments," "an example," "a specific example," or "some examples," etc., means that a particular feature, structure, material, or characteristic described in connection with the embodiment or example is included in at least one embodiment or example of the invention. In this specification, the schematic representations of the terms used above are not necessarily intended to refer to the same embodiment or example. Furthermore, the particular features, structures, materials, or characteristics described may be combined in any suitable manner in any one or more embodiments or examples. Furthermore, various embodiments or examples and features of different embodiments or examples described in this specification can be combined and combined by one skilled in the art without contradiction.
Finally, it should be noted that: the above examples are only intended to illustrate the technical solution of the present invention, but not to limit it; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those of ordinary skill in the art that: the technical solutions described in the foregoing embodiments may still be modified, or some technical features may be equivalently replaced; and such modifications or substitutions do not depart from the spirit and scope of the corresponding technical solutions of the embodiments of the present invention.

Claims (10)

1. A user interface testing method, comprising:
obtaining an original image and a target image of an application, wherein the original image is a page screenshot of the application running in a first running environment, the target image is a page screenshot of the application running in a second running environment, and the application passes a user interface test in the first running environment in advance;
zooming the target image based on the resolution of the original image to obtain a target zoomed image;
and acquiring page similarity between the original image and the target zooming image, and determining whether the application passes the user interface test in the second running environment or not based on the page similarity.
2. The method for testing the user interface of claim 1, wherein the scaling the target image based on the resolution of the original image to obtain a target scaled image comprises:
acquiring the resolution of the original image;
obtaining the width and the height of the original image based on the resolution of the original image;
scaling the target image in an equal proportion based on the width and the height of the original image to obtain an initial scaled image;
and obtaining the target scaling image based on the resolution of the initial scaling image.
3. The method for testing a user interface of claim 2, wherein the obtaining the target scaled image based on the resolution of the initial scaled image comprises:
judging whether the resolution of the initial zooming image is consistent with the resolution of the original image or not;
if the two images are consistent, the initial zooming image is used as the target zooming image;
and if not, adjusting the number of pixel points in the initial zoomed image, and taking the initial zoomed image as the target zoomed image after the resolution of the initial zoomed image is consistent with the resolution of the original image.
4. The method for testing the user interface of any one of claims 1 to 3, wherein the obtaining of the page similarity between the original image and the target zoomed image and the determining whether the application passes the user interface test in the second running environment based on the page similarity comprise:
acquiring page similarity between the original image and the target zoomed image;
and if the page similarity is lower than a preset threshold value, determining that the application passes the user interface test in the second running environment, otherwise, determining that the application does not pass the user interface test in the second running environment.
5. The method for testing the user interface of claim 4, wherein the obtaining of the page similarity between the original image and the target zoomed image comprises:
comparing whether the corresponding pixel points in the original image and the target zoomed image are the same or not;
and obtaining the page similarity based on the number of different pixel points in the comparison result.
6. The method for testing the user interface of claim 1, before the obtaining of the page similarity between the original image and the target zoomed image and the determining of whether the application passes the user interface test in the second operating environment based on the page similarity, further comprising:
converting the original image and the target zoomed image into a gray scale image, wherein the acquiring of the page similarity between the original image and the target zoomed image comprises: and obtaining the page similarity based on the gray level image of the original image and the gray level image of the target scaling image.
7. The method for testing the user interface of claim 1, wherein the obtaining of the original image and the target image of the application comprises:
starting the application under the first running environment and the second running environment respectively;
and controlling the application to synchronously execute in the first running environment and the second running environment so as to obtain the original image and the target image aiming at the same user interface in the application.
8. A user interface testing apparatus, comprising:
the system comprises an image acquisition module, a display module and a display module, wherein the image acquisition module is used for acquiring an original image and a target image of an application, the original image is a page screenshot of the application running in a first running environment, the target image is a page screenshot of the application running in a second running environment, and the application passes a user interface test in the first running environment in advance;
the zooming module is used for zooming the target image based on the resolution of the original image to obtain a target zoomed image;
and the judging module is used for acquiring the page similarity between the original image and the target zooming image and determining whether the application passes the user interface test in the second running environment or not based on the page similarity.
9. An electronic device comprising a memory, a processor and a computer program stored on the memory and executable on the processor, wherein the steps of the user interface testing method according to any one of claims 1 to 7 are implemented when the program is executed by the processor.
10. A non-transitory computer readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the steps of the user interface testing method according to any one of claims 1 to 7.
CN202110523555.4A 2021-05-13 2021-05-13 User interface testing method and device, electronic equipment and storage medium Pending CN113238942A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110523555.4A CN113238942A (en) 2021-05-13 2021-05-13 User interface testing method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110523555.4A CN113238942A (en) 2021-05-13 2021-05-13 User interface testing method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN113238942A true CN113238942A (en) 2021-08-10

Family

ID=77134127

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110523555.4A Pending CN113238942A (en) 2021-05-13 2021-05-13 User interface testing method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN113238942A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113656131A (en) * 2021-08-16 2021-11-16 维沃移动通信有限公司 Remote control method, device, electronic equipment and storage medium

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108446227A (en) * 2018-03-12 2018-08-24 广东睿江云计算股份有限公司 A kind of virtual machine browser compatibility test method based on selenium
CN109857652A (en) * 2019-01-16 2019-06-07 深圳壹账通智能科技有限公司 A kind of automated testing method of user interface, terminal device and medium
CN112199268A (en) * 2019-07-08 2021-01-08 中移互联网有限公司 Software compatibility testing method and electronic equipment

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN108446227A (en) * 2018-03-12 2018-08-24 广东睿江云计算股份有限公司 A kind of virtual machine browser compatibility test method based on selenium
CN109857652A (en) * 2019-01-16 2019-06-07 深圳壹账通智能科技有限公司 A kind of automated testing method of user interface, terminal device and medium
CN112199268A (en) * 2019-07-08 2021-01-08 中移互联网有限公司 Software compatibility testing method and electronic equipment

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113656131A (en) * 2021-08-16 2021-11-16 维沃移动通信有限公司 Remote control method, device, electronic equipment and storage medium
CN113656131B (en) * 2021-08-16 2024-07-26 维沃移动通信有限公司 Remote control method, device, electronic equipment and storage medium

Similar Documents

Publication Publication Date Title
CN103631958B (en) A kind of page automatic adaptation realizes the method that content multi-screen is shown
CN111061526A (en) Automatic testing method and device, computer equipment and storage medium
CN111309618B (en) Page element positioning method, page testing method and related devices
CN107885645B (en) Method and device for calculating rendering duration of first screen of page and electronic equipment
CN110825651A (en) Webpage compatibility testing method, device, system and storage medium
CN110032314B (en) Long screen capture method and device, storage medium and terminal equipment
CN106296622B (en) Automatic layout jigsaw method and device
CN111459501A (en) SVG-based Web configuration picture storage and display system, method and medium
CN111159597A (en) Skeleton screen generation method and system, computer equipment and storage medium
CN113238942A (en) User interface testing method and device, electronic equipment and storage medium
CN111666199B (en) Debugging method executed on intelligent terminal and software debugger
CN108717357B (en) Page display code conversion method, device, equipment and computer storage medium
CN112948267A (en) Webpage testing method, webpage testing system, storage medium and electronic equipment
CN112463602A (en) User interface testing method and system
CN110456999B (en) Program creation method, program creation device, electronic equipment and computer readable storage medium
US9354772B2 (en) Method and device for movement of image object
CN107395692A (en) Terminal screen methods of exhibiting and device
US20140129916A1 (en) Evaluation of resizing capability of web browser
CN108037914B (en) Method and device for developing android native system by combining js
CN115588458A (en) Storage device testing method, system, device and readable storage medium
CN112115057B (en) Automatic test method, device and equipment for application program page building flow
CN114896175A (en) Automatic test method, device, equipment and medium for report export function
CN114242181A (en) Desert sand concrete strength prediction model training method, device, equipment and medium
CN112286785B (en) Abnormality detection method and device for user interface
CN112261227A (en) Method for multi-screen equal-proportion adaptation of mobile terminal

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
CB02 Change of applicant information
CB02 Change of applicant information

Address after: Room 221, 2 / F, block C, 18 Kechuang 11th Street, Daxing District, Beijing, 100176

Applicant after: Jingdong Technology Holding Co.,Ltd.

Address before: Room 221, 2nd floor, Block C, 18 Kechuang 11th Street, Daxing Economic and Technological Development Zone, Beijing, 100176

Applicant before: Jingdong Digital Technology Holding Co., Ltd