CN114610611A - Page automatic test processing method and device, computer equipment and storage medium - Google Patents

Page automatic test processing method and device, computer equipment and storage medium Download PDF

Info

Publication number
CN114610611A
CN114610611A CN202210224743.1A CN202210224743A CN114610611A CN 114610611 A CN114610611 A CN 114610611A CN 202210224743 A CN202210224743 A CN 202210224743A CN 114610611 A CN114610611 A CN 114610611A
Authority
CN
China
Prior art keywords
verification code
page
homologous
type
automation test
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
CN202210224743.1A
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.)
Kingdee Medical Software Technology Co ltd
Original Assignee
Kingdee Medical Software Technology 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 Kingdee Medical Software Technology Co ltd filed Critical Kingdee Medical Software Technology Co ltd
Priority to CN202210224743.1A priority Critical patent/CN114610611A/en
Publication of CN114610611A publication Critical patent/CN114610611A/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

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The application relates to a page automatic test processing method, a page automatic test processing device, computer equipment and a storage medium. The method comprises the following steps: determining verification code elements in a target page based on the page automation test script; identifying the type of the verification code corresponding to the verification code element; if the verification code type is a non-homologous verification code, calling a verification code address corresponding to the verification code element to download a verification code image; the non-homologous verification code is used for representing that the verification code address uniquely corresponds to a verification code image; identifying the verification code image to obtain verification code content; and taking the verification code content as an entry parameter, and carrying out corresponding page automation test based on the page automation test script. The method can ensure the accuracy of the automatic page test.

Description

