CN114416516A - Test case and test script generation method, system and medium based on screenshot - Google Patents

Test case and test script generation method, system and medium based on screenshot Download PDF

Info

Publication number
CN114416516A
CN114416516A CN202111410835.0A CN202111410835A CN114416516A CN 114416516 A CN114416516 A CN 114416516A CN 202111410835 A CN202111410835 A CN 202111410835A CN 114416516 A CN114416516 A CN 114416516A
Authority
CN
China
Prior art keywords
event
picture
screenshot
test
web page
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.)
Granted
Application number
CN202111410835.0A
Other languages
Chinese (zh)
Other versions
CN114416516B (en
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.)
Inspur Software Group Co Ltd
Original Assignee
Inspur Software Group 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 Inspur Software Group Co Ltd filed Critical Inspur Software Group Co Ltd
Priority to CN202111410835.0A priority Critical patent/CN114416516B/en
Publication of CN114416516A publication Critical patent/CN114416516A/en
Application granted granted Critical
Publication of CN114416516B publication Critical patent/CN114416516B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

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
    • G06F8/00Arrangements for software engineering
    • G06F8/30Creation or generation of source code
    • G06F8/31Programming languages or programming paradigms
    • G06F8/315Object-oriented languages

Landscapes

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

Abstract

The invention discloses a test case based on screenshot and a test script generation method, a test case based on screenshot and a test script generation system and a test script generation medium, belongs to the technical field of test case generation, and solves the technical problem of how to compile the test case through pictures and automatically generate an automatic script according to the picture test case. The method comprises the following steps: for each step of the test case, configuring a script execution statement for each operation event in the step and packaging to obtain a corresponding component; for each step of the test case, recording an operation file corresponding to each operation event through a web page, constructing an operation file in a JSON format based on the screenshot picture and the operation attribute, and storing a mapping relation among the components, the operation events and the operation file through a database; and matching the component and the operation file based on the mapping relation among the component, the operation event and the operation file, and replacing the operation file into a script execution statement to obtain the test script in the form of a character string.

Description

