Method and computing device for automatically passing sliding verification code for automated testing
By cutting and binarizing the sliding verification code picture, the offset of the slider is calculated, and the automatic sliding verification code operation is realized, solving the problem of inefficient verification of traditional sliding verification codes and reducing the cost of automated testing.
Patent Information
- Application Number
- CN202411328920.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-24
- Publication Date
- 2025-03-14
- Estimated Expiration
- 2044-09-24
AI Technical Summary
Traditional sliding verification code verification requires manual operation by users, which is inefficient and is not applicable in automated testing scenarios. The existing cracking method is costly.
By obtaining the verification code picture of the sliding verification code, performing picture cutting and binarization processing, calculating the difference value to determine the offset of the slider, and completing the verification code through calling the verification interface or simulated sliding operations.
Automatic sliding verification code operation is realized, reducing equipment performance requirements, reducing automated testing costs, and improving testing efficiency and accuracy.
Smart Images

Figure CN118860901B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image processing and pattern recognition, and in particular to a method and computing device for automatically passing a sliding verification code for automated testing. Background Art
[0002] In the process of software development and testing, as network security becomes increasingly important, verification codes are widely used as a means of verifying user identities. Among them, sliding verification codes are favored due to their high security and user experience. However, the traditional sliding verification code verification process requires manual operation by users, which is not only inefficient but also not applicable in some automated testing scenarios. Most of the existing sliding verification code cracking methods use machine learning to solve this problem, but the cost of implementing this method is high.
[0003] To this end, a technical solution is needed that can realize automatic sliding verification code operation, is easy to expand and compatible, has low equipment performance requirements, and effectively reduces the cost of automated testing. Summary of the invention
[0004] The present invention aims to provide a method and computing device for automatically passing a sliding verification code for automated testing, which can realize automatic sliding verification code operation, is easy to expand and compatible, has low equipment performance requirements, and effectively reduces the cost of automated testing.
[0005] According to one aspect of the present invention, a method for automatically passing a sliding verification code for automated testing is provided, the method comprising:
[0006] Obtain a verification code image of a sliding verification code, wherein the verification code image includes a slider image and a base image;
[0007] Performing image cropping processing on the verification code image;
[0008] Binarize the processed verification code image to obtain a first two-dimensional array of the slider image and a second two-dimensional array of the base image;
[0009] Calculate the difference value between the first two-dimensional array and the second two-dimensional array according to a preset offset value;
[0010] When the difference value is less than a set threshold, a final offset is obtained, and the final offset is the distance that the slider image of the sliding verification code needs to slide;
[0011] Complete the verification code by calling the verification interface or automatically simulating the sliding operation.
[0012] According to some embodiments, obtaining a verification code image of a sliding verification code includes: calling an interface of the sliding verification code to obtain the verification code image and a parameter encryption token.
[0013] According to some embodiments, performing image cropping processing on the verification code image includes:
[0014] Detecting the position data and height data of the actual slider from the slider image;
[0015] The slider image and the base image are cropped according to the position data and the height data.
[0016] According to some embodiments, binarization is performed on the processed verification code image to obtain a first two-dimensional array of the slider image and a second two-dimensional array of the base image, including:
[0017] Detecting the edge color value of the slider image;
[0018] The slider image and the base image are binarized according to the edge color value.
[0019] According to some embodiments, binarization of the slider image and the base image is performed according to the edge color value, including:
[0020] Create the first two-dimensional array according to the width and height of the slider image;
[0021] Creating the second two-dimensional array according to the width and height of the film image;
[0022] For the pixel points in the first two-dimensional array and the second two-dimensional array, according to the edge color value, all pixel point positions that meet the edge color value are set to the first value, and the remaining positions are set to the second value.
[0023] According to some embodiments, calculating the difference value of the first two-dimensional array and the second two-dimensional array according to a preset offset value includes:
[0024] Overlapping the first two-dimensional array and the second two-dimensional array according to the preset offset value, and performing an OR operation on the overlapped first two-dimensional array to obtain a third two-dimensional array;
[0025] Performing a point-by-point XOR operation on the third two-dimensional array and the second two-dimensional array;
[0026] The number of 1s in the statistical operation results is recorded as the difference value.
[0027] According to some embodiments, obtaining the final offset when the difference value is less than a set threshold includes: calculating the difference value again after increasing the preset offset value each time until the difference value is less than the set threshold.
[0028] According to some embodiments, completing the verification code passing by calling the verification interface includes:
[0029] According to the verification logic of the verification code interface, the final offset is parameterized;
[0030] Encrypting the final offset after the concatenation of the parameters and the parameter encryption token;
[0031] After automatically simulating the sliding operation, the verification interface is called to verify that the verification code has passed.
[0032] According to another aspect of the present invention, a computer program product is provided, comprising a computer program, wherein when the computer program is executed by a processor, the method as described above is implemented.
[0033] According to another aspect of the present invention, there is provided a computing device, comprising:
[0034] Processor; and
[0035] A memory stores a computer program, and when the computer program is executed by the processor, the method described in any one of the above items is implemented.
[0036] According to an embodiment of the present invention, by performing image processing on the slider image and the base image of the sliding verification code image, the processed verification code image is binarized to obtain a two-dimensional array of the slider image and the base image, and the two-dimensional array is calculated according to a preset offset value to obtain a difference value, and when the difference value is less than a set threshold, a final offset is obtained, which is the distance the slider needs to slide. The present invention can realize automatic sliding verification code operation, is easy to expand and compatible, and has low equipment performance requirements, effectively reducing the cost of automated testing.
[0037] According to some embodiments, the automatic sliding verification code can reduce the waiting time of the test, can complete the verification process faster, and make the entire test process smoother. The present invention simplifies the interaction process.
[0038] According to some embodiments, the present invention is scalable and adaptable, and can work on a variety of devices and browsers, including desktop computers, tablet computers, and smart phones.
[0039] According to some embodiments, the automatic sliding verification code can more accurately find the movement trajectory and distance of the slider, reduce the number of repeated attempts due to human errors, thereby improving the accuracy of verification and overall work efficiency in automated testing, and realize the automatic verification function through the interface, which is easy to integrate.
[0040] It is to be understood that the foregoing general description and the following detailed description are exemplary only and are not restrictive of the invention. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings required for describing the embodiments are briefly introduced below.
[0042] Figure 1 A schematic flow chart showing a method for automatically passing a sliding verification code according to an example embodiment.
[0043] Figure 2 A schematic diagram of a picture binarization process according to an example embodiment is shown.
[0044] Figure 3 A schematic diagram of a slider offset movement according to an example embodiment is shown.
[0045] Figure 4 A block diagram of a computing device is shown according to an exemplary embodiment. DETAILED DESCRIPTION
[0046] Example embodiments will now be described more fully with reference to the accompanying drawings. However, example embodiments can be implemented in many forms and should not be construed as limited to the embodiments set forth herein; rather, these embodiments are provided so that the present invention will be comprehensive and complete and fully convey the concepts of the example embodiments to those skilled in the art. The same reference numerals in the figures represent the same or similar parts, and thus their repeated description will be omitted.
[0047] In addition, the described features, structures or characteristics may be combined in one or more embodiments in any suitable manner. In the following description, many specific details are provided to provide a full understanding of the embodiments of the present invention. However, those skilled in the art will appreciate that the technical solution of the present invention can be practiced without one or more of the specific details, or other methods, components, devices, steps, etc. may be adopted. In other cases, known methods, devices, implementations or operations are not shown or described in detail to avoid blurring various aspects of the present invention.
[0048] The block diagrams shown in the accompanying drawings are merely functional entities and do not necessarily correspond to physically independent entities. That is, these functional entities may be implemented in software form, or in one or more hardware modules or integrated circuits, or in different networks and / or processor devices and / or microcontroller devices.
[0049] The flowcharts shown in the accompanying drawings are only exemplary and do not necessarily include all the contents and operations / steps, nor must they be executed in the order described. For example, some operations / steps can be decomposed, and some operations / steps can be combined or partially combined, so the actual execution order may change according to actual conditions.
[0050] It should be understood that although the terms first, second, third, etc. may be used herein to describe various components, these components should not be limited by these terms. These terms are used to distinguish one component from another component. Therefore, the first component discussed below can be referred to as the second component without departing from the teachings of the present inventive concept. As used herein, the term "and / or" includes any one of the associated listed items and all combinations of one or more.
[0051] The user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in the present invention are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.
[0052] Those skilled in the art will appreciate that the drawings are merely schematic diagrams of example embodiments, and the modules or processes in the drawings are not necessarily necessary for implementing the present invention, and therefore cannot be used to limit the protection scope of the present invention.
[0053] In today's digital age, network security issues are becoming increasingly prominent, and various verification methods are emerging to protect users' information security and privacy. Among them, sliding verification, as an emerging identity authentication method, has gradually been favored by many websites and applications for its uniqueness and user experience advantages. Sliding verification is also commonly known as slider verification, which is a user-interactive verification method. It requires users to slide the slider to the correct position in the specified path or direction through a mouse or touch screen to complete the verification process.
[0054] However, the traditional sliding verification code verification process requires manual operation by users, which is not only inefficient and costly to implement, but also not applicable in certain automated testing scenarios.
[0055] To this end, the present invention proposes a method for automatically passing a sliding verification code for automated testing, which can realize automatic sliding verification code operation, is easy to expand and compatible, has low equipment performance requirements, and effectively reduces the cost of automated testing.
[0056] Exemplary embodiments of the present invention are described below with reference to the accompanying drawings.
[0057] Figure 1 A schematic flow chart showing a method for automatically passing a sliding verification code according to an example embodiment.
[0058] See also Figure 1 , at S101, it is detected that a sliding verification code needs to be verified.
[0059] According to some embodiments, this process is entered when it is detected that a sliding verification code verification operation is required.
[0060] According to some embodiments, the workflow of sliding verification code is as follows.
[0061] Display the verification code image. The user interface displays a picture with a missing part, such as an incomplete line or an obscured pattern, and there will be a slider next to the picture. The user needs to drag the slider to the correct position to complete the missing part so that the picture looks complete. This process may also involve some additional actions, such as holding down the slider and dragging it to a specified position, or dragging it along a specific track.
[0062] The verification logic of the sliding verification code is that when the user completes the drag, the system will check whether the slider is placed correctly. If the sliding path is consistent with the expectation, the verification is successful, otherwise the verification fails. The backend server usually records the start and end time of the sliding, the sliding path and other information, and determines whether the verification is passed based on this information. Some additional checks may also be included, such as sliding speed, acceleration, etc., to distinguish between human users and automated behaviors.
[0063] The technology stack for implementing sliding verification codes may include the front-end, back-end, and security enhancements. The front-end includes HTML (Hypertext Markup Language), CSS (Cascading Style Sheets), JavaScript (scripting language), etc., which are used to render verification code images and sliders and handle user interaction events. The Canvas API may also be used to draw and process graphic changes during the sliding process. The back-end languages include Node.js, Python, and Java, which are used to process verification requests sent by the front-end and use the database to store and retrieve the data required for verification.
[0064] In S103, a verification code image is obtained.
[0065] According to some embodiments, a verification code interface is called to obtain a sliding verification code image, including a slider and a base image and a parameter encryption token.
[0066] According to some embodiments, the verification code image includes a slider image and a base image, and data for detecting the actual slider position and height is obtained from the slider image.
[0067] Get the image data of the sliding verification code according to different verification code implementation schemes. For the image data encoded by Base64, you need to convert the Base64 content into image data first. For the verification code image provided by providing the image address, you can directly download the verification code image. Generally, the sliding verification code will provide two images, namely the background image with a gap and the slider foreground image.
[0068] Call the verification code interface to obtain the verification code image and parameter encryption token. Parameter encryption token (Token) is a security mechanism for authentication and authorization. It is often used in Web applications and APIs to verify the identity of users and authorize access to specific resources. Tokens can be in a variety of formats, the most common of which are JSON Web Tokens (JWT) and OAuth tokens.
[0069] JSON Web Tokens is an open standard (RFC 7519) for securely transmitting information between two entities. JWT consists of three parts: the Header contains information about the JWT type and the algorithm used for the signature; the Payload contains a series of claims that are used to transmit information; the Signature is used to verify the integrity of the JWT and confirm its source. Each part of the JWT is separated by a dot (.), and each part needs to be Base64 URL-safe encoded.
[0070] OAuth 2.0 is a standard protocol for authorization that defines access tokens and refresh tokens. An OAuth token is usually an opaque string that clients use to request protected resources. An OAuth token can be a string of any length, depending on the implementation. Typically, an OAuth token is a random string that does not contain any readable information to ensure security.
[0071] The parameter encryption token of the present invention uses an OAuth token. For example, the data format of the parameter encryption token is "98fc6998f5ea4d1a93278b425404154e".
[0072] In S105 , the slider and the base image are cropped according to the actual height of the slider.
[0073] According to some embodiments, the slider image and the base map image are cropped according to the actual height of the slider for subsequent processing.
[0074] According to some embodiments, the position data and height data of the actual slider are detected from the sliding image; the slider image and the base image are cropped according to the position data and height data, and the height of the cropped base image is equal to the slider height.
[0075] The prospect of sliding verification code Figure 1 Generally, only the position where the slider is located has image information, and the rest of the position is transparent. The vertical start and end positions of the slider are determined by midline sampling and then horizontal diffusion scanning. Based on this information, the background map is cropped to remove useless information and improve the efficiency of subsequent processing.
[0076] In S107, the slider edge color is obtained.
[0077] According to some embodiments, the edge color of the slider is identified, which will be used in the subsequent binarization process.
[0078] In S109, the slider and the base image are binarized according to the slider edge color.
[0079] According to some embodiments, the two acquired images are binarized according to the edge features of the slider foreground image to simplify the amount of subsequent data matching calculations. In actual verification, the image binarization is used to calculate the difference value, and the calculation speed of the difference value after binarization is faster than that before binarization.
[0080] According to some embodiments, the edge of the slider image is transparent, and the edge color value of the slider image is detected, that is, the edgemost opaque pixel is obtained. The slider image and the base image are binarized according to the edge color value. The first two-dimensional array is created according to the width and height of the slider image; and the second two-dimensional array is created according to the width and height of the base image.
[0081] The processed verification code image is binarized. First, the edge color value of the slider image is detected. The slider image and the base image are binarized according to the slider edge color. According to the width and height of the slider image and the base image, the first two-dimensional array of the slider image and the second two-dimensional array of the base image are created.
[0082] For the pixel points in the first two-dimensional array and the second two-dimensional array, according to the edge color value, all pixel point positions that meet the edge color value are set to 1, and the remaining positions are set to 0.
[0083] like Figure 2 As shown in the figure, the slider and the base map are binarized according to the slider edge color. The specific rules are as follows: create a two-dimensional array according to the image width and height, traverse all the pixels of the image, compare the RGBA value of the pixel with the RGBA value of the slider edge color, and if the difference between the two calculated values is less than a certain threshold, the corresponding position of the two-dimensional array is set to 1, otherwise it is set to 0. Finally, two two-dimensional arrays Arr1 and Arr2 are obtained, which represent the binary data of the slider and the base map respectively, so as to simplify the image data and facilitate feature extraction.
[0084] At S111 , the offset value starts from zero and becomes the base map width minus the slider width.
[0085] Preset an offset value, the preset offset value is 1. The initial value of the offset value starts from zero, and this value will be used to simulate the movement of the slider.
[0086] According to some embodiments, the offset value starts from zero and is the width of the base image minus the width of the slider. This range defines the position that the slider can move from the leftmost to the rightmost position, ensuring that the slider can completely cover the gap on the base image or complete the splicing. The maximum movable distance of the slider is from the initial position (usually the left) to the right edge of the base image minus the width of the slider itself. During the sliding of the slider, ensure that the slider does not exceed the maximum offset.
[0087] In S113, the offset value is increased by one.
[0088] According to some embodiments, the system begins a loop and increments the offset value by one each time through the loop.
[0089] In S115 , the slider is offset from the left side relative to the base map and overlaps with the base map.
[0090] The first two-dimensional array and the second two-dimensional array are overlapped according to the preset offset value, and an XOR operation is performed to obtain a third two-dimensional array; the third two-dimensional array and the fourth two-dimensional array are XORed with the second two-dimensional array point by point; and the number of operation results that are 1 is counted and recorded as the difference value.
[0091] like Figure 3 As shown, Arr1 is offset from the left relative to Arr2 to simulate the movement of the slider. The operation logic is: the two two-dimensional arrays Arr1 and Arr2 are ORed according to the overlapping part of the offset value to obtain a new two-dimensional array Arr3. For example, when the offset value is k, Arr3[m][n]= OR(Arr1[m][n+k], Arr2[m][n]).
[0092] In S117, the overlapped image is compared with the original base image.
[0093] The overlapping image is compared with the non-overlapping binary base map. The comparison logic is: perform point-by-point XOR operation on the array Arr3 and the base map Arr2, and count the number of 1s as the difference value. The calculation formula is:
[0094]
[0095] In S119, it is determined that the difference value is less than a set threshold.
[0096] Each time the preset offset value is increased, the difference value is calculated again until the difference value is less than a set threshold.
[0097] The threshold is set based on experience. When there is a complete match, the difference value will be extremely small (usually 0). When there is a mismatch, the difference value is generally about 200 pixels on the edge of the slider. Therefore, the threshold can be configured to 20-100 to adapt to some calculation deviations.
[0098] When the difference value is greater than or equal to the set threshold, the process returns to step S113 to recalculate; when the difference value is less than the set threshold, the process stops calculating to obtain the final offset.
[0099] In S121, the current offset value is the moving position required for the sliding verification code.
[0100] If the difference between the calculated image and the original background image is less than a certain threshold, the current offset value is the required moving position of the sliding verification code, that is, the final offset. The final offset refers to the distance the slider needs to slide.
[0101] At S123, the interface parameter data is processed.
[0102] The system processes the parameter data for calling the verification interface, encrypts the verification request parameters according to the final moving position and the parameter encryption token obtained in S103. The parameter data includes offset data and encrypted data.
[0103] At S125, a verification interface is called for verification.
[0104] After calculating the final difference value, the extracted features are matched with the known sliding verification code pattern to determine the sliding path.
[0105] After determining the sliding distance and sliding path, automatic sliding is performed. According to the matching results, the user's sliding operation is automatically simulated to complete the passing of the verification code.
[0106] If the verification is successful, success is returned; if the verification fails, the process returns to step S103 and starts the process again.
[0107] In S127, success is returned.
[0108] According to some embodiments, a verification interface is called to verify the result, the verification interface is called using the processed parameters, and the verification result is checked.
[0109] According to the verification logic of the verification code interface, the final offset is parameter-joined, and the final offset after parameter-joining and the parameter encryption token are encrypted.
[0110] The parameter in parameter concatenation refers to the concatenation offset. The concatenation method is JSONObject.of("x",offset, "y", 5).toString(), which consists of a string containing xy, where y is a fixed value.
[0111] The encryption method of the present invention uses AES encryption.
[0112] private String f(String content, string key){ 2 usages
[0113] key=Stringutils,isNotBlank(key)?key:"XwKsGIMCdPMEhR1B";
[0114] if(!Application.IS_DEV){
[0115] return jsutils.execute(Jsltils.Jsfile.cRp0 Js,newJsUtils.CryptoJsParans
[0116] (JsUtils.CryptoJsParams.Func.F, JSONObj}
[0117] else {var aes= new SymmetricCrypto(SymetricAlgorithm,AES,
[0118] key.getBytes(StandardCharsets.UTF_8));
[0119] return aes.encryptBase64(content.getBytes(Standardcharsets.UTf_8));
[0120] }
[0121] }
[0122] The final offset and parameter encryption token are encrypted because the business interface needs to be encrypted, and the business encryption logic needs to be implemented through the hook interface.
[0123] According to the embodiment of the present invention, the present invention does not use an image recognition library based on OpenCV, but only involves binarization after rasterization of the image. The calculation cost is significantly lower than that of image recognition, and the recognition speed is fast.
[0124] According to some embodiments, when the present invention is applied to automated testing, verification code verification cannot be turned off in some scenarios, and verification steps can be automatically skipped without manual intervention. The time consumption for calculating the difference value from obtaining the verification code to completing the entire process is only 40ms, while manual verification takes at least 1 second, which greatly saves verification time.
[0125] According to some embodiments, there are two ways to slide the slider in actual use. One is to directly call the interface, which is suitable for pure interface automation testing. The other is to directly move the slider and button by operating the DOM and then trigger the DOM event to simulate human operation, which is suitable for page automation testing.
[0126] Figure 4 A block diagram of a computing device is shown according to an exemplary embodiment.
[0127] like Figure 4 As shown, computing device 30 includes processor 12 and memory 14. Computing device 30 may also include bus 22, network interface 16, and I / O interface 18. Processor 12, memory 14, network interface 16, and I / O interface 18 may communicate with each other via bus 22.
[0128] The processor 12 may include one or more general-purpose CPUs (Central Processing Units, processors), microprocessors, or application-specific integrated circuits, etc., for executing relevant program instructions. According to some embodiments, the computing device 30 may also include a high-performance graphics card (GPU) 20 for accelerating the processor 12.
[0129] The memory 14 may include a machine system readable medium in the form of a volatile memory, such as a random access memory (RAM), a read-only memory (ROM) and / or a cache memory. The memory 14 is used to store one or more programs including instructions and data. The processor 12 may read the instructions stored in the memory 14 to execute the above-mentioned method according to the embodiment of the present invention.
[0130] The computing device 30 may also communicate with one or more networks via the network interface 16. The network interface 16 may be a wireless network interface.
[0131] The bus 22 may include an address bus, a data bus, a control bus, etc. The bus 22 provides a path for exchanging information between components.
[0132] It should be noted that, in the specific implementation process, the computing device 30 may also include other components necessary for normal operation. In addition, those skilled in the art may understand that the above device may only include components necessary for implementing the embodiments of this specification, and need not include all components shown in the figure.
[0133] The present invention also provides a computer-readable storage medium having a computer program stored thereon, which implements the steps of the above method when the program is executed by a processor. The computer-readable storage medium may include, but is not limited to, any type of disk, including a floppy disk, an optical disk, a DVD, a CD-ROM, a micro drive, and a magneto-optical disk, a ROM, a RAM, an EPROM, an EEPROM, a DRAM, a VRAM, a flash memory device, a magnetic card or an optical card, a nanosystem (including a molecular memory IC), a network storage device, a cloud storage device, or any type of medium or device suitable for storing instructions and / or data.
[0134] An embodiment of the present invention further provides a computer program product, which includes a computer program. The computer program is operable to enable a computer to execute part or all of the steps of any one of the methods described in the above method embodiments.
[0135] Those skilled in the art can clearly understand that the technical solution of the present invention can be implemented with the help of software and / or hardware. "Unit" and "module" in this specification refer to software and / or hardware that can independently complete or cooperate with other components to complete specific functions, where the hardware can be, for example, a field programmable gate array, an integrated circuit, etc.
[0136] It should be noted that, for the above-mentioned method embodiments, for the sake of simplicity, they are all described as a series of action combinations, but those skilled in the art should know that the present invention is not limited by the described action sequence, because according to the present invention, certain steps can be performed in other sequences or simultaneously. Secondly, those skilled in the art should also know that the embodiments described in the specification are all preferred embodiments, and the actions and modules involved are not necessarily required by the present invention.
[0137] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0138] In the several embodiments provided by the present invention, it should be understood that the disclosed devices can be implemented in other ways. For example, the device embodiments described above are only schematic, such as the division of units, which is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some service interfaces, and the indirect coupling or communication connection of devices or units can be electrical or other forms.
[0139] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0140] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of software functional units.
[0141] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable memory. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, which is stored in a memory and includes several instructions for a computer device (which can be a personal computer, server or network device, etc.) to perform all or part of the steps of the methods of various embodiments of the present invention.
[0142] In the above embodiments, the description of each embodiment has its own emphasis. For parts that are not described in detail in a certain embodiment, reference can be made to the relevant descriptions of other embodiments.
[0143] The exemplary embodiments of the present invention are specifically shown and described above. It should be understood that the present invention is not limited to the detailed structures, configurations or implementations described herein; on the contrary, the present invention is intended to cover various modifications and equivalent configurations included in the spirit and scope of the appended clauses.
Claims
1. A method for automatically passing a sliding verification code for automated testing, characterized in that: include: Obtain a verification code image of a sliding verification code, wherein the verification code image includes a slider image and a base image; Performing image cropping processing on the verification code image; Binarize the processed verification code image to obtain a first two-dimensional array of the slider image and a second two-dimensional array of the base image; Calculate the difference value between the first two-dimensional array and the second two-dimensional array according to a preset offset value; When the difference value is less than a set threshold, a final offset is obtained, and the final offset is the distance that the slider image of the sliding verification code needs to slide; Complete the verification code by calling the verification interface or automatically simulating the sliding operation; The process of binarizing the processed verification code image to obtain a first two-dimensional array of the slider image and a second two-dimensional array of the base image includes: Detecting the edge color value of the slider image; Create the first two-dimensional array according to the width and height of the slider image; Create the second two-dimensional array according to the width and height of the base map image; For pixel points in the first two-dimensional array and the second two-dimensional array, according to the edge color value, all pixel point positions that meet the edge color value are set to the first value, and the remaining positions are set to the second value; The first two-dimensional array and the second two-dimensional array are calculated to obtain a difference value according to a preset offset value, including: Overlapping the first two-dimensional array and the second two-dimensional array according to the preset offset value, and performing an OR operation on the overlapped first two-dimensional array to obtain a third two-dimensional array; Performing a point-by-point XOR operation on the third two-dimensional array and the second two-dimensional array; The number of 1s in the statistical operation results is recorded as the difference value.
2. The method according to claim 1, characterized in that Obtaining a verification code image of a sliding verification code includes: calling an interface of the sliding verification code to obtain the verification code image and a parameter encryption token.
3. The method according to claim 1, characterized in that The verification code image is cropped, including: Detecting the position data and height data of the actual slider from the slider image; The slider image and the base image are cropped according to the position data and the height data.
4. The method according to claim 1, characterized in that: When the difference value is less than a set threshold, a final offset is obtained, including: after the preset offset value is increased each time, the difference value is calculated again until the difference value is less than the set threshold.
5. The method according to claim 2, characterized in that: The verification code is passed by calling the verification interface, including: According to the verification logic of the verification code interface, the final offset is parameterized; Encrypting the final offset after the concatenation of the parameters and the parameter encryption token; After automatically simulating the sliding operation, the verification interface is called to verify that the verification code has passed.
6. A computer program product, characterized in that The method comprises a computer program, which implements the method according to any one of claims 1 to 5 when being executed by a processor.
7. A computing device, characterized in that include: processor; as well as A memory storing a computer program, wherein when the computer program is executed by the processor, the method according to any one of claims 1 to 5 is implemented.
Citation Information
Patent Citations
Slider verification method and device based on dynamic path
CN111338938A
Automatic processing method, device and equipment for slide block verification and medium
CN112381105A