Script updating method and device

By comparing the similarity of interface control context information in old and new versions of software, the interface control identifier in scripts is automatically updated, which solves the problem that the script cannot be updated automatically in the existing technology, and efficient testing of new versions of software is achieved.

CN112685056BActive Publication Date: 2025-04-15HUAWEI TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN201910995649.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2019-10-18
Publication Date
2025-04-15
Estimated Expiration
2039-10-18

AI Technical Summary

Technical Problem

The prior art cannot automatically update scripts for older versions of software to newer versions of software, resulting in the inability to perform automated testing.

Method used

By comparing the similarity between the context information of the interface controls in the old version of the software and the candidate interface controls in the new version of the software, we determine the new interface controls used to replace the old interface controls and update the identification in the script to obtain a new script suitable for the new version of the software.

Benefits of technology

Automatic update of scripts is achieved, making testing of new versions of software more efficient and accurate, reducing labor costs and difficulty.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN112685056B_ABST
    Figure CN112685056B_ABST
Patent Text Reader

Abstract

The present application discloses a script updating method and device, belonging to the field of computer technology. The method includes: executing a first script on a second software; when the execution of a first code snippet fails, obtaining the context information of a first interface control and the context information of multiple candidate interface controls in the second software; wherein the context information of any interface control is used to indicate: the changes in the interface of the software where any interface control is located before and after the operation of any interface control; determining the similarity between the context information of the first interface control and the context information of each candidate interface control; determining the second interface control among multiple candidate interface controls based on the determined similarity; replacing the identifier of the first interface control in the first code snippet in the first script with the identifier of the second interface control to obtain a second script. The present application solves the problem that the updated software cannot be tested based on the script of the software before the update, and the present application is used for script updating.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a script updating method and device. Background Art

[0002] With the development of computer technology, there are more and more software based on graphical user interface (GUI), and such software includes interface controls. At present, automatic testing of such software is more and more widely used.

[0003] When performing automated testing on such software, it is usually necessary to execute a script suitable for operating the software on the software, and then determine whether the software has a fault based on the execution result of the script.

[0004] However, the software may be updated, and the scripts applicable to the software before the update may not be applicable to the software after the update, resulting in the inability to test the updated software based on the scripts of the software before the update. Summary of the invention

[0005] The present application provides a script updating method and device, which can solve the problem that the updated software cannot be tested based on the script of the software before the update. The technical solution is as follows:

[0006] On the one hand, a script updating method is provided, which is used to update a first script suitable for operating a first software into a second script suitable for operating a second software, wherein the second software is obtained based on the first software, the first software and the second software both include an interface control, the first script includes a first code snippet for operating a first interface control in the first software, and the first code snippet includes an identifier of the first interface control, and the method includes: executing the first script on the second software; when the execution of the first code snippet fails, obtaining context information of the first interface control and context information of multiple candidate interface controls in the second software; wherein the context information of the first interface control and any one of the multiple candidate interface controls is used to indicate: changes in the interface of the software where the any one interface control is located before and after the operation of the any one interface control; determining the similarity between the context information of the first interface control and the context information of each of the multiple candidate interface controls; determining a second interface control among the multiple candidate interface controls based on the determined similarity; replacing the identifier of the first interface control in the first code snippet in the first script with the identifier of the second interface control to obtain the second script.

[0007] Since the script updating device can determine the second interface control used to replace the first interface control from among the plurality of candidate interface controls by comparing the similarity of the context information of the first interface control in the first software and the candidate interface control in the second software, and then update the first script of the first software according to the first interface control and the second interface control to obtain the second script. Since the interface control operated by the code snippet in the second script is the interface control in the second software, the second script can realize the operation of the second software.

[0008] Furthermore, the script updating method provided in the embodiment of the present application can automatically update the first script without requiring excessive operations by staff. Therefore, the labor cost and difficulty of the script updating process are low.

[0009] In addition, in the embodiment of the present application, the second interface control used to replace the first interface control is searched based on the similarity of the context information of the interface control. Even if the auxiliary information different from the context information in the second interface control has changed, the second interface control can be accurately found through the context information. Therefore, in the embodiment of the present application, the accuracy of finding the second interface control is high, and the efficiency of script updating is also high.

[0010] Optionally, the context information of any interface control includes: information of an interface triggered by operating any interface control. The information of the interface may be a feature of the interface.

[0011] Optionally, when the first script also includes a reference code snippet for execution before the first code snippet, the context information of any interface control includes: the positional relationship between any interface control and the reference interface control in the first software, and the reference code snippet is used to operate the reference interface control. The reference code snippet may be the previous code snippet of the first code snippet, or the previous several code snippets, which is not limited in the present embodiment of the application.

[0012] Optionally, the positional relationship between any one of the interface controls and the reference interface control includes: the distance between any one of the interface controls and the reference interface control, and / or the relative orientation between any one of the interface controls and the reference interface control. By way of example, the distance between any one of the interface controls and the reference interface control may be: the Euclidean distance between any one of the interface controls and the reference interface control, or the ratio of the Euclidean distance to the length of the diagonal of the display area of ​​the terminal, or the ratio of the Euclidean distance to the length of a certain side of the display area); the relative orientation between any one of the interface controls and its reference interface control may be: the angle between a line connecting the center point of the reference interface control to the center point of any one of the interface controls and a certain side of the display area.

[0013] Optionally, determining the similarity between the context information of the first interface control and the context information of each candidate interface control among the multiple candidate interface controls includes: determining at least one of the similarity of the interface information, the similarity of the distance, and the similarity of the relative orientation in the context information of the first interface control and the context information of each candidate interface control; based on the at least one similarity, determining the similarity between the context information of the first interface control and the context information of each candidate interface control. The similarity of the above distances can be calculated using a distance similarity formula, which includes: s2=1 / (1+|d1-d2|), where s2 represents the similarity between the above distance d1 of the first interface control and the above distance d2 of a candidate interface control, and |d1-d2| represents the absolute value of d1-d2; the similarity of the above relative orientations can be calculated using a relative orientation similarity formula, which includes: s3=cos|a1-a2|, where s3 represents the similarity of the above relative orientations, a1 represents the angle between a line from the center point of the reference interface control of the first interface control to the center point of the first interface control and a side of the display area, a2 represents the angle between a line from the center point of the reference interface control to the center point of the candidate interface control and a side of the display area, |a1-a2| represents the absolute value of a1-a2, and cos|a1-a2| represents the cosine of |a1-a2|.

[0014] Optionally, determining the second interface control among the multiple candidate interface controls based on the determined similarity includes: determining the similarity between the context information of the first interface control and the context information of each candidate interface control as the first similarity corresponding to each candidate interface control; when there is at least one candidate interface control among the multiple candidate interface controls whose corresponding first similarity is greater than a first similarity threshold, determining the interface control corresponding to the maximum first similarity among the at least one candidate interface control as the second interface control. It can be seen that the script updating device selects a second interface control whose context information has a higher similarity with the context information of the first interface control from among the multiple candidate interface controls based on the first similarity corresponding to the candidate interface controls and the first similarity threshold. The second interface control is likely to be an interface control for implementing the same function as the first interface control, and the second interface control may be an interface control for replacing the first interface control.