Test case and test script generation method, system and medium based on screenshot
Technical Field
The invention relates to the technical field of test case generation, in particular to a test case and test script generation method, a test case and test script generation system and a test script generation medium based on screenshots.
Background
In the agile test process, the requirement for rapid iteration is very obvious, in order to improve the test efficiency, an automatic test mode is often adopted, but in the agile test of the traditional automatic test mode, because certain time is needed for developing an automatic test script, a case manager is usually required to develop the automatic script according to the test case after the test case is designed, and the logic and the steps are the same except that one of the test case and the test script is a natural language and the other is a script language, so that certain resource waste can be caused by two times of compiling. Meanwhile, in an agile test mode, the responsibilities of the case manager and the automatic specialist are separated, namely the case manager is responsible for designing the test case, the automatic specialist is responsible for developing the automatic test script, and whether the test script written by the automatic specialist completely covers the test case cannot be known through an operation result and can only be known through a manual examination or statistical mode.
Based on the problems, the technical problem to be solved by the invention is how to write the test case by the picture and automatically generate the automation script according to the picture test case.
Disclosure of Invention
The technical task of the invention is to provide a test case based on screenshot and a test script generation method, a system and a medium aiming at the defects, so as to solve the technical problem of writing the test case by pictures and automatically generating an automatic script according to the picture test case.
In a first aspect, the test case and test script generation method based on the screenshot of the present invention is applied to a test case generation system including a remote real machine platform, a database and a mobile phone, wherein the remote real machine provides a web page and a mouse, and the generation method includes the following steps:
for each step of the test case, configuring a script execution statement for each operation event in the step and packaging to obtain a corresponding component, storing the preset component in a database, and storing the mapping relation between the component and the operation event through the database;
for each step of the test case, recording an operation file corresponding to each operation event through a web page, monitoring a corresponding mouse click event for each operation event, forming a corresponding screenshot picture in a click area of the web page on a mouse, performing attribute configuration on the operation event through the web page to obtain an operation attribute, constructing the operation file in a JSON format based on the screenshot picture and the operation attribute, and storing a mapping relation among components, the operation events and the operation file through a database;
after the operation files related to all steps in the test case are recorded, matching the components and the operation files based on the mapping relation of the components, the operation events and the operation files, replacing the operation files into script execution statements to obtain test scripts in a character string form, and displaying the test scripts through a remote real machine platform.
Preferably, the recording the operation file of each operation event in the step through a web page includes the following steps:
monitoring a mouse click event by a method for monitoring the event;
based on a click area of a mouse, forming a screenshot picture corresponding to the operation event on a web page, wherein the screenshot picture is stored on the remote real machine and returns a picture ID of the screenshot picture;
performing attribute configuration on the operation event through page service provided by a web page, wherein the attribute configuration comprises a configuration attribute name and related operation parameters to obtain a corresponding operation attribute;
constructing an operation file in a JSON format based on an operation name, a picture ID and operation parameters, recording the picture ID in the operation file in a picture attribute mode, and storing a mapping relation among the components, the operation event, the picture ID and the operation parameters through a database, wherein the mapping relation takes the operation name as a keyword;
after the operation files related to all steps in the test case are recorded, matching the components and the corresponding operation files through the operation names based on the mapping relation among the components, the operation events, the picture IDs and the operation parameters, and replacing the picture IDs and the operation parameters into corresponding script execution statements to obtain the test scripts in the form of character strings.
Preferably, before a mouse click event is monitored, a picture mode is selected through a page service provided by a web page, and the picture mode comprises a mobile phone real machine screen mode and a UI picture mode.
Preferably, the method includes monitoring a corresponding mouse click event, and when a corresponding screenshot picture is formed in a mouse click area of a web page, the method includes two modes, which are respectively:
in the first mode, when a left mouse button is clicked to execute a mouse click event, the corresponding operation event type is the click event, and a square screenshot picture with a preset size and with a click point as a center is formed on a web page based on a click area of the mouse;
in the second mode, when a right mouse button is clicked to execute a mouse click event, the corresponding operation event type is other events, a screenshot frame with a click point as a center is formed on a web page based on a click area of the mouse, and a screenshot picture with a required size is formed by selecting a required area through the screenshot frame; the other events include input, wait, scroll, screenshot, search, swipe, and assertion;
after a required area is selected through a screenshot frame to form a screenshot picture with a required size, attribute configuration is carried out on the operation event through a toolbar popped up from a web page, and the attribute configuration comprises the steps of selecting the name of the operation event through a selection frame and inputting related parameters of the operation event through an input frame.
Preferably, the generated test script is regenerated into a new modified test script in a mode of modifying pictures or sequential logic;
modifying the picture or sequential logic by:
recording an operation file of an operation event to be modified through a web page to obtain a new operation file;
storing the new operation file through a remote real machine platform, and storing the mapping relation of the component, the operation event and the new operation file through a database;
and replacing the new operation file into a script execution statement to obtain a new test script in a character string form, and displaying the test script through a remote real machine platform.
Preferably, the test case is executed by the following method:
acquiring a real-time screen capture of the mobile phone through a mobile agent node;
finding out coordinates of a corresponding screenshot in the test script in the real-time screenshot through a picture comparison function of opencv so as to perform operation positioning;
and executing the corresponding test case to perform event operation.
Preferably, before acquiring a real-time screen capture of the mobile phone by the mobile agent node, acquiring the resolution of the mobile phone screen as a real-time resolution, taking the capture in the test script as a source image, taking the resolution of the source image as a standard resolution, and calculating the proportion of the real-time resolution to the standard resolution;
after the mobile agent node obtains the real-time screen capture of the mobile phone, resolution conversion is carried out on the real-time screen capture based on the proportion of the real-time resolution to the standard resolution, so that the resolution of the converted real-time screen image is adaptive to the standard resolution.
In a second aspect, the test case and test script generation system based on screenshots of the present invention is configured to execute the test case and test script generation method based on screenshots of any one of the first aspect, and the generation system includes:
the mobile phones comprise at least one mobile phone, and the at least one mobile phone forms an equipment pool;
a database for storage;
the remote real-machine platform is in remote interaction with the mobile phone and the database and is used for executing the following operations:
for each step of the test case, configuring a script execution statement for each operation event in the step and packaging to obtain a corresponding component; storing the preset components in a database, and storing the mapping relation between the components and the operation events through the database;
for each step of each test case, recording an operation file corresponding to each operation event through a web page, monitoring a corresponding mouse click event for each operation event, forming a corresponding screenshot picture in a click area of the web page on a mouse, performing attribute configuration on the operation event corresponding to the mouse click event through the web page to obtain an operation attribute, and constructing an operation file in a JSON format based on the screenshot picture and the operation attribute;
after the operation files related to all steps in the test case are recorded, matching the components and the operation files based on the mapping relation of the components, the operation events and the operation files, replacing the operation files into script execution statements to obtain a test script in a character string form, and displaying the test script;
for the generated test script, a new modified test script is regenerated in a mode of modifying pictures or sequential logic;
the mapping relations of the components, the operation events and the operation files are stored in a database;
before monitoring a mouse click event, the remote real machine platform is further used for selecting a picture mode through a page service provided by a web page, wherein the picture mode comprises a mobile phone real machine screen mode and a UI picture mode;
in the remote real-time machine platform, when a corresponding screenshot picture is formed in a mouse clicking area of a web page, the remote real-time machine platform comprises two modes which are respectively:
in the first mode, when a left mouse button is clicked to execute a mouse click event, the corresponding operation event type is the click event, and a square screenshot picture with a preset size and with a click point as a center is formed on a web page based on a click area of the mouse;
in the second mode, when a right mouse button is clicked to execute a mouse click event, the corresponding operation event type is other events, a screenshot frame with a click point as a center is formed on a web page based on a click area of the mouse, and a screenshot picture with a required size is formed by selecting a required area through the screenshot frame; the other events include input, wait, scroll, screenshot, search, swipe, and assertion; after a required area is selected through a screenshot frame to form a screenshot picture with a required size, attribute configuration is carried out on an operation event through a toolbar popped up from a web page, wherein the attribute configuration comprises the steps of selecting the name of the operation event through a selection frame and inputting related parameters of the operation event through an input frame;
the remote live-machine platform is used for modifying pictures or sequential logic by the following method:
recording an operation file of an operation event to be modified through a web page to obtain a new operation file;
storing the new operation file through a remote real machine platform, and storing the mapping relation of the component, the operation event and the new operation file through a database;
and replacing the new operation file into a script execution statement to obtain a new test script in a character string form, and displaying the test script through a remote real machine platform.
Preferably, the recording of the operation file of each operation event in the step through a web page in the remote live machine platform includes the following steps:
monitoring a mouse click event corresponding to the operation event by a method for monitoring the event;
based on a click area of a mouse, forming a screenshot picture corresponding to the operation event on a web page, wherein the screenshot is stored on the remote real machine and returns a picture ID of the screenshot picture;
performing attribute configuration on the operation event through page service provided by a web page, wherein the attribute configuration comprises selecting an operation name and inputting an operation parameter to obtain an operation attribute corresponding to the operation event;
forming an operation file in the JSON format based on an operation name, a picture ID and operation parameters, recording the corresponding picture ID in the operation file in a picture attribute mode, and storing a mapping relation among the components, the operation event, the picture ID and the operation parameters through a database, wherein the mapping relation takes the operation name as a keyword;
after the operation files related to all steps in the test case are recorded, matching the components and the corresponding operation files through the operation names based on the mapping relation among the components, the operation events, the picture IDs and the operation parameters, and replacing the picture IDs and the operation parameters into corresponding script execution statements to obtain the test scripts in the form of character strings.
In a third aspect, the medium of the present invention is a computer-readable medium having stored thereon computer instructions, which, when executed by a processor, cause the processor to perform the method according to any one of the first aspect.
The test case and test script generation method, system and medium based on the screenshot have the following advantages:
1. an operation file is formed based on the configured operation attributes of the screenshot, the operation file is replaced into an execution script statement, a test script is generated, the screenshot operation mode enables the operation to be convenient and simple, and the development difficulty is reduced;
2. the recorded script can generate a readable traditional test case through a case generator, so that the test case is convenient to check, the original case-to-script is broken through, the recorded case-to-script is converted, the one-time recording and multi-place use are realized, and the JSON recording record-Python automatic script-test case linkage is realized;
3. the graphical test case and the automatic test script can be generated, so that part of workload is reduced, the working efficiency is improved, in addition, the graphical test case is more convenient and visual, and a prototype diagram does not need to be checked when manual test or automatic test is executed;
3. the automatic test script can be written under the condition that the UI diagram is completed without waiting for the completion of function development, and the script is debugged and run immediately after the function development is completed, so that the waiting time among links is reduced, and the test work is truly moved to the left;
4. the test case set by the case designer has clear logic and complete coverage, and the test omission can be reduced to the greatest extent after the case is evaluated by multiple persons such as products, research and development, and the like, so that the quality of the generated automatic test script is more reliable, and the reliability of an automatic test result is improved.
Drawings
In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings needed for the embodiments or the prior art descriptions will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present invention, and it is obvious for those skilled in the art to obtain other drawings based on the drawings without creative efforts.
The invention is further described below with reference to the accompanying drawings.
FIG. 1 is a block flow diagram of a test case and test script generation method based on screenshots in embodiment 1;
FIG. 2 is a schematic diagram of a screenshot frame appearing on a double-click device interface in the test case and test script generation method based on the screenshot in embodiment 1;
FIG. 3 is a diagram illustrating a right key on a screenshot frame for selecting a desired operation in a test case and test script generation method based on screenshot in embodiment 1;
FIG. 4 is a schematic diagram of a top operation bar in the test case and test script generation method according to the screenshot in embodiment 1;
fig. 5 is a schematic diagram of an input prompt indicating presence or absence in a condition input box of if in the test case and test script generation method based on the screenshot in embodiment 1;
fig. 6 is a schematic diagram of example 1 when all installation package names installed on the device are popped out in an input box of a start app selected in a test case and test script generation method based on a screenshot;
FIG. 7 is a schematic diagram of a common method area customization in a test case and test script generation method based on screenshots in embodiment 1;
fig. 8 is a schematic diagram of recording information in script recording in a test case and test script generation method based on screenshots in embodiment 1;
FIG. 9 is a schematic diagram of recording information indentation in a test case and test script generation method based on screenshots in embodiment 1;
FIG. 10 is a schematic diagram of information dragged in a test case and test script generation method according to the screenshot in embodiment 1;
FIG. 11 is a schematic diagram illustrating a waiting queue of a common method that can be temporarily stored in a use case information area in a test case and test script generation method according to the screenshot in embodiment 1;
fig. 12 is a schematic diagram of a use case information area introduced in the test case and test script generation method based on the screenshot in embodiment 1.
Detailed Description
The present invention is further described in the following with reference to the drawings and the specific embodiments so that those skilled in the art can better understand the present invention and can implement the present invention, but the embodiments are not to be construed as limiting the present invention, and the embodiments and the technical features of the embodiments can be combined with each other without conflict.
The embodiment of the invention provides a test case based on screenshot and a test script generation method, a test case based on screenshot and a test script generation system and a test script generation medium, which are used for solving the technical problems of how to compile the test case by pictures and automatically generating an automatic script according to the picture test case.
Example 1:
the invention relates to a test case and test script generating method based on screenshot, which is applied to a test case generating system comprising a remote real machine platform, a database and a mobile phone, wherein the remote real machine provides a web page and a mouse, and the generating method comprises the following steps:
s100, configuring script execution statements for each operation event in the step and packaging to obtain a corresponding component for each step of the test case, storing the components in a database, and storing the mapping relation between the components and the operation events through the database;
s200, recording an operation file corresponding to each operation event through a web page for each step of the test case, monitoring a corresponding mouse click event for each operation event, forming a corresponding screenshot picture in a click area of the web page on a mouse, performing attribute configuration on the operation event through the web page to obtain an operation attribute, constructing an operation file in a JSON format based on the screenshot picture and the operation attribute, and storing a mapping relation among components, the operation events and the operation file through a database;
s300, after recording operation files related to all steps in the test case, matching the components and the operation files based on the mapping relation of the components, the operation events and the operation files, replacing the operation files into script execution statements to obtain test scripts in a character string form, and displaying the test scripts through a remote real machine platform.
In this embodiment, the recording of the operation file of each operation event in the step S200 through the web page includes the following steps:
(1) monitoring a mouse click event by a method for monitoring the event;
(2) based on a click area of a mouse, forming a screenshot picture corresponding to the operation event on a web page, wherein the screenshot picture is stored on the remote real machine and returns a picture ID of the screenshot picture;
(3) performing attribute configuration on the operation event through page service provided by a web page, wherein the attribute configuration comprises a configuration attribute name and related operation parameters to obtain a corresponding operation attribute;
(4) constructing an operation file in a JSON format based on the picture ID and the operation parameters, recording the picture ID in the operation file in a picture attribute mode, and storing a mapping relation among the components, the operation events, the picture ID and the operation parameters through a database, wherein the mapping relation takes an operation name as a keyword;
(5) after the operation files related to all steps in the test case are recorded, matching the components and the corresponding operation files through the operation names based on the mapping relation among the components, the operation events, the picture IDs and the operation parameters, and replacing the picture IDs and the operation parameters into corresponding script execution statements to obtain the test scripts in the form of character strings.
In the above steps, recording is performed through a web page of a remote real machine, before recording, a picture mode needs to be selected through a page service provided by the web page, and the picture mode includes a mobile phone real machine screen mode and a UI picture mode. When the browser is executed, two modes are provided for a user to select, namely, the user selects a real machine mode or a picture mode, wherein the real machine mode is to select idle equipment in an equipment pool to connect, the picture mode needs to upload pictures needed to be used to a web page for user screenshot operation, and the uploaded pictures or the current screen pictures of the real machine are displayed on the browser page after the selection is completed.
In this embodiment, a corresponding mouse click event is monitored, and when a corresponding screenshot picture is formed in a mouse click area of a web page, two modes are included, which are respectively:
in the first mode, when a left mouse button is clicked to execute a mouse click event, the corresponding operation event type is the click event, and a square screenshot picture with a preset size and with a click point as a center is formed on a web page based on a click area of the mouse;
in the second mode, when a right mouse button is clicked to execute a mouse click event, the corresponding operation event type is other events, a screenshot frame with a click point as a center is formed on a web page based on a click area of the mouse, and a screenshot picture with a required size is formed by selecting a required area through the screenshot frame; other events referred to by this embodiment include input, wait, scroll, screenshot, search, slide, and assertion; after a required area is selected through a screenshot frame to form a screenshot picture with a required size, attribute configuration is carried out on the operation event through a toolbar popped up from a web page, and the attribute configuration comprises the steps of selecting the name of the operation event through a selection frame and inputting related parameters of the operation event through an input frame.
Specifically, when the method is executed, clicking is carried out on a UI picture displayed on a web page or an area of a real-time screen of a real machine to start recording, an event clicking event of a mouse is monitored by adopting an event monitoring method in front js codes, the event clicking operation of a left button is recorded automatically, and when the left button of the mouse is clicked, a square screenshot with a default size is carried out on the clicked area automatically by taking the clicking point as the center. In the using process, for operation events needing to be performed such as input, waiting, scrolling, screenshot, searching, sliding and assertion, a right mouse button is clicked, when the click event of the right button is monitored in a front-end js method, a screenshot frame appears by taking a click point as a center, a required area is framed, a selection frame of the supported operation events is automatically popped up, the operation events needing to be performed are selected, an input frame with required parameters corresponding to each operation event added is popped up, and a user inputs related parameters.
The remote real machine platform of the embodiment comprises a front end platform, a rear end platform and a server, wherein the front end platform and the rear end platform are interactive, and the rear end platform and the server are interactive. The front-end platform is provided with a browser client, and web pages and page services are provided through the browser client. A mouse interacts with the front end platform.
When a test case is recorded, for each step of operation event, a screenshot picture formed on a web page is stored in a back-end platform and a picture ID of the screenshot picture is returned, an operation file in a JSON format is formed based on the picture ID and operation parameters, when the operation files of the operation events of all steps of the test case are recorded, the operation files related to the test case are stored in the back-end platform, wherein the mapping relation among components, the operation events and the picture IDs and the mapping relation among the components, the operation events, the picture IDs and the operation files are stored in a database.
Each operation event such as clicking, inputting, waiting, rolling, screenshot, searching, sliding and assertion in json transmitted by a front-end platform corresponds to a corresponding script execution statement preset in python and is stored in a database, after the json of the front-end platform is transmitted to a rear-end platform, the name of the operation is taken out of the json, the corresponding script execution statement preset in the database is taken out, the operation parameters and the screenshot picture intercepted by the operation are replaced into the script execution statement, conversion from json to an automatic script is formed, and after the script is generated, the json is returned to the front-end platform in a character string mode for displaying.
When the use case relates to modification adjustment, the pictures or the sequential logic are directly modified. The automation script is regenerated for use in the automated test. The specific operation is as follows:
(1) recording an operation file of an operation event to be modified through a web page to obtain a new operation file;
(2) storing a new operation file through a remote real machine platform, and storing a mapping relation among the components, the operation events and the new operation file through a database;
(3) and replacing the new operation file into a script execution statement to obtain a new test script in a character string form, and displaying the test script through a remote real machine platform.
When the use case script is executed, the current real-time screenshot of the equipment is obtained through the mobile agent node, the coordinates of the screenshot in the script in the real-time picture are found through the picture comparison function of the opencv, the positioning is firstly carried out, the operation of the event is carried out, and the accurate execution of the script is finally realized.
The parameters of the screenshot picture relate to the original proportion of a source picture, relate to the situation that different resolutions of equipment are different, need to stipulate the standard resolution of a source picture first, then carry on the proportional calculation with standard resolution in the source picture, receive the proportion of the source picture and standard resolution, then carry on the resolution conversion according to this proportion to the screenshot that will gather and record. In the execution process, before a mobile agent node acquires a real-time screen capture of a mobile phone, acquiring the resolution of the mobile phone screen as a real-time resolution, taking the capture in a test script as a source graph, taking the resolution of the source graph as a standard resolution, and calculating the proportion of the real-time resolution to the standard resolution; after the mobile agent node obtains the real-time screen capture of the mobile phone, resolution conversion is carried out on the real-time screen capture based on the proportion of the real-time resolution to the standard resolution, so that the resolution of the converted real-time screen image is adaptive to the standard resolution.
The database stores components and mapping relations, the components can be stored through a non-relational database, and the mapping relations between the components and operation events, the mapping relations between the components, the operation events, operation files and the like need to be stored through a relational database. Therefore, it is necessary to select an appropriate database according to the storage type.
In the test case and the test script generation method based on the screenshot, case personnel design the test case, prefabricate components of each operation event according to the test case, record relevant screenshots, operation parameters and the like of the operation events on a web page to obtain operation files, reduce development difficulty through the screenshot form, and generate readable traditional test cases through a case generator by the recorded script, so that the test cases are convenient to check, the original cases to scripts are broken through, and the scripts are converted into the test cases which are recorded. The JSON recording record-Python automation script-test case linkage is realized; and the generated graphical test case and the generated automatic test script reduce part of workload and improve working efficiency. In addition, the graphical test case is more convenient and visual, and the prototype diagram does not need to be checked when the manual test or the automatic test is executed.
An example of the method of this embodiment is as follows:
step 1: double-clicking the device interface, displaying a cutout frame, adjusting the size and position of the cutout frame, and selecting a picture to be operated (e.g., clicking, waiting, and determining whether the picture exists), as shown in fig. 2;
step 2: selecting required operations including clicking/long pressing/clicking/double clicking/inputting/searching/sliding/asserting/waiting for appearing/judging existence/screenshot/returning to homepage, popping up a popup window for prompting input if parameters are required to be input, such as input content required to be input, sliding range and direction required to slide, and the like, displaying a recording message in a middle script recording area if the input is not required or is finished according to the prompt input, displaying operation types, operated pictures, remark messages and the like, carrying out corresponding operation of operation message display by a mobile phone in a synchronous mode, stopping the mobile phone following definition operation if the synchronization is canceled by clicking in the recording process, exiting the recording mode by double clicking the screen again, and directly simulating a finger operation screen by a mouse, the recording of the next strip is also switched between the recording state and the non-recording state by double clicking, as shown in fig. 3;
step 3: the top operation bar provides some common methods, such as wait (wait), if (if/else/elif), for, while, app (start/clear/stop), etc., and selecting click will also add a piece of information in the script recording information area, and give the correct suggested content in the corresponding information input box, as shown in fig. 4;
if an input prompt with or without exists in the condition input box of the graph if, a camera button on the right side of the information is clicked to replace a picture for judgment, if the picture does not exist, the background generates a judgment script according to characters in the data input box, as shown in fig. 5;
selecting an input box of the start app to pop out all installation package names installed by the device, as shown in fig. 6;
the public method area also supports customization, that is, the information recorded in the current script recording area or the recorded information with the stored label as the public method is stored as a public method, and the public method can be directly clicked and added later, so that the recorded information contained in the method can be added into the current recorded script, as shown in fig. 7;
step 4: in the script, xx operation is often required when xx occurs, otherwise, the logic of xx operation is performed, the recording information is represented as a piece of recording information under a double-click judgment condition in the script recording, and the recording information is selected to be light green, as shown in fig. 8;
and then normal recording operation is carried out, at the moment, two indentation grids of the recorded information are added under the selected condition information, and the recorded information supports infinite nesting indentation. Clicking the minus button on the left side of the parent information can contract the child information and click the plus expansion, as shown in fig. 9;
the recording information at the same level supports the dragging adjustment sequence, and when the dragged information contains child information, the child information is dragged to adjust the position along with the parent information, as shown in fig. 10;
step 5: the use case information area can temporarily store a public method waiting queue, namely, use cases contained in use cases, selection items and selection items at the upper left corner can be screened, only public scripts can be seen, after selection, clicking determination is carried out, information of the imported scripts can be displayed in the use case information area, and the public scripts are different from background colors of non-public scripts and used for distinguishing, as shown in fig. 11;
the script of the introduced use case information area can be directly clicked to add to the current script information, or can be clicked to edit and replace all current recording information to modify, or can be removed from the introduced script queue, and a new window is opened for previewing, as shown in fig. 12;
step 6: after the recording is finished, clicking the upper left corner for saving, renaming according to the prompt, selecting the affiliated project-module, clicking to determine the saving, and enabling the recorded use case to appear under the project module appointed in the script management menu bar; and entering a task list, clicking to create a task, inputting required information, and selecting a recorded and stored use case to click to submit.
Example 2:
the invention relates to a test case and test script generating system based on screenshot, which is used for executing the generating system and comprises at least one mobile phone, a database and a remote real machine platform, wherein the at least one mobile phone forms an equipment pool; the database is used for storage.
The remote real machine platform is in remote interaction with the mobile phone and the database and is used for executing the following operations:
for each step of the test case, configuring a script execution statement for each operation event in the step and packaging to obtain a corresponding component; storing the preset components in a database, and storing the mapping relation between the components and the operation events through the database;
for each step of each test case, recording an operation file corresponding to each operation event through a web page, monitoring a corresponding mouse click event for each operation event, forming a corresponding screenshot picture in a click area of the web page on a mouse, performing attribute configuration on the operation event corresponding to the mouse click event through the web page to obtain an operation attribute, and constructing an operation file in a JSON format based on the screenshot picture and the operation attribute;
after the operation files related to all steps in the test case are recorded, matching the components and the operation files based on the mapping relation of the components, the operation events and the operation files, replacing the operation files into script execution statements to obtain a test script in a character string form, and displaying the test script;
and for the generated test script, regenerating a new modified test script in a mode of modifying pictures or sequential logic.
The mapping relation among the components, the operation events and the operation files is stored in a database.
Before monitoring a mouse click event, the remote real machine platform is also used for selecting a picture mode through a page service provided by a web page, wherein the picture mode comprises a mobile phone real machine screen mode and a UI picture mode.
In the remote real-time machine platform, when a corresponding screenshot picture is formed in a mouse clicking area of a web page, the method comprises two modes, namely:
in the first mode, when a left mouse button is clicked to execute a mouse click event, the corresponding operation event type is the click event, and a square screenshot picture with a preset size and with a click point as a center is formed on a web page based on a click area of the mouse;
in the second mode, when a right mouse button is clicked to execute a mouse click event, the corresponding operation event type is other events, a screenshot frame with a click point as a center is formed on a web page based on a click area of the mouse, and a screenshot picture with a required size is formed by selecting a required area through the screenshot frame; other events include input, wait, scroll, screenshot, search, swipe, and assertion; after a required area is selected through a screenshot frame to form a screenshot picture with a required size, attribute configuration is carried out on the operation event through a toolbar popped up from a web page, and the attribute configuration comprises the steps of selecting the name of the operation event through a selection frame and inputting related parameters of the operation event through an input frame.
The remote live machine platform is used for modifying pictures or sequential logic by the following method: recording an operation file of an operation event to be modified through a web page to obtain a new operation file; storing the new operation file through a remote real machine platform, and storing the mapping relation of the component, the operation event and the new operation file through a database; and replacing the new operation file into a script execution statement to obtain a new test script in a character string form, and displaying the test script through a remote real machine platform.
In this embodiment, the recording of the operation file of each operation event in the steps through the web page in the remote live machine platform includes the following steps:
(1) monitoring a mouse click event corresponding to the operation event by a method for monitoring the event;
(2) based on a click area of a mouse, forming a screenshot picture corresponding to the operation event on a web page, wherein the screenshot is stored on the remote real machine and returns a picture ID of the screenshot picture;
(3) performing attribute configuration on the operation event through page service provided by a web page, wherein the attribute configuration comprises selecting an operation name and inputting an operation parameter to obtain an operation attribute corresponding to the operation event;
(4) forming an operation file in the JSON format based on the operation name, the picture ID and the operation parameters, recording the corresponding picture ID in the operation file in a picture attribute mode, and storing a mapping relation among the component, the operation event, the picture ID and the operation parameters through a database, wherein the mapping relation takes the operation name as a keyword;
(5) after the operation files related to all steps in the test case are recorded, matching the components and the corresponding operation files through the operation names based on the mapping relation among the components, the operation events, the picture IDs and the operation parameters, and replacing the picture IDs and the operation parameters into corresponding script execution statements to obtain the test scripts in the form of character strings.
The system of this embodiment can execute the test case and test script generation method based on the screenshot disclosed in embodiment 1, and generate the test script by this method.
Example 3:
a medium being a computer readable medium having stored thereon computer instructions which, when executed by a processor, cause the processor to perform the method disclosed in embodiment 1. Specifically, a system or an apparatus equipped with a storage medium on which software program codes that realize the functions of any of the above-described embodiments are stored may be provided, and a computer (or a CPU or MPU) of the system or the apparatus is caused to read out and execute the program codes stored in the storage medium.
In this case, the program code itself read from the storage medium can realize the functions of any of the above-described embodiments, and thus the program code and the storage medium storing the program code constitute a part of the present invention.
Examples of the storage medium for supplying the program code include a floppy disk, a hard disk, a magneto-optical disk, an optical disk (e.g., CD-ROM, CD-R, CD-RW, DVD-ROM, DVD-RAM, DVD-RW, DVD + RW), a magnetic tape, a nonvolatile memory card, and a ROM. Alternatively, the program code may be downloaded from a server computer via a communications network.
Further, it should be clear that the functions of any one of the above-described embodiments may be implemented not only by executing the program code read out by the computer, but also by causing an operating system or the like operating on the computer to perform a part or all of the actual operations based on instructions of the program code.
Further, it is to be understood that the program code read out from the storage medium is written to a memory provided in an expansion board inserted into the computer or to a memory provided in an expansion unit connected to the computer, and then causes a CPU or the like mounted on the expansion board or the expansion unit to perform part or all of the actual operations based on instructions of the program code, thereby realizing the functions of any of the above-described embodiments.
It should be noted that not all steps and modules in the above flows and system structure diagrams are necessary, and some steps or modules may be omitted according to actual needs. The execution order of the steps is not fixed and can be adjusted as required. The system structure described in the above embodiments may be a physical structure or a logical structure, that is, some modules may be implemented by the same physical entity, or some modules may be implemented by a plurality of physical entities, or some components in a plurality of independent devices may be implemented together.
In the above embodiments, the hardware unit may be implemented mechanically or electrically. For example, a hardware element may comprise permanently dedicated circuitry or logic (such as a dedicated processor, FPGA or ASIC) to perform the corresponding operations. The hardware elements may also comprise programmable logic or circuitry, such as a general purpose processor or other programmable processor, that may be temporarily configured by software to perform the corresponding operations. The specific implementation (mechanical, or dedicated permanent, or temporarily set) may be determined based on cost and time considerations.
While the invention has been shown and described in detail in the drawings and in the preferred embodiments, it is not intended to limit the invention to the embodiments disclosed, and it will be apparent to those skilled in the art that various combinations of the code auditing means in the various embodiments described above may be used to obtain further embodiments of the invention, which are also within the scope of the invention.

