CN115687093A - Test script generation method, device, equipment and storage medium - Google Patents

Test script generation method, device, equipment and storage medium Download PDF

Info

Publication number
CN115687093A
CN115687093A CN202211250224.9A CN202211250224A CN115687093A CN 115687093 A CN115687093 A CN 115687093A CN 202211250224 A CN202211250224 A CN 202211250224A CN 115687093 A CN115687093 A CN 115687093A
Authority
CN
China
Prior art keywords
information
source code
target
webpage source
control
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
CN202211250224.9A
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.)
Industrial and Commercial Bank of China Ltd ICBC
Original Assignee
Industrial and Commercial Bank of China Ltd ICBC
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 Industrial and Commercial Bank of China Ltd ICBC filed Critical Industrial and Commercial Bank of China Ltd ICBC
Priority to CN202211250224.9A priority Critical patent/CN115687093A/en
Publication of CN115687093A publication Critical patent/CN115687093A/en
Pending legal-status Critical Current

Links

Images

Landscapes

  • Debugging And Monitoring (AREA)

Abstract

The disclosure provides a test script generation method, a test script generation device and a storage medium, which can be applied to the technical field of testing and the technical field of finance. The method comprises the following steps: after the version of the application program in the target page is upgraded, acquiring first webpage source code information and second webpage source code information of the target page, wherein the first webpage source code information represents webpage source code information before the version of the application program is upgraded, and the second webpage source code information represents webpage source code information after the version of the application program is upgraded; determining control change information of a target page and link address information corresponding to the control change information according to the first webpage source code information and the second webpage source code information; determining a target script according to the link address information; and according to the control change information, executing change operation aiming at the target script to generate a test script.

Description

