A method and device for adding tolerance to image assertions in page automation testing
By adding tolerance to image assertions in UI automation testing, combining the comparison strategies of absolute tolerance, default tolerance and edge tolerance, the accuracy of image assertions in dynamically changing images is solved, and the reliability of the test is improved and compatibility reduce maintenance workload.
Patent Information
- Application Number
- CN202111317080.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-09
- Publication Date
- 2024-12-31
- Estimated Expiration
- 2041-11-09
AI Technical Summary
In UI automation testing, the accuracy of image assertions is affected by dynamically changing image content and pixel differences that cannot be recognized by the naked eye, making it difficult to compatible with conventional tolerance settings, maintenance workloads and inaccurate test results.
Add tolerances to image assertions in page automation tests, use any image editing tool to set skip areas, compare pixels row by row by column, and adopt a comparison strategy that combines absolute tolerance, default tolerance and edge tolerance. Adjust tolerance rules to improve image comparison accuracy and compatibility.
It reduces the difficulty of maintaining image assertions, improves the reliability and accuracy of test cases, can be effectively compatible with different contrast scenarios, and reduces the risk of test failure and missed error information.
Smart Images

Figure CN113989418B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of UI automated testing, and in particular to a method and device for adding tolerance to image assertions in page automated testing. Background Art
[0002] In the process of UI automation testing, there are often a large number of checkpoints in the key steps. In order to cover as many checkpoints as possible, image assertions will be used to compare the image capture of the running software or system with the basic target image. In this process, the test results are obtained through a series of matching and comparison.
[0003] The prior art still has the following disadvantages:
[0004] 1. Images during software operation often have some content that changes dynamically, which will affect the accuracy of image assertions. Additional data is often required to record the areas that need to be excluded. Conventional solutions store some image area information separately in the structured data of the use case, which requires relatively large maintenance and modification workload.
[0005] Even if the content of the screenshots taken during actual software operation is exactly the same, the ARGB colors of some image pixels will differ to varying degrees. These differences are normal differences that cannot be recognized by the naked eye and should be considered normal. To solve this problem, image assertions will add tolerance values. Conventional tolerances are difficult to cope with actual usage scenarios. If the tolerance setting is too strict, a large number of assertions that should have passed will fail. If the tolerance setting is too loose, critical information of errors will be missed.
[0006] A large number of tests have shown that when there is a large transition between pixels in a regular image, the color difference of the pixel in multiple screenshots is large. For example, the edge of some graphics in the image has a large color difference, and it is difficult for the regular tolerance to be fully compatible with it. Summary of the invention
[0007] Based on the technical problem that the maintenance and modification workload of structured data is large and the maintenance is difficult as mentioned in the background technology, the present invention proposes a method and device for adding tolerance to image assertions in page automation testing.
[0008] The present invention proposes a method for adding tolerance to image assertions in page automation testing, comprising the following steps:
[0009] S1: Use any image editing tool to open the assertion source image, and fill the area to be skipped with a color block of a set color to quickly set the skip area. Multiple skip areas can be set for the same assertion source image;
[0010] S2: First, determine whether p2 is a skip value, compare the current image with the asserted source image row by row and column by column, and perform skip processing by identifying whether the source pixel at the current coordinate belongs to the skip color;
[0011] S3: For non-skipped pixels, first determine whether the current pixel is an absolute tolerance pixel. If it is, use the absolute tolerance for pixel comparison. If not, use the default tolerance for comparison.
[0012] S4: If both the absolute tolerance and the default tolerance fail to match the pixel, determine again whether the current pixel is an edge pixel. If so, use the edge tolerance for comparison again, and use the edge tolerance comparison result as the final result.
[0013] Preferably, in S1, the assertion source image is a source image used in the image assertion comparison between the target image and the source image; in S2, the current image is a real-time screenshot image representing the operation of the software or system, and the screenshot timing or conditions are consistent with those for obtaining the assertion source image, and the current image should be consistent with the assertion source image in key information points; in S3, when the value of any one of the source pixel or the target pixel is one of the absolute color difference values, it is necessary to use the absolute tolerance for pixel comparison;
[0014] Default tolerance: It is the default tolerance used in image pixel comparison. If the comparison result is less than this tolerance, it means that the comparison is passed. If the value is 0, it means that the ARGB value of the current pixel is required to be completely consistent with the ARGB value of the source pixel. In S4, when the target pixel is determined to be an edge pixel, the edge tolerance is used for pixel comparison.
[0015] A method for adding tolerance to image assertions in page automation testing, wherein the method for determining edge pixels comprises the following steps:
[0016] Get the current image pixel ARGB (p1) by coordinates, and assert the source image pixel ARGB (p2);
[0017] When p1 does not belong to any absolute color and there is any absolute color around p1, or p1 belongs to any absolute color and there are more than one non-absolute color pixels around p1, p1 is determined to be an edge pixel;
[0018] To perform edge tolerance comparison, it is also necessary to satisfy that p2 is not a point of the same color. When the ARGB of the pixels around p2 is completely consistent with p2, P2 is a point of the same color. In this case, the edge tolerance comparison will be skipped.
[0019] Preferably, the test system is provided with a control module, an acquisition module, a determination module and a target value module, wherein the determination module includes a classification module, a comparison module and a prompt module.
[0020] Preferably, the control module controls the operation of the acquisition module, the determination module and the target value module respectively;
[0021] Classification module: is used to separate various types of judgments;
[0022] Control module: It is used to control the determination module in the test system to perform classification determination;
[0023] Determination module: It is used to determine whether the tolerance in the test system is matched;
[0024] Target value module: It is used to store target values that can be used as a comparison standard in the judgment process;
[0025] Comparison module: used to compare the classified judgment items with the standard target values stored in the target value module;
[0026] Prompt module: It is used to display the final result after reminder judgment and comparison.
[0027] The beneficial effects of the present invention are:
[0028] The method and device for adding tolerance to image assertions in page automation testing can directly mark areas that need to be skipped in the assertion source image, can conveniently mark multiple complex areas, and are easy to operate. At the same time, the difficulty of assertion maintenance is greatly reduced, and the workload of test case maintenance is reduced.
[0029] The invention discloses a method and device for adding tolerance to image assertion in page automation testing, which can specify an absolute color set, and improve the accuracy of absolute color comparison by identifying absolute colors in an image to cope with different comparison strategies.
[0030] The method and device for adding tolerance to image assertions in page automation testing introduce default tolerance, absolute tolerance, and edge tolerance, and dynamically use different tolerance rules in different areas in image comparison, thereby ensuring high reliability of image comparison while also having very good compatibility.
[0031] The parts not involved in the device are the same as those in the prior art or can be implemented by using the prior art. BRIEF DESCRIPTION OF THE DRAWINGS
[0032] Figure 1 A method and device flow chart for adding tolerance to image assertions in page automation testing proposed by the present invention;
[0033] Figure 2 A flow chart of determining the edge tolerance comparison range in a method and device for adding tolerance to image assertions in page automation testing proposed by the present invention;
[0034] Figure 3The present invention provides a test system structure block diagram of a method and device for adding tolerance to image assertions in page automation testing. DETAILED DESCRIPTION
[0035] The technical solution of the present invention will be clearly and completely described below in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all of the embodiments.
[0036] The components of the embodiments of the present invention generally described and shown in the drawings herein may be arranged and designed in a variety of different configurations. Therefore, the following detailed description of the embodiments of the present invention provided in the drawings is not intended to limit the scope of the claimed invention, but merely represents selected embodiments of the present invention.
[0037] Based on the embodiments in the patent of the present invention, all other embodiments obtained by ordinary technicians in this field without making any creative work shall fall within the scope of protection of the patent of the present invention.
[0038] In the description of the present invention, it should be noted that the terms "center", "upper", "lower", "left", "right", "vertical", "horizontal", "inner", "outer", etc., indicating the orientation or positional relationship, are based on the orientation or positional relationship shown in the drawings, and are only for the convenience of describing the present invention and simplifying the description, rather than indicating or implying that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as a limitation on the present invention. In addition, the terms "first", "second", and "third" are used for descriptive purposes only, and cannot be understood as indicating or implying relative importance.
[0039] In the description of the present invention, it should be noted that, unless otherwise clearly specified and limited, the terms "installation", "connection" and "connection" should be understood in a broad sense, for example, it can be a fixed connection, a detachable connection, or an integral connection; it can be a mechanical connection or an electrical connection; it can be a direct connection, or it can be indirectly connected through an intermediate medium, or it can be the internal connection of two components. For ordinary technicians in this field, the specific meanings of the above terms in the present invention can be understood according to specific circumstances.
[0040] The circuits, electronic components and control modules involved are all prior art and can be fully implemented by those skilled in the art. Needless to say, the content of the patent protection of the present invention does not involve improvements to the software and methods.
[0041] Reference Figure 1-3 , a method for adding tolerance to image assertions in page automation testing, comprising the following steps:
[0042] S1: Use any image editing tool to open the assertion source image, and fill the area to be skipped with a color block of a set color to quickly set the skip area. Multiple skip areas can be set for the same assertion source image;
[0043] S2: First, determine whether p2 is a skip value, compare the current image with the asserted source image row by row and column by column, and perform skip processing by identifying whether the source pixel at the current coordinate belongs to the skip color;
[0044] S3: For non-skipped pixels, first determine whether the current pixel is an absolute tolerance pixel. If it is, use the absolute tolerance for pixel comparison. If not, use the default tolerance for comparison.
[0045] S4: If both the absolute tolerance and the default tolerance fail to match the pixel, determine again whether the current pixel is an edge pixel. If so, use the edge tolerance for comparison again, and use the edge tolerance comparison result as the final result.
[0046] Reference Figure 1-2 In the present invention, in S1, the assertion source image is a source image used in the image assertion comparison between the target image and the source image. In S2, the current image is a real-time screenshot image representing the operation of the software or system. The timing or condition of the screenshot is consistent with that of obtaining the assertion source image. The current image should be consistent with the assertion source image in key information points. In S3, when the value of any one of the source pixel or the target pixel is one of the absolute color difference values, it is necessary to use the absolute tolerance for pixel comparison;
[0047] Default tolerance: It is the default tolerance used in image pixel comparison. If the comparison result is less than this tolerance, it means that the comparison is passed. If the value is 0, it means that the ARGB value of the current pixel is required to be completely consistent with the ARGB value of the source pixel. In S4, when the target pixel is determined to be an edge pixel, the edge tolerance is used for pixel comparison.
[0048] A method for adding tolerance to image assertions in page automation testing, wherein the method for determining edge pixels comprises the following steps:
[0049] Get the current image pixel ARGB (p1) by coordinates, and assert the source image pixel ARGB (p2);
[0050] When p1 does not belong to any absolute color and there is any absolute color around p1, or p1 belongs to any absolute color and there are more than one non-absolute color pixels around p1, p1 is determined to be an edge pixel;
[0051] To perform edge tolerance comparison, it is also necessary to satisfy that p2 is not a point of the same color. When the ARGB of the pixels around p2 is completely consistent with p2, P2 is a point of the same color. In this case, the edge tolerance comparison will be skipped.
[0052] Reference Figure 3 A device for adding tolerance to image assertions in page automation testing is characterized in that it includes a test system, in which a control module, an acquisition module, a determination module and a target value module are arranged, and the determination module includes a classification module, a comparison module and a prompt module.
[0053] Reference Figure 3 ,In the present invention, the control module respectively controls the operation of the acquisition ,module, the determination module and the target value module;
[0054] Classification module: is used to separate various types of judgments;
[0055] Control module: It is used to control the determination module in the test system to perform classification determination;
[0056] Determination module: It is used to determine whether the tolerance in the test system is matched;
[0057] Target value module: It is used to store target values that can be used as a comparison standard in the judgment process;
[0058] Comparison module: used to compare the classified judgment items with the standard target values stored in the target value module;
[0059] Prompt module: It is used to display the final result after reminder judgment and comparison.
[0060] The above description is only a preferred specific implementation manner of the present invention, but the protection scope of the present invention is not limited thereto. Any technician familiar with the technical field can make equivalent replacements or changes according to the technical scheme and inventive concept of the present invention within the technical scope disclosed by the present invention, which should be covered by the protection scope of the present invention.
Claims
1. A method for adding tolerance to image assertions in page automation testing, characterized in that: The following steps are involved: S1: Use an image editing tool to open the assertion source image, and fill the area to be skipped with a color block of a set color to quickly set the skip area. Multiple skip areas can be set for the same assertion source image; S2: During the execution of the image assertion, first determine whether p2 is a skip value, compare the current image with the assertion source image row by row and column by column, and perform skip processing by identifying whether the source pixel at the current coordinate belongs to the skip color; S3: During the execution of image assertion, for non-skipped pixels, it is first determined whether the current pixel belongs to the absolute tolerance pixel. If it is, the absolute tolerance is used for pixel comparison. If not, the default tolerance is used for comparison. S4: During the execution of the image assertion, if the pixel comparison using the absolute tolerance and the comparison using the default tolerance fail, it is determined again whether the current pixel is an edge pixel. If it is, the edge tolerance is used for comparison again, and the edge tolerance comparison result is used as the final result. In S1, the assertion source image is the source image used in the comparison between the target image and the source image of the image assertion. In S2, the current image is an instant screenshot image during the operation of the software or system. The timing or condition of the screenshot is consistent with that of obtaining the assertion source image. The current image should be consistent with the assertion source image in key information points. In S3, when the value of any one of the source pixel or the target pixel is one of the absolute color difference values, it is necessary to use the absolute tolerance for pixel comparison; Default tolerance: is the default tolerance used in image pixel comparison. If the comparison result is less than the tolerance, it means that the comparison is passed. If the value is 0, it means that the ARGB value of the current pixel is required to be completely consistent with the ARGB value of the source pixel. In S4, when the target pixel is determined to be an edge pixel, the edge tolerance is used for pixel comparison. The method for determining edge pixels includes the following steps: Get the current image pixel ARGB(p1) by coordinates, and assert the source image pixel ARGB(p2); When p1 does not belong to any absolute color and there is any absolute color around p1, or p1 belongs to any absolute color and there are more than one non-absolute color pixels around p1, p1 is determined to be an edge pixel; To perform edge tolerance comparison, it is also necessary to satisfy that p2 is not a point of the same color. When the ARGB of the pixels around p2 is completely consistent with p2, P2 is a point of the same color. In this case, the edge tolerance comparison will be skipped.
2. A device for adding tolerance to image assertions in page automation testing, applied to the method for adding tolerance to image assertions in page automation testing as claimed in claim 1, characterized in that: The invention comprises a test system, wherein the test system is provided with a control module, an acquisition module, a determination module and a target value module, wherein the determination module comprises a classification module, a comparison module and a prompt module.
3. The device for adding tolerance to image assertions in page automation testing according to claim 2, characterized in that: The control module controls the operation of the acquisition module, the determination module and the target value module respectively; Classification module: is used to separate various types of judgments; Control module: It is used to control the determination module in the test system to perform classification determination; Determination module: It is used to determine whether the tolerance in the test system is matched; Target value module: It is used to store target values that can be used as a comparison standard in the judgment process; Comparison module: used to compare the classified judgment items with the standard target values stored in the target value module; Prompt module: It is used to display the final result after reminder judgment and comparison.