[0015] Optionally, the method further includes: before obtaining the context information of the multiple candidate interface controls, screening the multiple candidate interface controls from multiple initial interface controls of the target interface, wherein the target interface is: the interface when the first code snippet in the first script is executed on the second software. By way of example, the multiple initial interface controls can be all interface controls in the target interface. Of course, the multiple initial interface controls can also be part of the interface controls in the target interface, which is not limited in the embodiments of the present application. Since the interface control used to replace the first interface control is most likely to be in the target interface when the first code snippet in the first script is executed on the second software, directly screening the multiple candidate interface controls from the multiple initial interface controls in the target interface can speed up the screening efficiency of the candidate interface controls.

[0016] Optionally, screening the multiple candidate interface controls from the multiple initial interface controls of the target interface includes: obtaining auxiliary information of the first interface control and auxiliary information of each of the multiple initial interface controls, the auxiliary information of any interface control including: image information and / or text information of any interface control; determining the multiple candidate interface controls in the target interface based on the similarity between any one of the information in the auxiliary information of the first interface control and any one of the information in the auxiliary information of each initial interface control. The script updating device preliminarily determines multiple candidate interface controls from the multiple initial interface controls based on the similarity of each type of information in the auxiliary information of the interface control, and the multiple candidate interface controls have a greater probability of being interface controls for updating the first interface control. After determining the multiple candidate interface controls, the interface control for updating the first interface control can be further determined from the multiple candidate interface controls through subsequent steps.

[0017] Optionally, the auxiliary information of any interface control includes: image information and text information of any interface control, and based on the similarity between any information in the auxiliary information of the first interface control and any information in the auxiliary information of each initial interface control, determining the multiple candidate interface controls in the target interface includes: determining the interface controls whose corresponding image similarity among the multiple initial interface controls is greater than the target image similarity, and / or, the interface controls whose corresponding text similarity among the multiple initial interface controls is greater than the target text similarity, as the multiple candidate interface controls; wherein the image similarity corresponding to each initial interface control includes: the similarity between the image information of the first interface control and the image information of each initial interface control; the text similarity corresponding to each initial interface control includes: the similarity between the text information of the first interface control and the text information of each initial interface control; the target image similarity is any non-maximum image similarity among the image similarities corresponding to the multiple initial interface controls, and the target text similarity is any non-maximum text similarity among the text similarities corresponding to the multiple initial interface controls.

[0018] Optionally, interface controls among the multiple initial interface controls whose corresponding image similarity is greater than the target image similarity, and / or interface controls among the multiple initial interface controls whose corresponding text similarity is greater than the target text similarity, are determined as the multiple candidate interface controls, including: when the image similarity and text similarity corresponding to the multiple initial interface controls are both less than a second similarity threshold, interface controls among the multiple initial interface controls whose corresponding image similarity is greater than the target image similarity, and / or interface controls among the multiple initial interface controls whose corresponding text similarity is greater than the target text similarity, are determined as the multiple candidate interface controls.

[0019] Optionally, the method also includes: when there is at least one initial interface control among the multiple initial interface controls whose corresponding target similarity is greater than or equal to the second similarity threshold, determining the interface control corresponding to the maximum target similarity among the at least one initial interface control as a third interface control, and the target similarity is: the image similarity or the text similarity; replacing the identifier of the first interface control in the first code fragment in the first script with the identifier of the third interface control to obtain the second script.

[0020] It can be seen that when there is at least one initial interface control among the multiple initial interface controls whose corresponding target similarity is greater than or equal to the second similarity threshold, the script updating device can determine that the at least one initial interface control has a higher similarity with the first interface control, and therefore, the third interface control among the at least one initial interface control can be directly used as the interface control for replacing the first interface control. If the image similarity and text similarity corresponding to the multiple initial interface controls are both less than the second similarity threshold, the script updating device can determine that the current multiple initial interface controls have a lower similarity with the first interface control, and at this time, the script updating device can select the initial interface control with a higher corresponding target similarity from the multiple initial interface controls as a candidate interface control.

[0021] Optionally, the method further includes: when the first code snippet in the first script fails to execute, detecting whether the identifier of the interface control in the first code snippet has been replaced; the obtaining of the context information of the first interface control used by the first code snippet to operate, and the context information of multiple candidate interface controls in the second software, includes: when the identifier of the interface control in the first code snippet has not been replaced, obtaining the context information of the first interface control used by the first code snippet to operate, and the context information of multiple candidate interface controls in the second software. When the identifier of the interface control in the first code snippet has not been replaced, it means that the reason for the failure of the execution of the first code snippet is likely that the interface control has been updated in the second software, and the script updating device can obtain the context information of the first interface control in the first software, and the context information of multiple candidate interface controls in the second software. When the identifier of the interface control in the first code snippet has been replaced, it means that the reason for the failure of the execution of the first code snippet is not that the interface control has been updated in the second software, so the script updating device does not need to perform subsequent steps, but ends immediately, and the staff further analyzes the reason for the failure of the execution of the first code snippet. In this way, the efficiency of determining the update of the first script can be accelerated.

[0022] Optionally, the acquiring the context information of the first interface control includes: acquiring the context information of the first interface control in a context information library; the method further includes: storing the context information of the plurality of candidate interface controls in the context information library.

[0023] On the other hand, a script updating device is provided, and the script updating device includes: various modules for executing the script updating method provided in the above aspect.

[0024] On the other hand, a script updating device is provided, comprising: at least one processor, at least one interface, a memory and at least one communication bus, wherein the processor is used to execute a program stored in the memory to implement the script updating method provided in the present application.

[0025] On the other hand, a readable storage medium is provided, wherein the storage medium stores a computer program, and when the computer program is executed by a processor, the script updating method provided in the present application is implemented. BRIEF DESCRIPTION OF THE DRAWINGS

[0026] Figure 1 A schematic diagram of an interface provided in an embodiment of the present application;

[0027] Figure 2 Another interface schematic diagram provided for an embodiment of the present application;

[0028] Figure 3 A schematic diagram of the structure of a script updating device provided in an embodiment of the present application;

[0029] Figure 4 A flowchart of a script updating method provided in an embodiment of the present application;

[0030] Figure 5 Another interface schematic diagram provided for an embodiment of the present application;

[0031] Figure 6 Another interface schematic diagram provided for an embodiment of the present application;

[0032] Figure 7 A schematic diagram of an interface of a first software provided in an embodiment of the present application;

[0033] Figure 8 A schematic diagram of an interface of a second software provided in an embodiment of the present application;

[0034] Fig. 9 A schematic diagram of the structure of another script updating device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0035] In order to make the objectives, technical solutions and advantages of the present application clearer, the implementation methods of the present application will be further described in detail below with reference to the accompanying drawings.

[0036] GUI software usually includes multiple interface controls (such as text boxes, buttons, drop-down menus and other interface elements), which can be called graphical user interface (GUI) controls. Interface controls refer to visual graphic "elements" that can be displayed in the interface, such as buttons, text boxes, etc., and interface controls encapsulate data and methods, and the execution of some logic can be triggered by operating the controls. When the terminal is running the software, it can usually display at least some of the multiple interface controls as needed. The interface here can be the interface of the terminal.

[0037] Before the software is released, the staff usually needs to use at least one script (such as a test script) to test the software to determine whether the software is faulty. For example, the script of the software usually includes multiple code snippets for sequential execution, each code snippet is used to operate an interface control in the software, and the interface controls operated by the multiple code snippets can be the same or different. Each code snippet includes the identification of the interface control that the code snippet is used to operate, and the indication information of the operation performed on the interface control. For example, the identification of the above-mentioned interface control can be implemented in a variety of ways, such as the number of the interface control, the image of the interface control, the storage address of the image of the interface control, the name of the image of the interface control, or the number of the image of the interface control, etc.