Test script generation method, device, equipment and storage medium
Technical Field
The present disclosure relates to the field of testing technologies and financial technologies, and in particular, to a method, an apparatus, a device, a medium, and a program product for generating a test script.
Background
In the process of using a QTP (Quick Test Professional) script to develop an automated Test, the recorded and valid QTP script is interrupted due to the inability to identify a newly added field object or the like due to changes in each field or value logic in a service interaction page caused by the update of each application version.
In the related art, generally, after an error is reported when a script is executed, a tester manually intervenes to check the reason of script interruption, and corrects the script in time to ensure the usability of the script. In order to ensure the validity of the QTP script, the testing work of each version requires a tester to perform backtracking inspection on the script, so that the testing efficiency is low.
Disclosure of Invention
In view of the foregoing, the present disclosure provides a test script generation method, apparatus, device, medium, and program product.
According to an aspect of the present disclosure, there is provided a test script generation method, including:
after the version of the application program in the target page is upgraded, acquiring first webpage source code information and second webpage source code information of the target page, wherein the first webpage source code information represents webpage source code information before the version of the application program is upgraded, and the second webpage source code information represents webpage source code information after the version of the application program is upgraded;
determining control change information of a target page and link address information corresponding to the control change information according to the first webpage source code information and the second webpage source code information;
determining a target script according to the link address information;
and according to the control change information, executing change operation aiming at the target script to generate a test script.
According to the embodiment of the disclosure, the control change information includes type information of the control, and according to the control change information, a test script is generated by executing change operation aiming at the target script, including:
determining step information of change operation according to the type information of the control;
and generating a test script by executing change operation according to the control change information and the step information.
According to the embodiment of the disclosure, the step information of the change operation is determined according to the type information of the control, and the step information comprises the following steps:
determining that the step information of the change operation is the information of the control change step under the condition that the type information of the control is the input type control;
and under the condition that the type information of the control is the selection type control, determining that the step information of the change operation comprises information of a control change step and information of a control parameter change step.
According to the embodiment of the disclosure, generating a test script by executing change operation according to the step information and the control change information includes:
determining target field information from the target script according to the control change information;
determining target parameter information from a test database according to the control change information;
and according to the step information, executing change operation aiming at the target script according to the target field information and the target parameter information, and generating the test script.
According to the embodiment of the disclosure, according to the step information, according to the target field information and the target parameter information, the change operation is executed for the target script, and the test script is generated, including:
according to the step information, changing parameter information in the target field information according to the target parameter information to obtain changed target field information;
and generating a test script according to the changed target field information.
According to the embodiment of the disclosure, determining control change information of a target page and link address information corresponding to the control change information according to first webpage source code information and second webpage source code information includes:
calculating a first hash value of the first webpage source code information by using a hash algorithm according to the first webpage source code information;
calculating a second hash value of the second webpage source code information by using a hash algorithm according to the second webpage source code information;
generating control change information of the target page according to the first hash value and the second hash value;
and determining link address information from the second webpage source code information according to the control change information of the target page.
According to the embodiment of the disclosure, determining link address information from the second webpage source code information according to the control change information of the target page includes:
classifying according to the page function according to the control change information of the target page to obtain changed page function information;
and determining link address information from the second webpage source code information according to the changed page function information.
According to an embodiment of the present disclosure, the test script generating method further includes:
obtaining test script operation result information by operating the test script;
receiving manually marked control change information under the condition that the test script operation result information is operation failure;
and executing the change operation aiming at the target script according to the manually marked control change information, and generating the changed test script.
Another aspect of the present disclosure provides a test script generating apparatus, including: the device comprises an acquisition module, a first determination module, a second determination module and a generation module. The acquisition module is used for acquiring first webpage source code information and second webpage source code information of a target page after the version of an application program in the target page is upgraded, wherein the first webpage source code information represents webpage source code information before the version of the application program is upgraded, and the second webpage source code information represents webpage source code information after the version of the application program is upgraded. And the first determining module is used for determining the control change information of the target page and the link address information corresponding to the control change information according to the first webpage source code information and the second webpage source code information. And the second determining module is used for determining the target script according to the link address information. And the generating module is used for executing change operation aiming at the target script according to the control change information to generate the test script.
According to an embodiment of the present disclosure, the generation module includes a first determination submodule and a first generation submodule. And the first determining submodule is used for determining step information of the change operation according to the type information of the control. And the first generation submodule is used for generating a test script by executing change operation according to the step information and the control change information.
According to an embodiment of the present disclosure, the first determination submodule includes a first determination unit and a second determination unit. The first determining unit is used for determining that the step information of the change operation is the information of the control change step under the condition that the type information of the control is the input type control. And the second determining unit is used for determining that the step information of the change operation comprises information of the control change step and information of the control parameter change step under the condition that the type information of the control is the selection type control.
According to an embodiment of the present disclosure, the first generation submodule includes a third determination unit, a fourth determination unit, and a first generation unit. And the third determining unit is used for determining target field information from the target script according to the control change information. And the fourth determining unit is used for determining the target parameter information from the test database according to the control change information. And the first generating unit is used for executing change operation aiming at the target script according to the step information and the target field information and the target parameter information to generate the test script.
According to an embodiment of the present disclosure, the first generation unit includes an obtaining subunit and a generation subunit. And the acquiring subunit is used for changing the parameter information in the target field information according to the step information and the target parameter information to obtain the changed target field information. And the generating subunit is used for generating a test script according to the changed target field information.
According to an embodiment of the present disclosure, the first determination module includes a first calculation submodule, a second generation submodule, and a second determination submodule. The first calculation submodule is used for calculating a first hash value of the first webpage source code information by using a hash algorithm according to the first webpage source code information. And the second calculation sub-module is used for calculating a second hash value of the second webpage source code information by using a hash algorithm according to the second webpage source code information. And the second generation submodule is used for generating control change information of the target page according to the first hash value and the second hash value. And the second determining submodule is used for determining link address information from the second webpage source code information according to the control change information of the target page.
According to an embodiment of the present disclosure, the second determination submodule includes an obtaining unit and a fifth determination unit. The obtaining unit is used for classifying according to the control change information of the target page and the page function to obtain the changed page function information. And the fifth determining unit is used for determining the link address information from the second webpage source code information according to the changed page function information.
According to an embodiment of the present disclosure, the test script generating apparatus further includes an obtaining module, a receiving module, and a second generating module. The obtaining module is used for obtaining the test script operation result information by operating the test script. And the receiving module is used for receiving manually marked control change information under the condition that the test script operation result information is operation failure. And the second generation module is used for executing the change operation aiming at the target script according to the manually marked control change information and generating the changed test script.
Another aspect of the present disclosure provides an electronic device including: one or more processors; memory for storing one or more programs, wherein the one or more programs, when executed by the one or more processors, cause the one or more processors to perform the above-described method.
Another aspect of the present disclosure also provides a computer-readable storage medium having stored thereon executable instructions that, when executed by a processor, cause the processor to perform the above-described method.
Another aspect of the disclosure also provides a computer program product comprising a computer program which, when executed by a processor, implements the above method.
According to the embodiment of the disclosure, after the version of the application program in the target page is upgraded, the first webpage source code information and the second webpage source code information of the target page are obtained, the control change information of the target page and the link address information corresponding to the control change information are determined according to the first webpage source code information and the second webpage source code information, the target script is determined according to the link address information, and finally the change operation is executed according to the target script according to the control change information, so that the test script is generated. The method comprises the steps of obtaining webpage source code information before and after the version of the application program in the target page is upgraded, comparing the webpage source code information before and after the version of the application program in the target page, determining control change information and a target script, and finally executing change operation aiming at the target script according to the control change information to generate a test script.
Drawings
The foregoing and other objects, features and advantages of the disclosure will be apparent from the following description of embodiments of the disclosure, which proceeds with reference to the accompanying drawings, in which:
FIG. 1 schematically illustrates an application scenario diagram of a test script generation method, apparatus, device, medium, and program product according to embodiments of the disclosure;
FIG. 2 schematically illustrates a flow chart of a test script generation method according to an embodiment of the present disclosure;
FIG. 3 schematically illustrates a flow diagram for generating a test script according to an embodiment of the present disclosure;
FIG. 4 schematically illustrates a flowchart for determining control change information and link address information corresponding to the control change information for a target page according to an embodiment of the disclosure;
FIG. 5 is a block diagram schematically illustrating a structure of a test script generating apparatus according to an embodiment of the present disclosure; and
FIG. 6 schematically shows a block diagram of an electronic device adapted to implement a test script generation method according to an embodiment of the present disclosure.
Detailed Description
Hereinafter, embodiments of the present disclosure will be described with reference to the accompanying drawings. It should be understood that the description is illustrative only and is not intended to limit the scope of the present disclosure. In the following detailed description, for purposes of explanation, numerous specific details are set forth in order to provide a thorough understanding of the embodiments of the disclosure. It may be evident, however, that one or more embodiments may be practiced without these specific details. Moreover, in the following description, descriptions of well-known structures and techniques are omitted so as to not unnecessarily obscure the concepts of the present disclosure.
The terminology used herein is for the purpose of describing particular embodiments only and is not intended to be limiting of the disclosure. The terms "comprises," "comprising," and the like, as used herein, specify the presence of stated features, steps, operations, and/or components, but do not preclude the presence or addition of one or more other features, steps, operations, or components.
All terms (including technical and scientific terms) used herein have the same meaning as commonly understood by one of ordinary skill in the art unless otherwise defined. It is noted that the terms used herein should be interpreted as having a meaning that is consistent with the context of this specification and should not be interpreted in an idealized or overly formal sense.
In those instances where a convention analogous to "at least one of A, B, and C, etc." is used, in general such a construction is intended in the sense one having skill in the art would understand the convention (e.g., "a system having at least one of A, B, and C" would include but not be limited to systems that have A alone, B alone, C alone, A and B together, A and C together, B and C together, and/or A, B, and C together, etc.).
In the process of implementing the present disclosure, it is found that, in the process of using the OTP script to launch the automated testing, due to the change of each field or value logic in the service interaction page caused by the update of each application version, the execution of the recorded and effective QTP script is interrupted due to the inability to identify the newly added field object, and the like. In the related art, after an error is reported when a script is executed, a tester manually intervenes to check the reason of the interruption of the script and timely corrects the interruption of the script to ensure the usability of the script. In order to ensure the validity of the QTP script, the testing work of each version requires a tester to perform backtracking inspection on the script, so that the testing efficiency is low.
Therefore, an embodiment of the present disclosure provides a test script generation method, including: after the version of the application program in the target page is upgraded, acquiring first webpage source code information and second webpage source code information of the target page, wherein the first webpage source code information represents webpage source code information before the version of the application program is upgraded, and the second webpage source code information represents webpage source code information after the version of the application program is upgraded; determining control change information of a target page and link address information corresponding to the control change information according to the first webpage source code information and the second webpage source code information; determining a target script according to the link address information; and according to the control change information, executing change operation aiming at the target script to generate a test script case.
Fig. 1 schematically shows an application scenario diagram of a test script generation method according to an embodiment of the present disclosure.
As shown in fig. 1, the application scenario 100 according to this embodiment may include terminal devices 101, 102, 103, a network 104, and a server 105. Network 104 is the medium used to provide communication links between terminal devices 101, 102, 103 and server 105. Network 104 may include various connection types, such as wired, wireless communication links, or fiber optic cables, to name a few.
A user may use terminal devices 101, 102, 103 to interact with a server 105 over a network 104 to receive or send messages or the like. The terminal devices 101, 102, 103 may have installed thereon various communication client applications, such as shopping-like applications, web browser applications, search-like applications, instant messaging tools, mailbox clients, social platform software, etc. (by way of example only).
The terminal devices 101, 102, 103 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop portable computers, desktop computers, and the like.
For example, after the version of the application program in the target page is upgraded, the terminal devices 101, 102, and 103 may obtain first webpage source code information and second webpage source code information of the target page, determine control change information of the target page and link address information corresponding to the control change information according to the first webpage source code information and the second webpage source code information, determine the target script according to the link address information, and finally perform a change operation on the target script according to the control change information to generate the test script.
The server 105 may be a server providing various services, such as a background management server (for example only) providing support for websites browsed by users using the terminal devices 101, 102, 103. The backend management server may analyze and process the received data such as the user request, and feed back a processing result (for example, a web page, information, or data obtained or generated according to the user request) to the terminal device.
It should be noted that the test script generation method provided by the embodiment of the present disclosure may be generally executed by the server 105. Accordingly, the test script generating apparatus provided by the embodiment of the present disclosure may be generally disposed in the server 105. The test script generation method provided by the embodiment of the present disclosure may also be executed by a server or a server cluster that is different from the server 105 and is capable of communicating with the terminal devices 101, 102, 103 and/or the server 105. Accordingly, the test script generating apparatus provided in the embodiment of the present disclosure may also be disposed in a server or a server cluster different from the server 105 and capable of communicating with the terminal devices 101, 102, 103 and/or the server 105.
It should be understood that the number of terminal devices, networks, and servers in fig. 1 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
The test script generation method of the disclosed embodiment will be described in detail below with fig. 2 to 4 based on the scenario described in fig. 1.
FIG. 2 schematically shows a flow chart of a test script generation method according to an embodiment of the present disclosure.
As shown in FIG. 2, the test script generating method 200 of this embodiment includes operations S210 to S240.
In operation S210, after the version of the application program in the target page is upgraded, first webpage source code information and second webpage source code information of the target page are obtained, where the first webpage source code information represents webpage source code information before the version of the application program is upgraded, and the second webpage source code information represents webpage source code information after the version of the application program is upgraded.
According to an embodiment of the present disclosure, the first web page source code information and the second web page source code information may include names, tags, dictionary entry input logic, and the like of respective front-end components in the web page source code.
According to an embodiment of the present disclosure, the front-end component may include input (input component information), select (select component information), time (set storage time component information), radio (radio component information), href (hypertext reference component information), and other controls.
According to an embodiment of the present disclosure, after the version upgrade of the application program in the target page, acquiring the first webpage source code information before the version upgrade of the application program in the target page may include: input component information, the second webpage source code information after upgrading may include: input component information, select component information.
In operation S220, control change information of the target page and link address information corresponding to the control change information are determined according to the first webpage source code information and the second webpage source code information.
According to the embodiment of the disclosure, the control change information of the target page may include addition, modification and deletion of a control in the target page.
According to an embodiment of the present disclosure, the link address information may include a web page link. The link address information corresponding to the control change information may include a web page link in which a control is newly added, modified, or deleted in the target page.
According to an embodiment of the present disclosure, acquiring the first web page source code information before the version upgrade of the application program in the target page may include: input component information, the second webpage source code information after upgrading may include: and the select component information can determine that the input component information in the target page is modified into the select component information and the webpage link corresponding to the modified select component information.
According to an embodiment of the present disclosure, acquiring the first web page source code information before the version upgrade of the application program in the target page may include: the input component information and the select component information, and the second webpage source code information after being upgraded may include: the input component information can determine that the select component information is deleted in the target page and the webpage link corresponding to the deleted select component information.
According to an embodiment of the present disclosure, acquiring the first web page source code information before the version upgrade of the application program in the target page may include: input component information, the second webpage source code information after upgrading may include: the input component information and the select component information can determine that select component information is newly added in the target page and a webpage link corresponding to the newly added select component information.
In operation S230, a target script is determined according to the link address information.
According to an embodiment of the present disclosure, the target script may include a script corresponding to a web page link that the control needs to be changed.
According to an embodiment of the present disclosure, acquiring the first web page source code information before the version upgrade of the application program in the target page may include: input component information, the second webpage source code information after upgrading may include: the input component information and the select component information can determine that select component information is newly added in the target page and a webpage link corresponding to the newly added select component information. And determining a script corresponding to the webpage link according to the webpage link corresponding to the newly added select component information. In operation S240, a test script is generated by performing a change operation with respect to the target script according to the control change information.
According to an embodiment of the present disclosure, acquiring the first web page source code information before the version upgrade of the application program in the target page may include: input component information, the second webpage source code information after upgrading may include: the input component information and the select component information can determine that select component information is newly added in a target page and a script corresponding to a webpage link of the control needing the new select component information, and for the script corresponding to the webpage link of the control needing the new select component information, change operation corresponding to the newly added select component information is performed on the script according to the newly added select component information, so that a test script is generated.
According to the embodiment of the disclosure, after the version of the application program in the target page is upgraded, the first webpage source code information and the second webpage source code information of the target page are obtained, the control change information of the target page and the link address information corresponding to the control change information are determined according to the first webpage source code information and the second webpage source code information, the target script is determined according to the link address information, and finally the change operation is executed according to the target script according to the control change information, so that the test script is generated. Therefore, after the version of the application program in the target page is upgraded, the webpage source code information before and after the version of the application program in the target page is upgraded is obtained, the control change information and the target script are determined by comparing the webpage source code information before and after the version of the application program in the target page, and finally, the change operation is executed aiming at the target script according to the control change information to generate the test script.
FIG. 3 schematically shows a flow diagram for generating a test script according to an embodiment of the present disclosure.
As shown in FIG. 3, generating a test script 300 of this embodiment includes operations S310 through S320.
In operation S310, step information of the change operation is determined according to the type information of the control.
According to an embodiment of the disclosure, the type information of the control may include an input control and a selection control, wherein the input control may include input and Stime, and the selection control may include select and radio.
In operation S320, a test script is generated by performing a change operation according to the control change information and the step information.
According to the embodiment of the disclosure, according to the new select component information in the target page and the script corresponding to the webpage link of the control requiring the new select component information, aiming at the script corresponding to the webpage link of the control requiring the new select component information, according to the new select component information and the new select component information being the type of the selective control, the script is changed corresponding to the new select component information and the selective control, and therefore the test script is generated.
According to the embodiment of the disclosure, the step information of the change operation is determined according to the type information of the control, so that the test script is generated by executing the change operation according to the step information and the change information of the control, the specific change operation step is determined according to the different types of information of the control, the change operation is executed on the script, the optimized script is generated, and meanwhile, the optimized script can be output as a test script case.
According to the embodiment of the disclosure, the step information of the change operation is determined according to the type information of the control, and the step information comprises the following steps: determining the step information of the change operation as the information of the control change step under the condition that the type information of the control is the input type control; and under the condition that the type information of the control is a selection type control, determining that the step information of the change operation comprises information of a control change step and information of a control parameter change step.
According to an embodiment of the disclosure, the input type control may include an input, a time, and other controls, for example, for the addition of the input and time controls, an inserted statement is input using an input method. For input-type controls, the step of altering the operation may include adding or deleting control statements.
According to an embodiment of the present disclosure, acquiring the first web page source code information before the version upgrade of the application program in the target page may include: input component information, the second webpage source code information after upgrading may include: the input component information and the Stime component information can determine that the Stime component information and the script corresponding to the webpage link of the control needing the new Stime component information are newly added in the target page, and for the script corresponding to the webpage link of the control needing the new Stime component information, change operation corresponding to the newly added Stime component information is carried out on the script according to the newly added Stime component information and the Stime which are input controls, and the control statement corresponding to the newly added Stime component information is added.
According to the embodiment of the disclosure, the selection type controls can include a select control, a radio control and the like, wherein the selection type controls can be divided into several categories such as text, numbers, dates, dictionary options and the like according to basic types. For example, for select, radio controls, a select method is used for input. And for the original object, if the select and the radio control have options of adding or changing the dictionary value, recording the options into a dictionary value table change table. For a selection-type control, the operation of the change operation may include adding or deleting a control statement and changing a selectable parameter of the control. According to an embodiment of the present disclosure, the step information of the change operation may include an operation of assigning a value to the control change information, for example, for a newly added control, for example, when a newly added control occurs in one or more types of input component information, select component information, stime component information, and radio component information, a corresponding script statement is added to the current script. And inputting the inserted statement by using an input method for newly adding input and Stime controls, inputting select and radio controls by using a select method, and defining parameters by using the input value according to standard assignment in the test data sample library according to the type information of the controls. And for the original object, if the select and the radio control have options of adding or changing the dictionary value, recording the options into a dictionary value table change table. Meanwhile, under the condition that the deleted or modified page control is used in the current script, the corresponding statement in the script is synchronously deleted or modified, and under the condition that the deleted or modified page control is not used in the current script, the processing is not needed.
According to the embodiment of the disclosure, when the type information of the control is the input type control, the step information of the change operation is determined to be the information of the control change step, and when the type information of the control is the selection type control, the step information of the change operation is determined to comprise the information of the control change step and the information of the control parameter change step, so that different change operation steps are executed according to different control type information, and the updating efficiency of the test script is improved.
According to the embodiment of the disclosure, generating a test script by executing change operation according to the control change information and the step information, comprises: determining target field information from the target script according to the control change information; determining target parameter information from a test database according to the control change information; and according to the step information, executing change operation aiming at the target script according to the target field information and the target parameter information, and generating the test script.
According to an embodiment of the present disclosure, the target field information may include a field that needs to be changed and corresponds to a field in the target page where a control is newly added, deleted, or modified, for example, acquiring the first webpage source code information before the version of the application program in the target page is upgraded may include: input component information, the second webpage source code information after upgrading may include: the input component information and the select component information can determine that select component information is newly added in the target page and the webpage link corresponding to the newly added select component information. And determining a script corresponding to the web page link according to the web page link corresponding to the newly added select component information, and determining target field information according to a field needing to be changed, which corresponds to the newly added select component information, in the target page in the script.
According to the embodiment of the disclosure, the controls can be classified into several categories, such as text, numbers, dates, dictionary options and the like, basically according to types, and the common test values of the above items in a specific business field are relatively fixed. Therefore, a test database is manually established, and standard assignments of the above components are defined.
According to an embodiment of the present disclosure, the target parameter information may include standard assignments obtained from a test database for parameter definition according to the type information of the control. For example, for the original script, if the select and radio controls have options of adding or changing dictionary values, the new or changed dictionary values are recorded in the dictionary value table change table. For the records present in the dictionary-value table change table, the first one of the dictionary values is used as a parameter value by default.
According to the embodiment of the disclosure, the target field information is determined from the target script according to the control change information, the target parameter information is determined from the test database, and the change operation is executed for the target script according to the target field information and the target parameter information according to the step information to generate the test script.
According to the embodiment of the disclosure, according to the step information, according to the target field information and the target parameter information, the change operation is executed for the target script, and the test script is generated, including: according to the step information, changing parameter information in the target field information according to the target parameter information to obtain changed target field information; and generating a test script according to the changed target field information.
According to an embodiment of the present disclosure, acquiring the first webpage source code information before the version upgrade of the application program in the target page may include: input component information, the second webpage source code information after upgrading may include: the input component information and the select component information can determine that select component information is newly added in the target page and a webpage link corresponding to the newly added select component information. And determining a script corresponding to the web page link according to the web page link corresponding to the newly added select component information, and determining target field information according to a field needing to be changed, corresponding to the newly added select component information, in the target page in the script. And according to the fact that the newly added select component is a selection type component, the operation of the change operation can comprise adding a control statement corresponding to the newly added select component information and changing the selectable parameters of the control, wherein the selectable parameters of the control are defined by selecting standard assignment values in the test database according to the type of the newly added select component information. For example, the newly added select component information is a dictionary value option, standard assignment in the dictionary value option in the test database is taken for parameter definition, and the obtained dictionary value or parameter value is assigned to the field of the change control to obtain the changed field.
According to the embodiment of the disclosure, according to the step information, the parameter information in the target field information is changed according to the target parameter information, so that the changed target field information is obtained, the test script is generated according to the changed target field information, the assignment of the dictionary value or the parameter value to the field of the change control is realized, the changed field is obtained, the related change operation is performed on the target script in a targeted manner, and the updating speed of the test script is improved.
Fig. 4 schematically illustrates a flowchart of determining control change information and link address information corresponding to the control change information of a target page according to an embodiment of the present disclosure.
As shown in fig. 4, the determining of the control change information of the target page and the link address information 400 corresponding to the control change information of the embodiment includes operations S410 to S440.
In operation S410, a first hash value of the first webpage source code information is calculated using a hash algorithm according to the first webpage source code information.
According to the embodiment of the disclosure, the full amount of the webpage source codes is obtained based on a certain period of version, the webpage source codes are downloaded to obtain first webpage source code information, a first hash value of the first webpage source code information is calculated and serves as an analysis basis, and the first webpage source code information represents the webpage source code information before the version of the application program is upgraded.
In operation S420, a second hash value of the second webpage source code information is calculated by using a hash algorithm according to the second webpage source code information.
According to the embodiment of the disclosure, after each version is delivered to the test environment, the latest version of the webpage source code is downloaded to obtain second webpage source code information, and a second hash value of the second webpage source code information is calculated, wherein the second webpage source code information represents the updated webpage source code information of the application program version.
In operation S430, control change information of the target page is generated according to the first hash value and the second hash value.
According to the embodiment of the disclosure, under the condition that the first hash value and the second hash value are different, the front-end page changes, controls such as input, select, stime, radio, href and the like in the source code are compared in a full-scale mode, page links, function names, newly-added/modified/deleted marks and the like are recorded, the page links, the function names, the newly-added/modified/deleted marks and the like are output as a version page function update table, and control change information of a target page is generated.
In operation S440, link address information is determined from the second webpage source code information according to the control change information of the target page.
According to an embodiment of the present disclosure, acquiring the first web page source code information before the version upgrade of the application program in the target page may include: input component information, the second webpage source code information after upgrading may include: the input component information and the select component information can determine that select component information is newly added in the target page and a webpage link corresponding to the newly added select component information.
According to the embodiment of the disclosure, according to the first webpage source code information, the first hash value of the first webpage source code information is calculated by using a hash algorithm, according to the second webpage source code information, the second hash value of the second webpage source code information is calculated by using the hash algorithm, and the control change information of the target page is generated according to the first hash value and the second hash value, so that the link address information is determined from the second webpage source code information according to the control change information of the target page, and the control change information is directly determined from the webpage source code by using the hash algorithm, so that the target script needing to be changed is determined in a targeted manner.
According to the embodiment of the disclosure, determining link address information from the second webpage source code information according to the control change information of the target page includes: classifying according to the page functions and the control change information of the target page to obtain changed page function information; and determining link address information from the second webpage source code information according to the changed page function information.
According to the embodiment of the disclosure, the fully acquired webpage source code includes different functional pages, for example, the fully acquired webpage source code includes pages with four functions of a, B, C, and D, and the webpage source code is classified according to the four functions of a, B, C, and D. The obtaining of the first webpage source code information before the version upgrade of the application program in the target page may include: input component information, the second webpage source code information after upgrading may include: the method comprises the steps of inputting component information and select component information, wherein the page of the inputting component information is an A function, the page of the select component information is a B function, the select component information can be determined to be newly added in a target page, the upgraded second webpage source code information is divided into an A function page and a B function page according to the page functions, changed page function information is obtained, and page links of the B function page are determined from the upgraded second webpage source code information according to the changed page function information.
According to the embodiment of the disclosure, the changed page function information is obtained by classifying according to the page functions according to the control change information of the target page, and the link address information is determined from the second webpage source code information according to the changed page function information, so that the link address corresponding to the changed page function is determined by classifying according to the page functions according to the control change information.
According to an embodiment of the present disclosure, the test script generating method further includes: obtaining test script operation result information by operating the test script; receiving manually marked control change information under the condition that the test script operation result information is operation failure; and executing the change operation aiming at the target script according to the manually marked control change information, and generating the changed test script.
According to the embodiment of the disclosure, the test script running result information can represent whether the script runs successfully or not.
According to the embodiment of the disclosure, the test cases are synchronously output under the condition that the test script operation result information represents that the script is successfully operated. And under the condition that the test script operation result information represents the operation failure, outputting a change list of the script page and analyzing error reporting reasons for a tester to review, executing change operation aiming at the target script according to the manually marked control change information, and generating a changed test script.
According to the embodiment of the disclosure, test script operation result information is obtained by operating the test script; receiving manually marked control change information under the condition that the test script operation result information is operation failure; according to the manually marked control change information, the change operation aiming at the target script is executed, and the changed test script is generated, so that the script is updated according to the manually marked change information under the condition that the operation of the automatic update script fails.
Based on the test script generation method, the disclosure also provides a test script generation device. The apparatus will be described in detail below with reference to fig. 5.
Fig. 5 schematically shows a block diagram of a test script generation apparatus according to an embodiment of the present disclosure.
As shown in fig. 5, the test script generating apparatus 500 of this embodiment includes an obtaining module 510, a first determining module 520, a second determining module 530, and a generating module 540.
The obtaining module 510 is configured to obtain first webpage source code information and second webpage source code information of a target page after a version of an application program in the target page is upgraded, where the first webpage source code information represents webpage source code information before the version of the application program is upgraded, and the second webpage source code information represents webpage source code information after the version of the application program is upgraded. In an embodiment, the obtaining module 510 may be configured to perform the operation S210 described above, which is not described herein again.
The first determining module 520 is configured to determine control change information of the target page and link address information corresponding to the control change information according to the first webpage source code information and the second webpage source code information. In an embodiment, the first determining module 520 may be configured to perform the operation S220 described above, which is not described herein again.
The second determining module 530 is configured to determine the target script according to the link address information. In an embodiment, the second determining module 530 may be configured to perform the operation S230 described above, which is not described herein again.
The generating module 540 is configured to generate a test script by executing a change operation for the target script according to the control change information. In an embodiment, the generating module 540 may be configured to perform the operation S240 described above, which is not described herein again.
According to an embodiment of the present disclosure, the generating module 540 includes a first determining submodule and a first generating submodule. And the first determining submodule is used for determining step information of the change operation according to the type information of the control. And the first generation submodule is used for generating a test script by executing change operation according to the step information and the control change information.
According to an embodiment of the present disclosure, the first determination submodule includes a first determination unit and a second determination unit. The first determining unit is used for determining that the step information of the changing operation is the information of the control changing step under the condition that the type information of the control is the input type control. And the second determining unit is used for determining that the step information of the change operation comprises information of the control change step and information of the control parameter change step under the condition that the type information of the control is the selection type control.
According to an embodiment of the present disclosure, the first generation submodule includes a third determination unit, a fourth determination unit, and a first generation unit. And the third determining unit is used for determining the target field information from the target script according to the control change information. And the fourth determining unit is used for determining the target parameter information from the test database according to the control change information. And the first generating unit is used for executing change operation aiming at the target script according to the step information and the target field information and the target parameter information to generate the test script.
According to an embodiment of the present disclosure, the first generation unit includes an obtaining subunit and a generation subunit. And the acquiring subunit is used for changing the parameter information in the target field information according to the step information and the target parameter information to obtain the changed target field information. And the generating subunit is used for generating a test script according to the changed target field information.
According to an embodiment of the present disclosure, the first determining module 520 includes a first calculating submodule, a second generating submodule, and a second determining submodule. The first calculation submodule is used for calculating a first hash value of the first webpage source code information by using a hash algorithm according to the first webpage source code information. And the second calculation submodule is used for calculating a second hash value of the second webpage source code information by using a hash algorithm according to the second webpage source code information. And the second generation submodule is used for generating control change information of the target page according to the first hash value and the second hash value. And the second determining submodule is used for determining link address information from the second webpage source code information according to the control change information of the target page.
According to an embodiment of the present disclosure, the second determination submodule includes an obtaining unit and a fifth determination unit. The obtaining unit is used for classifying according to the control change information of the target page and the page function to obtain changed page function information. And the fifth determining unit is used for determining the link address information from the second webpage source code information according to the changed page function information.
According to an embodiment of the present disclosure, the test script generating apparatus 500 further includes an obtaining module, a receiving module, and a second generating module. The obtaining module is used for obtaining test script operation result information by operating the test script. And the receiving module is used for receiving manually marked control change information under the condition that the test script operation result information is operation failure. And the second generation module is used for executing the change operation aiming at the target script according to the manually marked control change information and generating the changed test script.
According to an embodiment of the present disclosure, any plurality of the obtaining module 510, the first determining module 520, the second determining module 530, and the generating module 540 may be combined and implemented in one module, or any one of the modules may be split into a plurality of modules. Alternatively, at least part of the functionality of one or more of these modules may be combined with at least part of the functionality of other modules and implemented in one module. According to an embodiment of the present disclosure, at least one of the obtaining module 510, the first determining module 520, the second determining module 530, and the generating module 540 may be implemented at least partially as a hardware circuit, such as a Field Programmable Gate Array (FPGA), a Programmable Logic Array (PLA), a system on a chip, a system on a substrate, a system on a package, an Application Specific Integrated Circuit (ASIC), or may be implemented by hardware or firmware in any other reasonable manner of integrating or packaging a circuit, or implemented by any one of three implementations of software, hardware, and firmware, or implemented by a suitable combination of any several of them. Alternatively, at least one of the obtaining module 510, the first determining module 520, the second determining module 530 and the generating module 540 may be at least partially implemented as a computer program module, which when executed may perform a corresponding function.
FIG. 6 schematically shows a block diagram of an electronic device adapted to implement a test script generation method according to an embodiment of the present disclosure.
As shown in fig. 6, an electronic device 600 according to an embodiment of the present disclosure includes a processor 601 that can perform various appropriate actions and processes according to a program stored in a Read Only Memory (ROM) 602 or a program loaded from a storage section 608 into a Random Access Memory (RAM) 603. Processor 601 may include, for example, a general purpose microprocessor (e.g., a CPU), an instruction set processor and/or associated chipset, and/or a special purpose microprocessor (e.g., an Application Specific Integrated Circuit (ASIC)), among others. The processor 601 may also include onboard memory for caching purposes. Processor 601 may include a single processing unit or multiple processing units for performing different actions of a method flow according to embodiments of the disclosure.
In the RAM 603, various programs and data necessary for the operation of the electronic apparatus 600 are stored. The processor 601, the ROM 602, and the RAM 603 are connected to each other via a bus 604. The processor 601 performs various operations of the method flows according to the embodiments of the present disclosure by executing programs in the ROM 602 and/or RAM 603. Note that the programs may also be stored in one or more memories other than the ROM 602 and RAM 603. The processor 601 may also perform various operations of the method flows according to embodiments of the present disclosure by executing programs stored in the one or more memories.
Electronic device 600 may also include input/output (I/O) interface 605, input/output (I/O) interface 605 also connected to bus 604, according to an embodiment of the present disclosure. The electronic device 600 may also include one or more of the following components connected to the I/O interface 605: an input portion 606 including a keyboard, a mouse, and the like; an output portion 607 including a display such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, and a speaker; a storage section 608 including a hard disk and the like; and a communication section 609 including a network interface card such as a LAN card, a modem, or the like. The communication section 609 performs communication processing via a network such as the internet. The driver 610 is also connected to the I/O interface 605 as needed. A removable medium 611 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 610 as necessary, so that a computer program read out therefrom is mounted in the storage section 608 as necessary.
The present disclosure also provides a computer-readable storage medium, which may be embodied in the device/apparatus/system described in the above embodiments; or may exist separately and not be assembled into the device/apparatus/system. The computer-readable storage medium carries one or more programs which, when executed, implement a method according to an embodiment of the disclosure.
According to embodiments of the present disclosure, the computer-readable storage medium may be a non-volatile computer-readable storage medium, which may include, for example but is not limited to: a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present disclosure, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. For example, according to an embodiment of the present disclosure, a computer-readable storage medium may include ROM 602 and/or RAM 603 and/or one or more memories other than ROM 602 and RAM 603 described above.
Embodiments of the present disclosure also include a computer program product comprising a computer program containing program code for performing the method illustrated by the flow chart. When the computer program product runs in a computer system, the program code is used for causing the computer system to realize the item recommendation method provided by the embodiment of the disclosure.
The computer program performs the above-described functions defined in the system/apparatus of the embodiments of the present disclosure when executed by the processor 601. The systems, apparatuses, modules, units, etc. described above may be implemented by computer program modules according to embodiments of the present disclosure.
In one embodiment, the computer program may be hosted on a tangible storage medium such as an optical storage device, a magnetic storage device, or the like. In another embodiment, the computer program may also be transmitted, distributed in the form of signals over a network medium, downloaded and installed via the communication section 609, and/or installed from a removable medium 611. The computer program containing program code may be transmitted using any suitable network medium, including but not limited to: wireless, wired, etc., or any suitable combination of the foregoing.
In such an embodiment, the computer program may be downloaded and installed from a network through the communication section 609, and/or installed from the removable medium 611. The computer program, when executed by the processor 601, performs the above-described functions defined in the system of the embodiments of the present disclosure. The systems, devices, apparatuses, modules, units, etc. described above may be implemented by computer program modules according to embodiments of the present disclosure.
In accordance with embodiments of the present disclosure, program code for executing computer programs provided by embodiments of the present disclosure may be written in any combination of one or more programming languages, and in particular, these computer programs may be implemented using high level procedural and/or object oriented programming languages, and/or assembly/machine languages. The programming language includes, but is not limited to, programming languages such as Java, C + +, python, the "C" language, or the like. The program code may execute entirely on the user computing device, partly on the user device, partly on a remote computing device, or entirely on the remote computing device or server. In situations involving remote computing devices, the remote computing devices may be connected to the user computing device through any kind of network, including a Local Area Network (LAN) or a Wide Area Network (WAN), or may be connected to external computing devices (e.g., through the internet using an internet service provider).
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
Those skilled in the art will appreciate that various combinations and/or combinations of features recited in the various embodiments and/or claims of the present disclosure can be made, even if such combinations or combinations are not expressly recited in the present disclosure. In particular, various combinations and/or combinations of the features recited in the various embodiments and/or claims of the present disclosure may be made without departing from the spirit or teaching of the present disclosure. All such combinations and/or associations are within the scope of the present disclosure.
The embodiments of the present disclosure are described above. However, these examples are for illustrative purposes only and are not intended to limit the scope of the present disclosure. Although the embodiments are described separately above, this does not mean that the measures in the embodiments cannot be used in advantageous combination. The scope of the disclosure is defined by the appended claims and equivalents thereof. Various alternatives and modifications can be devised by those skilled in the art without departing from the scope of the disclosure, and these alternatives and modifications are intended to fall within the scope of the disclosure.

