Automated testing method, device, equipment and storage medium for front-end application

By using the whistle tool to intercept and replace keywords and functions in the front-end application's documentation, automated testing can be completed in the current tab, resolving the issue of Cypress being unable to open new pages in new tabs and achieving compatibility with older front-end projects.

CN115098397BActive Publication Date: 2025-10-28GUANGZHOU PINWEI SOFTWARE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202210842931.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-07-18
Publication Date
2025-10-28
Estimated Expiration
2042-07-18

AI Technical Summary

Technical Problem

Cypress's automated testing tools cannot continue executing automated tests when a new page is opened in a new tab, resulting in incompatibility with older front-end projects.

Method used

The Whistle tool intercepts the document returned by the front-end application under test, and uses preset document replacement rules to replace the target keywords and functions in a format suitable for the current tab, generating a new document and completing the test in the current tab.

Benefits of technology

It enables automated testing of opening a new page in the current tab, solves Cypress compatibility issues with older front-end projects, and expands the application scenarios of automated testing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115098397B_ABST
    Figure CN115098397B_ABST
Patent Text Reader

Abstract

This application discloses an automated testing method, apparatus, device, and storage medium for front-end applications. The method involves responding to a request from the front-end application under test to initiate automated testing, intercepting a first document returned by the application, then responding to a request from the application to open a new tab, replacing each first target keyword in the intercepted first document according to a preset first document replacement rule to obtain a second document corresponding to the first document, then replacing each first target function in the second document according to a preset second document replacement rule to obtain a third document corresponding to the second document, and finally opening the third document in the current tab to complete the automated testing process of the front-end application under test. This achieves automated testing of the front-end application under test, allowing a new page that would normally open in a new tab to open in the current page.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of automated testing technology, specifically to an automated testing method, apparatus, device, and storage medium for front-end applications. Background Technology

[0002] Cypress is a next-generation end-to-end automated testing tool built for modern web applications. It addresses the challenges developers and QA engineers face when testing modern applications. Typically, it's set up within a front-end project and installed in the project's root directory. Cypress simplifies setting up, writing, running, and debugging tests, supporting end-to-end testing, integration testing, and unit testing. It allows testing of virtually anything running within the front-end application.

[0003] However, Cypress is not compatible with older front-end projects and only supports automated testing of single-page applications. This means that automated tests can only be executed when a new page is opened in the current tab, and cannot continue to be executed when a new page is opened in a new tab. Summary of the Invention

[0004] In view of this, this application provides an automated testing method, apparatus, device, and storage medium for front-end applications to solve the problem that some front-end applications can only execute automated tests when a new page is opened in the current tab, and cannot continue to execute automated tests when a new page is opened in a new tab.

[0005] To achieve the above objectives, the following solution is proposed:

[0006] Firstly, an automated testing method for front-end applications includes:

[0007] In response to the request instruction from the front-end application under test to initiate automated testing, intercept the first document returned by the front-end application under test;

[0008] In response to the request instruction from the front-end application under test to open a new tab, the intercepted first target keywords in the first document are replaced according to the preset first document replacement rule to obtain a second document corresponding to the first document;

[0009] The first objective functions in the second document are replaced according to the preset second document replacement rules to obtain a third document corresponding to the second document;

[0010] Open the third document in the current tab to complete the automated testing process of the front-end application to be tested.

[0011] Preferably, the step of replacing each first target keyword in the intercepted first document according to a preset first document replacement rule to obtain a second document corresponding to the first document includes:

[0012] The intercepted first document is parsed to obtain the parsed document;

[0013] Use regular expression matching to find each first target keyword in the parsed document;

[0014] According to the preset first document replacement rule, each of the first target keywords found is replaced with each of the second target keywords to obtain a second document corresponding to the first document.

[0015] Preferably, the step of replacing each first objective function in the second document according to a preset second document replacement rule to obtain a third document corresponding to the second document includes:

[0016] Insert target statements at the corresponding positions of each first target function in the second document, and replace each first target function in the second document with each second target function according to the preset second document replacement rules to obtain a third document corresponding to the second document.

[0017] Preferably, the step of responding to the request instruction from the front-end application under test to initiate automated testing and intercepting the first document returned by the front-end application under test includes:

[0018] Respond to the request command initiated by the front-end application to conduct automated testing, and obtain the target type corresponding to the request command;