[0038] When testing the software, it is necessary to execute the script on the software (that is, to execute the multiple code snippets recorded in the script in sequence). For example, the script includes code snippets 1 and 2 for sequential execution, and code snippet 1 indicates to operate interface control 1 in the software (such as clicking or entering text), and code snippet 2 indicates to operate interface control 2 in the software. When the terminal executes the script on the software, Figure 1 As shown, the terminal can first display Figure 1 The interface shown in FIG. 1 (the interface includes an interface control 1); thereafter, the terminal executes the code snippet 1 in the script (for example, clicking the interface control 1), so that the terminal displays the following Figure 2 The interface shown (the interface includes interface control 2, interface control 3 and interface control 4); finally, the terminal executes code snippet 2 in the script (such as clicking interface control 2).

[0039] If at least one script is used to test the software and the at least one script is successfully executed, the staff determines that the software does not have a fault. If there is a script that fails to execute among the at least one script, the staff determines that the software has a fault and can repair the software based on the script that failed to execute.

[0040] With the development of technology, software is often updated and replaced, resulting in multiple versions of the software (different versions of the software usually have one or more different interface controls). In addition, before each version of the software is released, the staff needs to test the software of that version. However, since the interface controls in different versions of software are different, after a script based on a certain version of software (such as the first software) is used to test the first software, if another version of the software (such as the second software) needs to be tested, the script cannot be applied to the test of the second software.

[0041] In this case, staff can usually adopt the following practices to test the second software.

[0042] Method 1: The staff needs to rewrite the script of the second software and use the script to test the second software. In this way, the staff needs to write scripts for each version of the software, which is a large workload and has a low test efficiency for the second software.

[0043] Method 2: The staff can manually modify the script of the first software so that the modified script can be applied to the second software. However, this process is time-consuming, labor-intensive, and difficult, and the labor cost of testing the second software is high.

[0044] Method 3: Pre-record the attribute information of the interface control in the first software (referred to as the old interface control). Then, according to the attribute information of the old interface control and the attribute information of the interface control in the second software (referred to as the new interface control), search for the new interface control corresponding to the old interface control in the second software, and then replace the old interface control in the script of the first software with the corresponding new interface control, thereby obtaining the script of the second software. The attribute information of the interface control may include: the title and / or class name of the parent window of the interface control, the position coordinates of the interface control relative to the parent window, and an image of a preset size at the position coordinates. At this time, according to the attribute information of the old interface control and the attribute information of the new interface control, the process of searching the new interface control corresponding to the old interface control in the second software includes: first, according to the title and / or class name of the parent window of the old interface control, find the parent window with the title and / or class name in the second software; then, according to the position coordinates of the old interface control relative to its parent window, intercept the image of the preset size at the position in the second software; finally, calculate the similarity between the image in the attribute information of the old interface control and the image intercepted in the second software, if the similarity is high, then the new interface control at the position of the image is the new interface control corresponding to the old interface control. However, when the position of the new interface control and the old interface control changes greatly, it is easy to find the wrong new interface control in the second software, which leads to an error in the script of the second software. In addition, when the image of the new interface control changes greatly relative to the image of the old interface control, but the text reflected by the image of the new interface control remains unchanged or the meaning does not change much relative to the text reflected by the image of the old interface control, it is also easy to find the wrong new interface control in the second software, which leads to an error in the script of the second software.

[0045] It can be seen that the three script update methods in the related art all have various problems, resulting in low efficiency and accuracy in obtaining the script of the second software, and high labor costs. The embodiment of the present application provides a script update method, which can quickly and effectively update the script with low labor costs.