Claims (12)

1. A test script generation method includes:
after the version of an application program in a target page is upgraded, acquiring first webpage source code information and second webpage source code information of the target page, wherein the first webpage source code information represents webpage source code information before the version of the application program is upgraded, and the second webpage source code information represents webpage source code information after the version of the application program is upgraded;
determining control change information of the target page and link address information corresponding to the control change information according to the first webpage source code information and the second webpage source code information;
determining a target script according to the link address information;
and according to the control change information, executing change operation aiming at the target script to generate a test script.
2. The method of claim 1, wherein the control change information includes type information of a control, and the generating the test script by performing a change operation on the target script according to the control change information includes:
determining step information of the change operation according to the type information of the control;
and generating the test script by executing the change operation according to the control change information and the step information.
3. The method of claim 2, wherein the step of determining the change operation information according to the type information of the control comprises:
determining the step information of the change operation as the information of the control change step under the condition that the type information of the control is the input type control;
and under the condition that the type information of the control is a selection type control, determining that the step information of the change operation comprises information of a control change step and information of a control parameter change step.
4. The method of claim 2, wherein generating the test script by performing the change operation according to the step information based on the control change information comprises:
determining target field information from the target script according to the control change information;
determining the target parameter information from the test database according to the control change information;
and according to the step information, executing the change operation aiming at the target script according to the target field information and the target parameter information, and generating the test script.
5. The method according to claim 4, wherein the executing the change operation for the target script according to the step information and the target field information and the target parameter information to generate the test script comprises:
according to the step information and the target parameter information, changing the parameter information in the target field information to obtain changed target field information;
and generating the test script according to the changed target field information.
6. The method of claim 1, wherein the determining control change information of the target page and link address information corresponding to the control change information according to the first webpage source code information and the second webpage source code information comprises:
calculating a first hash value of the first webpage source code information by using a hash algorithm according to the first webpage source code information;
calculating a second hash value of the second webpage source code information by utilizing the hash algorithm according to the second webpage source code information;
generating control change information of the target page according to the first hash value and the second hash value;
and determining the link address information from the second webpage source code information according to the control change information of the target page.
7. The method of claim 6, wherein the determining the link address information from the second webpage source code information according to the control change information of the target page comprises:
classifying according to page functions according to the control change information of the target page to obtain changed page function information;
and determining the link address information from the second webpage source code information according to the changed page function information.
8. The method of claim 1, further comprising:
obtaining test script operation result information by operating the test script;
receiving manually marked control change information under the condition that the test script operation result information is operation failure;
and executing the change operation aiming at the target script according to the manually marked control change information, and generating a changed test script.
9. A test script generating apparatus comprising:
the system comprises an acquisition module, a processing module and a display module, wherein the acquisition module is used for acquiring first webpage source code information and second webpage source code information of a target page after the version of an application program in the target page is upgraded, the first webpage source code information represents webpage source code information before the version of the application program is upgraded, and the second webpage source code information represents webpage source code information after the version of the application program is upgraded;
the first determining module is used for determining control change information of the target page and link address information corresponding to the control change information according to the first webpage source code information and the second webpage source code information;
the second determining module is used for determining a target script according to the link address information; and
and the generating module is used for generating a test script by executing change operation aiming at the target script according to the control change information.
10. An electronic device, comprising:
one or more processors;
a storage device for storing one or more programs,
wherein the one or more programs, when executed by the one or more processors, cause the one or more processors to perform the method of any of claims 1-8.
11. A computer readable storage medium having stored thereon executable instructions which, when executed by a processor, cause the processor to perform the method according to any one of claims 1 to 8.
12. A computer program product comprising a computer program which, when executed by a processor, implements the method according to any one of claims 1 to 8.
CN202211250224.9A 2022-10-12 2022-10-12 Test script generation method, device, equipment and storage medium Pending CN115687093A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202211250224.9A CN115687093A (en) 2022-10-12 2022-10-12 Test script generation method, device, equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202211250224.9A CN115687093A (en) 2022-10-12 2022-10-12 Test script generation method, device, equipment and storage medium