[0019] Intercept the first document returned by the front-end application under test that corresponds to the target type.

[0020] Secondly, an automated testing device for front-end applications includes:

[0021] The interception module is used to respond to the request command of the front-end application under test to initiate automated testing and intercept the first document returned by the front-end application under test;

[0022] The second document acquisition module is used to respond to the request instruction to open a new tab initiated by the front-end application under test, and replace each first target keyword in the intercepted first document according to the preset first document replacement rule to obtain a second document corresponding to the first document;

[0023] The third document acquisition module is used to replace each first objective function in the second document according to the preset second document replacement rules to obtain a third document corresponding to the second document;

[0024] The current tab opening module is used to open the third document in the current tab to complete the automated testing process of the front-end application to be tested.

[0025] Preferably, the second document obtaining module includes:

[0026] The parsing module is used to parse the intercepted first document to obtain the parsed document;

[0027] The search module is used to search for each first target keyword in the parsed document using regular expression matching methods;

[0028] The replacement module is used to replace each of the found first target keywords with each of the second target keywords according to the preset first document replacement rules, so as to obtain a second document corresponding to the first document.

[0029] Preferably, the third document obtaining module includes:

[0030] The third document acquisition submodule is used to insert target statements at the corresponding positions of each first target function in the second document, and replace each first target function in the second document with each second target function according to the preset second document replacement rules, so as to obtain a third document corresponding to the second document.

[0031] Preferably, the interception module includes:

[0032] The first interception submodule is used to respond to the request instruction of the front-end application to be tested to initiate automated testing and obtain the target type corresponding to the request instruction;

[0033] The second interception submodule is used to intercept the first document returned by the front-end application under test that corresponds to the target type.

[0034] Thirdly, an automated testing device for a front-end application, including a memory and a processor;

[0035] The memory is used to store programs;

[0036] The processor is used to execute the program to implement the various steps of the automated testing method for the front-end application as described in the first aspect.

[0037] Fourthly, a storage medium storing a computer program thereon, which, when executed by a processor, implements the steps of the automated testing method for the front-end application as described in the first aspect.

[0038] As can be seen from the above technical solution, this application intercepts the first document returned by the front-end application under test in response to its request for automated testing. Then, in response to the request to open a new tab, it replaces each first target keyword in the intercepted first document according to a preset first document replacement rule to obtain a second document corresponding to the first document. Next, it replaces each first target function in the second document according to a preset second document replacement rule to obtain a third document corresponding to the second document. Finally, it opens the third document in the current tab to complete the automated testing process of the front-end application under test. This solution utilizes a preset first document replacement rule to replace each first target keyword in the intercepted first document to obtain a second document, and then uses the same rule to replace each first target function in the second document to obtain a third document. This allows a new page that would normally open in a new tab to open in the current page, thus completing the automated testing. Attached Figure Description

[0039] 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.

[0040] Figure 1 An optional flowchart of an automated testing method for a front-end application provided in an embodiment of this application;

[0041] Figure 2 and Figure 3 Code snippet examples provided for embodiments of this application;

[0042] Figure 4 Another optional flowchart for the automated testing method of the front-end application provided in the embodiments of this application;

[0043] Figure 5 A schematic diagram of the structure of an automated testing device for a front-end application provided in an embodiment of this application;

[0044] Figure 6 This is a schematic diagram of the structure of an automated testing device for a front-end application provided in an embodiment of this application. Detailed Implementation

[0045] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0046] In end-to-end automated testing, automation test engineers lack the authority to modify the project's source code to adapt it for automated testing. Cypress, a next-generation end-to-end automated testing tool built for modern web applications, is a relatively new tool developed in the last two years. It addresses the difficulties faced by developers and QA engineers when testing modern applications. Cypress is typically set up within a front-end project and installed in the project's root directory. Cypress simplifies setting up, writing, running, and debugging tests, supporting end-to-end testing, integration testing, and unit testing. It allows testing of any content running within the front-end application. However, Cypress is incompatible with older front-end projects (previous-generation web applications). This means Cypress only supports single-page automation testing; while a new page can be opened in the current tab during automated testing, attempting to open a new page in a different tab will terminate the automated testing process.