[0046] The script updating method provided in the embodiment of the present application can be used in the script updating device provided in the embodiment of the present application. Figure 3 A schematic diagram of the structure of a script updating device provided in an embodiment of the present application is shown in FIG. Figure 3 As shown, the script updating device may include: a memory 301 and a processor 302, wherein the memory 301 stores a program, and the processor 302 is used to execute the program stored in the memory 301 to implement the script updating method provided in the embodiment of the present application. Optionally, the script updating device may also include: at least one interface 303 ( Figure 3 An interface is shown in FIG. 1 ) and at least one communication bus 304 ( Figure 3The interface 303 is used to communicate with other storage devices or network devices. The memory 302 and the interface 303 are connected to the processor 301 through the communication bus 304 respectively.

[0047] For example, Figure 4 A flowchart of a script updating method provided in an embodiment of the present application, which can be used in a script updating device (such as Figure 3 The script updating method can be applied to update a first script suitable for operating a first software to a second script suitable for operating a second software, wherein both the first software and the second software include interface controls (that is, both the first software and the second software can be GUI software), and the second software is obtained based on the first software. The first script and the second script can be test scripts, or other operation scripts different from the test scripts, which is not limited in the embodiments of the present application.

[0048] like Figure 4 As shown, the script updating method may include:

[0049] Step 401: Execute the first script on the second software.

[0050] The first script is a script suitable for operating the first software, and the first script includes a first code snippet indicating operation of a first interface control in the first software, and the first code snippet includes an identifier of the first interface control. Optionally, the first script may include multiple code snippets for sequential execution, and each of the multiple code snippets indicates operation of an interface control in the first script, and the interface controls operated by these code snippets may be the same or different, and the first code snippet may be any code snippet among the multiple code snippets.

[0051] The second software is obtained based on the first software. For example, the second software can be obtained by modifying the first software, and the second software can be a new version of the first software. Optionally, the second software can also be modified by modifying the first software. In this case, the second software can be a new version of the new version of the first software. The embodiment of the present application does not limit which new version of the first software the second software is.

[0052] In step 401, the script updating device may first obtain the first script (for example, the staff may input the first script into the script updating device so that the script updating device obtains the first script). Afterwards, the script updating device may sequentially execute multiple code snippets in the first script on the interface controls in the second software according to the first script, so as to achieve the purpose of executing the first script on the second software.

[0053] Step 402: When the first code snippet in the first script fails to execute, obtain auxiliary information of the first interface control and auxiliary information of multiple initial interface controls in the target interface.

[0054] In the process of executing the first script on the second software, the script updating device needs to continuously determine whether each code snippet in the first script is successfully executed. For example, if multiple code snippets executed sequentially in the first script are all successfully executed, the first script is considered to be successfully executed; once it is found that there is a code snippet that failed to execute among the multiple code snippets executed sequentially in the first script, the script updating device can use the code snippet as the first code snippet.

[0055] When the first code segment fails to execute, the script updating device determines that the interface control recorded in the current first script may need to be replaced. At this time, the script updating device may first determine the first interface control used by the first code segment to operate, and obtain auxiliary information of the first interface control.

[0056] When it is found that the execution of the first code snippet fails, the script updating device can also determine the target interface, which is: the interface when the first code snippet is executed on the second software. Afterwards, the script updating device can obtain multiple initial interface controls in the target interface, and obtain auxiliary information of each initial interface control in the multiple initial interface controls. For example, the multiple initial interface controls can be all interface controls in the target interface. Of course, the multiple initial interface controls can also be some interface controls in the target interface, which is not limited in the embodiment of the present application.

[0057] Optionally, for each interface control, the auxiliary information of the interface control includes: image information of the interface control (such as features of the image in the interface control) and / or text information (such as features of the text displayed in the image in the interface control). For example, the auxiliary information of the interface control includes: image information of the interface control, or text information of the interface control, or text information and image information of the interface control. In the embodiment of the present invention, it is taken that the auxiliary information of the interface control includes image information and text information. It should be noted that if the image of a certain interface control does not display text, the text information of the interface control is a preset value (such as 0).

[0058] Optionally, the image information of the interface control may be an image feature, and the script updating device may extract the image feature (usually identified by a numerical vector) using a traditional image feature extraction method, such as scale-invariant feature transform (SIFT), histogram of oriented gradient (HOG) or deep learning method, etc. The deep learning method is, for example, a convolutional neural network (CNN) method, etc.

[0059] When extracting text information of the interface control, the script updating device may first use text recognition technology to obtain the text displayed by the image of the interface control. The text recognition technology may include: optical character recognition (OCR) technology, template matching technology, etc. to extract text from the interface control image. Then, the script updating device may convert the text into text information (such as a numerical vector that includes semantic information and is easy to calculate) through a semantic feature extraction model. The semantic feature extraction model may be, for example, various word embedding models.

[0060] Step 403: Determine the similarity between any one of the information in the auxiliary information of the first interface control and the any one of the information in the auxiliary information of each of the multiple initial interface controls.

[0061] Optionally, the auxiliary information of any interface control includes: image information and text information of the any interface control. In this case, the script updating device can calculate the similarity between the image information of the first interface control and the image information of each initial interface control, and determine the similarity between the image information of the first interface control and the image information of each initial interface control as the image similarity corresponding to each initial interface control. The script updating device can also calculate the similarity between the text information of the first interface control and the text information of each initial interface control, and determine the similarity between the text information of the first interface control and the text information of each initial interface control as the text similarity corresponding to each initial interface control.

[0062] When calculating the above similarity (such as image similarity or text similarity), the script updating device may adopt a vector similarity calculation method, such as a cosine similarity calculation method, a similarity calculation method based on Euclidean distance, etc. Of course, the script updating device may also adopt a calculation method other than the vector similarity calculation method, such as a set similarity calculation method, a Jaccard similarity calculation method, etc. when calculating text similarity, which is not limited in the present embodiment of the application.

[0063] Step 404: Determine multiple candidate interface controls from the multiple initial interface controls based on the similarity between any one of the information in the auxiliary information of the first interface control and the any one of the information in the auxiliary information of each initial interface control.

[0064] After determining the similarity between any one of the auxiliary information of the first interface control and any one of the auxiliary information of the initial interface control, the script updating device can determine, as multiple candidate interface controls, interface controls whose corresponding image similarities among multiple initial interface controls are greater than the target image similarity, and / or interface controls whose corresponding text similarities among multiple initial interface controls are greater than the target text similarity; wherein the target image similarity is any non-maximum image similarity among the image similarities corresponding to the multiple initial interface controls, and the target text similarity is any non-maximum text similarity among the text similarities corresponding to the multiple initial interface controls.

[0065] For example, the script updating device may sort the corresponding image similarities in the multiple initial interface controls in descending order, and determine the image similarity ranked at the k+1th position among these image similarities as the target image similarity, and then determine the interface controls corresponding to the image similarities from the 1st position to the kth position as candidate interface controls. The script updating device may sort the corresponding text similarities in the multiple initial interface controls in descending order, and determine the image similarity ranked at the h+1th position among these text similarities as the target image similarity, and then determine the interface controls corresponding to the image similarities from the 1st position to the hth position as candidate interface controls.

[0066] Among them, when multiple candidate interface controls only include interface controls corresponding to the above-mentioned 1st image similarity to the kth image similarity, k≥2; when multiple candidate interface controls only include interface controls corresponding to the above-mentioned 1st image similarity to the hth text similarity, h≥2; when multiple candidate interface controls include not only interface controls corresponding to the above-mentioned 1st image similarity to the kth image similarity, but also interface controls corresponding to the above-mentioned 1st image similarity to the hth text similarity, k+h≥2.

[0067] For example, it is assumed that the multiple initial interface controls include: initial interface control 1, initial interface control 2, initial interface control 3 and initial interface control 4, the image similarity corresponding to initial interface control 1 is 98%, and the text similarity corresponding to initial interface control 1 is 50%; the image similarity corresponding to initial interface control 2 is 90%, and the text similarity corresponding to initial interface control 2 is 60%; the image similarity corresponding to initial interface control 3 is 85%, and the text similarity corresponding to initial interface control 3 is 50%; the image similarity corresponding to initial interface control 4 is 80%, and the text similarity corresponding to initial interface control 4 is 55%. If k=h=2, the script updating device can determine the two interface controls (initial interface controls 1 and 2, respectively) with higher corresponding image similarities among the four initial interface controls as multiple candidate interface controls, or the script updating device can determine the two interface controls (initial interface controls 2 and 4, respectively) with higher corresponding text similarities among the four initial interface controls as multiple candidate interface controls.

[0068] It can be seen that the script updating device preliminarily determines multiple candidate interface controls among multiple initial interface controls based on the similarity of each type of information in the auxiliary information of the interface control in step 404. The multiple candidate interface controls have a high probability of being the interface controls used to update the first interface control. After determining the multiple candidate interface controls, the interface control used to update the first interface control can be further determined among the multiple candidate interface controls through subsequent steps.

[0069] Step 405: Obtain context information of the first interface control and context information of multiple candidate interface controls.

[0070] When further determining the interface control for updating the first interface control from among the multiple candidate interface controls, the interface control for updating the first interface control may be determined based on the similarity of the context information of the interface controls. For example, in step 405, the script updating device may obtain the context information of the first interface control and the context information of the multiple candidate interface controls, so as to subsequently determine the second interface control for updating the first interface control from among the multiple candidate interface controls based on the obtained context information.

[0071] For example, the context information of any interface control among the first interface control and the multiple candidate interface controls is used to indicate: the changes in the interface of the software where the any interface control is located before and after the operation of the any interface control. At this time, the context information of the first interface control is used to indicate: the changes in the interface of the first software before and after the operation of the first interface control. The context information of the candidate interface control is used to indicate: the changes in the interface of the second software before and after the operation of the candidate interface control.

[0072] For example, the context information of any of the above-mentioned interface controls is used to indicate: the relationship between the interface control used by the any one of the interface controls and at least one other code snippet for operation, and / or, the interface triggered by the operation of the any one of the interfaces. Among them, the other code snippet is a code snippet in the first script that is different from the first code snippet (such as a code snippet executed before the first code snippet, or a code snippet executed after the first code snippet). Optionally, the context information of any of the interface controls includes: information about the interface triggered by the operation of the any of the interface controls (such as the characteristics of the interface). Optionally, when the first script includes a reference code snippet for operation before the first code snippet, the context information of any of the above-mentioned interface controls includes: the positional relationship between the any of the interface controls and the reference interface control used by the reference code snippet in the first software for operation. The reference code snippet can be the previous executed code snippet of the first code snippet, or the first few executed code snippets, which is not limited in the embodiments of the present application.

[0073] By way of example, the positional relationship between any one of the interface controls and the reference interface control may include: the distance between any one of the interface controls and the reference interface control (the distance in the display area of ​​the terminal), and / or the relative orientation between any one of the interface controls and the reference interface control (the relative orientation in the display area of ​​the terminal). By way of example, the distance between any one of the interface controls and the reference interface control may be: the Euclidean distance between any one of the interface controls and the reference interface control, or the ratio of the Euclidean distance to the length of the diagonal of the display area of ​​the terminal, or the ratio of the Euclidean distance to the length of a certain side of the display area); the relative orientation between any one of the interface controls and the reference interface control may be: the angle between a line from the center point of the reference interface control to the center point of any one of the interface controls and a certain side of the display area.

[0074] For example, Figure 5 and Figure 6 Two interface schematic diagrams are provided for the embodiments of the present application. Assume that the first code snippet in the first script indicates Figure 5 Click on the interface control 51 in Figure 5 After the interface control 51 in is clicked, the terminal can display the following Figure 6 The interface shown; the second code snippet in the first script indicates Figure 6. If the second code snippet fails to execute, the script updating device may determine the second code snippet as the first code snippet, and at this time, the first code snippet may be used as a reference code snippet. The interface control 61 indicated by the second code snippet is the first interface control, and the interface control 51 used to operate the first code snippet is the reference interface control. At this time, the relative orientation of the first interface control (interface control 61) and the reference interface control (interface control 51) is: 120 degrees to the upper left of the reference interface control, and the distance between the first interface control and the reference interface control is 90 mm.

[0075] Step 406: Determine the similarity between the context information of the first interface control and the context information of each candidate interface control in the plurality of candidate interface controls.

[0076] In step 406, the script updating device may first determine at least one similarity among the similarity of the information of the interface, the similarity of the distance, and the similarity of the relative position in the context information of the first interface control and the context information of each candidate interface control; and then, based on the at least one similarity, determine the similarity of the context information of the first interface control and the context information of each candidate interface control. For example, in the embodiment of the present application, the at least one similarity includes the similarity of the information of the interface, the similarity of the distance, and the similarity of the relative position.

[0077] The method for calculating the similarity of the information of the above interface may refer to the method for calculating the image similarity in step 403, and the embodiment of the present application will not be described in detail here.

[0078] The similarity of the above distances can be calculated using a distance similarity formula, which includes: s2=1 / (1+|d1-d2|), s2 represents the similarity between the above distance d1 of the first interface control and the above distance d2 of a candidate interface control, and |d1-d2| represents the absolute value of d1-d2;

[0079] The similarity of the above relative orientation can be calculated using the relative orientation similarity formula, which includes: s3=cos|a1-a2|, s3 represents the similarity of the above relative orientation, a1 represents the angle between the line connecting the center point of the reference interface control of the first interface control to the center point of the first interface control and a certain edge of the display area, a2 represents the angle between the line connecting the center point of the reference interface control to the center point of the candidate interface control and a certain edge of the display area, |a1-a2| represents the absolute value of a1-a2, and cos|a1-a2| represents the cosine of |a1-a2|.

[0080] Furthermore, when the at least one similarity simultaneously includes the similarity of the information of the above-mentioned interfaces, the similarity of the distances, and the similarity of the relative positions, the script updating device can calculate the similarity of the context information based on the similarity of the interface information, the similarity of the distances, and the similarity of the relative positions, as well as the similarity weight formula when determining the similarity of the context information of the first interface control and the context information of each candidate interface control. Among them, the similarity weight formula includes: S=q1*s1+q2*s2+q3*s3; S represents the similarity between the context information of the first interface control and the context information of a candidate interface control; s1 represents the similarity between the information of the above interface of the first interface control and the information of the above interface of the candidate interface control; s2 represents the similarity between the above distance of the first interface control and the above distance of the candidate interface control; s3 represents the similarity between the above relative position of the first interface control and the above relative position of the candidate interface control; q1 is the weight of s1, q2 is the weight of s2, q3 is the weight of s3, q1, q2 and q3 are all greater than or equal to zero, and less than or equal to 1, and q1+q2+q3=1.

[0081] Step 407: Determine a second interface control from among the multiple candidate interface controls based on the similarity between the context information of the first interface control and the context information of each candidate interface control from among the multiple candidate interface controls.

[0082] In step 407, the script updating device may first determine the similarity between the context information of the first interface control and the context information of each candidate interface control as the first similarity corresponding to each candidate interface control. Afterwards, the script updating device may determine whether the first similarity corresponding to each candidate interface control among the multiple candidate interface controls is greater than the first similarity threshold. When there is at least one candidate interface control among the multiple candidate interface controls whose corresponding first similarity is greater than the first similarity threshold, the script updating device may determine that the interface control among the at least one candidate interface control that corresponds to the maximum first similarity is the second interface control.

[0083] For example, assume that multiple candidate interface controls include: interface control 1, interface control 2, and interface control 3, and the first similarity corresponding to interface control 1 is 80%, the first similarity corresponding to interface control 2 is 90%, and the first similarity corresponding to interface control 3 is 50%. If the first similarity threshold is 70%, the script updating device can determine that the first similarities corresponding to interface control 1 and interface control 2 are both greater than the first similarity threshold, and the first similarity corresponding to interface control 3 is less than the first similarity threshold. Afterwards, the script updating device can determine the interface control (interface control 2) corresponding to the maximum first similarity between interface control 1 and interface control 2 as the above-mentioned second interface control.

[0084] It can be seen that the script updating device selects a second interface control whose context information has a higher similarity with the context information of the first interface control from among multiple candidate interface controls according to the first similarity and the first similarity threshold corresponding to the candidate interface controls in step 407. The second interface control is likely to be an interface control for implementing the same function as the first interface control, and the second interface control may be an interface control for replacing the first interface control.

[0085] Step 408: Replace the identifier of the first interface control in the first code snippet recorded in the first script with the identifier of the second interface control to obtain a second script.

[0086] After determining the second interface control, the script updating device can adjust the first code segment in the first script so that the interface control identifier in the first code segment is replaced by the identifier of the second interface control. In this way, when the second script is executed on the second software, the first code segment is likely to be executed successfully.

[0087] It should be noted that the update of the first code snippet can be completed by replacing the identifier of the first interface control in the first code snippet recorded in the first script with the identifier of the second interface control. In the embodiment of the present application, the case where there is only one code snippet that needs to be updated in the first script (that is, the above-mentioned first code snippet) is taken as an example. Optionally, there may be multiple code snippets that need to be updated in the first script. After replacing the identifier of the first interface control in the first code snippet recorded in the first script with the identifier of the second interface control, the remaining code snippets in the first script can continue to be executed on the second software, and refer to the above-mentioned steps 402 to 408. Once a code snippet that fails to execute is found, refer to the process of updating the first code snippet to update the code snippet that failed to execute. When all code snippets in the first script are executed successfully, the script update device can consider that the first script has been updated to a second script that can be used to operate the second software.

[0088] In addition, in the above embodiment, taking the existence of a code fragment that fails to execute in the first script as an example, when there is no script that fails to execute in the first script, the script updating device can determine that the first script is also a second script that can be used to operate the second software, and the embodiment of the present application is not limited to this.

[0089] In step 404, the script updating device directly determines the interface controls whose corresponding image similarity is greater than the target image similarity and / or the interface controls whose corresponding text similarity is greater than the target text similarity in multiple initial interface controls as multiple candidate interface controls after determining the similarity of each information in the auxiliary information between the first interface control and the initial interface control as an example. Optionally, the script updating device may first determine whether the image similarity and text similarity corresponding to each initial interface control are both less than the second similarity threshold after determining the similarity of each information in the auxiliary information between the first interface control and the initial interface control. Afterwards, when the image similarity and text similarity corresponding to the multiple initial interface controls are both less than the second similarity threshold, the interface controls whose corresponding image similarity is greater than the target image similarity and / or the interface controls whose corresponding text similarity is greater than the target text similarity in multiple initial interface controls are determined as multiple candidate interface controls.

[0090] At this time, the script updating method may further include: when there is at least one initial interface control among multiple initial interface controls whose corresponding target similarity is greater than or equal to a second similarity threshold, the script updating device determines the interface control corresponding to the maximum target similarity among the at least one initial interface control as a third interface control, and the target similarity is: image similarity or text similarity; thereafter, the script updating device replaces the identifier of the first interface control in the first code fragment in the first script with the identifier of the third interface control to obtain the above-mentioned second script.

[0091] It can be seen that when there is at least one initial interface control among the multiple initial interface controls whose corresponding target similarity is greater than or equal to the second similarity threshold, the script updating device can determine that the at least one initial interface control has a higher similarity with the first interface control, and therefore, the third interface control among the at least one initial interface control can be directly used as the interface control for replacing the first interface control. If the image similarity and text similarity corresponding to the multiple initial interface controls are both less than the second similarity threshold, the script updating device can determine that the current multiple initial interface controls have a lower similarity with the first interface control, and at this time, the script updating device can select the initial interface control with a higher corresponding target similarity from the multiple initial interface controls as a candidate interface control.

[0092] In the above embodiment, when the first script fails to execute, the script updating device directly obtains the auxiliary information of the first interface control and the auxiliary information of each initial interface control in the multiple initial interface controls as an example. Optionally, when the first script fails to execute, the script updating device can detect whether the identifier of the interface control in the first code snippet has been replaced. When the identifier of the interface control in the first code snippet has not been replaced, it means that the reason for the failure of the first code snippet to execute is likely that the interface control has been updated in the second software. At this time, the script updating device can obtain the auxiliary information of the first interface control and the auxiliary information of each initial interface control in the multiple initial interface controls. When the identifier of the interface control in the first code snippet has been replaced, it means that the reason for the failure of the first code snippet to execute is not that the interface control has been updated in the second software. Therefore, the script updating device does not need to execute subsequent steps, but ends immediately, and the staff further analyzes the reason for the failure of the first code snippet to execute. In this way, the efficiency of determining the update of the first script can be accelerated.

[0093] Optionally, in the above embodiment, screening the above-mentioned multiple candidate interface controls from multiple initial interface controls in the second software is taken as an example. Of course, the multiple candidate interface controls may also be all interface controls in the second software (in this case, there is no need to execute steps 402 to 404), or, the multiple candidate interface controls may also be some interface controls randomly selected from the second software (in this case, there is no need to execute steps 402 to 404). The embodiment of the present application is not limited to this.

[0094] Optionally, the script updating device may maintain a context information library. In this case, the script updating device in the above step 405 may obtain the context information of the first interface control from the context information library. For example, the context information library is used to store context information groups corresponding to scripts of multiple software, and the context information group may include context information of the interface control used for operation by each code snippet in the script. In step 405, the script updating device may obtain the context information of the first interface control from the context information group corresponding to the script of the first software in the context information library.

[0095] For example, each software may have one or more scripts, and the context information library includes: a context information group corresponding to each script. For example, in the context information library, the context information group corresponding to each script can be recorded in a context information table corresponding to the identifier of the script, and the identifier of the script can be the number (also known as ID) or name of the script. For example, the context information table can be shown in Table 1 below, wherein the context information table may include: a code snippet in the script (such as recording the code snippet by recording the ID of the code snippet), an interface control used by the code snippet to operate (such as recording the interface control by recording the ID of the interface control), information of the interface triggered by the interface control operated by the code snippet, the distance between the interface control operated by the code snippet and the reference interface control, and the relative position between the interface control operated by the code snippet and the reference interface control. Optionally, the context information table may also include a save path of the interface triggered by the interface control operated by the code snippet, and a reference interface control (such as recording the reference interface control by recording the reference interface control ID). It should be noted that if a code snippet does not have a reference code snippet, the relative positions of the interface controls used to operate the code snippet and the reference interface controls can be set to zero, the distance between the interface controls used to operate the code snippet and the reference interface controls can also be set to zero, and the reference interface control ID can also be set to zero.

[0096] Table 1

[0097]

[0098]

[0099] When the script updating device obtains the context information of the first interface control, it can first search the context information table corresponding to the first script of the first software in the context information library based on the information of the first software (such as the version number) and the identifier of the first script. Afterwards, the script updating device can use the above-mentioned orientation, the above-mentioned distance and the above-mentioned interface information corresponding to the ID of the first code fragment (the code fragment indicating the first interface control) in the context information table as the context information of the first interface control. In this case, after obtaining the context information of multiple candidate interface controls, the script updating device can also store the context information of these candidate interface controls in the context information library, such as storing the context information group corresponding to the script of the second software, and the context information group includes: the context information of the interface control used for operation by each code fragment in the script of the second software. In this way, when other software is obtained based on the second software, when executing Figure 4 In the process of the method shown, the original second software is used as Figure 4 The first software in the method shown, the other software as Figure 4The second software in the method shown directly searches for the context information of the first interface control in the context information library.

[0100] Furthermore, the script updating device may also maintain an auxiliary information library for storing auxiliary information of each interface control of the software. At this time, in the above step 402, the script updating device may search the auxiliary information of the first interface control and the initial interface control in the auxiliary information library.

[0101] By way of example, the auxiliary information library may include an auxiliary information table corresponding to the software as shown in Table 2, wherein the auxiliary information table may include: interface controls in the software (such as recording the interface controls by recording their IDs), text displayed by images in the interface controls, information on the text displayed by images in the interface controls (that is, text information of the interface controls), the save path of the interface controls, information on the images in the interface controls, an identifier of the interface where the interface controls are located (such as an ID), and the position of the interface controls in the display area of ​​the terminal.

[0102] Table 2

[0103]

[0104] When the script updating device obtains the auxiliary information of any interface control, it can first obtain the ID of the interface control, and then search the auxiliary information corresponding to the ID of the interface control in the auxiliary information library according to the ID of the interface control (such as the text information of the above-mentioned interface control, and the image information of the interface control). Among them, when the script updating device obtains the ID of the first interface control, it can obtain the ID of the first interface control corresponding to the ID of the first code fragment in the context information library. It should be noted that if the auxiliary information library does not include the auxiliary information corresponding to the ID of a certain interface control, the script updating device needs to adopt other methods (such as receiving auxiliary information input by the staff) to obtain the auxiliary information, and then add the obtained auxiliary information to the auxiliary information library.

[0105] Figure 4 In the illustrated embodiment, the script updating device first obtains the auxiliary information and then obtains the context information. Optionally, the script updating device may also first obtain the context information and then obtain the auxiliary information.

[0106] The following is an example of Figure 4 The script update method shown in the figure is explained.

[0107] For example, Figure 7 A schematic diagram of an interface of a first software provided in an embodiment of the present application, Figure 8The interface diagram of the second software provided in the embodiment of the present application. Assume that the first script of the first software includes: Code fragment a): Click interface control 1 (such as Figure 7 As shown); Code snippet b): Click interface control 2 (as shown Figure 7 shown).