Publications (1)

Publication Number Publication Date
CN115687093A true CN115687093A (en) 2023-02-03

Family

ID=85065248

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202211250224.9A Pending CN115687093A (en) 2022-10-12 2022-10-12 Test script generation method, device, equipment and storage medium

Country Status (1)

Country Link
CN (1) CN115687093A (en)

Similar Documents

Publication Publication Date Title
US9858091B2 (en) Generating customized on-demand videos from automated test scripts
CN113778848A (en) Test code generation method, device, computer system and medium
CN113760729A (en) Code detection method and device
CN113535577B (en) Application testing method and device based on knowledge graph, electronic equipment and medium
CN114237651A (en) Installation method and device of cloud native application, electronic equipment and medium
CN111930629A (en) Page testing method and device, electronic equipment and storage medium
US9208046B2 (en) Method and system for optimizing testing efforts in system of systems testing
CN115203178A (en) Data quality inspection method and device, electronic equipment and storage medium
CN115687093A (en) Test script generation method, device, equipment and storage medium
CN111400623B (en) Method and device for searching information
CN113918525A (en) Data exchange scheduling method, system, electronic device, medium, and program product
CN113326079A (en) Service version switching method, switching device, electronic equipment and storage medium
CN114035864A (en) Interface processing method, interface processing device, electronic device, and storage medium
CN109697141B (en) Method and device for visual testing
CN112506781A (en) Test monitoring method, test monitoring device, electronic device, storage medium, and program product
CN116594876A (en) Interface testing method, device, equipment and storage medium
US20220237021A1 (en) Systems and methods of telemetry diagnostics
CN116401170A (en) Buried point management method, buried point management device, electronic equipment, medium and computer program product
CN115718842A (en) Software recommendation method and device for bug fixing, electronic equipment and medium
CN113656326A (en) Program testing method, program testing device, computer system and storage medium
CN113360417A (en) Test method, session modifier, electronic device, and medium
CN114691527A (en) Unit test case generation method, apparatus, device, medium, and program product
CN113568657A (en) Icon configuration method, icon configuration system, electronic device, and medium
CN115421738A (en) Version deployment method and device, electronic equipment and storage medium
CN114218254A (en) Report generation method, device, equipment and storage medium

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