[0047] To address the aforementioned shortcomings, this invention provides an automated testing method for front-end applications. This invention can be used in numerous general-purpose or dedicated computing device environments or configurations, and can also be applied to various computer terminals or smart terminals. The computer terminal or smart terminal may include a whistle tool. Simply put, the whistle tool injects corresponding code to solve the limitation of Cypress's insufficient support for front-end applications. The executing entity can be the processor or server of the computer terminal or smart terminal. The method flowchart is as follows: Figure 1 As shown, it specifically includes:

[0048] S1: Responds to the request command from the front-end application under test to initiate automated testing, and intercepts the first document returned by the front-end application under test.

[0049] In the embodiments provided in this application, the Cypress automated testing tool can be installed in the front-end project. The operating system can be Windows 10 or OS 7, and Node.js version 12 or above can be installed. By running `npm install cypress` in the command line of the root directory of the front-end project (web application), this step will execute the download and installation process as well as the dependency packages used during the process. After the installation is completed, you can run `cypress open` or `cypressrun` in the command line of the root directory.

[0050] In this step, the front-end application under test initiates a request for automated testing. The Whistle tool can respond to the request and intercept the first document returned by the front-end application under test, which can be an HTML document or a JS file.

[0051] S2: Respond to the request instruction from the front-end application under test to open a new tab, and replace each first target keyword in the intercepted first document according to the preset first document replacement rules to obtain the second document corresponding to the first document.

[0052] If the intercepted first document contains one or more first target keywords, in this step, the front-end application under test will initiate a request to open a new tab. The whistle tool will replace or rewrite each first target keyword in the intercepted first document according to the preset first document replacement rules, thereby obtaining a second document corresponding to the first document, so that the relevant text or elements in the first document can adapt to the requirements of opening the current tab.

[0053] Here is an example:

[0054] For example, if the first document is an HTML document, and the first target keyword in this HTML document is `target="_blank"`, then retrieving the leaf node element in the DOM tree that will redirect to the new tab, if the leaf node attribute is... <a href="#"target="_blank"> The default first document replacement rule is to replace "_blank" with "_self", which allows...<ahref="#"target="_blank"> Replace with <a href="#"target="_self">This replaces the original first target keywords "_blank" in the first document with "_self" to accommodate the requirement of opening in the current tab.

[0055] S3: Replace each of the first objective functions in the second document according to the preset second document replacement rules to obtain the third document corresponding to the second document.

[0056] In step S2, a second document corresponding to the first document is obtained. The second document contains one or more first target functions. These one or more first target keywords can be replaced or rewritten according to the preset second document replacement rules to obtain a third document corresponding to the second document, so that the relevant functions or elements in the second document can adapt to the requirements of the current tab being opened.

[0057] Here is an example:

[0058] The resulting second document can be an HTML document. The default rule for rewriting the second document is to replace the first target function `window.open` with `location.href` to obtain the third document, which can then be opened in the current tab.

[0059] S4: Open the third document in the current tab to complete the automated testing process of the front-end application to be tested.

[0060] After completing the above steps, the third document can be opened in the current tab, thus completing the automated testing process for the front-end application to be tested.

[0061] Some of the methods and embodiments provided in this application can be accessed through... Figure 2 and Figure 3The program implementation is shown above. As can be seen from the above technical solution, this application intercepts the first document returned by the front-end application under test in response to its request for automated testing. Then, in response to the request to open a new tab, it replaces each first target keyword in the intercepted first document according to a preset first document replacement rule to obtain a second document corresponding to the first document. Then, it replaces each first target function in the second document according to a preset second document replacement rule to obtain a third document corresponding to the second document. Finally, it opens the third document in the current tab to complete the automated testing process of the front-end application under test. This solution uses a preset first document replacement rule to replace each first target keyword in the intercepted first document to obtain a second document, and then uses the preset second document replacement rule to replace each first target function in the second document to obtain a third document. Therefore, this application, by intercepting the first document and performing corresponding replacement operations, makes the new page that would normally open in a new tab open in the current tab instead, thus completing the automated testing process.

[0062] It is understandable that Whistle and Cypress are two completely independent tools. When the automated testing method for front-end applications provided in this application is applied to Whistle, Whistle enables front-end applications that cannot automatically implement page redirection to perform automated testing to open hyperlinks or new pages in the current tab, thereby completing the automated testing process.