[0108] When the first script is executed on the second software, after executing code fragment a), due to Figure 8 The interface of the second software shown does not include Figure 7 Therefore, the code segment b) will fail to execute. At this time, the script updating device can determine that the code segment b) is the first code segment, and the interface control 2 used for operation by the code segment b) is the first interface control.

[0109] Afterwards, the script updating device may update the script based on the method in steps 402 to 404. Figure 8 Filter multiple candidate interface controls (such as Figure 8 Interface control 3, interface control 4 and interface control 5 in the code snippet b). Among them, the text displayed by the image of interface control 3 includes "wallet", and the text displayed by the image of interface control 4 includes "card package", both of which have a high similarity with the information (such as text features) of the text "payment" displayed by the image of interface control 2 used for operation in code snippet b); the text of interface control 5 includes "WeChat", and the image of interface control 5 has a high similarity with the image of interface control 2 used for operation in code snippet b). In this example, in step 404, one interface control with a high corresponding image similarity among multiple initial interface controls and two interface controls with a high corresponding text similarity among the multiple initial interface controls are determined as the multiple candidate interface controls.

[0110] Next, the script updating device can use the method in step 405 to step 407 to determine Figure 7 Interface control 1 (first interface control) and Figure 8 The context information of interface control 3 in Figure 8 The interface control 3 among the interface control 3, the interface control 4 and the interface control 5 is determined as the second interface control. For example, click Figure 7 The interface triggered by the interface control 1 in the click Figure 8 The interface triggered by interface control 3 in the example is highly similar. Figure 8 The functions of interface control 3 in Figure 7 The functions of interface control 1 in are similar to those in Figure 8 The interface control 3 in the second software is most likely used to replace Figure 7 The interface controls in interface control 1.