Claims (10)

1. A test case and test script generation method based on screenshot is characterized by being applied to a test case generation system comprising a remote real machine platform, a database and a mobile phone, wherein the remote real machine provides a web page and a mouse, and the generation method comprises the following steps:
for each step of the test case, configuring a script execution statement for each operation event in the step and packaging to obtain a corresponding component, storing the preset component in a database, and storing the mapping relation between the component and the operation event through the database;
for each step of the test case, recording an operation file corresponding to each operation event through a web page, monitoring a corresponding mouse click event for each operation event, forming a corresponding screenshot picture in a click area of the web page on a mouse, performing attribute configuration on the operation event through the web page to obtain an operation attribute, constructing the operation file in a JSON format based on the screenshot picture and the operation attribute, and storing a mapping relation among components, the operation events and the operation file through a database;
after the operation files related to all steps in the test case are recorded, matching the components and the operation files based on the mapping relation of the components, the operation events and the operation files, replacing the operation files into script execution statements to obtain test scripts in a character string form, and displaying the test scripts through a remote real machine platform.
2. The method for generating test cases and test scripts according to claim 1, wherein the operation files of each operation event in the step are recorded through a web page, and the method comprises the following steps:
monitoring a mouse click event by a method for monitoring the event;
based on a click area of a mouse, forming a screenshot picture corresponding to the operation event on a web page, wherein the screenshot picture is stored on the remote real machine and returns a picture ID of the screenshot picture;
performing attribute configuration on the operation event through page service provided by a web page, wherein the attribute configuration comprises a configuration attribute name and related operation parameters to obtain a corresponding operation attribute;
constructing an operation file in a JSON format based on an operation name, a picture ID and operation parameters, recording the picture ID in the operation file in a picture attribute mode, and storing a mapping relation among the components, the operation event, the picture ID and the operation parameters through a database, wherein the mapping relation takes the operation name as a keyword;
after the operation files related to all steps in the test case are recorded, matching the components and the corresponding operation files through the operation names based on the mapping relation among the components, the operation events, the picture IDs and the operation parameters, and replacing the picture IDs and the operation parameters into corresponding script execution statements to obtain the test scripts in the form of character strings.
3. The method for generating test cases and test scripts based on screenshots according to claim 1 or 2, wherein before a mouse click event is monitored, a picture mode is selected through a page service provided by a web page, and the picture mode comprises a mobile phone real machine screen mode and a UI picture mode.
4. The test case and test script generation method based on the screenshot according to claim 1 or 2, characterized in that a corresponding mouse click event is monitored, and when a corresponding screenshot picture is formed in a click area of a mouse on a web page, two modes are included, which are respectively:
in the first mode, when a left mouse button is clicked to execute a mouse click event, the corresponding operation event type is the click event, and a square screenshot picture with a preset size and with a click point as a center is formed on a web page based on a click area of the mouse;
in the second mode, when a right mouse button is clicked to execute a mouse click event, the corresponding operation event type is other events, a screenshot frame with a click point as a center is formed on a web page based on a click area of the mouse, and a screenshot picture with a required size is formed by selecting a required area through the screenshot frame; the other events include input, wait, scroll, screenshot, search, swipe, and assertion;
after a required area is selected through a screenshot frame to form a screenshot picture with a required size, attribute configuration is carried out on the operation event through a toolbar popped up from a web page, and the attribute configuration comprises the steps of selecting the name of the operation event through a selection frame and inputting related parameters of the operation event through an input frame.
5. The test case and test script generation method based on the screenshot according to claim 1 or 2, characterized in that for the generated test script, a new modified test script is regenerated by modifying pictures or sequential logic;
modifying the picture or sequential logic by:
recording an operation file of an operation event to be modified through a web page to obtain a new operation file;
storing the new operation file through a remote real machine platform, and storing the mapping relation of the component, the operation event and the new operation file through a database;
and replacing the new operation file into a script execution statement to obtain a new test script in a character string form, and displaying the test script through a remote real machine platform.
6. The method for generating test cases and test scripts according to claims 1 or 2, wherein the test cases are executed by:
acquiring a real-time screen capture of the mobile phone through a mobile agent node;
finding out coordinates of a corresponding screenshot in the test script in the real-time screenshot through a picture comparison function of opencv so as to perform operation positioning;
and executing the corresponding test case to perform event operation.
7. The method for generating the test case and the test script based on the screenshot according to claim 6, wherein before the mobile agent node obtains the real-time screenshot of the mobile phone, the resolution of the mobile phone screen is collected as the real-time resolution, the screenshot in the test script is used as the source image, the resolution of the source image is used as the standard resolution, and the ratio of the real-time resolution to the standard resolution is calculated;
after the mobile agent node obtains the real-time screen capture of the mobile phone, resolution conversion is carried out on the real-time screen capture based on the proportion of the real-time resolution to the standard resolution, so that the resolution of the converted real-time screen image is adaptive to the standard resolution.
8. The test case and test script generation system based on the screenshot is characterized in that the test case and test script generation system is used for executing the test case and test script generation method based on the screenshot in any one of claims 1 to 7, and the generation system comprises:
the mobile phones comprise at least one mobile phone, and the at least one mobile phone forms an equipment pool;
a database for storage;
the remote real-machine platform is in remote interaction with the mobile phone and the database and is used for executing the following operations:
for each step of the test case, configuring a script execution statement for each operation event in the step and packaging to obtain a corresponding component; storing the preset components in a database, and storing the mapping relation between the components and the operation events through the database;
for each step of each test case, recording an operation file corresponding to each operation event through a web page, monitoring a corresponding mouse click event for each operation event, forming a corresponding screenshot picture in a click area of the web page on a mouse, performing attribute configuration on the operation event corresponding to the mouse click event through the web page to obtain an operation attribute, and constructing an operation file in a JSON format based on the screenshot picture and the operation attribute;
after the operation files related to all steps in the test case are recorded, matching the components and the operation files based on the mapping relation of the components, the operation events and the operation files, replacing the operation files into script execution statements to obtain a test script in a character string form, and displaying the test script;
for the generated test script, a new modified test script is regenerated in a mode of modifying pictures or sequential logic;
the mapping relations of the components, the operation events and the operation files are stored in a database;
before monitoring a mouse click event, the remote real machine platform is further used for selecting a picture mode through a page service provided by a web page, wherein the picture mode comprises a mobile phone real machine screen mode and a UI picture mode;
in the remote real-time machine platform, when a corresponding screenshot picture is formed in a mouse clicking area of a web page, the remote real-time machine platform comprises two modes which are respectively:
in the first mode, when a left mouse button is clicked to execute a mouse click event, the corresponding operation event type is the click event, and a square screenshot picture with a preset size and with a click point as a center is formed on a web page based on a click area of the mouse;
in the second mode, when a right mouse button is clicked to execute a mouse click event, the corresponding operation event type is other events, a screenshot frame with a click point as a center is formed on a web page based on a click area of the mouse, and a screenshot picture with a required size is formed by selecting a required area through the screenshot frame; the other events include input, wait, scroll, screenshot, search, swipe, and assertion; after a required area is selected through a screenshot frame to form a screenshot picture with a required size, attribute configuration is carried out on an operation event through a toolbar popped up from a web page, wherein the attribute configuration comprises the steps of selecting the name of the operation event through a selection frame and inputting related parameters of the operation event through an input frame;
the remote live-machine platform is used for modifying pictures or sequential logic by the following method:
recording an operation file of an operation event to be modified through a web page to obtain a new operation file;
storing the new operation file through a remote real machine platform, and storing the mapping relation of the component, the operation event and the new operation file through a database;
and replacing the new operation file into a script execution statement to obtain a new test script in a character string form, and displaying the test script through a remote real machine platform.
9. The system for generating test cases and test scripts based on screenshots according to claim 8, wherein the operation file of each operation event in the step is recorded in the remote real-machine platform through a web page, and the method comprises the following steps:
monitoring a mouse click event corresponding to the operation event by a method for monitoring the event;
based on a click area of a mouse, forming a screenshot picture corresponding to the operation event on a web page, wherein the screenshot is stored on the remote real machine and returns a picture ID of the screenshot picture;
performing attribute configuration on the operation event through page service provided by a web page, wherein the attribute configuration comprises selecting an operation name and inputting an operation parameter to obtain an operation attribute corresponding to the operation event;
forming an operation file in the JSON format based on an operation name, a picture ID and operation parameters, recording the corresponding picture ID in the operation file in a picture attribute mode, and storing a mapping relation among the components, the operation event, the picture ID and the operation parameters through a database, wherein the mapping relation takes the operation name as a keyword;
after the operation files related to all steps in the test case are recorded, matching the components and the corresponding operation files through the operation names based on the mapping relation among the components, the operation events, the picture IDs and the operation parameters, and replacing the picture IDs and the operation parameters into corresponding script execution statements to obtain the test scripts in the form of character strings.
10. A medium, being a computer readable medium, characterized in that the computer readable medium has stored thereon computer instructions, which, when executed by a processor, cause the processor to carry out the method according to any one of claims 1-7.
CN202111410835.0A 2021-11-25 2021-11-25 Test case based on screenshot, test script generation method, system and medium Active CN114416516B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111410835.0A CN114416516B (en) 2021-11-25 2021-11-25 Test case based on screenshot, test script generation method, system and medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111410835.0A CN114416516B (en) 2021-11-25 2021-11-25 Test case based on screenshot, test script generation method, system and medium