Page automatic test processing method and device, computer equipment and storage medium
Technical Field
The present application relates to the field of computer technologies, and in particular, to a method and an apparatus for processing a page automation test, a computer device, and a storage medium.
Background
With the development of computer technology, more and more websites distinguish robots from users by adopting a verification code method in pages. While the presence of captchas prevents automatic registration, logging, and water-pouring of malicious robots, it also poses challenges to implementing page automation testing of websites.
In the traditional method, the automatic testing of the web page is realized by a way that a developer of the web site removes a verification code in the web page or adds a universal verification code. However, this method needs to modify the code logic structure of the page program itself, which may cause the tested page program to be inconsistent with the actual online page program, and may not ensure the accuracy of the page automation test.
Disclosure of Invention
In view of the above, it is necessary to provide a method, an apparatus, a computer device, a computer readable storage medium, and a computer program product for page automation test processing, which can ensure accuracy.
In a first aspect, the present application provides a method for automated testing and processing of a page. The method comprises the following steps:
determining verification code elements in a target page based on the page automation test script;
identifying the type of the verification code corresponding to the verification code element;
if the verification code type is a non-homologous verification code, calling a verification code address corresponding to the verification code element to download a verification code image; the non-homologous verification code is used for representing that the verification code address uniquely corresponds to a verification code image;
identifying the verification code image to obtain verification code content;
and taking the verification code content as an input parameter, and carrying out corresponding page automatic test based on the page automatic test script.
In one embodiment, the method further comprises:
if the verification code type is the homologous verification code, cutting an area where the verification code element is located in the target page to obtain a verification code screenshot;
and identifying the verification code screenshot to obtain verification code content.
In one embodiment, the method further comprises:
performing full screen capture on the target page to obtain a page picture;
if the verification code type is the homologous verification code, cutting the area of the verification code element in the target page to obtain a verification code screenshot, wherein the step of cutting the area of the verification code element in the target page comprises the following steps:
if the verification code type is the homologous verification code, calling an image processing library to cut an area where the verification code element is located in the target page to obtain a verification code screenshot;
the identifying the verification code screenshot to obtain verification code content comprises:
and calling an image verification code identification library to identify the verification code screenshot to obtain verification code content.
In one embodiment, if the type of the verification code is a homologous verification code, clipping an area in which the verification code element is located in the target page to obtain a verification code screenshot includes:
performing full screen capture on the target page to obtain a page picture;
if the verification code type is a homologous verification code, extracting page position attribute information of the verification code element from attribute information of the verification code element;
determining a page picture area where the identifying code element is located based on the page position attribute information;
and cutting the page picture area from the page picture to obtain the verification code screenshot.
In one embodiment, the method further comprises:
determining an operating system for executing the page automation test script to obtain an interface scaling coefficient of the operating system;
the determining, based on the page position attribute information, a page picture region in which the captcha element is located includes:
and determining a page picture area where the verification code element is located according to the interface scaling factor and the page position attribute information.
In one embodiment, the page automation test script runs in a browser; the method further comprises the following steps:
acquiring browser type parameters from a page automation test script;
if the browser type parameter represents that an interface browser exists, controlling the browser to operate the page automation test script with the interface;
and if the browser type parameters represent the headless browser, controlling the browser to operate the page automation test script without an interface.
In one embodiment, the identifying the type of the corresponding authenticator of the authenticator element includes:
extracting a verification code address from the attribute information of the verification code element;
calling the verification code address repeatedly for multiple times to download the verification code image to obtain multiple verification code images;
if the plurality of verification code images are consistent, the verification code type corresponding to the characterization verification code element is a non-homologous verification code;
and if the plurality of verification code images are not consistent, representing that the verification code type corresponding to the verification code element is the homologous verification code.
In one embodiment, the taking the verification code content as an entry reference and performing the corresponding page automation test based on the page automation test script includes:
inputting the verification code content into the target page as an input parameter based on a page automation test script;
after the information that the content of the characterization verification code is wrong is obtained, a retry mechanism is triggered to execute the step of calling the verification code address corresponding to the verification code element to download the verification code image again if the verification code type is the non-homologous verification code, and retry is stopped until the information that the content of the characterization verification code is correct is obtained or the retry stop condition is met.
In a second aspect, the application further provides a page automation test processing device. The device comprises:
the determining module is used for determining verification code elements in the target page based on the page automation test script;
the identification module is used for identifying the corresponding verification code type of the verification code element; if the verification code type is a non-homologous verification code, calling a verification code address corresponding to the verification code element to download a verification code image; the non-homologous verification code is used for representing that the verification code address uniquely corresponds to a verification code image; identifying the verification code image to obtain verification code content;
and the test module is used for taking the verification code content as an input parameter and carrying out corresponding page automatic test based on the page automatic test script.
In a third aspect, the present application also provides a computer device. The computer device comprises a memory and a processor, wherein the memory stores a computer program, and the processor realizes the steps of the method of the embodiments of the application when executing the computer program.
In a fourth aspect, the present application further provides a computer-readable storage medium. The computer readable storage medium has stored thereon a computer program which, when executed by a processor, performs the steps of the method according to embodiments of the present application.
In a fifth aspect, the present application further provides a computer program product. The computer program product comprises a computer program which, when executed by a processor, performs the steps of the method according to embodiments of the present application.
According to the page automatic test processing method, the page automatic test processing device, the computer equipment, the storage medium and the computer program product, verification code elements in a target page are determined based on the page automatic test script; identifying the type of the identifying code corresponding to the identifying code element; if the verification code type is the non-homologous verification code, calling a verification code address corresponding to the verification code element to download the verification code image; the non-homologous verification code is used for representing that the verification code address uniquely corresponds to a verification code image; identifying the verification code image to obtain verification code content; and taking the verification code content as an entry parameter, and carrying out corresponding page automation test based on the page automation test script. The page automatic test is carried out by using the automatically identified verification code content, the code logic structure of the page program is not required to be modified, the problem that the tested page program is inconsistent with the online page program can be avoided, and the accuracy of the page automatic test is ensured. In addition, the definition of the verification code image of the downloaded non-homologous verification code is high, and the accuracy of the identified verification code content can be ensured.
Drawings
FIG. 1 is a diagram of an application environment of a method for automated testing of pages in an embodiment;
FIG. 2 is a flowchart illustrating a method for automated testing of pages in one embodiment;
FIG. 3 is a diagram of a destination page in one embodiment;
FIG. 4 is a flowchart illustrating an exemplary process for automated testing of pages in accordance with an alternative embodiment;
FIG. 5 is a block diagram showing the structure of a page automatic test processing apparatus according to an embodiment;
FIG. 6 is a diagram illustrating an internal structure of a computer device according to an embodiment;
fig. 7 is an internal structural diagram of a computer device in another embodiment.
Detailed Description
In order to make the objects, technical solutions and advantages of the present application more apparent, the present application is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the present application and are not intended to limit the present application.
The page automatic test processing method provided by the embodiment of the application can be applied to the application environment shown in fig. 1. Wherein the terminal 102 communicates with the server 104 via a network. The data storage system may store data that the server 104 needs to process. The data storage system may be integrated on the server 104, or may be located on the cloud or other network server. The terminal 102 may trigger the server 104 to execute the page automation test script. The server 104 may determine, based on the page automation test script, a captcha element in the target page and identify a captcha type corresponding to the captcha element. If the verification code type is a non-homologous verification code, the server 104 may call the verification code address corresponding to the verification code element to download the verification code image. The server 104 may identify the verification code image to obtain the verification code content. The server 104 may take the content of the verification code as an entry reference and perform a corresponding page automation test based on the page automation test script. The page automation test script may also be executed locally by the terminal 102. The terminal 102 may be, but not limited to, various personal computers, notebook computers, smart phones, tablet computers, internet of things devices and portable wearable devices, and the internet of things devices may be smart speakers, smart televisions, smart air conditioners, smart car-mounted devices, and the like. The portable wearable device can be a smart watch, a smart bracelet, a head-mounted device, and the like. The server 104 may be implemented as a stand-alone server or as a server cluster comprised of multiple servers.
In an embodiment, as shown in fig. 2, a method for processing a page automation test is provided, which is described by taking the method as an example applied to the terminal in fig. 1, and includes the following steps:
step 202, determining verification code elements in a target page based on a page automation test script; identifying the corresponding type of the verification code element.
The page automation test script is a program script for automatically testing the page. The captcha element is an element in the target page. The automatic page test is an automatic test means for realizing automatic operation and verification in a code mode by simulating a manual operation user interface.
Specifically, the page automation test script has a locator of a predefined verification code element and a target website of the target page. The terminal can call the target website to access the target page and position the verification code elements in the target page according to the locators of the verification code elements. The terminal may identify the type of the authentication code corresponding to the authentication code element. It is to be appreciated that the captcha type corresponding to the captcha element can be predefined in the page automation test script.
In one embodiment, the page automation test script is written using a browser automation test framework (Selenium). The Selenium test runs directly in the browser, supporting multiple types of browsers just as a real user is operating.
In one embodiment, the terminal may identify the type of the authenticator corresponding to the authenticator element by calling the authenticator address corresponding to the authenticator element.
In one embodiment, a page automation test script has predefined automation operation elements and locators for performing the automation operation elements. It is to be understood that an automation element is a page element that is automatically operated when the terminal executes a page automation script. The element locator is used to locate a page element in the page.
In one embodiment, the target page may be a landing page, such as the target page shown in FIG. 3. The automation elements may include a username element, a password element, an authentication code element, a login button element, and the like. The page automation test script comprises a locator of a user name element, a password element, an authentication code element, a login button element and the like.
In one embodiment, the target page may be a page under test. The tested page is a page subjected to page automatic testing through the page automatic testing script.
In one embodiment, the target page may be a landing page of the page under test. It can be understood that after the verification by the target page verification code, the terminal can access the tested page to perform the page automation test.
In step 204, if the verification code type is the non-homologous verification code, the verification code address corresponding to the verification code element is called to download the verification code image.
The non-homologous verification code is used for representing that the verification code address uniquely corresponds to one verification code image. It will be appreciated that the authentication code is a series of randomly generated numbers or symbols that produce a picture that is superimposed with some interference to distinguish whether the user is a computer or a human. The captcha image is the source image corresponding to the captcha elements in the target page. It can be understood that the target page displays an image obtained by adjusting the verification code image according to the running environment of the target page and the page attribute information of the verification code element.
Specifically, if the type of the verification code identified by the terminal is the non-homologous verification code, the verification code address corresponding to the verification code element is called to download the verification code image. It can be understood that the attribute information of the captcha element includes a captcha address, and the terminal may extract the captcha address from the attribute information of the captcha element.
In one embodiment, the terminal may invoke a request library to initiate a request to download the authentication code image to the authentication code address. It will be appreciated that the terminal may invoke the acquisition of the captcha image resource from the captcha address. Wherein the request repository is an open source repository for sending requests. The request repository may be a request repository in the boa programming language (Requests). Requests is used for network request processing and uniform resource locator address resource acquisition.
Step 206, identifying the verification code image to obtain verification code content; and taking the verification code content as an entry parameter, and carrying out corresponding page automation test based on the page automation test script. In one embodiment, the terminal may identify the authentication code image using an image recognition technique. For example, the terminal may perform optical character recognition on the authentication code image. The optical character recognition is a process of determining a shape by detecting dark and bright modes and then translating the shape into computer characters by a character recognition method, and the optical character recognition is to recognize characters on a picture and then extract the characters.
Specifically, the terminal may identify the verification code image by using an optical character recognition technology, so as to obtain the verification code content included in the verification code image. The terminal can take the verification code content as a parameter of the page automation test script and execute the page automation test script to carry out corresponding page automation test. It is understood that the contents of the authentication code are authentication code information recognized by the terminal.
According to the page automatic test processing method, verification code elements in a target page are determined based on a page automatic test script; identifying the type of the identifying code corresponding to the identifying code element; if the verification code type is the non-homologous verification code, calling a verification code address corresponding to the verification code element to download the verification code image; the non-homologous verification code is used for representing that the verification code address only corresponds to a verification code image; identifying the verification code image to obtain verification code content; and taking the verification code content as an entry parameter, and carrying out corresponding page automation test based on the page automation test script. The page automatic test is carried out by using the automatically identified verification code content, the code logic structure of the page program is not required to be modified, the problem that the tested page program is inconsistent with the online page program can be avoided, and the accuracy of the page automatic test is ensured. In addition, the verification code image definition of the downloaded non-homologous verification code is high, and the accuracy of the identified verification code content can be ensured.
In one embodiment, the method further comprises: if the verification code type is the homologous verification code, cutting an area where verification code elements are located in a target page to obtain a verification code screenshot; and carrying out optical character recognition on the verification code screenshot to obtain the verification code content.
The homologous verification code is used for representing that the verification code address corresponds to a plurality of verification code images. It will be appreciated that for a homologous captcha type, multiple calls to the same captcha address result in different captcha images.
Specifically, if the type of the identifying code identified by the terminal is the homologous identifying code, the terminal may determine, based on the attribute information of the identifying code element, an area where the identifying code element is located in the target page, and cut the area to obtain the identifying code screenshot. The terminal can carry out optical character recognition on the verification code screenshot to obtain the verification code content.
In this embodiment, the terminal may obtain the verification code screenshot aiming at the verification code element of which the verification code type is the homologous verification code, and identify the verification code screenshot, so that the problem that the downloaded verification code image is inconsistent with the verification code image in the target page can be avoided, and the accuracy of verification code identification is ensured.
In one embodiment, if the type of the verification code is the homologous verification code, clipping an area where the verification code element is located in the target page, and obtaining the verification code screenshot includes: if the verification code type is the homologous verification code, calling an image processing library to cut an area where verification code elements are located in a target page to obtain a verification code screenshot; carrying out optical character recognition on the verification code screenshot to obtain verification code content, wherein the verification code content comprises the following steps: and calling an image verification code recognition library to perform optical character recognition on the verification code screenshot to obtain verification code content.
The image processing library is an open source library for performing image processing. The image verification code identification library is an open source library for identifying the image verification code by using an optical character recognition technology.
Specifically, if the type of the verification code is the homologous verification code, extracting the position information of the verification code element from the attribute information of the verification code element, determining the area of the verification code element in the target page according to the position information, and calling an image processing library to cut the area to obtain the verification code screenshot. The terminal can transmit the verification code screenshot into an image verification code recognition library for optical character recognition to obtain verification code content. If the verification code type is the non-homologous verification code, the verification code address corresponding to the verification code element is called to download the verification code image, and the verification code image is transmitted into an image verification code identification library to carry out optical character identification, so that the verification code content is obtained.
In one embodiment, the Image processing Library may be a Python Image Library (PIL) of Python programming language (Python). The image verification code recognition library may be a Python program language (Python) image verification code recognition library (dddocr). Ddddocr can recognize the image to obtain a character string with operators in the character string.
In this embodiment, if the type of the verification code is the homologous verification code, the verification code screenshot is obtained by cutting through the image processing library and the verification code content in the verification code screenshot is identified through the image verification code identification library, so that the verification code identification using the open source library is simpler and more convenient.
In one embodiment, if the type of the verification code is the homologous verification code, clipping an area where the verification code element is located in the target page, and obtaining the verification code screenshot includes: performing full screen capture on a target page to obtain a page picture; if the verification code type is the homologous verification code, extracting page position attribute information of the verification code element from the attribute information of the verification code element; determining a page picture area where the identifying code element is located based on the page position attribute information; and cutting a page picture area from the page picture to obtain the verification code screenshot.
The page position attribute information refers to information used for representing positions in the attribute information of the verification code elements. The captcha screenshot is an image cut out of a page picture.
In one embodiment, the page location attribute information may include location coordinates and element size of the captcha element. It will be appreciated that the element size of a captcha element may include the height and width of the captcha element.
Specifically, the terminal may perform a full screen capture on the target page to obtain a page picture. It will be appreciated that the page picture is a screenshot that includes the area in which the captcha element is located. If the verification code type is the homologous verification code, the terminal can extract the position coordinates and the element size of the verification code element from the attribute information of the verification code element. The terminal can determine the page picture area where the verification code element is located based on the position coordinates and the element size, and call the image processing library to cut the page picture area from the page picture to obtain the verification code screenshot.
In one embodiment, the terminal may save the page picture to a specified directory and obtain the picture and window size information of the page picture. It can be understood that the subsequent terminal can obtain the page picture from the specified directory, and determine the position and size of the page picture region where the identifying code element is located according to the picture and window size information of the page picture, and the position coordinates and element size of the identifying code element.
In the embodiment, a full screen capture is performed on a target page to obtain a page picture; if the verification code type is the homologous verification code, extracting page position attribute information of the verification code element from the attribute information of the verification code element so as to cut a page picture area from a page picture to obtain a verification code screenshot, and intercepting the verification code screenshot from the page picture, so that the problem that the screenshot is inaccurate in a target page due to overlarge pages or different size resolutions can be solved.
In one embodiment, the method further comprises: determining an operating system for executing the page automation test script to obtain an interface scaling coefficient of the operating system; determining the page picture region where the identifying code element is located based on the page position attribute information includes: and determining the page picture area where the verification code element is located according to the interface scaling coefficient and the page position attribute information.
Wherein the interface scaling factor is used to indicate the scaling of the page.
Specifically, the terminal may determine an operating system executing the page automation test script to obtain an interface scaling factor of the operating system. The terminal can respectively multiply the position coordinates and the element size extracted from the attribute information of the verification code elements by the interface scaling factor to obtain the position coordinates and the element size of the verification code elements in the page picture so as to determine the page picture area where the verification code elements are located. For example, the interface scaling factor for the first operating system may be set to 1.25 and the interface scaling factor for the second operating system may be set to 2. The first operating system may be a microsoft operating system (Windows) and the second operating system may be an apple operating system (Mac).
In the embodiment, the page picture area where the verification code is located is determined according to the interface scaling coefficients of different operating systems, so that the method can be suitable for different operating systems, the differences of the different operating systems in resolution and page layout are eliminated, and an accurate verification code screenshot is obtained.
In one embodiment, a page automation test script runs in a browser; the method further comprises the following steps: acquiring browser type parameters from a page automation test script; if the browser type parameter represents that an interface browser exists, controlling the browser to run a page automation test script with the interface; and if the browser type parameters represent the headless browser, controlling the browser to run the page automatic test script without an interface.
The headless browser is a browser without an interface, and the headless browser can control the browser to not display the interface when running through programming, and can also automatically execute various tasks, such as testing, screen capturing for a webpage, and the like. An interface-bound browser is a browser with an interface. The browser type parameter is used to indicate the browser type.
Specifically, the terminal can obtain browser type parameters from the page automatic test script, if the browser type parameters represent that an interface browser exists, the terminal can initialize the interface browser and control the interface browser to run the page automatic test script with the interface; if the browser type parameter represents a headless browser, the terminal can control the browser to run the page automatic test script without an interface. It can be understood that a tester can add browser type parameters through a terminal to adapt to various types of browsers.
In one embodiment, a tester may use a terminal to import a Selenium required dependency library, define automation test classes, and instantiate a browser object to write a page automation test script. It is to be appreciated that a tester can customize the incoming browser type parameters when instantiating a browser object.
In the embodiment, if the browser type parameter represents that an interface browser exists, the browser is controlled to operate an automatic page test script with the interface; if the browser type parameters represent the headless browser, the browser is controlled to operate the page automatic test script without interfaces, and the requirements of different page automatic test scenes can be met.
In one embodiment, identifying the type of captcha to which the captcha element corresponds includes: extracting a verification code address from attribute information of the verification code element; repeatedly calling the verification code address for multiple times to download the verification code image to obtain multiple verification code images; if the plurality of verification code images are consistent, the verification code type corresponding to the characterization verification code element is a non-homologous verification code; if the multiple verification code images are not consistent, the verification code type corresponding to the characterization verification code element is the homologous verification code.
Specifically, the terminal may extract the verification code address from the attribute information of the verification code element, and repeatedly call the verification code address for multiple times to download the verification code image, so as to obtain multiple verification code images. The terminal can call the image identifying code identifying library to carry out optical character identification on the plurality of identifying code images to obtain the identifying code contents of the plurality of identifying code images. If the verification code contents of the verification code images are consistent, the verification code type corresponding to the characterization verification code element is a non-homologous verification code; and if the verification code contents of the verification code images are not consistent, the verification code type corresponding to the characterization verification code element is the homologous verification code.
In one embodiment, the terminal may perform similarity comparison on the plurality of verification code images to determine whether the plurality of verification code images are consistent.
In one embodiment, if the verification code type is a non-homologous verification code, the verification code address corresponding to the verification code element is updated in the process of repeatedly calling the verification code address to download the verification code image; if the verification code type is the non-homologous verification code, calling the verification code address corresponding to the verification code element to download the verification code image comprises: and if the verification code type is the non-homologous verification code, downloading the corresponding verification code image according to the updated verification code address corresponding to the verification code element. It can be understood that, in the process of automatically identifying the type of the verification code by the terminal, the verification code of the target page is refreshed, so that an updated verification code address corresponding to the verification code element needs to be acquired.
In the embodiment, the verification code type corresponding to the verification code element is judged by downloading a plurality of verification code images by calling the verification code address for a plurality of times, the verification code types of corresponding pages do not need to be manually defined by testers for the verification codes in different pages, the verification code types can be automatically identified, and the method is more convenient.
In one embodiment, taking the verification code content as an entry reference, and performing the corresponding page automation test based on the page automation test script comprises: inputting the verification code content into a target page as an input parameter based on the page automation test script; after the information that the content of the characterization verification code is wrong is obtained and returned by the target page, triggering a retry mechanism to execute the step of calling the verification code address corresponding to the verification code element to download the verification code image again if the verification code type is the non-homologous verification code, and stopping retry until the information that the content of the characterization verification code is correct is obtained and the retry stop condition is met.
Specifically, the terminal may use the content of the verification code as a parameter of the page automation test script, and input the content of the verification code into the target page by executing the page automation test script. The terminal can trigger a retry mechanism after acquiring the information that the content of the characterization verification code is wrong and returned by the target page, so as to execute the step of calling the verification code address corresponding to the verification code element to download the verification code image if the verification code type is the non-homologous verification code again, and stop retry until the information that the content of the characterization verification code is correct and returned by the target page is acquired or the retry stop condition is met. It can be understood that when the retry mechanism is triggered, the verification code in the target page is refreshed, and the terminal can re-acquire the verification code screenshot or download the verification code image to identify the verification code content. If the information that the representation verification code information is correct and the retry stop condition is met is not obtained, the terminal can return the information that the representation verification code identification fails.
In one embodiment, the terminal may invoke a retry library to implement a retry mechanism. Wherein the retry library is an open source library for implementing the retry function. Such as the universal retry library (Tenacity) of the python programming language. Tenacity can customize the retry scenario, retry mechanism. It will be appreciated that the tester may use Tenacity to define the retry mechanism, defining the retry conditions, retry intervals, and number of retries. If the retry condition is satisfied, a plurality of retries are performed at the retry interval, and after the number of retries is reached, that is, after the retry stop condition is satisfied, the retries are stopped.
In the embodiment, after the information representing the verification code content error returned by the target page is acquired, the retry mechanism is triggered to perform the optical character recognition again to obtain the verification code content, so that the verification code recognition accuracy can be further improved.
In one embodiment, a schematic flow chart of a page automation test process is shown in FIG. 4. The tester can instantiate the browser object with the browser automation test framework through the terminal. It can be understood that the information of the browser object includes a browser type parameter, and the terminal may initialize the browser according to the browser type parameter and call the target page address to open the target page. The terminal can perform full screen capture on the target page to obtain a page picture, and extract the position coordinates and the element size of the verification code elements from the verification code element attribute information. If the verification code type is the homologous verification code, cutting a verification code screenshot from the page picture by the terminal; and if the verification code type is the non-homologous verification code image, the terminal calls the verification code address to download the verification code image. The terminal can call the image identifying code identifying library to carry out optical character identification on the identifying code screenshot or the identifying code image to obtain the identifying code content. The terminal can transmit the verification code content as a parameter into the page automation test script, and execute the page automation test script to input the verification code content in the target page. The terminal can trigger a retry mechanism after acquiring that the target page returns the information representing the verification code content error. The terminal can stop retrying after acquiring that the target page returns the information representing that the verification code content is correct.
In one embodiment, the terminal may display an execution process log of the execution page automation test script, or the server may transmit the execution process log of the execution page automation test script to the terminal for display when the server executes the page automation test script. When the verification code type is the homologous verification code, the execution process log can include the width, height and format of a page picture obtained by full screen capturing of a target page and the height and width of a browser window for executing the page automatic test script; the width coefficient and the height coefficient corresponding to the operating system, the position coordinate and the element size of the identifying code element extracted from the identifying code attribute information, the position coordinate of the page picture area where the identifying code element is located, the identified identifying code content and the identifying code identifying result. Wherein the element size of the captcha element includes an element width and an element height.
It should be understood that, although the steps in the flowcharts related to the embodiments as described above are sequentially displayed as indicated by arrows, the steps are not necessarily performed sequentially as indicated by the arrows. The steps are not performed in the exact order shown and described, and may be performed in other orders, unless explicitly stated otherwise. Moreover, at least a part of the steps in the flowcharts related to the embodiments described above may include multiple steps or multiple stages, which are not necessarily performed at the same time, but may be performed at different times, and the execution order of the steps or stages is not necessarily sequential, but may be rotated or alternated with other steps or at least a part of the steps or stages in other steps.
Based on the same inventive concept, the embodiment of the application also provides a page automatic test processing device for realizing the page automatic test processing method. The implementation scheme for solving the problem provided by the apparatus is similar to the implementation scheme described in the method, so the specific limitations in one or more embodiments of the apparatus for processing a page automatic test provided below may refer to the limitations on the method for processing a page automatic test described above, and are not described herein again.
In one embodiment, as shown in fig. 5, there is provided a page automation test processing apparatus 500, including: a determination module 502, an identification module 504, and a test module 506, wherein:
a determining module 502, configured to determine, based on the page automation test script, a captcha element in the target page;
an identifying module 504, configured to identify a type of the captcha corresponding to the captcha element; if the verification code type is a non-homologous verification code, calling a verification code address corresponding to the verification code element to download a verification code image; the non-homologous verification code is used for representing that the verification code address uniquely corresponds to a verification code image; identifying the verification code image to obtain verification code content;
and the test module 506 is configured to use the verification code content as an entry parameter, and perform a corresponding page automation test based on the page automation test script.
In an embodiment, the identifying module 504 is further configured to, if the type of the verification code is the homologous verification code, cut an area in which the verification code element is located in the target page, and obtain a verification code screenshot; and identifying the verification code screenshot to obtain the verification code content.
In an embodiment, the identifying module 504 is further configured to, if the type of the verification code is the homologous verification code, call the image processing library to clip an area where the verification code element is located in the target page, and obtain a verification code screenshot; and calling an image verification code recognition library to recognize the verification code screenshot to obtain verification code content.
In an embodiment, the identifying module 504 is further configured to perform a full screen capture on the target page to obtain a page picture; if the verification code type is the homologous verification code, extracting page position attribute information of the verification code element from the attribute information of the verification code element; determining a page picture area where the identifying code element is located based on the page position attribute information; and cutting a page picture area from the page picture to obtain the verification code screenshot.
In one embodiment, the identifying module 504 is further configured to determine an operating system executing the page automation test script to obtain an interface scaling factor of the operating system; determining the page picture region where the identifying code element is located based on the page position attribute information includes: and determining the page picture area where the verification code element is located according to the interface scaling coefficient and the page position attribute information.
In one embodiment, a page automation test script runs in a browser; the determining module 502 is further configured to obtain a browser type parameter from the page automation test script; if the browser type parameter represents that an interface browser exists, controlling the browser to run a page automation test script with the interface; and if the browser type parameters represent the headless browser, controlling the browser to run the page automatic test script without the interface.
In one embodiment, the identifying module 504 is further configured to extract a captcha address from the attribute information of the captcha element; repeatedly calling the verification code address for multiple times to download the verification code image to obtain multiple verification code images; if the plurality of verification code images are consistent, the verification code type corresponding to the characterization verification code element is a non-homologous verification code; if the multiple verification code images are not consistent, the verification code type corresponding to the characterization verification code element is the homologous verification code.
In one embodiment, the test module 506 is further configured to input the content of the verification code as an entry into the target page based on the page automation test script; after the information that the content of the characterization verification code is wrong is obtained and returned by the target page, triggering a retry mechanism to execute the step of calling the verification code address corresponding to the verification code element to download the verification code image again if the verification code type is the non-homologous verification code, and stopping retry until the information that the content of the characterization verification code is correct is obtained and the retry stop condition is met.
The modules in the page automatic test processing device can be wholly or partially realized by software, hardware and a combination thereof. The modules can be embedded in a hardware form or independent from a processor in the computer device, and can also be stored in a memory in the computer device in a software form, so that the processor can call and execute operations corresponding to the modules.
In one embodiment, a computer device is provided, which may be a server, and its internal structure diagram may be as shown in fig. 6. The computer device includes a processor, a memory, an Input/Output interface (I/O for short), and a communication interface. The processor, the memory and the input/output interface are connected through a system bus, and the communication interface is connected to the system bus through the input/output interface. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system, a computer program, and a database. The internal memory provides an environment for the operation of an operating system and computer programs in the non-volatile storage medium. The database of the computer device is used for storing data related to the page automation test processing. The input/output interface of the computer device is used for exchanging information between the processor and an external device. The communication interface of the computer device is used for connecting and communicating with an external terminal through a network. The computer program is executed by a processor to implement a method for automated testing processing of pages.
In one embodiment, a computer device is provided, which may be a terminal, and its internal structure diagram may be as shown in fig. 7. The computer apparatus includes a processor, a memory, an input/output interface, a communication interface, a display unit, and an input device. The processor, the memory and the input/output interface are connected by a system bus, and the communication interface, the display unit and the input device are connected by the input/output interface to the system bus. Wherein the processor of the computer device is configured to provide computing and control capabilities. The memory of the computer device comprises a nonvolatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of an operating system and computer programs in the non-volatile storage medium. The input/output interface of the computer device is used for exchanging information between the processor and an external device. The communication interface of the computer device is used for carrying out wired or wireless communication with an external terminal, and the wireless communication can be realized through WIFI, a mobile cellular network, NFC (near field communication) or other technologies. The computer program is executed by a processor to implement a method for automated testing processing of pages. The display unit of the computer equipment is used for forming a visual and visible picture, and can be a display screen, a projection device or a virtual reality imaging device, the display screen can be a liquid crystal display screen or an electronic ink display screen, the input device of the computer equipment can be a touch layer covered on the display screen, a key, a track ball or a touch pad arranged on the shell of the computer equipment, and can also be an external keyboard, a touch pad or a mouse and the like.
Those skilled in the art will appreciate that the configurations shown in fig. 6 and 7 are merely block diagrams of portions of configurations related to aspects of the present application, and do not constitute limitations on the computing devices to which aspects of the present application may be applied, as particular computing devices may include more or less components than shown, or combine certain components, or have a different arrangement of components.
In an embodiment, a computer device is provided, comprising a memory and a processor, the memory having stored therein a computer program, the processor implementing the steps of the above method embodiments when executing the computer program.
In an embodiment, a computer-readable storage medium is provided, on which a computer program is stored, which computer program, when being executed by a processor, carries out the steps of the above-mentioned method embodiments.
In an embodiment, a computer program product is provided, comprising a computer program which, when being executed by a processor, carries out the steps of the above-mentioned method embodiments.
It should be noted that, the user information (including but not limited to user equipment information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, displayed data, etc.) referred to in the present application are information and data authorized by the user or sufficiently authorized by each party, and the collection, use and processing of the related data need to comply with the relevant laws and regulations and standards of the relevant country and region.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by hardware instructions of a computer program, which can be stored in a non-volatile computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. Any reference to memory, database, or other medium used in the embodiments provided herein may include at least one of non-volatile and volatile memory. The nonvolatile Memory may include a Read-Only Memory (ROM), a magnetic tape, a floppy disk, a flash Memory, an optical Memory, a high-density embedded nonvolatile Memory, a resistive Random Access Memory (ReRAM), a Magnetic Random Access Memory (MRAM), a Ferroelectric Random Access Memory (FRAM), a Phase Change Memory (PCM), a graphene Memory, and the like. Volatile Memory can include Random Access Memory (RAM), external cache Memory, and the like. By way of illustration and not limitation, RAM can take many forms, such as Static Random Access Memory (SRAM) or Dynamic Random Access Memory (DRAM), among others. The databases referred to in various embodiments provided herein may include at least one of relational and non-relational databases. The non-relational database may include, but is not limited to, a block chain based distributed database, and the like. The processors referred to in the embodiments provided herein may be general purpose processors, central processing units, graphics processors, digital signal processors, programmable logic devices, quantum computing based data processing logic devices, etc., without limitation.
The technical features of the above embodiments can be arbitrarily combined, and for the sake of brevity, all possible combinations of the technical features in the above embodiments are not described, but should be considered as the scope of the present specification as long as there is no contradiction between the combinations of the technical features.
The above-mentioned embodiments only express several embodiments of the present application, and the description thereof is more specific and detailed, but not construed as limiting the scope of the present application. It should be noted that, for a person skilled in the art, several variations and modifications can be made without departing from the concept of the present application, which falls within the scope of protection of the present application. Therefore, the protection scope of the present application shall be subject to the appended claims.