[0111] Finally, the script updating device can use the method in step 408 to replace the interface control identifier in the code segment b) in the first script with Figure 7 The identifier of interface control 1 in is updated to Figure 8 Just click the icon of interface control 3 in the figure.

[0112] In summary, in the script updating method provided in the embodiment of the present application, the script updating device can determine the second interface control used to replace the first interface control among multiple candidate interface controls by comparing the similarity of the context information of the first interface control in the first software and the candidate interface control in the second software, and then update the first script of the first software according to the first interface control and the second interface control to obtain the second script. Since the interface control used to operate by the code snippet in the second script is the interface control in the second software, the second script can realize the operation of the second software.

[0113] Furthermore, the script updating method provided in the embodiment of the present application can automatically update the first script without requiring excessive operations by staff. Therefore, the labor cost and difficulty of the script updating process are low.

[0114] In addition, in the embodiment of the present application, the second interface control used to replace the first interface control is searched based on the similarity of the context information of the interface control. Even if the auxiliary information of the second interface control has changed, the second interface control can be accurately found through the context information. Therefore, in the embodiment of the present application, the accuracy of finding the second interface control is high, and the efficiency of script updating is also high.

[0115] Fig. 9 A schematic diagram of the structure of another script updating device provided in an embodiment of the present application, wherein the script updating device can be used for Figure 3 The script updating device is used to update a first script suitable for operating a first software into a second script suitable for operating a second software, wherein the second software is obtained based on the first software, the first software and the second software both include interface controls, the first script includes a first code snippet indicating operation of a first interface control in the first software, and the first code snippet includes an identifier of the first interface control.