[0063] In one embodiment provided in this application, step S1, the process of intercepting the first document returned by the front-end application under test in response to the request instruction of the front-end application under test to initiate automated testing, may include:

[0064] In response to the automated testing request from the front-end application under test, the whistle tool obtains the target type corresponding to the request, which is the document type of the first document to be intercepted. Then, the whistle tool can intercept the first document corresponding to the target type from the documents returned by the front-end application under test, such as an HTML document or a JS document.

[0065] Understandably, this process can be compared to this: when a user wants to access some shopping webpages, clicking on the product keywords or product images they want to view will take them to the product details page. When the click action is initiated, it is equivalent to giving the webpage a request instruction to open the details page. After receiving this request instruction, the webpage provides feedback to the user to open the details page, allowing the user to enter the details page to learn more about the product.

[0066] The above process can include: the front-end application under test initiating an automated testing request instruction; after receiving the automated testing request instruction from the front-end application under test, the whistle tool responds by having the front-end application under test return various documents; the whistle tool can then obtain the target type corresponding to the request instruction and select the first document corresponding to the target type from the various documents returned by the front-end application under test, thereby intercepting it.

[0067] In the method provided by this embodiment of the invention, the step of replacing each first target keyword in the intercepted first document according to a preset first document replacement rule to obtain a second document corresponding to the first document is as follows: Figure 4 As shown, the specific explanation is as follows:

[0068] S21: Parse the first intercepted document to obtain the parsed document.

[0069] S22: Use regular expression matching to find each first target keyword in the parsed document.

[0070] S23: Replace each found first target keyword with each second target keyword according to the preset first document replacement rule to obtain the second document corresponding to the first document.

[0071] Specifically, after the whistle tool intercepts the first document, it can parse the intercepted document to obtain a parsed document. Using this parsed document, the first target keyword that needs to be replaced can be quickly located. In this application, regular expression matching can be used to search the parsed document to find each first target keyword. Then, according to the preset first document replacement rules, each found first target keyword is replaced with a second target keyword to obtain a second document corresponding to the first document.

[0072] Optionally, in the method provided in this application embodiment, the process of replacing each first objective function in the second document according to a preset second document replacement rule to obtain a third document corresponding to the second document may include:

[0073] It is understandable that in the second document corresponding to the first document, regular expression matching can also be used to find one or more first target functions in the second document, and then target statements can be inserted at the corresponding positions of each first target function. The found first target functions can be replaced or rewritten with each second target keyword according to the preset second document replacement rules to obtain the third document corresponding to the second document.

[0074] The target statement can be a JavaScript statement. The default second document replacement rule is to replace the first target function window.open with location.href. That is, the second document replacement rule replaces the first target function window.open in the second document with the second target function location.href. Since the second target function location.href allows the HTML document to be opened normally in the current tab, the third document can be opened successfully in the current tab.

[0075] In another embodiment of this application, the first objective function can be replaced with the second objective function first using the second document replacement rule, and then the first objective keyword can be replaced with the second objective keyword using the first document replacement rule; alternatively, the first objective keyword and the first objective function in the first document can be replaced with the second objective keyword and the second objective function respectively using the first document replacement rule and the second document replacement rule simultaneously, without any limitation.

[0076] Additionally, if after completing steps S1 to S3, the third document cannot be opened in the current tab but opens in a new tab, it indicates that the automated test failed after the replacement. In this case, you can return to step S1 and check whether the first document returned by the front-end application under test was successfully intercepted. If the interception was successful, you can check whether the replacement of the first target keyword and the first target function in step S2 or S3 was successful.

[0077] and Figure 1 Corresponding to the method described above, this embodiment of the invention also provides an automated testing device for front-end applications, used for testing... Figure 1 In the specific implementation of the method, the automated testing device for front-end applications provided in this embodiment of the invention can be used on computer terminals or various mobile devices, combined with Figure 5 This section introduces automated testing devices for front-end applications, such as... Figure 5 As shown, the device may include:

[0078] The interception module 10 is used to respond to the request instruction of the front-end application under test to initiate automated testing and intercept the first document returned by the front-end application under test;

[0079] The second document acquisition module 20 is used to respond to the request instruction to open a new tab initiated by the front-end application under test, and replace each first target keyword in the intercepted first document according to the preset first document replacement rule to obtain a second document corresponding to the first document;