Claims (10)

1. A page automatic test processing method is characterized by comprising the following steps:
determining verification code elements in a target page based on the page automation test script;
identifying the type of the verification code corresponding to the verification code element;
if the verification code type is a non-homologous verification code, calling a verification code address corresponding to the verification code element to download a verification code image; the non-homologous verification code is used for representing that the verification code address uniquely corresponds to a verification code image;
identifying the verification code image to obtain verification code content;
and taking the verification code content as an entry parameter, and carrying out corresponding page automation test based on the page automation test script.
2. The method of claim 1, further comprising:
if the verification code type is the homologous verification code, cutting an area where the verification code element is located in the target page to obtain a verification code screenshot;
and identifying the verification code screenshot to obtain verification code content.
3. The method of claim 2, further comprising:
performing full screen capture on the target page to obtain a page picture;
if the verification code type is the homologous verification code, cutting the area of the verification code element in the target page to obtain a verification code screenshot, wherein the step of cutting the area of the verification code element in the target page comprises the following steps:
if the verification code type is a homologous verification code, extracting page position attribute information of the verification code element from attribute information of the verification code element;
determining a page picture area where the identifying code element is located based on the page position attribute information;
and cutting the page picture area from the page picture to obtain the verification code screenshot.
4. The method of claim 3, further comprising:
determining an operating system for executing the page automation test script to obtain an interface scaling coefficient of the operating system;
the determining, based on the page position attribute information, a page picture region in which the captcha element is located includes:
and determining the page picture area where the verification code element is located according to the interface scaling factor and the page position attribute information.
5. The method of claim 1, wherein the page automation test script runs in a browser; the method further comprises the following steps:
acquiring browser type parameters from a page automation test script;
if the browser type parameter represents that an interface browser exists, controlling the browser to operate the page automation test script with the interface;
and if the browser type parameters represent the headless browser, controlling the browser to operate the page automation test script without an interface.
6. The method of claim 1, wherein the identifying the type of captcha to which the captcha element corresponds comprises:
extracting a verification code address from the attribute information of the verification code element;
calling the verification code address repeatedly for multiple times to download the verification code image to obtain multiple verification code images;
if the plurality of verification code images are consistent, the verification code type corresponding to the characterization verification code element is a non-homologous verification code;
and if the plurality of verification code images are not consistent, representing that the verification code type corresponding to the verification code element is the homologous verification code.
7. The method according to any one of claims 1 to 6, wherein the taking the verification code content as an entry and performing the corresponding page automation test based on a page automation test script comprises:
inputting the verification code content into the target page as an input parameter based on a page automation test script;
after the information that the content of the characterization verification code is wrong is obtained, a retry mechanism is triggered to execute the step of calling the verification code address corresponding to the verification code element to download the verification code image again if the verification code type is the non-homologous verification code, and retry is stopped until the information that the content of the characterization verification code is correct is obtained or the retry stop condition is met.
8. A page automation test processing apparatus, the apparatus comprising:
the determining module is used for determining verification code elements in the target page based on the page automation test script;
the identification module is used for identifying the corresponding verification code type of the verification code element; if the verification code type is a non-homologous verification code, calling a verification code address corresponding to the verification code element to download a verification code image; the non-homologous verification code is used for representing that the verification code address uniquely corresponds to a verification code image; identifying the verification code image to obtain verification code content;
and the test module is used for taking the verification code content as an input parameter and carrying out corresponding page automatic test based on the page automatic test script.
9. A computer device comprising a memory and a processor, the memory storing a computer program, characterized in that the processor, when executing the computer program, implements the steps of the method of any of claims 1 to 7.
10. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the steps of the method of any one of claims 1 to 7.
CN202210224743.1A 2022-03-07 2022-03-07 Page automatic test processing method and device, computer equipment and storage medium Pending CN114610611A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210224743.1A CN114610611A (en) 2022-03-07 2022-03-07 Page automatic test processing method and device, computer equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210224743.1A CN114610611A (en) 2022-03-07 2022-03-07 Page automatic test processing method and device, computer equipment and storage medium

