Application testing method and device, equipment and storage medium
By embedding web view components within the native application framework and intercepting rewrite data requests, the limitations of testing in hybrid applications are addressed, enabling accurate testing of hybrid applications and improving testing efficiency.
Patent Information
- Application Number
- CN202410565193.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-06
- Publication Date
- 2025-11-11
AI Technical Summary
Existing technologies cannot accurately test application pages developed using technologies other than native technologies in hybrid applications, resulting in testing limitations.
Embed a web page view component in the native application framework, intercept web page data requests through the request interception function, rewrite them as native data requests, use the native application framework for data interaction, generate test cases, and perform application testing.
It enables testing of application pages developed using technologies other than native technologies in hybrid applications, reducing testing limitations and improving testing efficiency and accuracy.
Smart Images

Figure CN120929360A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and in particular to an application testing method, apparatus, device, and storage medium. Background Technology
[0002] With the continuous development of technology, more and more devices can test the application pages displayed by installed applications and generate test results. Based on the test results, it can be determined whether the page elements on the application page are displayed, whether the display position is correct, whether the displayed content meets expectations, and whether the page interaction is responsive, so as to ensure that the application can run normally and stably.
[0003] In related technologies, application testing methods typically involve first performing corresponding operations on all page elements presented by the application to generate corresponding test cases; then replaying each obtained test case to obtain the corresponding replay results; and finally, determining whether the replay results match the operation results recorded in the corresponding test cases to generate the application's test results.
[0004] The generated test cases record the operations performed on the corresponding page elements and the results of those operations. When replaying the test cases, the recorded operations are simulated for the corresponding operable objects to obtain the replay results.
[0005] However, as applications have evolved from native applications developed using a single development model to hybrid applications developed using a hybrid development model, they are offering richer and more diverse user experiences. For example, native applications developed using a single native technology have evolved into hybrid applications that combine native technologies and web technologies.
[0006] Therefore, in hybrid applications, some technologies cannot directly process data across platforms. Consequently, it is impossible to test application pages developed using technologies other than native technologies in hybrid applications.
[0007] It is evident that the testing methods for applications based on related technologies have significant limitations and cannot accurately test hybrid applications. Summary of the Invention
[0008] This application provides an application testing method, apparatus, device, and storage medium to address the problem that application testing methods have significant limitations and cannot accurately test hybrid applications.
[0009] Firstly, an application testing method is provided, applied to a hybrid application that embeds a webpage view component within a native application framework, wherein the webpage view component is used to: present a webpage in the hybrid application; the method includes:
[0010] Obtain a test case recording instruction for a webpage element; wherein the webpage element is used to constitute the webpage, and the webpage element is associated with a network address for accessing other webpages;
[0011] Based on the request interception function provided by the webpage view component, when a webpage operation is triggered by a webpage element indicated by the record instruction for the use case, the generated webpage data request is intercepted; wherein, the webpage data request is used to: obtain webpage response data from the network address for updating the webpage presented by the hybrid application;
[0012] Based on the data sending and receiving functions provided by the native application framework, the obtained web page data request is rewritten as a native data request, and based on the native data request, native response data is obtained from the network address to replace the web page response data;
[0013] Based on the native response data, test cases for the web page elements are generated, and when a test case replay instruction for the web page elements is received, application testing is performed based on the obtained test cases.
[0014] Secondly, an application testing apparatus is provided for use in hybrid applications that embed webpage view components within a native application framework, wherein the webpage view components are used to: present webpages in the hybrid application; the apparatus includes:
[0015] Acquisition module: used to acquire test case recording instructions for web page elements; wherein, the web page elements are used to constitute the web page, and the web page elements are associated with network addresses for accessing other web pages;
[0016] Processing module: Based on the request interception function provided by the webpage view component, when it is detected that a webpage element triggered by the recording instruction for the use case has triggered a webpage operation, the generated webpage data request is intercepted; wherein, the webpage data request is used to: obtain webpage response data from the network address for updating the webpage presented by the hybrid application;
[0017] The processing module is further configured to: rewrite the obtained web page data request into a native data request based on the data sending and receiving functions provided by the native application framework, and obtain native response data from the network address to replace the web page response data based on the native data request;
[0018] The processing module is further configured to: generate test cases for the web page element based on the native response data, and perform application testing based on the obtained test cases when receiving a test case replay instruction for the web page element.
[0019] Optionally, the acquisition module is specifically used for:
[0020] In response to a use case update operation triggered by the current webpage presented by the hybrid application, the first node relationship information of the current webpage is obtained; wherein, the first node relationship information represents: a hierarchical relationship formed according to the presentation effect of the current webpage, with the element attributes of each current element constituting the current webpage as nodes;
[0021] In response to a selection operation triggered by at least one of the current elements represented by the first node relationship information, a use case recording instruction is generated for the at least one element; wherein the at least one element includes the web page element.
[0022] Optionally, the processing module is specifically used for:
[0023] Based on the request interception function provided by the webpage view component, when it is detected that the webpage update function corresponding to the webpage element is initialized based on the function initialization function provided by the webpage view component, it is determined that a webpage operation has been triggered for the webpage element; wherein, the webpage update function is used to: generate the webpage data request;
[0024] Based on the request interception function provided by the webpage view component, the webpage data request is intercepted, and a preset data transmission interface is called to transmit the webpage data request; wherein, the data transmission interface is used to: establish data interaction between the native application framework and the webpage view component.
[0025] Optionally, the processing module is specifically used for:
[0026] When it is determined that the web page data request contains a special web page request, the web page response data is obtained from the network address based on the data sending and receiving function of the web page view component; wherein, the special web page request is a request that requires identification through a data parsing strategy;
[0027] Add preset new function data to the webpage response data; wherein, the new function data is used to: add data parsing function to the native application framework;
[0028] Based on the data parsing function, the request parameters of the special request are parsed from the web page data request;
[0029] The native data request is generated based on the webpage data request and the request parameters.
[0030] Optionally, the processing module is specifically used for:
[0031] Based on the data sending and receiving functions provided by the native application framework, a native special request carrying the request parameters is generated;
[0032] Send the native special request and the webpage special request to the network address respectively to obtain the network link information corresponding to the native special request and the webpage special request respectively;
[0033] When it is determined that the network link information corresponding to the native special request and the webpage special request match, the webpage data request is rewritten as a native data request based on the native special request.
[0034] Optionally, the processing module is specifically used for:
[0035] The native response data is transmitted by calling a preset data transmission interface; wherein, the data transmission interface is used to: establish data interaction between the native application framework and the web page view component;
[0036] Based on the webpage rendering function of the webpage view component, the webpage rendered by the hybrid application is updated according to the native response data;
[0037] Obtain the node update structure of the updated webpage and generate the webpage rendering data of the updated webpage; wherein, the node update structure represents: a node hierarchy structure formed according to the rendering effect of the updated webpage, with the element attributes of each updated element constituting the updated webpage as nodes.
[0038] The test cases are generated based on the native response data and the webpage rendering data.
[0039] Optionally, the processing module is specifically used for:
[0040] During the process of updating the webpage presented by the hybrid application, the second node relationship information of the intermediate webpages presented at multiple times is continuously acquired; wherein, the second node relationship information represents: the hierarchical relationship formed according to the presentation effect of the intermediate webpages, with the element attributes of each intermediate element constituting the intermediate webpages presented at the corresponding times as nodes.
[0041] Whenever it is determined that the intermediate structure of a node obtained at the current moment is different from the intermediate structure of a node obtained at a historical moment adjacent to the current moment, a screenshot of the intermediate webpage presented at the current moment is taken to obtain a screenshot of the intermediate webpage.
[0042] The test cases are generated based on at least one intermediate webpage screenshot, the native response data, and the webpage rendering data.
[0043] Optionally, the processing module is specifically used for:
[0044] Receive a test case replay instruction for the webpage element; wherein the test case replay instruction is used to: instruct the replay of the test case;
[0045] When it is detected that a webpage operation has been triggered by a webpage element indicated by the test case replay instruction, the native response data recorded by the test case is obtained;
[0046] Application testing was conducted based on the aforementioned native response data.
[0047] Optionally, the processing module is specifically used for:
[0048] Based on the native response data, the webpage presented by the hybrid application is updated to obtain test presentation data; wherein, the test presentation data includes third node relationship information, which represents: the hierarchical relationship formed according to the display effect of the updated webpage, with the element attributes of each updated element constituting the updated webpage as nodes;
[0049] When it is determined that the test presentation data matches the webpage presentation data recorded in the test case, a test success result is generated indicating that the test for the webpage element has passed;
[0050] When it is determined that the test presentation data does not match the webpage presentation data recorded in the test case, a test failure result representing the failure of the test for the webpage element is generated based on the mismatched data in the test presentation data and the webpage presentation data.
[0051] Optionally, the processing module is further configured to:
[0052] After obtaining the test case recording instruction for the web page element, when it is determined that there is a basic test case for the web page element in the pre-stored test case library, the basic test case is obtained; wherein, the basic test case is associated with adaptation information, and the adaptation information represents: the device information of the installation device of the application that adapts to the basic test case for application testing;
[0053] When it is determined that the adaptation information associated with the basic use case does not match the device information of the installation device of the hybrid application, a use case re-encoding instruction is generated for the web page element based on the basic use case; wherein, the use case re-encoding instruction is used to: instruct the basic use case to be adjusted to adapt to the device information of the installation device of the hybrid application;
[0054] Based on the test case re-encoding instruction and the basic test case, test cases for the web page elements are generated.
[0055] Optionally, the processing module is specifically used for:
[0056] Based on the request interception function provided by the webpage view component, when it is detected that a webpage operation has been triggered by the webpage element indicated by the re-recording instruction of the use case, the webpage presented by the hybrid application is updated based on the native response data recorded by the basic use case to obtain the webpage presentation data.
[0057] Based on the obtained webpage rendering data, the basic test cases are adjusted to obtain test cases for the webpage elements.
[0058] Thirdly, a computer program product is provided, including a computer program that, when executed by a processor, implements the method described in the first aspect.
[0059] Fourthly, a computer device is provided, comprising:
[0060] Memory, used to store program instructions;
[0061] A processor is configured to invoke program instructions stored in the memory and execute the method described in the first aspect according to the obtained program instructions.
[0062] Fifthly, a computer-readable storage medium is provided, the computer-readable storage medium storing computer-executable instructions for causing a computer to perform the method as described in the first aspect.
[0063] In this embodiment of the application, for hybrid applications that embed web page view components in a native application framework, the method of recording test cases and replaying test cases is used to perform application testing on the web page elements in the web page presented by the hybrid application. This achieves the purpose of testing application pages developed using technologies other than native technologies in hybrid applications, reducing the limitations of testing.
[0064] Specifically, when a webpage operation is triggered for a specific webpage element, the request interception function provided by the webpage view component can be used to intercept the webpage data request generated based on that operation. This prevents the webpage view component from sending webpage data requests to the network address associated with the webpage element, thus avoiding cross-domain restrictions or other security policies that prevent direct access to resources or services provided through the native application framework.
[0065] Furthermore, based on the data sending and receiving functions provided by the native application framework, the obtained web page data requests are rewritten as native data requests. This allows the native application framework to send native data requests to the network address associated with the web page element and receive the returned native response data from the network address. This achieves the goal of having the native application framework replace the network view component to interact with the network address, enabling the native data requests to directly access resources or services provided by the native application framework, thus providing conditions for generating test cases.
[0066] Therefore, based on the native response data, test cases for web page elements can be generated, and when a test case replay instruction is received for a web page element, application testing can be performed based on the obtained test cases. This achieves the goal of testing application pages developed using technologies other than native technologies in hybrid applications, reducing testing limitations. Attached Figure Description
[0067] Figure 1A This is a schematic diagram of a scenario for the application testing method provided in an embodiment of this application;
[0068] Figure 1B This is a schematic diagram illustrating the principle of a testing method applied in related technologies.
[0069] Figure 1C This is one application scenario of the application testing method provided in the embodiments of this application;
[0070] Figure 2A A schematic diagram illustrating the principle of the application testing method provided in this application embodiment;
[0071] Figure 2B A flowchart illustrating an application testing method provided in this application embodiment;
[0072] Figure 3A A schematic diagram of the principle of the application testing method provided in the embodiments of this application is shown in Figure 2.
[0073] Figure 3B A schematic diagram three illustrating the principle of the application testing method provided in this application embodiment;
[0074] Figure 3C A schematic diagram four illustrating the principle of the application testing method provided in this application embodiment;
[0075] Figure 4A A schematic diagram five illustrating the principle of the application testing method provided in the embodiments of this application;
[0076] Figure 4B A schematic diagram six illustrating the principle of an application testing method provided in an embodiment of this application;
[0077] Figure 4C A schematic diagram seven illustrating the principle of an application testing method provided in an embodiment of this application;
[0078] Figure 4D A schematic diagram of the application testing method provided in the embodiments of this application. Figure 8 ;
[0079] Figure 5A A schematic diagram of the application testing method provided in the embodiments of this application. Figure 9 ;
[0080] Figure 5B A schematic diagram of the principle of the application testing method provided in the embodiments of this application is shown in Figure 10.
[0081] Figure 5C 11. A schematic diagram of the principle of the application testing method provided in the embodiments of this application;
[0082] Figure 5D A schematic diagram twelve illustrating the principle of an application testing method provided in this application embodiment;
[0083] Figure 5E A schematic diagram thirteen illustrating the principle of an application testing method provided in this application embodiment;
[0084] Figure 6A Fourteen is a schematic diagram illustrating the principle of an application testing method provided in this application embodiment;
[0085] Figure 6B A schematic diagram fifteen illustrating the principle of an application testing method provided in this application embodiment;
[0086] Figure 6C A schematic diagram sixteen illustrating the principle of an application testing method provided in an embodiment of this application;
[0087] Figure 7A A schematic diagram seventeen illustrating the principle of an application testing method provided in this application embodiment;
[0088] Figure 7B Schematic diagram eighteen, illustrating the principle of the application testing method provided in this application embodiment;
[0089] Figure 7C A flowchart illustrating an application testing method provided in this application embodiment is shown in Figure 3.
[0090] Figure 8 A schematic diagram of the structure of an application testing device provided in an embodiment of this application;
[0091] Figure 9 This is a schematic diagram of the structure of an application testing device provided in an embodiment of this application. Detailed Implementation
[0092] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings.
[0093] The following explanations of some terms used in the embodiments of this application are provided to facilitate understanding by those skilled in the art.
[0094] (1) Hybrid App:
[0095] A hybrid app is a mobile application that combines features of native apps and web apps. Hybrid apps typically use web technologies (such as HTML, CSS, and JavaScript) to develop the user interface and display the application content on mobile devices through a built-in browser engine (such as WebView). At the same time, hybrid apps can also leverage the functionality and features of native apps, such as accessing device hardware and push notifications.
[0096] (2) Native Applications:
[0097] Native applications are applications specifically developed for a particular mobile operating system (such as iOS or Android). These applications are developed using the native programming languages and tools of the specific platform (such as Objective-C or Swift for iOS, and Java or Kotlin for Android), run on the specific operating system, and can fully utilize the device's capabilities and performance.
[0098] (3) Document Object Model (DOM):
[0099] The DOM is a standard programming interface for the Extensible Markup Language (XML). It's a platform- and language-independent application programming interface (API) that allows dynamic access to programs and scripts, updating their content, structure, and document style. Documents can be further processed, and the results can be added to the current page. The DOM is a tree-based API that requires the entire document to be represented in memory during processing.
[0100] (4) Software Development Kit (SDK):
[0101] An SDK is a collection of development tools used to build application software for specific software packages, software frameworks, hardware platforms, operating systems, etc. SDKs facilitate application creation through compilers, debuggers, software frameworks, and more. An SDK can simply provide some application programming interface (API) files for a programming language, or it may include complex hardware that can communicate with an embedded system.
[0102] This application relates to cloud computing, which can be applied to multiple fields, such as smart homes, smart wearable devices, virtual assistants, smart speakers, smart marketing, autonomous driving, smart transportation, smart maps, driver assistance systems, vehicle terminals, aircraft, digital twins, virtual humans, robots, AI-generated content (AIGC), conversational interaction, smart healthcare, smart customer service, and game AI. It is believed that with the development of technology, blockchain technology and cloud computing will be applied in more fields and play an increasingly important role.
[0103] Cloud computing is a computing model that distributes computing tasks across a resource pool composed of a large number of computers, enabling various application systems to access computing power, storage space, and information services as needed. The network providing these resources is called the "cloud." From the user's perspective, the resources in the "cloud" are infinitely scalable, readily available, on-demand, expandable, and pay-as-you-go.
[0104] It should be noted that in the embodiments of this application, data such as the acquisition of use case recording instructions are involved. When the above embodiments of this application are applied to specific products or technologies, user permission or consent is required, and the collection, use and processing of related data must comply with the relevant laws, regulations and standards of the relevant countries and regions.
[0105] In this application embodiment, the terms "module" or "unit" refer to a computer program or part of a computer program that has a predetermined function and works with other related parts to achieve a predetermined goal, and can be implemented wholly or partially using software, hardware (such as processing circuitry or memory), or a combination thereof. Similarly, a processor (or multiple processors or memory) can be used to implement one or more modules or units. Furthermore, each module or unit can be part of an overall module or unit that includes the functionality of that module or unit.
[0106] The application fields of the application testing methods provided in the embodiments of this application will be briefly introduced below.
[0107] With the continuous development of technology, more and more devices can test the application pages displayed by installed applications and generate test results. Based on the test results, it can be determined whether the page elements on the application page are displayed, whether the display position is correct, whether the displayed content meets expectations, and whether the page interaction is responsive, so as to ensure that the application can run normally and stably.
[0108] For example, please refer to Figure 1A (1) in the example describes an expected presentation effect of the application page within the application. Please refer to [reference needed]. Figure 1A (2) in the example describes a test presentation effect where the application page is displayed in the application during application testing. In this test presentation effect, the icon elements are not displayed.
[0109] In related technologies, application testing methods typically involve first performing corresponding operations on all page elements presented by the application to generate corresponding test cases; then replaying each obtained test case to obtain the corresponding replay results; and finally, determining whether the replay results match the operation results recorded in the corresponding test cases to generate the application's test results.
[0110] The generated test cases record the operations performed on the corresponding page elements and the results of those operations. When replaying the test cases, the recorded operations are simulated for the corresponding operable objects to obtain the replay results.
[0111] For example, to perform corresponding actions on each page element in the current page presented by the application, please refer to [reference needed]. Figure 1B In step (1), a selection operation is performed on a page element "Third Icon" on the current page. A screenshot of the application page displayed after the selection operation is performed is obtained, and a test case for that page element is generated. When replaying the test case, please refer to... Figure 1B In (2), a selection operation on the page element "third icon" is simulated based on the test cases, and a screenshot of the application page after the simulated selection operation is executed is obtained. By comparing whether the content presented in the two screenshots is the same, the application test results for this page element can be obtained.
[0112] However, as applications have evolved from native applications developed using a single development model to hybrid applications developed using a hybrid development model to provide richer and more diverse user experiences—for example, from native applications developed using a single native technology to hybrid applications combining native and web technologies—some technologies in hybrid applications cannot be directly used for cross-platform data processing.
[0113] For example, in an instant messaging application, a mini-program page can be displayed. This instant messaging application is developed using native technologies, while the mini-program page is embedded and presented using web technologies. Therefore, during the presentation of the mini-program page, the process of sending and receiving network data cannot be directly perceived by the native technologies.
[0114] Therefore, it is impossible to test application pages developed using technologies other than native technologies in hybrid applications.
[0115] It is evident that the testing methods for applications based on related technologies have significant limitations and cannot accurately test hybrid applications.
[0116] To address the limitations of traditional application testing methods and their inability to accurately test hybrid applications, this application proposes an application testing method. This method is applied to hybrid applications that embed webpage view components within a native application framework. These webpage view components are used to present webpages within the hybrid application.
[0117] This method involves obtaining a test case recording instruction for a webpage element. The webpage element constitutes the webpage and is associated with a network address for accessing other webpages. Based on the request interception function provided by the webpage view component, when a webpage operation is triggered by the webpage element indicated by the test case recording instruction, the generated webpage data request is intercepted. This webpage data request is used to obtain webpage response data from the network address to update the webpage presented by the hybrid application. Based on the data sending and receiving functions provided by the native application framework, the obtained webpage data request is rewritten as a native data request, and based on this native data request, native response data is obtained from the network address to replace the webpage response data. Based on the native response data, test cases for the webpage element are generated, and upon receiving a test case replay instruction for the webpage element, application testing is performed based on the obtained test cases.
[0118] In this embodiment of the application, for hybrid applications that embed web page view components in a native application framework, the method of recording test cases and replaying test cases is used to perform application testing on the web page elements in the web page presented by the hybrid application. This achieves the purpose of testing application pages developed using technologies other than native technologies in hybrid applications, reducing the limitations of testing.
[0119] Specifically, when a webpage operation is triggered for a specific webpage element, the request interception function provided by the webpage view component can be used to intercept the webpage data request generated based on that operation. This prevents the webpage view component from sending webpage data requests to the network address associated with the webpage element, thus avoiding cross-domain restrictions or other security policies that prevent direct access to resources or services provided through the native application framework.
[0120] Furthermore, based on the data sending and receiving functions provided by the native application framework, the obtained web page data requests are rewritten as native data requests. This allows the native application framework to send native data requests to the network address associated with the web page element and receive the returned native response data from the network address. This achieves the goal of having the native application framework replace the network view component to interact with the network address, enabling the native data requests to directly access resources or services provided by the native application framework, thus providing conditions for generating test cases.
[0121] Therefore, based on the native response data, test cases for webpage elements can be generated, and when a test case replay instruction for a webpage element is received, application testing can be performed based on the obtained test cases. This achieves the goal of testing application pages developed using technologies other than native technologies in hybrid applications, reducing testing limitations. Furthermore, by recording test cases only once, testing of elements in other webpages associated with a given webpage element can be achieved, eliminating the need to record separate test cases for each element on other webpages, thus improving testing efficiency.
[0122] The application scenarios of the application testing method provided in this application are described below.
[0123] Please refer to Figure 1C This is a schematic diagram of an application scenario for the application testing method provided in this application. The application scenario includes an application terminal 101 and a test terminal 102, wherein the application terminal 101 includes a first client 1011 and a first server 1012, and the test terminal 102 includes a second client 1021 and a second server 1022.
[0124] The application terminal 101 and the test terminal 102 can communicate with each other, the first client 1011 and the first server 1012 can communicate with each other, and the second client 1021 and the second server 1022 can communicate with each other. The communication method can be wired, such as through a network cable or serial cable; or wireless, such as through Bluetooth or Wi-Fi. There are no specific restrictions.
[0125] First client 1011 generally refers to a device that can be used to display web pages presented by hybrid applications and respond to operations, such as terminal devices, third-party applications accessible by terminal devices, or web pages accessible by terminal devices. First server 1012 generally refers to a device that can execute processing logic for application testing methods, such as terminal devices or servers.
[0126] The second client 1021 generally refers to a device that can present the application testing process and respond to operations, such as a terminal device, a third-party application accessible by the terminal device, or a webpage accessible by the terminal device. The second server 1022 generally refers to a device that can manage test cases, such as a terminal device or a server.
[0127] Terminal devices include, but are not limited to, mobile phones, computers, smart medical devices, smart home appliances, vehicle terminals, or aircraft. Servers include, but are not limited to, cloud servers, local servers, or associated third-party servers. Both client 101 and server 102 can use cloud computing to reduce the use of local computing resources; similarly, they can also use cloud storage to reduce the use of local storage resources.
[0128] As one embodiment, the first client 1011 and the second client 1021 can be the same device, the first server 1012 and the second server 1022 can be the same device, or they can be different devices, or they can be different devices with some modules shared, etc., and there are no specific restrictions.
[0129] The following is based on Figure 1C This application testing method, using a software development kit (SDK) as an example, is specifically described in this paper, applied to a hybrid application that embeds web view components within a native application framework. Please refer to... Figure 2A This is a schematic diagram of a hybrid application interface. This hybrid application can access an online shopping platform from a mobile phone via a web view component, and can also utilize the phone's resources by calling upon the native application framework. The hybrid application displays a webpage of the online shopping platform by accessing the corresponding network address.
[0130] Please refer to Figure 2B This is a flowchart illustrating an application testing method provided in an embodiment of this application.
[0131] S201, Obtain the test case recording instruction for web page elements.
[0132] Web page elements are used to construct web pages; please continue to refer to [the documentation / reference]. Figure 2A The icons and text within this element can function as webpage elements. Webpage elements are associated with network addresses that access other webpages; for example, for... Figure 2A The selection of the "supermarket" element or its corresponding icon can take you from the homepage of the currently displayed online shopping platform to the supermarket shopping page within the platform.
[0133] The test case recording instruction is used to instruct the generation of test cases related to the web page element. For example, it can generate test cases that trigger entry into other web pages corresponding to the network address associated with the web page element; or it can generate test cases that trigger entry into the current web page containing the web page element from other web pages to present the web page element. There are no specific limitations. In this embodiment, the generation of test cases that trigger entry into other web pages corresponding to the network address associated with the web page element is used as an example for description.
[0134] As one example, there are several methods for obtaining test case recording instructions. Two of them will be introduced below as examples.
[0135] Method 1: Generate instructions through response operations.
[0136] In response to a test case update operation triggered by the current webpage presented by the hybrid application, the first node relationship information of the current webpage is obtained. In response to a selection operation triggered by at least one element among the current elements represented by the first node relationship information, a test case recording instruction for at least one element is generated. Each of the at least one obtained elements is then used as a webpage element to generate corresponding test cases.
[0137] Test case update operations can instruct the addition of new test cases for the current webpage, or the modification of existing test cases for the current webpage. The first-level node relationship information is represented by the element attributes of each current element constituting the current webpage as nodes, forming a hierarchical relationship according to the current webpage's presentation. For example, the first-level node relationship information is the Document Object Model (DOM) of the current webpage. Test cases already generated for each current element in the current webpage can be stored according to the hierarchical relationship represented by the first-level node relationship information.
[0138] For example, please refer to Figure 3A In response to the rendering operation of test cases for each current element contained in the current webpage presented in a hybrid application, the rendering operation of test cases for each current element contained in the current webpage is treated as a test case update operation to obtain the first node relationship information of the current webpage. Based on the hierarchical relationship of each node represented by the first node relationship information, the stored test cases for each current element contained in the current webpage are displayed in a pop-up window. Each folder contains test cases for at least one current element belonging to each node of the same hierarchical relationship. Each folder has a corresponding "Add" button, used to add test cases for at least one current element belonging to other nodes of the same hierarchical relationship within the folder.
[0139] For example, please refer to Figure 3BIn response to the addition of test cases for each current element contained in the current webpage, the addition of test cases for each current element in the current webpage is treated as a test case update operation, and the first node relationship information of the current webpage is obtained. According to the hierarchical relationship of each node in the first node relationship information, each current element is presented sequentially in a pop-up window. This pop-up window indicates that in response to the selection of the "OK" button, corresponding test cases are added for each presented current element. In response to the deletion operation triggered by at least one current element presented in the pop-up window, at least one current element can be deleted from the pop-up window. Then, in response to the selection of the "OK" button, corresponding test cases are added for each presented current element that has had at least one current element deleted. Therefore, any device with the hybrid application installed can be used to trigger the test case update operation. It eliminates the need for a dedicated device for testing the hybrid application, requiring communication between the other device and the hybrid application to complete the application testing process. This reduces latency in data communication and the possibility of data communication anomalies, improving the flexibility of application testing.
[0140] Method 2: Receive instructions sent by other devices.
[0141] On other devices with the hybrid application installed, each element contained in each webpage that the hybrid application can display is presented. In response to a use case update operation triggered for at least one of the presented elements, a corresponding use case recording instruction is generated for each of the at least one element. Each of the at least one element is then used as a webpage element. The other devices send the generated use case recording instructions to the device with the hybrid application installed.
[0142] When a device with a hybrid application is running a hybrid application and a webpage containing a webpage element that indicates a use case recording instruction is displayed, it is determined that a use case recording instruction for that webpage element has been received.
[0143] By sending test case recording instructions through other devices, the application testing process can be uniformly managed by other devices. This allows for comprehensive macro-analysis of test results on other devices, improving the convenience of debugging hybrid applications based on test results and the accuracy of debugging strategy formulation.
[0144] Please refer to Figure 3C On other devices, web page elements such as "department store" are displayed. In response to a selection operation on the web page element "department store", a test case recording instruction for the web page element "department store" is generated as a response to a test case update operation triggered on the web page element "department store". The other devices then send the generated test case recording instruction to the installation device with the hybrid application installed.
[0145] When the hybrid application running on the installed device presents a current webpage containing the webpage element "department store", it is determined that a use case recording instruction for the webpage element "department store" has been received.
[0146] As one implementation, existing test cases can be stored as base test cases in a test case library. This allows other devices to perform application testing on the hybrid application based on the test case library when running the hybrid application. This enables continuous and automated application testing after the hybrid application is launched, eliminating the need for manual intervention by testers. Furthermore, for different devices with different device information, adapted test cases can be automatically re-recorded based on the base test cases, eliminating the need for manual triggering of test case generation and re-execution of the entire test case generation process, thus improving application testing efficiency and intelligence.
[0147] Please refer to Figure 4A This is a schematic diagram of a stored test case library. The basic test cases are divided into multiple folders according to the webpage to which the webpage element belongs, and the hierarchical relationship between the nodes contained within the webpage element and other nodes in the DOM. Each folder is associated with a test case replay button. When one or more test case replay buttons are selected, test case replay instructions can be generated for the basic test cases contained in the corresponding folder for application testing.
[0148] After receiving the test case recording instruction for a webpage element, you can first determine whether the basic test case corresponding to the webpage element exists in the pre-stored test case library. If it does not exist, you can continue to execute S202 to S204 to perform application testing. If it already exists, you can further determine whether the installation device of the hybrid application is compatible with the pre-stored basic test case. If it is compatible, you can directly use the basic test case to perform application testing. If it is not compatible, you can automatically re-record the test case based on the basic test case to perform application testing.
[0149] If a basic test case for a given webpage element exists in the pre-stored test case library, that basic test case is retrieved. The basic test case is associated with adaptation information, which represents the device information of the application being tested using the basic test case. Device information may include the device model, the operating system version, or the device resolution, etc., without specific limitations.
[0150] When it is determined that the adaptation information associated with the obtained basic use cases matches the device information of the hybrid application's installed device, the obtained basic use cases are used as test cases for web page elements for application testing. When it is determined that the adaptation information associated with the obtained basic use cases does not match the device information of the hybrid application's installed device, a use case re-encoding instruction is generated for the web page elements based on the basic use cases. The use case re-encoding instruction is used to: instruct the basic use cases to be adjusted to adapt to the device information of the hybrid application's installed device. Based on the use case re-encoding instruction and the basic use cases, test cases for the web page elements are generated.
[0151] For example, the adaptation information associated with the basic use case indicates that the resolution of the device on which the basic use case is installed is 1920×1080. Please refer to [reference needed]. Figure 4B (1) in the text describes the presentation effect of other web pages associated with a web page element. The device information for the installed device in the hybrid application indicates that the resolution of the installed device is 2560×1440. Please refer to [reference needed]. Figure 4B (2) in the text is a presentation effect of other web pages associated with web page elements.
[0152] The same webpages display differently on devices with varying resolutions. This is due to differences in the display distance between elements, the size of individual elements, and character size. Directly testing based on basic test cases can lead to inaccurate application testing. Recording test cases for each specific device would result in extensive repetitive processes, leading to low testing efficiency and unnecessary resource consumption. Therefore, automated test case re-recording based on basic test cases can obtain test cases adapted to the installed devices without requiring extensive repetitive processes.
[0153] As one embodiment, after generating test case re-encoding instructions for web page elements based on basic test cases, the request interception function provided by the web page view component can be used to detect whether the web page element indicated by the test case re-encoding instructions has triggered a web page operation. When it is detected that the web page element indicated by the test case re-encoding instructions has triggered a web page operation, the web page presented by the hybrid application is updated based on the native response data recorded in the basic test cases to obtain web page presentation data. Based on the obtained web page presentation data, the basic test cases are adjusted to obtain test cases for the web page elements. The specific process is similar to the process of generating test cases described later and will not be repeated here.
[0154] Since the processing logic of the hybrid application is the same when running on different devices, the response data obtained from the same webpage operation should also be the same. Only the display effect when presenting the webpage based on the same response data will be slightly different. Therefore, the native response data recorded in the basic test cases can be directly used to update the webpage presented by the hybrid application. Based on the webpage presentation data characterizing the presentation effect, the webpage presentation data recorded in the basic test cases can be replaced to obtain test cases for the webpage element adapted to the current installed device. This allows application testing to be performed based on the obtained test cases when a test case replay instruction for that webpage element is received.
[0155] By implementing an automated test case re-recording process, the complete test case recording process is no longer required to be repeated, thus improving the efficiency of re-recording test cases and consequently improving the efficiency of application testing based on test cases.
[0156] Please refer to Figure 4C After storing basic test cases for webpage elements on an installation device with a resolution of 1920×1080, if the basic test cases are incompatible on an installation device with a resolution of 2560×1440, test cases can be re-recorded based on the basic test cases. The native response data from the basic test cases is retrieved, and the webpage rendered by the hybrid application running on the 2560×1440 installation device is updated. The updated webpage rendering data is then used as the updated rendering data to update the webpage rendering data in the basic test cases, resulting in test cases adapted to the 2560×1440 installation device.
[0157] As one example, during the test case re-recording process, based on the DOM in the webpage rendering data, the sub-structures of each node that make up each element are determined, denoted as ViewPath1. Please refer to... Figure 4D Based on the updated rendering data, the outermost view in the webpage's layout file, namely the root view (RootView), is obtained. The root view is the top-level container of the layout file, and its location allows us to obtain the overall structure and hierarchy of the webpage's layout.
[0158] For each ViewPath1, iterate through the ViewPath2 that has the highest similarity to ViewPath1 from the RootView.
[0159] If ViewPath1 and ViewPath2 are exactly the same, then the data corresponding to ViewPath2 in the rendering data can be replaced and updated based on the data corresponding to ViewPath1 in the webpage rendering data.
[0160] If ViewPath1 and ViewPath2 are not the same, then determine whether the difference in levels between ViewPath1 and ViewPath2 is greater than a preset threshold. If it is greater than the preset threshold, it means that ViewPath1 and ViewPath2 are very dissimilar, and then determine that the elements represented by ViewPath1 and ViewPath2 are not the same element.
[0161] If the similarity is not greater than a preset threshold, it means that the elements represented by ViewPath1 and ViewPath2 are likely the same element. Therefore, the above process can be repeated with the element corresponding to ViewPath2 as the RootView to determine the ViewPath3 with the highest similarity. If ViewPath3 contains multiple elements, then based on the coordinates of the elements in the webpage, the elements that match the elements represented by ViewPath1 are determined and the corresponding data is replaced; otherwise, it is determined that the elements represented by them are not the same element.
[0162] S202, Based on the request interception function provided by the webpage view component, when it is detected that a webpage element triggered by the use case recording instruction has triggered a webpage operation, the generated webpage data request is intercepted.
[0163] After receiving the test case recording instruction, you can run the request interception function provided by the web view component to continuously detect whether the web element indicated by the test case recording instruction has been triggered by web operations. Web operations can be, for example, touch selection of an icon, voice selection of a web element, gesture selection of a web element, or condition fulfillment of access conditions associated with a web element, etc. There are no specific restrictions.
[0164] When a webpage action is triggered by a webpage element specified in the use case recording instruction, it indicates that the page loading process for another webpage will begin. Therefore, the webpage data request generated based on this webpage action can be intercepted. This webpage data request is used to retrieve webpage response data from a network address to update the webpage rendered by the hybrid application. This delays the retrieval of webpage response data from the network address, creating an opportunity for subsequent processes.
[0165] As one example, when detecting whether a webpage operation has been triggered for a webpage element, this can be determined based on whether the webpage update function corresponding to the webpage element has been initialized. Before updating the webpage presented by the hybrid application, other webpages associated with the webpage element need to be loaded by calling the webpage update function. Therefore, when the initialization of the webpage update function corresponding to the webpage element is detected, it can be determined that a webpage operation has been triggered for the webpage element to request access to other webpages associated with the webpage element. This allows webpage data requests to be intercepted before other webpages are loaded, creating an opportunity for subsequent processes.
[0166] Therefore, based on the request interception function provided by the webpage view component, when the function initialization function provided by the webpage view component is detected and the webpage update function corresponding to the webpage element is initialized, it is determined that a webpage operation has been triggered for the webpage element, and the webpage update function is used to generate a webpage data request.
[0167] Based on the request interception function provided by the webpage view component, webpage data requests are intercepted, and a preset data transfer interface is called to transfer the webpage data requests. The data transfer interface is used to establish data interaction between the native application framework and the webpage view component.
[0168] The data transfer interface can be written in JavaScript to establish a bridge for data interaction between the native application framework and web page view components, enabling the transfer of data. Through this interface, intercepted web page data requests can be processed using the functionalities provided by the native application framework.
[0169] For example, please refer to Figure 5A In a hybrid application running on Android, an embedded WebView component can be used. The `shouldInterceptRequest` method provided by the WebView component can be used to detect whether the WebView component has initialized a WebView function, which is used to present other web pages associated with web page elements within the hybrid application. After confirming through `shouldInterceptRequest` that the WebView function has been initialized, data requests for web pages generated by the WebView component can be intercepted. Using a data transfer interface written in JavaScript, the WebView component forwards the intercepted web page data requests to the Android system for processing.
[0170] For example, please refer to Figure 5B In a hybrid application running on iOS, an embedded WebKit component accesses a property named `browsingContextController` through the KVC methods provided by the WebKit component. This property is an object of type `WKBrowsingContextController`, which manages the browsing context, i.e., a separate browsing environment within the browser. Through the `WKBrowsingContextController` object, one can detect whether the WebKit component initializes a WebKit function named `NYX_initWithFrame` using the `initWithFrame` method, and whether it calls the `loadRequest` method named `NYX_loadRequest` to load other web pages associated with web page elements within the hybrid application.
[0171] By using the registerSchemeForCustomProtocol method provided by the WebKit component, an abstract base class NSURLProtocol can be registered to intercept web page data requests generated by the WebKit component, i.e., HTTP requests or HTTPS requests.
[0172] For example, please refer to Figure 5C In a hybrid application running on iOS, which embeds WebKit components and AJAX components, if the WebKit component is detected using the initWithFrame method to initialize a WebKit function named NYX_initWithFrame, the XMLHttpRequest code can be rewritten using the JavaScript programming language to intercept AJAX requests through a custom XMLHttpRequest method.
[0173] S203, based on the data sending and receiving functions provided by the native application framework, rewrites the obtained web page data request into a native data request, and obtains the native response data from the network address to replace the web page response data based on the native data request.
[0174] After intercepting a webpage data request, the data sending and receiving functions provided by the native application framework can be used to rewrite the obtained webpage data request into a native data request. This allows the native application framework to replace the network view component, interact with the network address, and obtain native response data from the network address based on the native data request, thus creating conditions for generating test cases.
[0175] For example, in a hybrid application running on Android that embeds a WebView component, we can use aspect-oriented programming (AOP) or hooking techniques to intercept relevant functions in the native application framework and the WebView component, delaying the loading of the webpage HTML and creating opportunities for a custom WebViewClient subclass. In this process, a custom WebViewClient subclass is created, overriding the necessary methods to intercept and handle WebView loading events. This custom WebViewClient is then set to the corresponding WebView. Thus, when a webpage data request is generated through the WebView component and the URL is loaded, various events during the loading process can be handled through the custom WebViewClient. By using the custom WebViewClient, the data transmission and reception functions provided by the native application framework can be used to copy the webpage data request, obtain the native data request, and interact with the network address based on the native data request.
[0176] As one example, when rewriting a webpage data request into a native data request based on the data sending and receiving functions provided by the native application framework, if the webpage data request contains a special webpage request, since the special webpage request requires identification through a data parsing strategy, the request data in the special webpage request cannot be directly obtained. Therefore, it is impossible to directly rewrite the special webpage request into a native special request. Thus, when it is determined that the webpage data request contains a special webpage request, the webpage response data can be obtained from the network address based on the data sending and receiving functions of the webpage view component. Pre-defined new feature data is added to the webpage response data. This new feature data is used to: add data parsing functionality to the native application framework; and parse the request parameters of the special request from the webpage data request based on the data parsing function. This allows the generation of a native data request based on the webpage data request and the request parameters.
[0177] If a webpage data request contains multiple data requests, each requesting a different webpage—for example, in a hybrid application updating from a first webpage to a second webpage, it might first update from the first webpage to a blank page, then from the blank page to a page awaiting rendering, and finally from the page awaiting rendering to the second webpage—then the webpage data request could include: a first data request to request an update from the first webpage to a blank page; a second data request to request an update from the blank page to the page awaiting rendering; and a third data request to request an update from the first webpage to a blank page. If the second data request is a special webpage request, then pre-defined new feature data can be added to the native response data obtained by rewriting the native data request through the first data request. This new feature data is used to add data parsing functionality to the native application framework. Thus, after the webpage view component generates the second data request but before loading the second response data from the network address, the request parameters for the special request can be parsed from the second data request based on the data parsing function. Therefore, based on the second data request and its parameters, a rewritten native data request can be generated.
[0178] By adding pre-defined new feature data to the webpage response data, the new feature data can be executed when the webpage response data is run, thereby enabling the native application framework to have data parsing capabilities and be able to parse special webpage requests.
[0179] For example, in POST requests, request parameters are typically sent through the request body, unlike GET requests where they are directly appended to the request header. Therefore, the data transmission and reception functions provided by the native application framework cannot directly retrieve these parameters. Thus, when intercepting other web pages, JavaScript code can be dynamically injected into them to proxy the POST request sending method. This allows the POST request parameters to be passed back to the native application framework's data transmission and reception functions via the dynamically injected JavaScript code. Based on these functions, a special native request can then be rewritten and initiated.
[0180] based on Figure 5A Please refer to Figure 5DIn a hybrid application running on the Android system, an embedded WebView component is used. POST requests triggered in the webpage rendered by the hybrid application can be dynamically injected with JavaScript code after the native application framework's data transmission and reception function establishes a connection with the webpage's network address. This JavaScript code is then dynamically injected during the loading of the webpage's text or HTML pages, and script files. This proxy handles the POST request sending method, allowing the injected JavaScript code to parse the request parameters. Based on these parameters, the native application framework's data transmission and reception function rewrites the request into a native data request, which is then forwarded to the network address. This achieves data interaction through proxying the POST request. The native application framework's data transmission and reception function obtains the native response data returned from the network address. A pre-defined data transfer interface then forwards this native response data to the network view component, which renders the page and updates the webpage rendered by the hybrid application to a different webpage.
[0181] As one implementation, when generating a native data request based on a webpage data request and request parameters, the network link information corresponding to the native data request and the webpage's specific request can be further compared, such as the Uniform Resource Locator (URL). Based on the URL, Hypertext Markup Language (HTML) can be used to link hypertext and hypermedia between webpages within a website, between systems, or between different systems. By comparing the network link information, it can be determined whether the request parameters carried in the generated native data request are complete, thereby generating a more accurate native data request.
[0182] Based on the data sending and receiving capabilities provided by the native application framework, a native special request carrying request parameters is generated. Both the native special request and the webpage special request are sent to the network address respectively, obtaining the corresponding network link information for each. When it is determined that the network link information corresponding to the native special request and the webpage special request match, the webpage data request is rewritten as a native data request based on the native special request.
[0183] For example, based on Figure 5B and Figure 5C Please refer to Figure 5E Hybrid applications running on iOS, embedding WebKit components, can intercept web page data requests and extract request headers, request bodies, and network link information (such as URLs). This allows them to rewrite the requests as native data requests and forward them. The native response data returned from the network address can include the data body (responseData) and the data header (responseHeader).
[0184] If the webpage data request is an AJAX request, then the obtained native response data is forwarded to the webpage view component via a custom XMLHttpRequest to end the request. If the webpage data request is not an AJAX request, then the obtained native response data is forwarded to the webpage view component via a custom NSURLProtocol to end the request.
[0185] S204 generates test cases for web page elements based on native response data, and performs application testing based on the obtained test cases when a test case replay instruction for a web page element is received.
[0186] When obtaining native response data, test cases for webpage elements can be generated based on this data. These generated test cases can be used as base test cases for the webpage elements and stored in a test case library. This allows for direct retrieval of test cases for the webpage element from the library for application testing when a replay instruction for that element is received. Alternatively, other installed devices can use the base test cases stored in the library to perform an automated re-encoding process, obtaining test cases for the webpage element adapted to other installed devices for application testing.
[0187] As one example, after obtaining native response data through the data sending and receiving functions provided by the native application framework, a preset data transmission interface can be called to transmit the native response data. This data transmission interface is used to establish data interaction between the native application framework and the webpage view component. Thus, native response data can be received based on the data sending and receiving functions provided by the webpage view component. Based on the webpage rendering function of the webpage view component, the webpage presented by the hybrid application is updated according to the native response data.
[0188] After updating the webpage, the node update structure of the updated webpage is obtained, and the webpage rendering data is generated. The node update structure is represented by the hierarchical structure of nodes formed according to the rendering effect of the updated webpage, with each updated element's attribute as a node. The node update structure is, for example, the DOM of the updated webpage. Please refer to [reference needed]. Figure 6A This is a DOM diagram consisting of nine nodes, forming three elements. The first element includes the first, third, and fourth nodes; the second element includes the second, fifth, sixth, and seventh nodes; and the third element includes the second, eighth, and ninth nodes.
[0189] Webpage rendering data can be the node update structure itself, or data obtained after converting the node update structure to other data formats; there are no specific restrictions. Therefore, test cases can be generated based on the native response data and webpage rendering data. The native response data recorded in the test cases represents: the webpage operation triggered for this webpage element; the webpage rendering data recorded in the test cases represents: the updated rendering effect of the webpage after the webpage operation is triggered for this webpage element.
[0190] Since the processing logic of the webpage content remains unchanged, triggering the operation on the webpage element will always result in obtaining the native response data. Therefore, by directly recording the native response data in the test case, it is not necessary to obtain the native response data from the actual network address during application testing. Instead, the native response data can be obtained directly from the test case, which improves the efficiency of data acquisition and thus improves the efficiency of application testing.
[0191] Based on the DOM-generated webpage rendering data, which serves as the expected rendering effect of the updated webpage, the test cases can accurately compare whether each node in the DOM matches, thereby accurately identifying the mismatched nodes and facilitating subsequent targeted debugging processes.
[0192] As one example, in the process of updating the webpage presented by the hybrid application, it can be updated directly from the first webpage to the second webpage; or it can be updated from the first webpage to an intermediate webpage first, and then from the intermediate webpage to the second webpage; or it can be updated from the first webpage to an intermediate webpage first, then from one intermediate webpage to another intermediate webpage, and finally from another intermediate webpage to the second webpage, etc., which will not be elaborated here.
[0193] Therefore, during the process of updating the webpages presented by the hybrid application, the second-node relationship information of the intermediate webpages presented at multiple moments is continuously acquired. The second-node relationship information is represented as a hierarchical relationship formed according to the presentation effect of the intermediate webpages, with each intermediate element's element attribute serving as a node. For example, the second-node relationship information is the DOM of the corresponding intermediate webpage.
[0194] Whenever the intermediate structure of a node obtained at the current moment differs from the intermediate structure obtained at adjacent historical moments, a screenshot of the intermediate webpage presented at the current moment is taken, resulting in an intermediate webpage screenshot. This allows for obtaining screenshots at each webpage update moment. Based on at least one obtained intermediate webpage screenshot, native response data, and webpage presentation data, test cases can be generated. These test cases can visually demonstrate the webpage update process during application testing, facilitating targeted debugging and other subsequent processes.
[0195] As one embodiment, a test case replay instruction is received for a webpage element. The test case replay instruction instructs the replay of test cases, i.e., application testing is performed on the webpage element indicated by the instruction. Therefore, it is possible to continuously monitor whether a webpage operation is triggered by the webpage element indicated by the instruction. When a webpage operation is detected to have been triggered by the instruction, the corresponding test case replay begins. Specifically, upon detecting a triggered webpage operation, the native response data recorded in the test case is obtained, and application testing is performed based on this native response data.
[0196] Since the processing logic of the webpage content remains unchanged, it is not necessary to actually obtain the native response data from the network address. The recorded native response data can be obtained directly from the test cases, which improves the efficiency of data acquisition and thus improves the efficiency of application testing.
[0197] For example, in a hybrid application running on Android that embeds a WebView component, please refer to... Figure 6B After receiving a test case replay instruction for a web page element, the WebView component initializes a WebView function to determine if a web page operation has been triggered by the web page element indicated by the test case replay instruction when presenting other web pages associated with the web page element in a hybrid application.
[0198] When it's determined that the WebView function is associated with a custom WebViewClient function, the request interception function provided by the web view component intercepts the web data requests generated by the web page operations. The custom WebViewClient function represents the data sending and receiving functionality provided by the native application framework, and proxies the data sending and receiving functionality provided by the web view component to interact with the network address.
[0199] The data transmission and reception functions provided by the native application framework rewrite web page data requests into native data requests. From a pre-stored test case library, test cases containing these native data requests are identified. Based on the native response data recorded in the test cases, the web page presented by the hybrid application is updated, the node update structure of the updated web page is obtained, and test presentation data for the updated web page is generated. Application testing is performed by comparing the test presentation data with the web page presentation data recorded in the test cases.
[0200] As one example, when conducting application testing based on native response data, the webpage presented by the hybrid application can be updated based on the native response data to obtain test presentation data. The test presentation data includes third-node relationship information, which represents the hierarchical relationship formed according to the display effect of the updated webpage, using the element attributes of each updated element constituting the updated webpage as nodes. The third-node relationship information can be the DOM of the updated webpage. The test presentation data can also include at least one test screenshot during the webpage update process. For example, if the hybrid application updates from presenting a first webpage to presenting a second webpage, then at least one test screenshot includes the test screenshot corresponding to the first webpage and the test screenshot corresponding to the second webpage. As another example, if the hybrid application updates from presenting a first webpage to presenting an intermediate webpage, and then updates from the intermediate webpage to the second webpage, then at least one test screenshot includes the test screenshot corresponding to the first webpage, the test screenshot corresponding to the intermediate webpage, and the test screenshot corresponding to the second webpage.
[0201] When it is determined that the test presentation data matches the webpage presentation data recorded in the test cases, a test success result is generated indicating that the test for the webpage element has passed. When it is determined that the test presentation data does not match the webpage presentation data recorded in the test cases, a test failure result is generated based on the mismatched data between the test presentation data and the webpage presentation data, indicating that the test for the webpage element has failed.
[0202] For example, if the test presentation data is the DOM of the webpage updated during application testing, and the webpage presentation data is the DOM of the webpage updated during test case recording, then each node can be compared sequentially to see if it matches. Based on the nodes that do not match, a test failure result representing the failure of the test for the webpage element can be generated.
[0203] Please refer to Figure 6C This is a visual representation of the test results. A pop-up window appears on the updated webpage, displaying the elements to which each node belongs in the updated webpage's DOM. Each element is associated with a subscript; the subscript of the element to which a non-matching node belongs is red (color not shown in the diagram), and the subscript of the element to which a matching node belongs is green (color not shown in the diagram). This allows for a clear and intuitive display of test results and failures, facilitating targeted debugging.
[0204] Therefore, based on the test failure results, the location to be repaired can be accurately identified, facilitating the rapid development of debugging solutions and the completion of debugging tasks.
[0205] The following example uses a system architecture to illustrate the application testing method provided in this application. Please refer to [link / reference]. Figure 7AThis includes business clients and business servers that run hybrid applications; test clients and test servers that run application testing methods; and a test management platform.
[0206] The business client is used to display the webpages presented by the hybrid application, including tasks such as initialization functions, generating webpage data requests, and loading various elements contained in the webpage. The business server is used to handle the data processing logic of the hybrid application. The test client is used to trigger test case recording, test case replay, and test case re-recording operations for the webpages presented by the hybrid application to execute the corresponding processes, as well as to obtain the DOM of the currently presented webpage and obtain test cases. The test server is used to handle the data processing logic of the application test methods. The test management platform is used to manage the test case library, distribute basic test cases from the test case library to the test server, and receive test cases reported by the test server.
[0207] The following is based on Figure 7A Taking a hybrid application installed on an Android system as an example, this paper provides an example of the application testing method provided in the embodiments of this application. Please refer to [link / reference]. Figure 7B and Figure 7C .
[0208] Test case recording process:
[0209] S71, the test client generates test case recording instructions.
[0210] By using the test client, the elements to be tested can be selected from the various web pages that the hybrid application can display, and test case recording instructions can be generated. During the process of the hybrid application being deployed and running on the business client and business server, test cases are recorded on the web pages displayed by the hybrid application, making the recorded test cases more realistic.
[0211] S701, in response to test operations triggered for hybrid applications, presents an element selection pop-up.
[0212] S702, determine the WebView function corresponding to the current webpage presented by the hybrid application.
[0213] S703 uses WebView functions to obtain the DOM and displays the corresponding elements in the element selection pop-up window.
[0214] S704, in response to a selection operation triggered for at least one of the elements currently rendered in the hybrid application, cancel the rendering of all elements except the at least one element in the element selection pop-up.
[0215] S705, in response to a reselection operation triggered for at least one other element besides at least one element currently presented in the hybrid application, the at least one other element is added to the element selection pop-up.
[0216] S706, in response to the confirmation operation of the element selection pop-up, generates a use case recording instruction for the element presented in the element selection pop-up.
[0217] S72, the test client determines that the webpage element indicated by the test case recording instruction triggered a webpage operation. The test client detects whether the ViewTree of the webpage containing the webpage element indicated by the test case recording instruction in the hybrid application has changed. If the ViewTree changes, it determines that the webpage element indicated by the test case recording instruction triggered a webpage operation.
[0218] S73, the test client detects the WebView initialization function, which is used to update the webpage containing the webpage elements.
[0219] In hybrid applications, before the web view component initiates a network data request through the business client, the test client locates the corresponding WebView function. By using reflection to delay the URL loading speed of functions such as WebView, loadUrl, and loadData, the system ensures that a custom WebViewClient is set to delegate the originally default associated WebViewClient to the WebView before initiating the network data request.
[0220] S74, the test client determines whether the WebView function is associated with a custom WebViewClient.
[0221] The WebView function is associated with a custom WebViewClient, indicating that test cases have been generated for this webpage element. Therefore, the test case recording process for this webpage element ends, and the application test is performed when the test case playback instruction is received.
[0222] If the WebView function is not associated with a custom WebViewClient, it means that no test cases have been generated for this web page element, so proceed to S75.
[0223] S75, the test client sets up and associates a custom WebViewClient with the WebView function. The custom WebViewClient proxies the WebViewClient originally associated with the WebView function to perform the processing defined in the custom WebViewClient.
[0224] S76, Test client intercepts web data requests generated by the data sending and receiving functions of the web view component in the hybrid application.
[0225] In the custom WebViewClient's `shouldInterceptRequest` method, the corresponding GET and POST requests for the webpage (such as an H5 page) are retrieved and converted into native data requests for response. When requesting to retrieve the webpage's DOM, JavaScript code is injected into the page to ensure that every network request made through the webpage is rewritten and forwarded by the native application framework, passing the request parameters to the native application framework.
[0226] S77, Test the client to call the data sending and receiving function of the native application framework in the hybrid application to rewrite the web data request as a native data request.
[0227] The native application framework is used to initiate network requests to the business server instead of the WebView component in the web page view component.
[0228] S78, the test client calls the native application framework in the hybrid application based on native data requests to achieve data interaction with the network address.
[0229] The business client encapsulates the native response data received from the network address by the native application framework into local resources, loads it, constructs the corresponding WebResourceResponse, and returns it to WebView.
[0230] The business client reports the native response data received by the native application framework to the test server, which is then used to generate corresponding test cases.
[0231] Test case replay process (similar to the reverse operation of test case recording):
[0232] The test client generates test case replay instructions. By selecting elements to be tested from the various web pages displayed by the hybrid application through the test client, for elements with existing test cases, a test case replay instruction is obtained when a web page operation is triggered on the selected element. For elements without existing test cases, a test case replay instruction is obtained after test cases are obtained through the test case recording process in steps S71-S78, and a web page operation is triggered on the selected element. Recording test cases on the web pages displayed by the hybrid application during its deployment and operation on both the business client and the business server makes the recorded test cases more realistic.
[0233] The test client determines whether the business client responds to web page operations triggered by web page elements, and checks whether a basic test case corresponding to the web page element exists in the test case library. If a basic test case corresponding to the web page element exists, the test case replay process can continue; if no basic test case corresponding to the web page element exists, the test case recording process begins.
[0234] The test client determines that a webpage action was triggered for the webpage element indicated by the test case replay instruction. The test client detects whether the ViewTree of the webpage containing the webpage element indicated by the test case replay instruction in the hybrid application has changed; if the ViewTree changes, it determines that a webpage action was triggered for the webpage element indicated by the test case replay instruction.
[0235] The test client detects the WebView initialization function, which is used to update the webpage containing the webpage elements.
[0236] The test client determines whether the WebView function is associated with a custom WebViewClient. If the WebView function is associated with a custom WebViewClient, it means that the WebViewClient has been proxied, so the application test continues. If the WebView function is not associated with a custom WebViewClient, it means that the WebViewClient has not been proxied, and the custom WebViewClient needs to be set and associated with the WebView function.
[0237] The test client intercepts web data requests generated by the data sending and receiving functions of the web view component in the hybrid application. It then calls the data sending and receiving functions of the native application framework within the hybrid application to rewrite the web data requests as native data requests.
[0238] The test client selects corresponding test cases from the test case library based on native data requests. Based on the native response data recorded in the test cases, the webpage view component in the hybrid application updates the webpage displayed by the hybrid application, obtaining the test presentation data. The test presentation data is then compared with the webpage presentation data recorded in the test cases to generate test results.
[0239] The test client can determine the WebView function corresponding to the current webpage rendered by the hybrid application. The DOM is then retrieved based on the WebView function and used as test rendering data.
[0240] This allows for comparison of the DOM of the test data and the DOM of the webpage data recorded in the test cases to determine if they are the same, thereby generating a node assertion report.
[0241] As one example, the process in which test cases are recorded is the same process in which test cases are played back. The test presentation data and webpage presentation data can include text, images, and XML path language (xPath) from the webpage tags. By comparing the DOM, the similarities and differences between nodes can be found, and a corresponding assertion report can be generated for each node, making it easy to intuitively find the cause of the error.
[0242] Based on the same inventive concept, embodiments of this application provide an application testing apparatus that embeds a webpage view component within a native application framework, enabling the presentation of a webpage within the hybrid application and achieving the functionality corresponding to the aforementioned application testing method. Please refer to... Figure 8 The device includes an acquisition module 801 and a processing module 802, wherein:
[0243] Acquisition module 801: used to acquire test case recording instructions for web page elements; wherein, web page elements are used to construct web pages, and web page elements are associated with network addresses for accessing other web pages;
[0244] Processing module 802: Based on the request interception function provided by the web page view component, when it detects that a web page element triggered by the use case recording instruction has triggered a web page operation, it intercepts the generated web page data request; wherein, the web page data request is used to: obtain web page response data from the network address for updating the web page presented by the hybrid application;
[0245] The processing module 802 is also used to: rewrite the obtained web page data request into a native data request based on the data sending and receiving functions provided by the native application framework, and obtain the native response data from the network address to replace the web page response data based on the native data request;
[0246] The processing module 802 is also used to: generate test cases for web page elements based on the native response data, and perform application testing based on the obtained test cases when receiving a test case replay instruction for web page elements.
[0247] In one possible embodiment, the acquisition module 801 is specifically used for:
[0248] In response to a use case update operation triggered for the current webpage presented by a hybrid application, the first node relationship information of the current webpage is obtained; wherein, the first node relationship information represents: the hierarchical relationship formed according to the presentation effect of the current webpage, with the element attributes of each current element constituting the current webpage as nodes;
[0249] In response to a selection operation triggered by at least one of the current elements represented by the first node relationship information, a use case recording instruction is generated for at least one element; wherein at least one element includes a web page element.
[0250] In one possible embodiment, the processing module 802 is specifically used for:
[0251] Based on the request interception function provided by the webpage view component, when the function initialization function provided by the webpage view component is detected, and the webpage update function corresponding to the webpage element is initialized, it is determined that a webpage operation has been triggered for the webpage element; among which, the webpage update function is used to: generate a webpage data request;
[0252] Based on the request interception function provided by the web view component, the web data request is intercepted and the preset data transmission interface is called to transmit the web data request; the data transmission interface is used to establish data interaction between the native application framework and the web view component.
[0253] In one possible embodiment, the processing module 802 is specifically used for:
[0254] When it is determined that a webpage data request contains a webpage-specific request, the webpage response data is obtained from the network address based on the data sending and receiving functions of the webpage view component; wherein, the webpage-specific request is a request that requires identification through a data parsing strategy;
[0255] Add preset new feature data to the webpage response data; the new feature data is used to: add data parsing functionality to the native application framework;
[0256] Based on the data parsing function, special request parameters are parsed from web page data requests;
[0257] Generate native data requests based on web page data requests and request parameters.
[0258] In one possible embodiment, the processing module 802 is specifically used for:
[0259] Based on the data sending and receiving functions provided by the native application framework, generate native special requests carrying request parameters;
[0260] Send native special requests and web special requests to the network address respectively, and obtain the network link information corresponding to each native special request and web special request;
[0261] When determining the matching of network link information corresponding to native special requests and web page special requests, the web page data request is rewritten as a native data request based on the native special request.
[0262] In one possible embodiment, the processing module 802 is specifically used for:
[0263] Call the preset data transfer interface to transfer native response data; the data transfer interface is used to: establish data interaction between the native application framework and the web page view component;
[0264] The web page rendering function based on the web page view component updates the web page rendered by the hybrid application according to the native response data;
[0265] Obtain the node update structure of the updated webpage and generate the webpage rendering data of the updated webpage; wherein, the node update structure is characterized by: the node hierarchy structure formed according to the rendering effect of the updated webpage, with the element attributes of each updated element constituting the updated webpage as nodes.
[0266] Test cases are generated based on native response data and webpage rendering data.
[0267] In one possible embodiment, the processing module 802 is specifically used for:
[0268] During the process of updating the webpage presented by the hybrid application, the second node relationship information of the intermediate webpages presented at multiple times is continuously obtained; wherein, the second node relationship information represents: the hierarchical relationship formed according to the presentation effect of the intermediate webpages, with the element attributes of each intermediate element constituting the intermediate webpages presented at the corresponding time as nodes.
[0269] Whenever the intermediate structure of a node obtained at the current moment is determined to be different from the intermediate structure of a node obtained at a historical moment adjacent to the current moment, a screenshot of the intermediate webpage presented at the current moment is taken to obtain the intermediate webpage screenshot.
[0270] Test cases are generated based on at least one intermediate webpage screenshot, native response data, and webpage rendering data.
[0271] In one possible embodiment, the processing module 802 is specifically used for:
[0272] Receive test case replay instructions for web page elements; wherein, the test case replay instructions are used to: instruct the replay of test cases;
[0273] When a webpage action is triggered by a webpage element indicated by a test case replay command, the native response data recorded in the test case is retrieved.
[0274] Application testing is performed based on native response data.
[0275] In one possible embodiment, the processing module 802 is specifically used for:
[0276] Based on the native response data, the webpage presented by the hybrid application is updated to obtain test presentation data; among which, the test presentation data includes third node relationship information, which is characterized by the hierarchical relationship formed according to the display effect of the updated webpage, with the element attributes of each updated element constituting the updated webpage as nodes.
[0277] When it is determined that the test presentation data matches the webpage presentation data recorded in the test cases, a test success result is generated indicating that the test for the webpage element has passed;
[0278] When it is determined that the test presentation data does not match the webpage presentation data recorded in the test cases, a test failure result representing the failure of the test for the webpage element is generated based on the mismatched data in the test presentation data and the webpage presentation data.
[0279] In one possible embodiment, the processing module 802 is further configured to:
[0280] After receiving the test case recording instruction for web page elements, if a basic test case for web page elements is found in the pre-stored test case library, the basic test case is retrieved. The basic test case is associated with adaptation information, which represents the device information of the application device on which the application is installed for application testing and is adapted to the basic test case.
[0281] When it is determined that the adaptation information associated with the basic use case does not match the device information of the installation device of the hybrid application, a use case re-encoding instruction for the web page element is generated based on the basic use case; wherein, the use case re-encoding instruction is used to: instruct the basic use case to be adjusted to adapt to the device information of the installation device of the hybrid application;
[0282] Test cases for web page elements are generated based on test case re-encoding instructions and basic test cases.
[0283] In one possible embodiment, the processing module 802 is specifically used for:
[0284] Based on the request interception function provided by the web page view component, when it is detected that a web page element triggered by the use case re-recording instruction has triggered a web page operation, the web page presented by the hybrid application is updated based on the native response data recorded by the basic use case to obtain the web page presentation data.
[0285] Based on the obtained webpage rendering data, adjust the basic test cases to obtain test cases for webpage elements.
[0286] Please refer to Figure 9 This is a computer device 900 provided in the embodiments of this application. The computer device 900 can, for example, be... Figure 1C The client 101 or server 102 in the system. The current and historical versions of the data storage program and the application software corresponding to the data storage program can be installed on a computer device 900, which includes a processor 980 and a memory 920. In some embodiments, the computer device 900 may include a display unit 940, which includes a display panel 941 for displaying a user-interactive interface, etc.
[0287] In one possible embodiment, the display panel 941 may be configured in the form of a liquid crystal display (LCD) or an organic light-emitting diode (OLED).
[0288] The processor 980 is used to read a computer program and then execute the methods defined by the computer program. For example, the processor 980 reads a data storage program or file, thereby running the data storage program on the computer device 900 and displaying the corresponding interface on the display unit 940. The processor 980 may include one or more general-purpose processors, and may also include one or more DSPs (Digital Signal Processors) for performing related operations to implement the technical solutions provided in the embodiments of this application.
[0289] The memory 920 generally includes main memory and secondary storage. Main memory can be random access memory (RAM), read-only memory (ROM), and cache, etc. Secondary storage can be a hard disk, optical disk, USB flash drive, floppy disk, or magnetic tape drive, etc. The memory 920 is used to store computer programs and other data. The computer programs include applications corresponding to each client, and other data may include data generated after the operating system or applications are run, including system data (e.g., operating system configuration parameters) and user data. In this embodiment, the computer program is stored in the memory 920, and the processor 980 executes the computer program in the memory 920 to implement any of the methods described in the preceding figures.
[0290] The aforementioned display unit 940 is used to receive input digital information, character information, or contact touch operations / non-contact gestures, and to generate signal inputs related to user settings and function control of the computer device 900. Specifically, in this embodiment, the display unit 940 may include a display panel 941. The display panel 941, for example, is a touch screen, which can collect touch operations performed by the user on or near it (such as operations performed by the user using a finger, stylus, or any suitable object or accessory on or on the display panel 941), and drive corresponding connection devices according to a pre-set program.
[0291] In one possible embodiment, the display panel 941 may include two parts: a touch detection device and a touch controller. The touch detection device detects the player's touch position and the signal generated by the touch operation, and transmits the signal to the touch controller. The touch controller receives touch information from the touch detection device, converts it into touch point coordinates, and sends it to the processor 980. It can also receive and execute commands from the processor 980.
[0292] The display panel 941 can be implemented using various types such as resistive, capacitive, infrared, and surface acoustic wave. In addition to the display unit 940, in some embodiments, the computer device 900 may also include an input unit 930. The input unit 930 may include an image input device 931 and other input devices 932, wherein the other input devices may include, but are not limited to, one or more of the following: a physical keyboard, function keys (such as volume control buttons, power buttons, etc.), a trackball, a mouse, and a joystick.
[0293] In addition to the above, the computer device 900 may also include a power supply 990 for powering other modules, an audio circuit 960, a near-field communication module 970, and an RF circuit 910. The computer device 900 may also include one or more sensors 950, such as an accelerometer, a light sensor, and a pressure sensor. The audio circuit 960 specifically includes a speaker 961 and a microphone 962, for example, the computer device 900 can use the microphone 962 to collect the user's voice and perform corresponding operations.
[0294] As one embodiment, the number of processors 980 can be one or more, and the processors 980 and the memory 920 can be coupled together or relatively independent.
[0295] As one example, Figure 9 The processor 980 in the middle can be used to implement, for example Figure 8 The functions of the acquisition module 801 and the processing module 802 in the process.
[0296] As one example, Figure 9 The processor 980 in the text can be used to implement the functions of the server or terminal devices discussed above.
[0297] Those skilled in the art will understand that all or part of the steps of the above method embodiments can be implemented by a computer program. The aforementioned computer program can be stored in a computer-readable storage medium. When the computer program is executed, it performs the steps of the above method embodiments. The aforementioned storage medium includes various media capable of storing program code, such as mobile storage devices, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0298] Alternatively, if the integrated units of this invention are implemented as software functional modules and sold or used as independent products, they can also be stored in a computer-readable storage medium. Based on this understanding, the technical solutions of the embodiments of this invention, or the parts that contribute to the prior art, can be embodied in the form of software products, for example, through computer program products. These computer program products are stored in a storage medium and include computer programs used to cause a computer device to execute all or part of the methods described in the various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as mobile storage devices, ROM, RAM, magnetic disks, or optical disks.
[0299] Obviously, those skilled in the art can make various modifications and variations to this application without departing from the spirit and scope of this application. Therefore, if such modifications and variations fall within the scope of the claims of this application and their equivalents, this application also intends to include such modifications and variations.
Claims
1. An application testing method, characterized in that, A hybrid application that embeds a webpage view component within a native application framework, the webpage view component being used to: render a webpage within the hybrid application; the method includes: Obtain a use case recording instruction for a webpage element; wherein the webpage element is used to constitute the webpage, and the webpage element is associated with a network address for accessing other webpages; Based on the request interception function provided by the webpage view component, when a webpage operation is triggered by a webpage element indicated by the record instruction for the use case, the generated webpage data request is intercepted; wherein, the webpage data request is used to: obtain webpage response data from the network address for updating the webpage presented by the hybrid application; Based on the data sending and receiving functions provided by the native application framework, the obtained web page data request is rewritten as a native data request, and based on the native data request, native response data is obtained from the network address to replace the web page response data; Based on the native response data, test cases for the web page elements are generated, and when a test case replay instruction for the web page elements is received, application testing is performed based on the obtained test cases.
2. The method according to claim 1, characterized in that, The step of obtaining the test case recording instructions for webpage elements includes: In response to a use case update operation triggered by the current webpage presented by the hybrid application, the first node relationship information of the current webpage is obtained; wherein, the first node relationship information represents: a hierarchical relationship formed according to the presentation effect of the current webpage, with the element attributes of each current element constituting the current webpage as nodes; In response to a selection operation triggered by at least one of the current elements represented by the first node relationship information, a use case recording instruction is generated for the at least one element; wherein the at least one element includes the web page element.
3. The method according to claim 1, characterized in that, The request interception function provided by the webpage view component, when it detects that a webpage element triggered by the use case recording instruction has triggered a webpage operation, intercepts the generated webpage data request, including: Based on the request interception function provided by the webpage view component, when it is detected that the webpage update function corresponding to the webpage element is initialized based on the function initialization function provided by the webpage view component, it is determined that a webpage operation has been triggered for the webpage element; wherein, the webpage update function is used to: generate the webpage data request; Based on the request interception function provided by the webpage view component, the webpage data request is intercepted, and a preset data transmission interface is called to transmit the webpage data request; wherein, the data transmission interface is used to: establish data interaction between the native application framework and the webpage view component.
4. The method according to claim 1, characterized in that, The data sending and receiving function based on the native application framework rewrites the obtained web page data request into a native data request, including: When it is determined that the web page data request contains a special web page request, the web page response data is obtained from the network address based on the data sending and receiving function of the web page view component; wherein, the special web page request is a request that requires identification through a data parsing strategy; Add preset new function data to the webpage response data; wherein, the new function data is used to: add data parsing function to the native application framework; Based on the data parsing function, the request parameters of the special request are parsed from the web page data request; The native data request is generated based on the webpage data request and the request parameters.
5. The method according to claim 4, characterized in that, The process of generating the native data request based on the webpage data request and the request parameters includes: Based on the data sending and receiving functions provided by the native application framework, a native special request carrying the request parameters is generated; Send the native special request and the webpage special request to the network address respectively to obtain the network link information corresponding to the native special request and the webpage special request respectively; When it is determined that the network link information corresponding to the native special request and the webpage special request match, the webpage data request is rewritten as a native data request based on the native special request.
6. The method according to any one of claims 1 to 5, characterized in that, The process of generating test cases for the webpage elements based on the native response data includes: The native response data is transmitted by calling a preset data transmission interface; wherein, the data transmission interface is used to: establish data interaction between the native application framework and the web page view component; Based on the webpage rendering function of the webpage view component, the webpage rendered by the hybrid application is updated according to the native response data; Obtain the node update structure of the updated webpage and generate the webpage rendering data of the updated webpage; wherein, the node update structure represents: a node hierarchy structure formed according to the rendering effect of the updated webpage, with the element attributes of each updated element constituting the updated webpage as nodes. The test cases are generated based on the native response data and the webpage rendering data.
7. The method according to claim 6, characterized in that, The process of generating the test cases based on the native response data and the webpage rendering data includes: During the process of updating the webpage presented by the hybrid application, the second node relationship information of the intermediate webpages presented at multiple times is continuously acquired; wherein, the second node relationship information represents: the hierarchical relationship formed according to the presentation effect of the intermediate webpages, with the element attributes of each intermediate element constituting the intermediate webpages presented at the corresponding times as nodes. Whenever it is determined that the intermediate structure of a node obtained at the current moment is different from the intermediate structure of a node obtained at a historical moment adjacent to the current moment, a screenshot of the intermediate webpage presented at the current moment is taken to obtain a screenshot of the intermediate webpage. The test cases are generated based on at least one intermediate webpage screenshot, the native response data, and the webpage rendering data.
8. The method according to any one of claims 1 to 5, characterized in that, Upon receiving a test case replay instruction for the webpage element, the step of performing application testing based on the obtained test cases includes: Receive a test case replay instruction for the webpage element; wherein the test case replay instruction is used to: instruct the replay of the test case; When it is detected that a webpage operation has been triggered by a webpage element indicated by the test case replay instruction, the native response data recorded by the test case is obtained; Application testing was conducted based on the aforementioned native response data.
9. The method according to claim 8, characterized in that, The application testing based on the native response data includes: Based on the native response data, the webpage presented by the hybrid application is updated to obtain test presentation data; wherein, the test presentation data includes third node relationship information, which represents: the hierarchical relationship formed according to the display effect of the updated webpage, with the element attributes of each updated element constituting the updated webpage as nodes; When it is determined that the test presentation data matches the webpage presentation data recorded in the test case, a test success result is generated indicating that the test for the webpage element has passed; When it is determined that the test presentation data does not match the webpage presentation data recorded in the test case, a test failure result representing the failure of the test for the webpage element is generated based on the mismatched data in the test presentation data and the webpage presentation data.
10. The method according to any one of claims 1 to 5, characterized in that, Following the step of obtaining the use case recording instruction for webpage elements, the following is also included: When a basic use case for the webpage element is found to exist in the pre-stored use case library, the basic use case is obtained; wherein, the basic use case is associated with adaptation information, and the adaptation information represents: the device information of the installation device of the application that adapts to the basic use case for application testing; When it is determined that the adaptation information associated with the basic use case does not match the device information of the installation device of the hybrid application, a use case re-encoding instruction is generated for the web page element based on the basic use case; wherein, the use case re-encoding instruction is used to: instruct the basic use case to be adjusted to adapt to the device information of the installation device of the hybrid application; Based on the test case re-encoding instruction and the basic test case, test cases for the web page elements are generated.
11. The method according to claim 10, characterized in that, The process of generating test cases for the webpage elements based on the test case re-recording instruction and the basic test cases includes: Based on the request interception function provided by the webpage view component, when it is detected that a webpage operation has been triggered by the webpage element indicated by the re-recording instruction of the use case, the webpage presented by the hybrid application is updated based on the native response data recorded by the basic use case to obtain the webpage presentation data. Based on the obtained webpage rendering data, the basic test cases are adjusted to obtain test cases for the webpage elements.
12. An application testing device, characterized in that, A hybrid application for embedding a webpage view component within a native application framework, the webpage view component being used to: render a webpage within the hybrid application; the apparatus includes: Acquisition module: used to acquire test case recording instructions for web page elements; wherein, the web page elements are used to constitute the web page, and the web page elements are associated with network addresses for accessing other web pages; Processing module: Based on the request interception function provided by the webpage view component, when it is detected that a webpage element triggered by the recording instruction for the use case has triggered a webpage operation, the generated webpage data request is intercepted; wherein, the webpage data request is used to: obtain webpage response data from the network address for updating the webpage presented by the hybrid application; The processing module is further configured to: rewrite the obtained web page data request into a native data request based on the data sending and receiving functions provided by the native application framework, and obtain native response data from the network address to replace the web page response data based on the native data request; The processing module is further configured to: generate test cases for the web page element based on the native response data, and perform application testing based on the obtained test cases when receiving a test case replay instruction for the web page element.
13. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the method as described in any one of claims 1 to 11.
14. A computer device, characterized in that, include: Memory, used to store program instructions; A processor is configured to invoke program instructions stored in the memory and execute the method as described in any one of claims 1 to 11 according to the obtained program instructions.
15. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions for causing a computer to perform the method as described in any one of claims 1 to 11.