[0116] like Fig. 9 As shown, the script updating device includes:

[0117] An execution module 901, configured to execute the first script on the second software;

[0118] The acquisition module 902 is used to acquire the context information of the first interface control and the context information of multiple candidate interface controls in the second software when the execution of the first code snippet fails, wherein the context information of any interface control among the first interface control and the multiple candidate interface controls is used to indicate: the change of the interface of the software where the any interface control is located before and after the operation of the any interface control;

[0119] A first determination module 903, used to determine the similarity between the context information of the first interface control and the context information of each candidate interface control in the plurality of candidate interface controls;

[0120] A second determination module 904, configured to determine a second interface control from among a plurality of candidate interface controls based on the determined similarity;

[0121] The first replacement module 905 is used to replace the identifier of the first interface control in the first code fragment in the first script with the identifier of the second interface control to obtain the second script.

[0122] In summary, in the script updating device provided by the embodiment of the present application, the second determination module can determine the second interface control used to replace the first interface control among multiple candidate interface controls by comparing the similarity of the context information of the first interface control in the first software and the candidate interface control in the second software, and then the first replacement module updates the first script of the first software according to the first interface control and the second interface control to obtain the second script. Since the interface control used to operate by the code snippet in the second script is the interface control in the second software, the second script can realize the operation of the second software.

[0123] Optionally, the context information of any interface control includes: information of an interface triggered by operating the any interface control.

[0124] Optionally, when the first script also includes a reference code snippet for execution before the first code snippet, the context information of any interface control includes: the positional relationship between any interface control and a reference interface control in the first software, and the reference code snippet indicates an operation to be performed on the reference interface control.

[0125] Optionally, the positional relationship between any one of the interface controls and the reference interface control includes: a distance between any one of the interface controls and the reference interface control, and / or a relative orientation between any one of the interface controls and the reference interface control.

[0126] Optionally, the first determining module is used to:

[0127] Determine at least one similarity among similarity of interface information, similarity of distance, and similarity of relative orientation in the context information of the first interface control and the context information of each interface control;

[0128] Based on at least one similarity, similarity between the context information of the first interface control and the context information of each candidate interface control is determined.

[0129] Optionally, the second determining module is used to:

[0130] Determine the similarity between the context information of the first interface control and the context information of each candidate interface control as a first similarity corresponding to each candidate interface control;

[0131] When there is at least one candidate interface control whose corresponding first similarity is greater than the first similarity threshold among the multiple candidate interface controls, the interface control corresponding to the maximum first similarity among the at least one candidate interface control is determined as the second interface control.

[0132] Optionally, the script updating device further includes:

[0133] A screening module is used to screen the multiple candidate interface controls from the multiple initial interface controls of the target interface before obtaining the context information of the multiple candidate interface controls, wherein the target interface is: the interface when the first code snippet is executed in the interface of the second software.

[0134] Optionally, the acquisition module is used to:

[0135] Acquire auxiliary information of the first interface control and auxiliary information of each initial interface control in the plurality of initial interface controls, wherein the auxiliary information of any interface control includes: image information and / or text information of any interface control;

[0136] Based on the similarity between any one of the auxiliary information of the first interface control and any one of the auxiliary information of each initial interface control, the multiple candidate interface controls in the target interface are determined.

[0137] Optionally, the auxiliary information of any interface control includes: image information and text information of any interface control, and the acquisition module is used to:

[0138] Determine, as the multiple candidate interface controls, interface controls whose corresponding image similarity is greater than the target image similarity among the multiple initial interface controls, and / or interface controls whose corresponding text similarity is greater than the target text similarity among the multiple initial interface controls;

[0139] The image similarity corresponding to each initial interface control includes: the similarity between the image information of the first interface control and the image information of each initial interface control; the text similarity corresponding to each initial interface control includes: the similarity between the text information of the first interface control and the text information of each initial interface control;

[0140] The target image similarity is any non-maximum image similarity among the image similarities corresponding to the multiple initial interface controls, and the target text similarity is any non-maximum text similarity among the text similarities corresponding to the multiple initial interface controls.

[0141] Optionally, the acquisition module is used to: when the image similarity and text similarity corresponding to multiple initial interface controls are both less than a second similarity threshold, determine the interface controls among the multiple initial interface controls whose corresponding image similarity is greater than the target image similarity, and / or, the interface controls among the multiple initial interface controls whose corresponding text similarity is greater than the target text similarity, as the multiple candidate interface controls.

[0142] Optionally, the script updating device further includes:

[0143] A third determination module is used to determine, when there is at least one initial interface control whose corresponding target similarity is greater than or equal to a second similarity threshold among the multiple initial interface controls, an interface control corresponding to the maximum target similarity among the at least one initial interface control as a third interface control, wherein the target similarity is: image similarity or text similarity;