Publications (1)

Publication Number Publication Date
CN114610611A true CN114610611A (en) 2022-06-10

Family

ID=81860631

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210224743.1A Pending CN114610611A (en) 2022-03-07 2022-03-07 Page automatic test processing method and device, computer equipment and storage medium

Country Status (1)

Country Link
CN (1) CN114610611A (en)

Similar Documents

Publication Publication Date Title
US9135151B2 (en) Automatic verification by comparing user interface images
US9846634B2 (en) Visual graphical user interface verification
US9760475B2 (en) Automatic updating of graphical user interface element locators based on image comparison
US9202039B2 (en) Secure identification of computing device and secure identification methods
US9946637B2 (en) Automatic updating of graphical user interface element locators based on dimension comparison
WO2017165071A1 (en) Visual regression analysis
WO2019019628A1 (en) Test method, apparatus, test device and medium for mobile application
CN110320378B (en) Method, apparatus, device and computer readable storage medium for applying for a quality control test
RU2611961C2 (en) Method and system of regression testing of web page functionality, machine-readable data storage media
CN110659092A (en) Webpage screenshot method and device, computer equipment and storage medium
US20230035104A1 (en) Verification method, apparatus and device, and storage medium
CN112308069A (en) Click test method, device, equipment and storage medium for software interface
CN112956157A (en) System and method for tracking client device events
CN110781427A (en) Method, device, equipment and storage medium for calculating first screen time
CN110365776B (en) Picture batch downloading method and device, electronic equipment and storage medium
WO2020119544A1 (en) Network transmission simulation method and apparatus, computer device and storage medium
CN113535577B (en) Application testing method and device based on knowledge graph, electronic equipment and medium
US20210271588A1 (en) Rendering gui test object of application under test to reflect test information
CN112083925A (en) Data acquisition method, device, equipment and storage medium based on H5 page development
CN115687146A (en) BIOS (basic input output System) test method and device, computer equipment and storage medium
CN114610611A (en) Page automatic test processing method and device, computer equipment and storage medium
WO2015039585A1 (en) Method and device for testing software reliability
CN115576805A (en) Log display method and device, readable medium and electronic equipment
CN111414525B (en) Method, device, computer equipment and storage medium for acquiring data of applet
US11546430B2 (en) Secure remote workspace

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