A method, device, equipment and readable storage medium for repairing scripts
By obtaining and comparing the information on the failed page of the automated test script running, and automatically replacing and executing the replaced script, the problem of high script maintenance costs in automated tests is solved, and the dynamic repair and stability improvement of the script is achieved.
Patent Information
- Application Number
- CN202111483982.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-07
- Publication Date
- 2025-05-06
- Estimated Expiration
- 2041-12-07
AI Technical Summary
In automated testing, script maintenance requires a large labor cost, especially in long-link testing, page element information changes cause script failure and requires manual re-maintenance.
By obtaining the screenshot information of the page of the script failure, the element screenshot information stored in the file server, and the element attribute information in the script database, the model is used to compare, and the replaced script is automatically replaced and executed to achieve automatic repair of the script.
It realizes dynamic repair of automated scripts, improves the stability of script operation, reduces manual maintenance costs, and supports scenarios such as scheduled testing, smoke testing and regression testing.
Smart Images

Figure CN114218087B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer testing, and in particular to a method, device, equipment and readable storage medium for repairing a script. Background Art
[0002] In the existing technology, step information in automated testing needs to be maintained manually. When the information of a certain element on the page changes, personnel need to re-maintain the script. The change of the element information at a certain step may cause the overall result to fail. Therefore, in automated testing, maintaining the script still requires a large manpower cost for manual maintenance. For long-link testing such as banking systems, the maintenance of the script requires even higher manpower costs. A method and device that can repair the script during operation is needed. Summary of the invention
[0003] The purpose of the present invention is to provide a method, device, equipment and readable storage medium for repairing scripts to improve the above problems. In order to achieve the above purpose, the technical solution adopted by the present invention is as follows:
[0004] In one aspect, the present application provides a method for repairing a script, the method comprising: obtaining first information, the first information being first screenshot information of a page where the script failed to run, first element screenshot information stored in a file server, and first element attribute information stored in a script database;
[0005] Sending the first information to a first model for processing to obtain second information, where the second information is comparison result information of the first information, and the first model is a model that compares the first page screenshot information with the first element screenshot information;
[0006] The second information is judged, and if the second information is that the first element screenshot information exists in the first page screenshot information, third information is obtained, where the third information is the second element screenshot information of the script failure page and the second element attribute information of the script failure page;
[0007] The third information is input into the second model for processing to obtain fourth information, wherein the fourth information is the operation result information of the replaced script file, and the second model is a model for sending the third information to the script for replacement and executing the replaced script;
[0008] The fourth information is judged, and if the replaced script file can run normally, the script is automatically repaired.
[0009] Optionally, sending the first information to a first model for processing to obtain second information includes:
[0010] Extracting pixel points of the first element screenshot information and pixel points of the page screenshot information;
[0011] Comparing the pixel points included in the first element screenshot information with the pixel points included in the page screenshot information to obtain an area where the pixel points included in the page screenshot information are the same as the pixel points included in the page screenshot information;
[0012] The pixel points included in the page screenshot information and the text information of the area where the pixel points included in the page screenshot information are the same are extracted to obtain a comparison result of the text information.
[0013] Optionally, judging the second information, if the first element screenshot information exists in the page screenshot information, obtaining third information includes:
[0014] determining whether the comparison result of the text information is the same, and if the comparison result of the text information is the same, determining that the first element screenshot information exists in the page screenshot information;
[0015] A screen capture is performed on the page where the script fails to run, element screenshot information containing the same element as the first element screenshot information is captured and named as second element screenshot information, and element attribute information contained in the second element screenshot information is called and named as second element attribute information.
[0016] Optionally, judging the second information, if the first element screenshot information exists in the page screenshot information, obtaining third information further includes:
[0017] If the comparison result of the text information is different, it is determined that the first element screenshot information is not included in the page screenshot information, and all step information of the script on the page where the operation fails is deleted;
[0018] The deleted step information is marked in red, the script is stopped from running, and a command to check whether the script has deleted the correct step information is sent to the communication device of the script maintainer.
[0019] Optionally, the third information is input into the second model for processing to obtain fourth information, including:
[0020] The second element screenshot information replaces the first element screenshot information in the script execution file, and the second element attribute information replaces the first element attribute information in the script execution file, to obtain a replaced script execution file;
[0021] The replaced script file is run on the script running failure page to obtain result information on whether the replaced script file can run normally.
[0022] Optionally, the judging the fourth information includes:
[0023] If the replaced script file can run normally, the second original screenshot information is uploaded to the file server to be replaced with the first element screenshot information, and the second element attribute information is uploaded to the script database to be replaced with the first element attribute information;
[0024] If the replaced script file cannot run normally, taking a screenshot of the page where the replaced script file cannot run normally, and obtaining second page screenshot information;
[0025] Compare the second page screenshot information with the first page screenshot information to determine whether the second page screenshot information is the same as the first page screenshot information. If they are the same, send an instruction to the communication device of the script maintainer that the script cannot be automatically repaired and needs manual repair. If they are different, repeat the above steps.
[0026] In a second aspect, an embodiment of the present application provides a device for repairing a script, the device comprising:
[0027] A first acquisition unit is used to acquire first information, where the first information is first screenshot information of a script execution failure page, first element screenshot information stored in a file server, and first element attribute information stored in a script database;
[0028] A first processing unit is configured to send the first information to a first model for processing to obtain second information, where the second information is comparison result information of the first information, and the first model is a model for comparing the first page screenshot information with the first element screenshot information;
[0029] A first judgment unit is used to judge the second information, and if the second information is the first element screenshot information exists in the first page screenshot information, obtain third information, wherein the third information is the second element screenshot information of the script failure page and the second element attribute information of the script failure page;
[0030] A second processing unit is used to input the third information into a second model for processing to obtain fourth information, wherein the fourth information is the operation result information of the replaced script file, and the second model is a model that sends the third information to the script for replacement and executes the replaced script;
[0031] The second judgment unit is used to judge the fourth information, and automatically repair the script if the replaced script file can run normally.
[0032] Optionally, the device comprises:
[0033] A first processing subunit, configured to extract pixel points of the first element screenshot information and pixel points of the page screenshot information;
[0034] A second processing subunit is used to compare the pixel points included in the first element screenshot information with the pixel points included in the page screenshot information to obtain an area where the pixel points included in the page screenshot information are the same as the pixel points included in the page screenshot information;
[0035] The third processing subunit is used to extract the pixel points included in the page screenshot information and the text information of the area where the pixel points included in the page screenshot information are the same, and obtain a comparison result of the text information.
[0036] Optionally, the device comprises:
[0037] A first judging subunit is used to judge whether the comparison result of the text information is the same, and if the comparison result of the text information is the same, it is determined that the first element screenshot information exists in the page screenshot information;
[0038] The fourth processing sub-unit is used to take a screenshot of the page where the script fails to run, capture the element screenshot information containing the same element as the first element screenshot information, name it as the second element screenshot information, and call the element attribute information contained in the second element screenshot information, name it as the second element attribute information.
[0039] Optionally, the device further comprises:
[0040] A third judgment unit is configured to, if the comparison result of the text information is different, determine that the page screenshot information does not contain the first element screenshot information, and delete all step information of the script on the failed execution page;
[0041] The third processing unit is used to mark the deleted step information in red, stop running the script, and send a command to the communication device of the script maintainer to check whether the script has deleted the correct step information.
[0042] Optionally, the device comprises:
[0043] a fifth processing subunit, configured to replace the first element screenshot information in the script execution file with the second element screenshot information, and replace the first element attribute information in the script execution file with the second element attribute information, to obtain a replaced script execution file;
[0044] The sixth processing sub-unit is used to run the replaced script file on the script running failure page to obtain result information on whether the replaced script file can run normally.
[0045] Optionally, the device comprises:
[0046] a second judgment subunit, configured to upload the second original screenshot information to a file server to replace the first element screenshot information, and upload the second element attribute information to a script database to replace the first element attribute information, if the replaced script file can run normally;
[0047] A third judgment subunit is used for, if the replaced script file cannot run normally, taking a screenshot of the page where the replaced script file cannot run normally, to obtain second page screenshot information;
[0048] The fourth judgment subunit is used to compare the second page screenshot information with the first page screenshot information to determine whether the second page screenshot information is the same as the first page screenshot information. If they are the same, an instruction is sent to the communication device of the script maintenance personnel that the script cannot be automatically repaired and needs manual repair. If they are different, the above steps are repeated.
[0049] In a third aspect, an embodiment of the present application provides a device for repairing a script, including:
[0050] Memory for storing computer programs;
[0051] A processor is used to implement the steps of the above-mentioned method for repairing a script when executing the computer program.
[0052] In a fourth aspect, an embodiment of the present application provides a readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the above-mentioned method for repairing the script are implemented.
[0053] The beneficial effects of the present invention are:
[0054] The present invention combines image comparison to detect multiple attributes of elements in the page, determines whether all attribute information of the elements has changed, and achieves dynamic and automatic repair of automated scripts and automatic healing of cases. The script can be repaired during operation, thereby achieving the purpose of dynamically repairing the script, improving the stability of script operation, reducing manual maintenance, saving labor costs, and better supporting scheduling tests, smoke tests, regression tests and other scenarios during operation.
[0055] Other features and advantages of the present invention will be described in the following description, and partly become apparent from the description, or be understood by implementing the embodiments of the present invention. The purpose and other advantages of the present invention can be realized and obtained by the structures particularly pointed out in the written description, claims, and drawings. BRIEF DESCRIPTION OF THE DRAWINGS
[0056] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for use in the embodiments are briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present invention and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without creative work.
[0057] Figure 1 A schematic diagram of a method flow for repairing a script according to an embodiment of the present invention;
[0058] Figure 2 A schematic diagram of the structure of a device for repairing a script according to an embodiment of the present invention;
[0059] Figure 3 It is a schematic diagram of the device structure of a repair script described in an embodiment of the present invention. DETAILED DESCRIPTION
[0060] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, rather than all of the embodiments. The components of the embodiments of the present invention generally described and shown in the drawings here can be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the present invention provided in the drawings is not intended to limit the scope of the claimed invention, but merely represents selected embodiments of the present invention. Based on the embodiments in the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.
[0061] It should be noted that similar reference numerals and letters represent similar items in the following drawings, so once an item is defined in one drawing, it does not need to be further defined and explained in the subsequent drawings. At the same time, in the description of the present invention, the terms "first", "second", etc. are only used to distinguish the description and cannot be understood as indicating or implying relative importance.
[0062] Example 1
[0063] like Figure 1As shown, this embodiment provides a method for repairing a script, and the method includes step S1, step S2, step S3, step S4 and step S5.
[0064] Step S1, obtaining first information, wherein the first information is first screenshot information of a script execution failure page, first element screenshot information stored in a file server, and first element attribute information stored in a script database;
[0065] Step S2: sending the first information to a first model for processing to obtain second information, where the second information is comparison result information of the first information, and the first model is a model for comparing the first page screenshot information with the first element screenshot information;
[0066] Step S3, judging the second information, if the second information is that the first element screenshot information exists in the first page screenshot information, obtaining third information, wherein the third information is the second element screenshot information of the script failure page and the second element attribute information of the script failure page;
[0067] Step S4: input the third information into the second model for processing to obtain fourth information, wherein the fourth information is the operation result information of the replaced script file, and the second model is a model that sends the third information to the script for replacement and executes the replaced script;
[0068] Step S5: judging the fourth information, and automatically repairing the script if the replaced script file can run normally.
[0069] It can be understood that the present invention first determines whether there are necessary elements for script execution in the page image, and then automatically finds the changed elements by comparing the page image, the element attribute information and the element screenshot information of the failed step page, and then automatically modifies the automation script information, and conducts a trial run of the script. Finally, the database file of the script is modified and saved. In this way, the failed script can be repaired during the script running process, the stability of the script running is improved, the labor cost investment is reduced, the script is dynamically monitored and repaired, and the scheduling test, smoke test, regression test and other scenarios can be better supported during the operation.
[0070] It can be understood that the present invention does not require a large amount of manpower to repetitively maintain script information, saving manpower and being applicable to application fields with extremely high stability requirements. Moreover, the present invention can process multiple elements during script execution at the same time and perform multi-terminal operations, thereby reducing labor costs while speeding up processing and greatly improving script maintenance efficiency.
[0071] It can be understood that the elements in the present invention include attributes such as id, name, class, xpath and lintext.
[0072] In a specific implementation of the present disclosure, step S2 includes step S21, step S22 and step S23.
[0073] Step S21, extracting pixel points of the first element screenshot information and pixel points of the page screenshot information;
[0074] Step S22: Compare the pixels included in the first element screenshot information with the pixels included in the page screenshot information to obtain an area where the pixels included in the page screenshot information are the same as the pixels included in the page screenshot information;
[0075] Step S23: extracting the text information of the area where the pixel points included in the page screenshot information are the same as the pixel points included in the page screenshot information, and obtaining a comparison result of the text information.
[0076] It can be understood that the present invention finds the location of the element that executes the script in the page by comparing the pixel points in the screenshot, and then compares whether the text information in the element is the same, so as to determine whether the page still has the element. If the element does not exist, it means that the element in the page has been modified and the script needs to be reset, and the maintenance personnel can be notified to perform maintenance.
[0077] In a specific implementation of the present disclosure, step S3 includes step S31 and step S32.
[0078] Step S31, determining whether the comparison result of the text information is the same, if the comparison result of the text information is the same, determining that the first element screenshot information exists in the page screenshot information;
[0079] Step S32: take a screenshot of the page where the script fails to run, capture the element screenshot information containing the same element as the first element screenshot information, name it as the second element screenshot information, and call the element attribute information contained in the second element screenshot information, name it as the second element attribute information.
[0080] It is understandable that if the present invention determines that the script contains an element for executing the script, the attribute information and screenshot information of the element are further called to ensure the normal execution of the next step of testing the script.
[0081] In a specific implementation of the present disclosure, step S3 further includes step S6 and step S7:
[0082] Step S6: If the comparison result of the text information is different, it is determined that the first element screenshot information is not included in the page screenshot information, and all step information of the script on the failed execution page is deleted;
[0083] Step S7: Mark the deleted step information in red, stop running the script, and send a command to the communication device of the script maintainer to check whether the script has deleted the correct step information.
[0084] It is understandable that if the result of comparing the text information is different, it is judged that there is no executable element in the script running interface, and the step information of the script execution is marked in red, and then sent to the maintenance personnel for maintenance. This reduces the script repair time, provides maintenance information in real time, and ensures the smooth operation of the script.
[0085] In a specific implementation of the present disclosure, step S4 includes step S41 and step S42.
[0086] Step S41: Replace the first element screenshot information in the script execution file with the second element screenshot information, and replace the first element attribute information in the script execution file with the second element attribute information, to obtain a replaced script execution file;
[0087] Step S42: Run the replaced script file on the script failure page to obtain result information on whether the replaced script file can run normally.
[0088] It can be understood that the present invention replaces the script execution file information, test-runs the replaced script, and determines whether the script can be repaired successfully. If the script cannot be repaired successfully, the screenshot and replacement can be repeated until three screenshots and replacements are unsuccessful, and then it is determined that the script cannot be repaired successfully.
[0089] In a specific implementation of the present disclosure, step S5 includes step S51, step S52 and step S53.
[0090] Step S51: if the replaced script file can run normally, the second original screenshot information is uploaded to the file server to be replaced with the first element screenshot information, and the second element attribute information is uploaded to the script database to be replaced with the first element attribute information;
[0091] Step S52: if the replaced script file cannot run normally, a screenshot of the page where the replaced script file cannot run normally is taken to obtain second page screenshot information;
[0092] Step S53: compare the second page screenshot information with the first page screenshot information to determine whether the second page screenshot information is the same as the first page screenshot information. If they are the same, send an instruction to the communication device of the script maintainer that the script cannot be automatically repaired and needs manual repair. If they are different, repeat the above steps.
[0093] It can be understood that after the trial run test, the present invention replaces the data stored in the database and the file server, deletes the original first element information, and completes the repair of the script. If it cannot run normally, a screenshot of the page that cannot run normally is taken to determine whether it is the same as the screenshot of the first page. If they are different, it proves that an error occurs in the replacement step. If they are the same, it proves that the repair is difficult and cannot be repaired automatically, and manual repair is required.
[0094] Example 2
[0095] like Figure 2 As shown, this embodiment provides a vehicle control device, which includes a first acquisition unit 701, a first processing unit 702, a first judgment unit 703, a second processing unit 704 and a second judgment unit 705.
[0096] The first acquisition unit 701 is used to acquire first information, where the first information is first screenshot information of the script execution failure page, first element screenshot information stored in the file server, and first element attribute information stored in the script database;
[0097] A first processing unit 702 is configured to send the first information to a first model for processing to obtain second information, where the second information is comparison result information of the first information, and the first model is a model for comparing the first page screenshot information with the first element screenshot information;
[0098] The first judging unit 703 is configured to judge the second information, and if the second information is the first element screenshot information existing in the first page screenshot information, obtain third information, wherein the third information is the second element screenshot information of the script execution failure page and the second element attribute information of the script execution failure page;
[0099] The second processing unit 704 is used to input the third information into the second model for processing to obtain fourth information, where the fourth information is the running result information of the replaced script file, and the second model is a model that sends the third information to the script for replacement and executes the replaced script;
[0100] The second judgment unit 705 is used to judge the fourth information, and automatically repair the script if the replaced script file can run normally.
[0101] In a specific implementation of the present disclosure, the first processing unit 702 includes a first processing sub-unit 7021 , a second processing sub-unit 7022 , and a third processing sub-unit 7023 .
[0102] The first processing subunit 7021 is used to extract the pixel points of the first element screenshot information and the pixel points of the page screenshot information;
[0103] The second processing sub-unit 7022 is used to compare the pixels included in the first element screenshot information with the pixels included in the page screenshot information to obtain an area where the pixels included in the page screenshot information are the same as the pixels included in the page screenshot information;
[0104] The third processing sub-unit 7023 is used to extract the pixel points included in the page screenshot information and the text information of the area where the pixel points included in the page screenshot information are the same, and obtain a comparison result of the text information.
[0105] In a specific implementation of the present disclosure, the first judgment unit 703 includes a first judgment subunit 7031 and a fourth processing subunit 7032 .
[0106] The first judging subunit 7031 is used to judge whether the comparison result of the text information is the same, and if the comparison result of the text information is the same, it is determined that the first element screenshot information exists in the page screenshot information;
[0107] The fourth processing sub-unit 7032 is used to take a screenshot of the page where the script fails to run, capture the element screenshot information containing the same element as the first element screenshot information, name it as the second element screenshot information, and call the element attribute information contained in the second element screenshot information, name it as the second element attribute information.
[0108] In a specific implementation of the present disclosure, the device further includes a third judgment unit 706 and a third processing unit 707 .
[0109] The third judgment unit 706 is configured to, if the comparison result of the text information is different, determine that the page screenshot information does not contain the first element screenshot information, and delete all step information of the script on the failed execution page;
[0110] The third processing unit 707 is used to mark the deleted step information in red, stop running the script, and send a command to the communication device of the script maintainer to check whether the script has deleted the correct step information.
[0111] In a specific implementation of the present disclosure, the second processing unit 704 includes a fifth processing sub-unit 7041 and a sixth processing sub-unit 7042 .
[0112] The fifth processing subunit 7041 is used to replace the first element screenshot information in the script execution file with the second element screenshot information, and replace the first element attribute information in the script execution file with the second element attribute information, so as to obtain a replaced script execution file;
[0113] The sixth processing sub-unit 7042 is used to run the replaced script file on the script running failure page to obtain result information on whether the replaced script file can run normally.
[0114] In a specific implementation of the present disclosure, the second judgment unit 705 includes a second judgment subunit 7051 , a third judgment subunit 7052 and a fourth judgment subunit 7053 .
[0115] The second judgment subunit 7051 is used for uploading the second original screenshot information to the file server to replace the first element screenshot information, and uploading the second element attribute information to the script database to replace the first element attribute information if the replaced script file can run normally;
[0116] The third judgment subunit 7052 is used to take a screenshot of the page where the replaced script file cannot run normally, if the replaced script file cannot run normally, to obtain second page screenshot information;
[0117] The fourth judgment subunit 7053 is used to compare the second page screenshot information with the first page screenshot information to determine whether the second page screenshot information is the same as the first page screenshot information. If they are the same, an instruction is sent to the communication device of the script maintenance personnel that the script cannot be automatically repaired and needs manual repair. If they are different, the above steps are repeated.
[0118] It should be noted that, regarding the device in the above embodiment, the specific manner in which each element performs the operation has been described in detail in the embodiment of the method, and will not be elaborated here.
[0119] Example 3
[0120] Corresponding to the above method embodiment, the present disclosure embodiment further provides a device for repairing a script. The device for repairing a script described below and the method for repairing a script described above can be referred to in correspondence with each other:
[0121] Figure 3 FIG. 8 is a block diagram of a device 800 for repairing a script according to an exemplary embodiment. Figure 3 As shown, the device 800 for repairing scripts may include: a processor 801 and a memory 802. The device 800 for repairing scripts may also include one or more of a multimedia component 803, an input / output (I / O) interface 804, and a communication component 805.
[0122] The processor 801 is used to control the overall operation of the device 800 for repairing the script to complete all or part of the steps in the method for repairing the script. The memory 802 is used to store various types of data to support the operation of the device 800 for repairing the script, and these data may include, for example, instructions for any application or method for operating on the device 800 for repairing the script, and application-related data, such as contact data, messages sent and received, pictures, audio, video, etc. The memory 802 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (Static Random Access Memory, referred to as SRAM), electrically erasable programmable read-only memory (Electrically Erasable Programmable Read-Only Memory, referred to as EEPROM), erasable programmable read-only memory (Erasable Programmable Read-Only Memory, referred to as EPROM), programmable read-only memory (Programmable Read-Only Memory, referred to as PROM), read-only memory (Read-Only Memory, referred to as ROM), magnetic memory, flash memory, magnetic disk or optical disk. The multimedia component 803 may include a screen and an audio component. The screen may be, for example, a touch screen, and the audio component is used to output and / or input audio signals. For example, the audio component may include a microphone, which is used to receive external audio signals. The received audio signal may be further stored in the memory 802 or sent through the communication component 805. The audio component also includes at least one speaker for outputting audio signals. The I / O interface 804 provides an interface between the processor 801 and other interface elements, and the above-mentioned other interface elements may be a keyboard, a mouse, buttons, etc. These buttons may be virtual buttons or physical buttons. The communication component 805 is used for wired or wireless communication between the device 800 of the repair script and other devices. Wireless communication, such as Wi-Fi, Bluetooth, Near Field Communication (NFC), 2G, 3G or 4G, or a combination of one or more of them, so the corresponding communication component 805 may include: Wi-Fi element, Bluetooth element, NFC element.
[0123] In an exemplary embodiment, the device 800 for repairing a script can be implemented by one or more application specific integrated circuits (ASIC), digital signal processors (DSP), digital signal processing devices (DSPD), programmable logic devices (PLD), field programmable gate arrays (FPGA), controllers, microcontrollers, microprocessors or other electronic components to execute the above-mentioned method of repairing a script.
[0124] In another exemplary embodiment, a computer-readable storage medium including program instructions is also provided, and when the program instructions are executed by a processor, the steps of the above-mentioned method for repairing a script are implemented. For example, the computer-readable storage medium may be the above-mentioned memory 802 including program instructions, and the above-mentioned program instructions may be executed by the processor 801 of the device 800 for repairing a script to complete the above-mentioned method for repairing a script.
[0125] Example 4
[0126] Corresponding to the above method embodiment, the embodiment of the present disclosure further provides a readable storage medium. The readable storage medium described below and the method for repairing a script described above can refer to each other.
[0127] A readable storage medium stores a computer program, which, when executed by a processor, implements the steps of the method for repairing a script in the above method embodiment.
[0128] The readable storage medium may specifically be a U disk, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, or other readable storage medium that can store program codes.
[0129] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. For those skilled in the art, the present invention may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention shall be included in the protection scope of the present invention.
[0130] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art can easily think of changes or substitutions within the technical scope disclosed by the present invention, which should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.
Claims
1. A method for repairing a script, characterized in that: include: Acquire first information, where the first information is first screenshot information of a script execution failure page, first element screenshot information stored in a file server, and first element attribute information stored in a script database; Sending the first information to a first model for processing to obtain second information, where the second information is comparison result information of the first information, and the first model is a model that compares the first page screenshot information with the first element screenshot information; The second information is judged, and if the second information is that the first element screenshot information exists in the first page screenshot information, third information is obtained, where the third information is the second element screenshot information of the script failure page and the second element attribute information of the script failure page; The third information is input into the second model for processing to obtain fourth information, wherein the fourth information is the operation result information of the replaced script file, and the second model is a model for sending the third information to the script for replacement and executing the replaced script; The fourth information is judged, and if the replaced script file can run normally, the script is automatically repaired; The second information is judged, and if the first element screenshot information exists in the page screenshot information, third information is obtained, including: determining whether the comparison result of the text information is the same, and if the comparison result of the text information is the same, determining that the first element screenshot information exists in the page screenshot information; Taking a screenshot of the page where the script fails to run, capturing element screenshot information containing the same element as the first element screenshot information, naming it as second element screenshot information, and calling element attribute information contained in the second element screenshot information, naming it as second element attribute information; Inputting the third information into the second model for processing to obtain fourth information includes: The second element screenshot information replaces the first element screenshot information in the script execution file, and the second element attribute information replaces the first element attribute information in the script execution file, to obtain a replaced script execution file; The replaced script file is run on the script running failure page to obtain result information on whether the replaced script file can run normally.
2. The method for repairing a script according to claim 1, characterized in that: Sending the first information to the first model for processing to obtain second information includes: Extracting pixel points of the first element screenshot information and pixel points of the page screenshot information; Comparing the pixel points included in the first element screenshot information with the pixel points included in the page screenshot information to obtain an area where the pixel points included in the page screenshot information are the same as the pixel points included in the page screenshot information; The pixel points included in the page screenshot information and the text information of the area where the pixel points included in the page screenshot information are the same are extracted to obtain a comparison result of the text information.
3. The method for repairing a script according to claim 1, characterized in that: The second information is judged, and if the first element screenshot information exists in the page screenshot information, the third information is acquired, further comprising: If the comparison result of the text information is different, it is determined that the first element screenshot information is not included in the page screenshot information, and all step information of the script on the page where the operation fails is deleted; The deleted step information is marked in red, the script is stopped from running, and a command to check whether the script has deleted the correct step information is sent to the communication device of the script maintainer.
4. The method for repairing a script according to claim 1, characterized in that: The judging of the fourth information includes: If the replaced script file can run normally, the second original screenshot information is uploaded to the file server to be replaced with the first element screenshot information, and the second element attribute information is uploaded to the script database to be replaced with the first element attribute information; If the replaced script file cannot run normally, taking a screenshot of the page where the replaced script file cannot run normally, and obtaining second page screenshot information; Compare the second page screenshot information with the first page screenshot information to determine whether the second page screenshot information is the same as the first page screenshot information. If they are the same, send an instruction to the communication device of the script maintainer that the script cannot be automatically repaired and needs manual repair. If they are different, repeat the above steps.
5. A device for repairing a script, characterized in that: include: A first acquisition unit is used to acquire first information, where the first information is first screenshot information of a script execution failure page, first element screenshot information stored in a file server, and first element attribute information stored in a script database; A first processing unit is configured to send the first information to a first model for processing to obtain second information, where the second information is comparison result information of the first information, and the first model is a model for comparing the first page screenshot information with the first element screenshot information; A first judgment unit is used to judge the second information, and if the second information is the first element screenshot information exists in the first page screenshot information, obtain third information, wherein the third information is the second element screenshot information of the script failure page and the second element attribute information of the script failure page; A second processing unit is used to input the third information into a second model for processing to obtain fourth information, wherein the fourth information is the operation result information of the replaced script file, and the second model is a model that sends the third information to the script for replacement and executes the replaced script; A second judgment unit is used to judge the fourth information, and automatically repair the script if the replaced script file can run normally; a first judging subunit, configured to judge whether the comparison result of the text information is the same, and if the comparison result of the text information is the same, determining that the first element screenshot information exists in the page screenshot information; The fourth processing sub-unit is used to take a screenshot of the script execution failure page, intercept element screenshot information containing the same element as the first element screenshot information, name it as second element screenshot information, and call element attribute information contained in the second element screenshot information, name it as second element attribute information; a fifth processing subunit, configured to replace the first element screenshot information in the script execution file with the second element screenshot information, and replace the first element attribute information in the script execution file with the second element attribute information, to obtain a replaced script execution file; The sixth processing sub-unit is used to run the replaced script file on the script running failure page to obtain result information on whether the replaced script file can run normally.
6. The device for repairing scripts according to claim 5, characterized in that: The device comprises: A first processing subunit, configured to extract pixel points of the first element screenshot information and pixel points of the page screenshot information; A second processing subunit is used to compare the pixel points included in the first element screenshot information with the pixel points included in the page screenshot information to obtain an area where the pixel points included in the page screenshot information are the same as the pixel points included in the page screenshot information; The third processing subunit is used to extract the pixel points included in the page screenshot information and the text information of the area where the pixel points included in the page screenshot information are the same, and obtain a comparison result of the text information.
7. The device for repairing scripts according to claim 5, characterized in that: The device also includes: A third judgment unit is configured to, if the comparison result of the text information is different, determine that the page screenshot information does not contain the first element screenshot information, and delete all step information of the script on the failed execution page; The third processing unit is used to mark the deleted step information in red, stop running the script, and send a command to the communication device of the script maintainer to check whether the script has deleted the correct step information.
8. The device for repairing scripts according to claim 5, characterized in that: The device comprises: A second judgment subunit is used for uploading the second original screenshot information to the file server to replace the first element screenshot information, and uploading the second element attribute information to the script database to replace the first element attribute information if the replaced script file can run normally; A third judgment subunit is used for, if the replaced script file cannot run normally, taking a screenshot of the page where the replaced script file cannot run normally, to obtain second page screenshot information; The fourth judgment subunit is used to compare the second page screenshot information with the first page screenshot information to determine whether the second page screenshot information is the same as the first page screenshot information. If they are the same, an instruction is sent to the communication device of the script maintainer indicating that the script cannot be automatically repaired and needs manual repair. If they are different, the above steps are repeated.
9. A device for repairing a script, characterized in that: include: Memory for storing computer programs; A processor, configured to implement the steps of the method for repairing a script as claimed in any one of claims 1 to 4 when executing the computer program.
10. A readable storage medium, characterized in that: The readable storage medium stores a computer program, which, when executed by a processor, implements the steps of the method for repairing a script as claimed in any one of claims 1 to 4.
Citation Information
Patent Citations
Method and system for repairing web automatic testing scripts
CN107451065A
Page element positioning method, page testing method and related devices
CN111309618A