A method, apparatus, device, and storage medium for automated testing of enterprise Web UI.
By generating and replacing the location code files for UI automation tests, and utilizing machine learning and multimodal large models to handle page changes, the problem of test case execution failure in existing technologies is solved, achieving efficient and seamless recovery and batch testing.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- HANGZHOU DBAPPSECURITY CO LTD
- Filing Date
- 2026-03-06
- Publication Date
- 2026-06-05
AI Technical Summary
Existing UI automation testing methods are prone to failure when the page structure changes, leading to test case execution failures, high maintenance costs, and existing self-healing methods cannot be seamlessly continued, resulting in delayed responses.
A script code file is generated based on the enterprise's webpage address input by the user. The code file is extracted and located using a preset code extraction function. Failed code is matched using machine learning array documents. If a match fails, a screenshot is taken and a replacement code is generated using a multimodal large model until no code fails to execute during the playback process.
It improves test coverage and accuracy, reduces script maintenance costs and technical barriers, and enables seamless test recovery under dynamic page changes.
Smart Images

Figure CN122152704A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer technology, and in particular to an automated testing method, apparatus, device, and storage medium for enterprise Web UI. Background Technology
[0002] With the rapid iteration of web applications, UI (User Interface) automated testing is crucial for ensuring software quality. Currently, mainstream UI automated testing methods primarily rely on script recording tools (such as Selenium IDE and Playwright Codegen) or manually written test scripts. However, recorded or written scripts heavily depend on specific locators of UI elements (such as IDs and XPaths). When there are minor changes to the page structure, element attributes, or text, the original locators often become invalid, leading to test case execution failures and significant maintenance costs. For large-scale test failures caused by dynamic page changes, manual troubleshooting and repair are required, which is time-consuming and difficult to adapt to the fast-paced requirements of agile development and continuous integration / continuous deployment.
[0003] Existing technologies are self-healing methods for automated test scripts based on dynamic analysis. They predict possible change patterns of elements through machine learning models and dynamically adjust the positioning strategy. However, after the repair, the entire test case needs to be rerun, and it cannot seamlessly continue at the failed step. It does not combine business semantic tags, which leads to the locator mismatching among similar elements after the repair. Moreover, it relies on historical data for training and is slow to respond to sudden changes in UI structure.
[0004] As can be seen from the above, how to reduce the cost of test cases and improve the success rate of tests is an urgent problem to be solved. Summary of the Invention
[0005] In view of this, the purpose of this invention is to provide an automated testing method, apparatus, device, and storage medium for enterprise Web UIs, which can reduce the cost of test cases and improve the test success rate. The specific solution is as follows: Firstly, this application provides an automated testing method for enterprise Web UI, including: A corresponding script code file is generated based on the enterprise webpage address input by the user. The script code file is then extracted using a preset code extraction function to obtain the location code file. The location code file is replayed using test cases. If target code fails to execute during the replay, the code keys in the machine learning array document are matched with the target code. If the matching fails, a screenshot of the webpage interface where the code execution failed is taken to obtain the corresponding webpage screenshot. Replacement code is generated based on the preset Playwright code generation template and the webpage screenshot, and using a multimodal large model. The target code is replaced using the replacement code to obtain a new location code file. Then, the process jumps to the step of replaying test cases on the location code file until no target code fails to execute during the replay process, thus obtaining the target location code file. The target location code file is then subjected to batch testing to obtain a corresponding test report.
[0006] Optionally, the step of generating a corresponding script code file based on the enterprise webpage address input by the user, and extracting the script code file using a preset code extraction function to obtain a location code file includes: Obtain the enterprise webpage address to be tested and the recording instruction input by the user, and generate the corresponding code generation command based on the enterprise webpage address to be tested and the recording instruction; Execute the code generation command to obtain a browser, generate corresponding Playwright code based on the webpage operation of the user terminal in the browser, and use each Playwright code to generate a corresponding original script file; The core positioning code in the script code file is extracted using a preset code extraction function to obtain the positioning code file.
[0007] Optionally, after performing use case playback on the location code file, the method further includes: If no target code fails to execute during playback, the location code file is identified as the target location code file, and then the process jumps to the step of batch testing the target location code file.
[0008] Optionally, after matching the code keys in the machine learning array document with the target code, the method further includes: If a match is successful, the target code block in the machine learning array document that matches the target code is identified as the replacement code, and then the process jumps to the step of replacing the target code with the replacement code.
[0009] Optionally, if the matching fails, a screenshot is taken of the webpage interface where the code execution failed to obtain the corresponding webpage screenshot. Replacement code is then generated based on a preset Playwright code generation template and the webpage screenshot, utilizing a multimodal large model, including: If the match fails, take a screenshot of the webpage where the code execution failed to obtain the corresponding webpage screenshot; The system obtains the natural language command input by the user in the input box, and generates replacement code based on the natural language command, a preset Playwright code generation template, and the webpage screenshot, using a multimodal large model.
[0010] Optionally, before performing batch testing on the target location code file, the method further includes: Use the target code in the target location code file as the key and the replacement code corresponding to the target code as the value; Based on the key and value, construct corresponding key-value pairs, and use the key and value to update the machine learning array document.
[0011] Optionally, the step of replacing the target code with the replacement code to obtain a new location code file, and then jumping to the step of replaying the location code file for test cases until no target code fails to execute during the replay process, to obtain the target location code file, includes: The target code is replaced with the replacement code to obtain a new location code file. Then, the process jumps to the step of playing back the use case of the location code file until there is no target code that fails to execute during the playback process. A screenshot of the successfully executed web page is then taken to obtain the target screenshot. The CV2 image recognition technology is used to compare the webpage screenshot and the target screenshot, and the comparison results are used to determine whether there are any differences between the webpage screenshot and the target screenshot. If there is a discrepancy, the location code file that did not fail to execute during the playback process will be identified as the target location code file.
[0012] Secondly, this application provides an automated testing device for enterprise Web UI, comprising: The code file extraction module is used to generate a corresponding script code file based on the enterprise webpage address input by the user, and to extract the script code file using a preset code extraction function to obtain the location code file; The code matching module is used to perform test case replay on the located code file. If there is target code that fails to execute during the replay process, the code keys in the machine learning array document are used to match the target code. The code block generation module is used to take a screenshot of the web page interface where the code execution failed if the matching fails, so as to obtain the corresponding web page screenshot. Based on the preset Playwright code generation template and the web page screenshot, the module generates replacement code using a multimodal large model. The code file testing module is used to replace the target code with the replacement code to obtain a new location code file. Then, it jumps to the step of replaying test cases on the location code file until there is no target code that fails to execute during the replay process, so as to obtain the target location code file. The target location code file is then batch tested to obtain a corresponding test report.
[0013] Thirdly, this application provides an electronic device, comprising: Memory, used to store computer programs; A processor is used to execute the computer program to implement the aforementioned enterprise Web UI automated testing method.
[0014] Fourthly, this application provides a computer-readable storage medium for storing a computer program, wherein the computer program, when executed by a processor, implements the aforementioned enterprise Web UI automated testing method.
[0015] This application generates a corresponding script code file based on the enterprise webpage address input by the user. A preset code extraction function is used to extract the script code file to obtain a location code file. Test case replay is performed on the location code file. If target code fails to execute during replay, the code keys in the machine learning array document are matched against the target code. If the match fails, a screenshot of the webpage interface where the code failed is taken to obtain a corresponding webpage screenshot. A replacement code is generated based on a preset Playwright code generation template and the webpage screenshot, using a multimodal large model. The replacement code is used to replace the target code to obtain a new location code file. Then, the process returns to the step of replaying test cases on the location code file until no target code fails to execute during replay, thus obtaining the target location code file. Batch testing is then performed on the target location code file to obtain a corresponding test report.
[0016] As can be seen from the above, this application requires no coding whatsoever. Simply inputting the URL of the webpage to be tested generates the corresponding script code file, from which the location code file containing the core operations is extracted. An initial replay test of the location code file is performed. If any target code fails to execute, machine learning array documents are used to match the target code. If no match is found, replacement code is generated based on screenshots of the test failure and a preset Playwright template, using a multimodal large model. Replay is then performed again after the replacement until no failed code is found during replay, preventing test interruption. This allows for batch testing of the repaired target location code file, generating corresponding test reports, significantly improving test coverage and accuracy, and reducing script-level costs and technical barriers. Attached Figure Description
[0017] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.
[0018] Figure 1 This application discloses a flowchart of an enterprise Web UI automated testing method. Figure 2 This application discloses a specific flowchart of an enterprise Web UI automated testing method. Figure 3 This application discloses a specific flowchart of an enterprise Web UI automated testing method. Figure 4 This is a schematic diagram of the structure of an enterprise Web UI automated testing device disclosed in this application; Figure 5 This is a structural diagram of an electronic device disclosed in this application. Detailed Implementation
[0019] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0020] Currently, existing technologies rely on self-healing methods for automated test scripts based on dynamic analysis. These methods predict possible change patterns of elements using machine learning models and dynamically adjust the localization strategy. However, after repair, the entire test case needs to be rerun, making seamless continuation at failed steps impossible. Furthermore, the lack of integration with business semantic tags leads to mismatches by the repaired locator among similar elements. Additionally, the reliance on historical data training results in a delayed response to sudden UI structure changes. To address these issues, this application provides an automated testing method for enterprise Web UIs. This method performs batch testing on the repaired target localization code files, generating corresponding test reports. This significantly improves test coverage and accuracy while reducing script-level costs and technical barriers.
[0021] See Figure 1 As shown in the figure, an embodiment of the present invention discloses an automated testing method for enterprise Web UI, including: Step S11: Generate a corresponding script code file based on the enterprise webpage address input by the user terminal, and extract the script code file using a preset code extraction function to obtain the location code file.
[0022] In this embodiment, the system obtains the enterprise's test webpage address and record button command input by the user to execute the corresponding Playwright command. The enterprise's test webpage address can be the enterprise's official website or backend system address. The Playwright command can be in the form of: "playwright codegen -o script filename to keep recording -bchromium target website address --ignore-https-errors". Based on the Playwright command, a driver browser for recording is launched. The user's actions in the driver browser are converted into Playwright code in page.xxx format. After the user's actions are completed, the driver browser is closed, and the Playwright codes are integrated to obtain the original script file. A preset code extraction function is used to extract the core positioning code from the original script file to obtain a positioning code file, which can be saved to a case.txt file.
[0023] Specifically, the step of generating a corresponding script code file based on the enterprise webpage address to be tested input by the user, and extracting the script code file using a preset code extraction function to obtain a location code file includes: obtaining the enterprise webpage address to be tested and recording instructions input by the user, and generating a corresponding code generation command based on the enterprise webpage address to be tested and the recording instructions; executing the code generation command to obtain a browser, generating corresponding Playwright code based on the webpage operation of the user in the browser, and generating a corresponding original script file using each Playwright code; and extracting the core location code from the script code file using the preset code extraction function to obtain a location code file.
[0024] Step S12: Play back the test cases of the location code file. If there is target code that fails to execute during the playback process, match the target code with each code key in the machine learning array document.
[0025] In this embodiment, after obtaining the location code file, an AI repair replay function is started to read and replay each location code file in the case.txt file. If all code executes normally during the replay process, and the webpage operation is consistent with the user's recording, with no execution failures, the case.txt file is renamed to testcase.txt and saved to the test case folder. If there is target code that fails to execute during the replay process, the machine learning module is entered, and the target code is compared one by one with the code blocks in the machine learning JSON array document. Specifically, after replaying the location code file, the process further includes: if there is no target code that fails to execute during the replay process, the location code file is identified as the target location code file, and then the process jumps to the step of batch testing the target location code file.
[0026] Understandably, if the obtained comparison results indicate that a target code block corresponding to the target code exists in the array document, then the target code block is identified as the replacement code. Specifically, after matching the code keys in the machine learning array document with the target code, the process further includes: if a match is successful, identifying the target code block in the machine learning array document that matches the target code as the replacement code, and then proceeding to the step of replacing the target code with the replacement code.
[0027] Step S13: If the matching fails, take a screenshot of the webpage interface where the code execution failed to obtain the corresponding webpage screenshot. Based on the preset Playwright code generation template and the webpage screenshot, generate replacement code using a multimodal large model.
[0028] In this embodiment, if the array document does not contain a target code block corresponding to the target code, it indicates a matching failure. The page.screenshot method is called to take a screenshot of the interface where the code execution failed, so as to obtain a webpage screenshot. Then, a corresponding input box pops up, and the natural language command entered by the user in the input box is obtained. The webpage screenshot, the natural language command, and the preset Playwright code generation template are transmitted to the multimodal large model to obtain the replacement code.
[0029] Specifically, if the matching fails, a screenshot is taken of the webpage where the code execution failed to obtain a corresponding webpage screenshot. Replacement code is then generated based on a preset Playwright code generation template and the webpage screenshot, using a multimodal large model. This includes: if the matching fails, taking a screenshot of the webpage where the code execution failed to obtain a corresponding webpage screenshot; obtaining the natural language command input by the user in the input box; and generating replacement code based on the natural language command, the preset Playwright code generation template, and the webpage screenshot, using a multimodal large model.
[0030] Step S14: Replace the target code with the replacement code to obtain a new location code file. Then, jump to the step of playing back the test cases of the location code file until there is no target code that fails to execute during the playback process, so as to obtain the target location code file. Perform batch testing on the target location code file to obtain the corresponding test report.
[0031] In this embodiment, after obtaining the replacement code, the target code is replaced to obtain a new positioning code file. Then, the code is replayed until no code execution failure occurs. A screenshot of the successfully executed webpage is taken to obtain a target screenshot. The differences between the target screenshot and the webpage screenshot are compared using CV2 (the module name of the OpenCV library in Python) image recognition technology. If the difference meets the target difference condition, it indicates that the code execution is successful, thereby determining the target positioning code file. If the target difference condition is not met, the process jumps to the step of generating replacement code based on a preset Playwright code generation template and the webpage screenshot using a multimodal large model, until the target difference condition is met. The target difference condition can be determined according to the actual situation.
[0032] Specifically, the step of replacing the target code with the replacement code to obtain a new location code file, and then proceeding to the step of replaying the location code file for test cases until no target code fails to execute during the replay process, to obtain the target location code file, includes: replacing the target code with the replacement code to obtain a new location code file, then proceeding to the step of replaying the location code file for test cases until no target code fails to execute during the replay process, and taking a screenshot of the successfully executed webpage interface to obtain a target screenshot; comparing the webpage screenshot and the target screenshot using CV2 image recognition technology, and determining whether there is a difference between the webpage screenshot and the target screenshot based on the obtained comparison result; if there is a difference, then the location code file that does not fail to execute during the replay process is determined as the target location code file.
[0033] It is understood that the machine learning array document is a dynamically updated document. After the target localization code file that has been successfully executed is determined, the replacement code of the target localization code file is determined as the value based on the target code key of the target localization code file, thereby forming a key-value pair, and the key-value pair is saved to the machine learning array document. Specifically, before performing batch testing on the target localization code file, the process further includes: using the target code in the target localization code file as the key and the replacement code corresponding to the target code as the value; constructing corresponding key-value pairs based on the key and value, and updating the machine learning array document using the key and value.
[0034] Furthermore, after obtaining the target location code file, the target location code file is renamed to testcase.txt, and all code files named testcase in the test case folder are batch tested to generate a corresponding test analysis result report.
[0035] As can be seen from the above, this application requires no coding whatsoever. Simply inputting the URL of the webpage to be tested generates the corresponding script code file, from which the location code file containing the core operations is extracted. An initial replay test of the location code file is performed. If any target code fails to execute, machine learning array documents are used to match the target code. If no match is found, replacement code is generated based on screenshots of the test failure and a preset Playwright template, using a multimodal large model. Replay is then performed again after the replacement until no failed code is found during replay, preventing test interruption. This allows for batch testing of the repaired target location code file, generating corresponding test reports, significantly improving test coverage and accuracy, and reducing script-level costs and technical barriers.
[0036] As can be seen from the above embodiments, this application achieves the accuracy of code testing based on the dynamic repair of execution failure code. Therefore, the process of dynamic repair of execution failure code is described.
[0037] Combination Figure 2 and Figure 3 As shown, this embodiment of the invention discloses a specific method for automated testing of enterprise Web UI, including: In this embodiment, based on the enterprise webpage address and recording instructions input by the user, the `playwrightcodegen` command is executed to drive the browser to record the user's actions and convert them into Playwright code in page.xxx format. After the browser is closed, the code is integrated to obtain the original script file, and the core positioning code in the original script file is extracted using a preset code extraction function to obtain the positioning code file. The positioning code file can be saved to the `case.txt` file. The AI repair replay function is used to read and replay each positioning code file in the `case.txt` file. If all code executes normally during the replay process without any execution failures, the `case.txt` file is renamed to `testcase.txt` and saved to the test case folder. If there is target code that fails to execute during the replay process, the target code is matched with the code block in the machine learning JSON array document. If the match is successful, the target code block is identified as the replacement code. Correspondingly, if matching fails, a screenshot of the webpage interface where code execution failed is taken, and an AI prompt input box pops up to obtain the natural language command entered by the user. A corresponding replacement code is generated using a preset Playwright code generation template and a multimodal large model. The replacement code is executed; if successful, the target code is replaced based on the replacement code to obtain a new location code file. If execution fails, the multimodal large model continues to generate replacement code until successful execution. Based on the new location code file, the process jumps to the step of replaying the location code file for test cases until no failed target code is found during replay. It is then determined whether there is a difference between the currently successfully executed target screenshot and the webpage screenshot. If the difference is satisfied, execution is further characterized as successful, thus obtaining the target location code file.
[0038] Understandably, the target code in the target location code file is used as the key, and the replacement code in the target location code file is used as the value to form a key-value pair. This key-value pair is then saved to the machine learning array document, thereby enabling dynamic updates to the machine learning array document. Next, the target location code file is renamed to testcase.txt, and all code files named "testcase" in the test case folder are batch-tested to generate corresponding test reports.
[0039] As shown above, this application generates a corresponding script code file based on the input enterprise's webpage address to be tested. It then replays the location code file containing core operations for testing. If target code fails to execute, it uses machine learning to match the target code with an array of documents. If no match is found, it generates replacement code based on the screenshot of the failed test and a multimodal large model. If the replacement code executes successfully, it replaces the target code to obtain a new location code file, which is then replayed. In this way, if the new target location code file executes successfully, batch testing can be performed to obtain a test report, avoiding test interruptions and improving test accuracy.
[0040] Accordingly, see Figure 4 As shown, this application also provides an enterprise Web UI automated testing apparatus, comprising: The code file extraction module 11 is used to generate a corresponding script code file based on the enterprise webpage address to be tested input by the user terminal, and to extract the script code file using a preset code extraction function to obtain the location code file; The code matching module 12 is used to perform test case replay on the located code file. If there is target code that fails to execute during the replay process, the code keys in the machine learning array document are used to match the target code. The code block generation module 13 is used to take a screenshot of the web page interface where the code execution failed if the matching fails, so as to obtain the corresponding web page screenshot, and generate replacement code based on the preset Playwright code generation template and the web page screenshot and using a multimodal large model. The code file testing module 14 is used to replace the target code with the replacement code to obtain a new positioning code file, and then jump to the step of playing back the test cases of the positioning code file until there is no target code that fails to execute during the playback process, so as to obtain the target positioning code file, and perform batch testing on the target positioning code file to obtain the corresponding test report.
[0041] In some specific embodiments, the code file extraction module 11 may specifically include: The command generation unit is used to obtain the enterprise webpage address to be tested and the recording instruction input by the user terminal, and generate a corresponding code generation command based on the enterprise webpage address to be tested and the recording instruction; The script file generation unit is used to execute the code generation command to obtain a browser, generate corresponding Playwright code based on the webpage operation of the user terminal in the browser, and generate corresponding original script files using each Playwright code; The code extraction unit is used to extract the core positioning code from the script code file using a preset code extraction function to obtain the positioning code file.
[0042] In some specific embodiments, the enterprise Web UI automated testing device may further include: The target code file determination unit is used to determine the location code file as the target location code file if no target code fails to execute during the playback process, and then jump to the step of performing batch testing on the target location code file.
[0043] In some specific embodiments, the enterprise Web UI automated testing device may further include: The replacement code determination unit is used to determine the target code block in the machine learning array document that matches the target code as the replacement code if a match is successful, and then jump to the step of replacing the target code with the replacement code.
[0044] In some specific embodiments, the code block generation module 13 may specifically include: The interface screenshot unit is used to take a screenshot of the webpage interface where the code execution failed if the matching fails, so as to obtain the corresponding webpage screenshot. The replacement code generation unit is used to obtain the natural language instruction entered by the user in the input box, and generate replacement code based on the natural language instruction, the preset Playwright code generation template and the webpage screenshot, using a multimodal large model.
[0045] In some specific embodiments, the enterprise Web UI automated testing device may further include: A key determination unit is used to use the target code in the target location code file as a key and the replacement code corresponding to the target code as a value. The document update unit is used to construct corresponding key-value pairs based on the key and value, and to update the machine learning array document using the key and value.
[0046] In some specific embodiments, the code file testing module 14 may specifically include: The target screenshot determination unit is used to replace the target code with the replacement code to obtain a new location code file, and then jump to the step of playing back the use case of the location code file until there is no target code that failed to execute during the playback process, and take a screenshot of the successfully executed web page to obtain the target screenshot. The screenshot judgment unit is used to compare the webpage screenshot and the target screenshot using CV2 image recognition technology, and to determine whether there is a difference between the webpage screenshot and the target screenshot based on the comparison result. The target file determination unit is used to determine the location code file that did not fail to execute during the playback process as the target location code file if there are differences.
[0047] Furthermore, embodiments of this application also disclose an electronic device, Figure 5 This is a structural diagram of an electronic device 20 according to an exemplary embodiment. The content of the diagram should not be construed as limiting the scope of this application. Specifically, the electronic device 20 may include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input / output interface 25, and a communication bus 26. The memory 22 stores a computer program, which is loaded and executed by the processor 21 to implement the relevant steps in the enterprise Web UI automated testing method disclosed in any of the foregoing embodiments. Furthermore, the electronic device 20 in this embodiment may specifically be a computer.
[0048] In this embodiment, the power supply 23 is used to provide operating voltage for each hardware device on the electronic device 20; the communication interface 24 can create a data transmission channel between the electronic device 20 and external devices, and the communication protocol it follows can be any communication protocol applicable to the technical solution of this application, and is not specifically limited here; the input / output interface 25 is used to acquire external input data or output data to the outside world, and its specific interface type can be selected according to specific application needs, and is not specifically limited here.
[0049] In addition, the memory 22, as a carrier for resource storage, can be a read-only memory, random access memory, disk or optical disk, etc. The resources stored thereon can include operating system 221, computer program 222, etc., and the storage method can be temporary storage or permanent storage.
[0050] The operating system 221 is used to manage and control the various hardware devices on the electronic device 20 and the computer program 222, which may be Windows Server, Netware, Unix, Linux, etc. In addition to including a computer program capable of performing the enterprise Web UI automated testing method executed by the electronic device 20 as disclosed in any of the foregoing embodiments, the computer program 222 may further include computer programs capable of performing other specific tasks.
[0051] Furthermore, this application also discloses a computer-readable storage medium for storing a computer program; wherein, when the computer program is executed by a processor, it implements the aforementioned disclosed enterprise Web UI automated testing method. Specific steps of this method can be found in the corresponding content disclosed in the foregoing embodiments, and will not be repeated here.
[0052] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the apparatus disclosed in the embodiments, since it corresponds to the method disclosed in the embodiments, the description is relatively simple; relevant parts can be referred to in the method section.
[0053] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0054] The steps of the methods or algorithms described in conjunction with the embodiments disclosed herein can be implemented directly by hardware, a software module executed by a processor, or a combination of both. The software module can be located in random access memory (RAM), main memory, read-only memory (ROM), electrically programmable ROM, electrically erasable programmable ROM, registers, hard disk, removable disk, CD-ROM, or any other form of storage medium known in the art.
[0055] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0056] The technical solutions provided in this application have been described in detail above. Specific examples have been used to illustrate the principles and implementation methods of this application. The descriptions of the above embodiments are only for the purpose of helping to understand the methods and core ideas of this application. At the same time, for those skilled in the art, there will be changes in the specific implementation methods and application scope based on the ideas of this application. Therefore, the content of this specification should not be construed as a limitation of this application.
Claims
1. A method for automated testing of enterprise Web UI, characterized in that, include: A corresponding script code file is generated based on the enterprise webpage address input by the user. The script code file is then extracted using a preset code extraction function to obtain the location code file. The location code file is replayed using test cases. If target code fails to execute during the replay, the code keys in the machine learning array document are matched with the target code. If the matching fails, a screenshot of the webpage interface where the code execution failed is taken to obtain the corresponding webpage screenshot. Replacement code is generated based on the preset Playwright code generation template and the webpage screenshot, and using a multimodal large model. The target code is replaced using the replacement code to obtain a new location code file. Then, the process jumps to the step of replaying test cases on the location code file until no target code fails to execute during the replay process, thus obtaining the target location code file. The target location code file is then subjected to batch testing to obtain a corresponding test report.
2. The enterprise Web UI automated testing method according to claim 1, characterized in that, The process involves generating a corresponding script code file based on the enterprise's webpage address input by the user, and then extracting the script code file using a preset code extraction function to obtain a location code file, including: Obtain the enterprise webpage address to be tested and the recording instruction input by the user, and generate the corresponding code generation command based on the enterprise webpage address to be tested and the recording instruction; Execute the code generation command to obtain a browser, generate corresponding Playwright code based on the webpage operation of the user terminal in the browser, and use each Playwright code to generate a corresponding original script file; The core positioning code in the script code file is extracted using a preset code extraction function to obtain the positioning code file.
3. The enterprise Web UI automated testing method according to claim 1, characterized in that, After performing test case playback on the location code file, the method further includes: If no target code fails to execute during playback, the location code file is identified as the target location code file, and then the process jumps to the step of batch testing the target location code file.
4. The enterprise Web UI automated testing method according to claim 1, characterized in that, After matching the code keys in the machine learning array document with the target code, the process further includes: If a match is successful, the target code block in the machine learning array document that matches the target code is identified as the replacement code, and then the process jumps to the step of replacing the target code with the replacement code.
5. The enterprise Web UI automated testing method according to claim 1, characterized in that, If the matching fails, a screenshot of the webpage where the code execution failed is taken to obtain the corresponding webpage screenshot. Replacement code is then generated based on a preset Playwright code generation template and the webpage screenshot, utilizing a multimodal large model, including: If the match fails, take a screenshot of the webpage where the code execution failed to obtain the corresponding webpage screenshot; The system obtains the natural language command input by the user in the input box, and generates replacement code based on the natural language command, a preset Playwright code generation template, and the webpage screenshot, using a multimodal large model.
6. The enterprise Web UI automated testing method according to claim 1, characterized in that, Before performing batch testing on the target location code file, the method further includes: Use the target code in the target location code file as the key and the replacement code corresponding to the target code as the value; Based on the key and value, construct corresponding key-value pairs, and use the key and value to update the machine learning array document.
7. The enterprise Web UI automated testing method according to any one of claims 1 to 6, characterized in that, The process of replacing the target code with the replacement code to obtain a new location code file, and then proceeding to the step of replaying the location code file for test cases until no target code fails to execute during the replay process, thus obtaining the target location code file, includes: The target code is replaced with the replacement code to obtain a new location code file. Then, the process jumps to the step of replaying the location code file as a test case until there is no target code that fails to execute during the replay process. A screenshot of the successfully executed web page is then taken to obtain the target screenshot. The CV2 image recognition technology is used to compare the webpage screenshot and the target screenshot, and the comparison results are used to determine whether there are any differences between the webpage screenshot and the target screenshot. If there is a discrepancy, the location code file that did not fail to execute during the playback process will be identified as the target location code file.
8. An automated testing device for enterprise Web UI, characterized in that, include: The code file extraction module is used to generate a corresponding script code file based on the enterprise webpage address input by the user, and to extract the script code file using a preset code extraction function to obtain the location code file; The code matching module is used to perform test case replay on the located code file. If there is target code that fails to execute during the replay process, the code keys in the machine learning array document are used to match the target code. The code block generation module is used to take a screenshot of the web page interface where the code execution failed if the matching fails, so as to obtain the corresponding web page screenshot. The module generates replacement code based on the preset Playwright code generation template and the web page screenshot, and uses a multimodal large model. The code file testing module is used to replace the target code with the replacement code to obtain a new location code file. Then, it jumps to the step of replaying test cases on the location code file until there is no target code that fails to execute during the replay process, so as to obtain the target location code file. The target location code file is then batch tested to obtain a corresponding test report.
9. An electronic device, characterized in that, include: Memory, used to store computer programs; A processor for executing the computer program to implement the enterprise Web UI automated testing method as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, Used to store a computer program, wherein the computer program, when executed by a processor, implements the enterprise Web UI automated testing method as described in any one of claims 1 to 7.