[0144] The second replacement module is used to replace the identifier of the first interface control in the first code fragment in the first script with the identifier of the third interface control to obtain the second script.

[0145] Optionally, the script updating device further includes:

[0146] A detection module, configured to detect whether an identifier of an interface control in the first code fragment has been replaced when the execution of the first code fragment in the first script fails;

[0147] The acquisition module is used to: when the identifier of the interface control in the first code snippet has not been replaced, acquire context information of the first interface control used for operation by the first code snippet and context information of multiple candidate interface controls in the second software.

[0148] Optionally, the acquisition module is used to: acquire context information of the first interface control in a context information library;

[0149] The script updater also includes:

[0150] The storage module is used to store context information of multiple candidate interface controls in a context information library.

[0151] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product, which includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present invention is generated in whole or in part. The computer can be a general-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website site, computer, server or data center to another website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line) or wireless (e.g., infrared, wireless, microwave, etc.) mode. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server, data center, etc. that contains one or more available media integrated. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium, or a semiconductor medium (e.g., a solid-state hard disk), etc.

[0152] It should be noted that the method embodiments provided in the embodiments of the present invention can be referenced with the corresponding device embodiments, and the embodiments of the present invention are not limited thereto. The sequence of steps of the method embodiments provided in the embodiments of the present invention can be appropriately adjusted, and the steps can be increased or decreased accordingly according to the circumstances. Any technician familiar with the technical field can easily think of a method of change within the technical scope disclosed in the present invention, and it should be covered within the protection scope of the present invention, so it will not be repeated.

[0153] The above description is only an optional embodiment of the present application and is not intended to limit the present application. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present application shall be included in the protection scope of the present application.

Claims

1. A script updating method, applied to update a first script applicable to operating a first software into a second script applicable to operating a second software, wherein: The second software is obtained based on the first software, the first software and the second software both include an interface control, the first script includes a first code snippet for operating a first interface control in the first software, and the first code snippet includes an identifier of the first interface control, wherein the method includes: executing the first script on the second software; When the first code snippet fails to execute, the context information of the first interface control is obtained from the context information library, and when the first code snippet fails to execute, the context information of multiple candidate interface controls in the second software is obtained; wherein the context information of any interface control among the first interface control and the multiple candidate interface controls is used to indicate: changes in the interface of the software where the any interface control is located before and after the operation of the any interface control; Determining a similarity between the context information of the first interface control and the context information of each candidate interface control in the plurality of candidate interface controls; Determine, among the multiple candidate interface controls, a candidate interface control whose context information has the greatest similarity to the context information of the first interface control as a second interface control; The identifier of the first interface control in the first code snippet in the first script is replaced with the identifier of the second interface control to obtain the second script.

2. The method according to claim 1, characterized in that The context information of any interface control includes: information of an interface triggered by operating any interface control.

3. The method according to claim 2, characterized in that When the first script also includes a reference code snippet for executing before the first code snippet, the context information of any interface control includes: the positional relationship between any interface control and a reference interface control in the first software, and the reference code snippet is used to operate the reference interface control.

4. The method according to claim 3, characterized in that The positional relationship between any one of the interface controls and the reference interface control includes: the distance between any one of the interface controls and the reference interface control, and / or the relative orientation between any one of the interface controls and the reference interface control.

5. The method according to claim 4, characterized in that Determining the similarity between the context information of the first interface control and the context information of each candidate interface control in the plurality of candidate interface controls includes: Determine at least one similarity among the similarity of the information of the interface, the similarity of the distance, and the similarity of the relative orientation in the context information of the first interface control and the context information of each candidate interface control; Based on the at least one similarity, similarity between the context information of the first interface control and the context information of each candidate interface control is determined.

6. The method according to any one of claims 1 to 5, characterized in that: Determining, among the plurality of candidate interface controls, a candidate interface control whose context information has the greatest similarity to the context information of the first interface control as the second interface control, comprises: Determine the similarity between the context information of the first interface control and the context information of each candidate interface control as a first similarity corresponding to each candidate interface control; When there is at least one candidate interface control whose corresponding first similarity is greater than a first similarity threshold among the multiple candidate interface controls, the interface control corresponding to the maximum first similarity among the at least one candidate interface control is determined to be the second interface control.

7. The method according to any one of claims 1 to 5, characterized in that: The method further comprises: Before acquiring context information of the plurality of candidate interface controls, the plurality of candidate interface controls are screened from a plurality of initial interface controls of a target interface, wherein the target interface is an interface when the first code snippet in the first script is executed on the second software.

8. The method according to claim 7, characterized in that The screening of the plurality of candidate interface controls from the plurality of initial interface controls of the target interface includes: Acquire auxiliary information of the first interface control and auxiliary information of each initial interface control of the multiple initial interface controls, wherein the auxiliary information of any interface control includes: image information and / or text information of any interface control; Based on the similarity between any one of the auxiliary information of the first interface control and any one of the auxiliary information of each initial interface control, the multiple candidate interface controls in the target interface are determined.

9. The method according to claim 8, characterized in that The auxiliary information of any one of the interface controls includes: image information and text information of any one of the interface controls, and based on the similarity between any one of the information in the auxiliary information of the first interface control and any one of the information in the auxiliary information of each of the initial interface controls, determining the multiple candidate interface controls in the target interface includes: Determine, as the multiple candidate interface controls, interface controls whose corresponding image similarity is greater than the target image similarity among the multiple initial interface controls, and / or interface controls whose corresponding text similarity is greater than the target text similarity among the multiple initial interface controls; The image similarity corresponding to each initial interface control includes: the similarity between the image information of the first interface control and the image information of each initial interface control; the text similarity corresponding to each initial interface control includes: the similarity between the text information of the first interface control and the text information of each initial interface control; The target image similarity is any non-maximum image similarity among the image similarities corresponding to the multiple initial interface controls, and the target text similarity is any non-maximum text similarity among the text similarities corresponding to the multiple initial interface controls.

10. The method according to claim 9, characterized in that Determining interface controls whose corresponding image similarity among the multiple initial interface controls is greater than the target image similarity, and / or interface controls whose corresponding text similarity among the multiple initial interface controls is greater than the target text similarity as the multiple candidate interface controls, includes: When the image similarities and text similarities corresponding to the multiple initial interface controls are both less than a second similarity threshold, interface controls among the multiple initial interface controls whose corresponding image similarities are greater than the target image similarity, and / or interface controls among the multiple initial interface controls whose corresponding text similarities are greater than the target text similarity, are determined as the multiple candidate interface controls.

11. The method according to claim 10, characterized in that The method further comprises: When there is at least one initial interface control whose corresponding target similarity is greater than or equal to the second similarity threshold among the multiple initial interface controls, determining the interface control corresponding to the maximum target similarity among the at least one initial interface control as the third interface control, wherein the target similarity is: the image similarity or the text similarity; The identifier of the first interface control in the first code snippet in the first script is replaced with the identifier of the third interface control to obtain the second script.

12. A script updating device, characterized in that: The script updating device comprises: a processor and a memory, wherein the processor is used to execute a program stored in the memory to implement the script updating method according to any one of claims 1 to 11.

13. A readable storage medium, characterized in that: The storage medium stores a computer program, and when the computer program is executed by a processor, the script updating method according to any one of claims 1 to 11 is implemented.

Citation Information

Patent Citations

  • Development method and device of code files of host computer

    CN104317602A

  • Method and device for updating test scripts

    CN107102938A