[0080] The third document acquisition module 30 is used to replace each first objective function in the second document according to the preset second document replacement rules to obtain a third document corresponding to the second document;

[0081] The current tab opening module 40 is used to open the third document in the current tab to complete the automated testing process of the front-end application to be tested.

[0082] As can be seen from the above technical solution, this application uses an interception module 10 to respond to the request instruction of the front-end application under test to initiate automated testing, intercepting the first document returned by the front-end application under test. Then, a second document acquisition module 20 responds to the request instruction of the front-end application under test to open a new tab, replacing each first target keyword in the intercepted first document according to a preset first document replacement rule to obtain a second document corresponding to the first document. A third document acquisition module 30 then replaces each first target function in the second document according to a preset second document replacement rule to obtain a third document corresponding to the second document. Finally, a current tab opening module 40 opens the third document in the current tab to complete the automated testing process of the front-end application under test. In this solution, the second document acquisition module 20 uses a preset first document replacement rule to replace each first target keyword in the intercepted first document to obtain the second document, and then the third document acquisition module 30 uses a preset second document replacement rule to replace each first target function in the second document to obtain the third document. Therefore, this application intercepts the first document through the interception module 10, and performs corresponding replacement operations on the first document through the second document acquisition module 20 and the third document acquisition module 30, so that the new page that was originally opened in a new tab becomes a new page that is opened in the current tab, thereby completing the automated testing process.

[0083] In one embodiment provided in this application, the interception module 10 may include:

[0084] The first interception submodule is used to respond to the request instruction of the front-end application to be tested to initiate automated testing and obtain the target type corresponding to the request instruction;

[0085] The second interception submodule is used to intercept the first document returned by the front-end application under test that corresponds to the target type.

[0086] Optionally, the second document obtaining module 20 in the device may include:

[0087] The parsing module is used to parse the intercepted first document to obtain the parsed document;

[0088] The search module is used to search for each first target keyword in the parsed document using regular expression matching methods;

[0089] The replacement module is used to replace each of the found first target keywords with each of the second target keywords according to the preset first document replacement rules, so as to obtain a second document corresponding to the first document.

[0090] Furthermore, the third document obtaining module 30 in the device may include:

[0091] The third document acquisition submodule is used to insert target statements at the corresponding positions of each first target function in the second document, and replace each first target function in the second document with each second target function according to the preset second document replacement rules, so as to obtain a third document corresponding to the second document.

[0092] Furthermore, embodiments of this application provide an automated testing device for front-end applications. Optionally, Figure 6 The hardware structure block diagram of the automated testing equipment for the front-end application is shown. (Refer to...) Figure 6 The hardware structure of the automated testing equipment for the front-end application may include: at least one processor 01, at least one communication interface 02, at least one memory 03 and at least one communication bus 04.

[0093] In this embodiment, the number of processor 01, communication interface 02, memory 03 and communication bus 04 is at least one, and processor 01, communication interface 02 and memory 03 communicate with each other through communication bus 04.

[0094] Processor 01 may be a central processing unit (CPU), an application-specific integrated circuit (ASIC), or one or more integrated circuits configured to implement embodiments of the present invention.

[0095] Memory 03 may include high-speed RAM, and may also include non-volatile memory, such as at least one disk storage device.

[0096] The memory stores a program, which the processor can call to execute the automated testing methods for the following front-end applications:

[0097] In response to the request instruction from the front-end application under test to initiate automated testing, intercept the first document returned by the front-end application under test;

[0098] In response to the request instruction from the front-end application under test to open a new tab, the intercepted first target keywords in the first document are replaced according to the preset first document replacement rule to obtain a second document corresponding to the first document;

[0099] The first objective functions in the second document are replaced according to the preset second document replacement rules to obtain a third document corresponding to the second document;

[0100] Open the third document in the current tab to complete the automated testing process of the front-end application to be tested.

[0101] Optionally, the refined and extended functions of the program can be found in the description of the automated testing method for the front-end application in the method embodiments.

[0102] This application embodiment also provides a storage medium that can store a program suitable for execution by a processor. When the program runs, it controls the device where the storage medium is located to execute the following automated testing method for a front-end application, including:

[0103] In response to the request instruction from the front-end application under test to initiate automated testing, intercept the first document returned by the front-end application under test;