Publications (2)

Publication Number Publication Date
CN114416516A true CN114416516A (en) 2022-04-29
CN114416516B CN114416516B (en) 2024-09-13

Family

ID=81266131

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111410835.0A Active CN114416516B (en) 2021-11-25 2021-11-25 Test case based on screenshot, test script generation method, system and medium

Country Status (1)

Country Link
CN (1) CN114416516B (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114895884A (en) * 2022-05-20 2022-08-12 深圳市比量科技传媒有限公司 Method and system for compiling and executing RPA script of terminal equipment
CN115237813A (en) * 2022-09-19 2022-10-25 平安银行股份有限公司 Script generation and test method, electronic device and computer storage medium
CN115422093A (en) * 2022-11-03 2022-12-02 易方信息科技股份有限公司 Screenshot effect-improving method, system and medium based on writing case automatic test

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20040107415A1 (en) * 2002-12-03 2004-06-03 Konstantin Melamed Web-interactive software testing management method and computer system including an integrated test case authoring tool
CN105843734A (en) * 2016-03-18 2016-08-10 厦门美图移动科技有限公司 Automatic test method and device and computing device
US20170277625A1 (en) * 2016-03-28 2017-09-28 Alexander Shtuchkin Generating annotated screenshots based on automated tests
CN111104315A (en) * 2019-11-29 2020-05-05 京东数字科技控股有限公司 Test script generation method and device and computer readable storage medium

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20040107415A1 (en) * 2002-12-03 2004-06-03 Konstantin Melamed Web-interactive software testing management method and computer system including an integrated test case authoring tool
CN105843734A (en) * 2016-03-18 2016-08-10 厦门美图移动科技有限公司 Automatic test method and device and computing device
US20170277625A1 (en) * 2016-03-28 2017-09-28 Alexander Shtuchkin Generating annotated screenshots based on automated tests
CN111104315A (en) * 2019-11-29 2020-05-05 京东数字科技控股有限公司 Test script generation method and device and computer readable storage medium

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
吴立金;韩新宇;张凯;唐龙利;: "一种非侵入的GUI自动化测试系统设计", 计算机测量与控制, no. 12, 25 December 2017 (2017-12-25) *

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN114895884A (en) * 2022-05-20 2022-08-12 深圳市比量科技传媒有限公司 Method and system for compiling and executing RPA script of terminal equipment
CN115237813A (en) * 2022-09-19 2022-10-25 平安银行股份有限公司 Script generation and test method, electronic device and computer storage medium
CN115422093A (en) * 2022-11-03 2022-12-02 易方信息科技股份有限公司 Screenshot effect-improving method, system and medium based on writing case automatic test

Also Published As

Publication number Publication date
CN114416516B (en) 2024-09-13

Similar Documents

Publication Publication Date Title
CN110764753B (en) Business logic code generation method, device, equipment and storage medium
WO2019144680A1 (en) Automatic testing method and apparatus, storage medium and electronic device
CN114416516B (en) Test case based on screenshot, test script generation method, system and medium
US9448908B2 (en) System and method for model based session management
US20150339213A1 (en) Automated testing of an application system
CN110018955A (en) Automatic test script is generated by conversion manual test use-case
CN109783388B (en) UI (user interface) automatic testing method and device and electronic equipment
US20140189576A1 (en) System and method for visual matching of application screenshots
US9904517B2 (en) System and method for automatic modeling of an application
US20140218385A1 (en) System and method for visual segmentation of application screenshots
CN101996131A (en) Automatic test method and automatic test platform for graphic user interface (GUI) based on x extensive makeup language (XML) packaging key word
US20060020931A1 (en) Method and apparatus for managing complex processes
CN111966336A (en) Page generation method and device based on VUE and visual graphic operation
JP2010079342A (en) System of generating operation instruction for web application
CN114201144A (en) Micro service system construction method, device and medium based on domain-driven design
CN113448845A (en) UI automation test method and system
Silva et al. A comparative study of milestones for featuring GUI prototyping tools
CN111797340B (en) Service packaging system for user-defined extraction flow
CN114356190A (en) AI visual modeling flow drawing method, system and application based on Web
CN104081347A (en) Graphical representation of an order of operations
CN112667517A (en) Method, device, equipment and storage medium for acquiring automatic test script
US11544179B2 (en) Source traceability-based impact analysis
JP2002014845A (en) Method for automatically generating test script part and device for the same
CN114238072A (en) HIL requirement design method, HIL requirement design device, computer equipment and storage medium
Pulido Applying behavior driven development practices and tools to low-code technology

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
GR01 Patent grant