[0104] In response to the request instruction from the front-end application under test to open a new tab, the intercepted first target keywords in the first document are replaced according to the preset first document replacement rule to obtain a second document corresponding to the first document;

[0105] The first objective functions in the second document are replaced according to the preset second document replacement rules to obtain a third document corresponding to the second document;

[0106] Open the third document in the current tab to complete the automated testing process of the front-end application to be tested.

[0107] Specifically, the storage medium can be a computer-readable storage medium, which can be an electronic storage device such as flash memory, EEPROM (Electrically Erasable Programmable Read-Only Memory), EPROM, hard disk, or ROM.

[0108] Optionally, the refined and extended functions of the program can be found in the description of the automated testing method for the front-end application in the method embodiments.

[0109] Furthermore, the functional modules in the various embodiments of this disclosure can be integrated together to form an independent part, or each module can exist independently, or two or more modules can be integrated to form an independent part. If the function is implemented as a software functional module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this disclosure, in essence, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, a live streaming device, or a network device, etc.) to execute all or part of the steps of the methods in the various embodiments of this disclosure.

[0110] 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.

[0111] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on the differences from other embodiments. The same or similar parts between the various embodiments can be referred to each other.

[0112] The above description of the disclosed embodiments enables those skilled in the art to make or use this application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of this application. Therefore, this application is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.

Claims

1. An automated testing method for front-end applications, characterized in that, include: Responding to a request instruction from the front-end application under test to initiate automated testing, intercepting the first document returned by the front-end application under test; including: responding to the request instruction from the front-end application under test to initiate automated testing, obtaining the target type corresponding to the request instruction; and intercepting the first document returned by the front-end application under test that corresponds to the target type; In response to the request instruction from the front-end application under test to open a new tab, the intercepted first target keywords in the first document are replaced according to the preset first document replacement rule to obtain a second document corresponding to the first document; The process involves replacing each first objective function in the second document according to a preset second document replacement rule to obtain a third document corresponding to the second document; including: inserting target statements at the corresponding positions of each first objective function in the second document, and replacing each first objective function in the second document with a second objective function according to the preset second document replacement rule to obtain a third document corresponding to the second document; Open the third document in the current tab to complete the automated testing process of the front-end application to be tested.

2. The method according to claim 1, characterized in that, The step of replacing each first target keyword in the intercepted first document according to a preset first document replacement rule to obtain a second document corresponding to the first document includes: The intercepted first document is parsed to obtain the parsed document; Use regular expression matching to find each first target keyword in the parsed document; According to the preset first document replacement rule, each of the first target keywords found is replaced with each of the second target keywords to obtain a second document corresponding to the first document.

3. An automated testing device for front-end applications, characterized in that, include: An interception module is used to respond to a request instruction from the front-end application under test to initiate automated testing and to intercept the first document returned by the front-end application under test; it includes: a first interception submodule, used to respond to a request instruction from the front-end application under test to initiate automated testing and to obtain the target type corresponding to the request instruction; and a second interception submodule, used to intercept the first document returned by the front-end application under test that corresponds to the target type. The second document acquisition module is used to respond to the request instruction to open a new tab initiated by the front-end application under test, and replace each first target keyword in the intercepted first document according to the preset first document replacement rule to obtain a second document corresponding to the first document; The third document obtaining module is used to replace each first target function in the second document according to a preset second document replacement rule to obtain a third document corresponding to the second document; it includes: a third document obtaining submodule, used to insert target statements at the corresponding positions of each first target function in the second document, and replace each first target function in the second document with each second target function according to the preset second document replacement rule to obtain a third document corresponding to the second document; The current tab opening module is used to open the third document in the current tab to complete the automated testing process of the front-end application to be tested.

4. The apparatus according to claim 3, characterized in that, The second document acquisition module includes: The parsing module is used to parse the intercepted first document to obtain the parsed document; The search module is used to search for each first target keyword in the parsed document using regular expression matching methods; The replacement module is used to replace each of the found first target keywords with each of the second target keywords according to the preset first document replacement rules, so as to obtain a second document corresponding to the first document.

5. An automated testing device for front-end applications, characterized in that, Including memory and processor; The memory is used to store programs; The processor is used to execute the program to implement the various steps of the automated testing method for the front-end application as described in any one of claims 1-2.

6. A storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the steps of the automated testing method for the front-end application as described in any one of claims 1-2.