Component testing method, apparatus, and storage medium
By automating the identification and execution of UI component tests, the tediousness and inefficiency of manual testing methods are solved, achieving an efficient component testing process that adapts to the testing needs of rapid iteration.
Patent Information
- Application Number
- CN202611380228.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-07
- Publication Date
- 2026-11-24
AI Technical Summary
In existing technologies, UI component testing relies on manual methods, resulting in cumbersome procedures, a large amount of repetitive work, and difficulty in meeting the needs of rapid iterative testing of large batches and multiple types of UI components.
By responding to component test requests and obtaining test parameters, the system automatically identifies target components and elements to be operated based on component information and operation descriptions, executes corresponding operations to obtain test results, and reduces tedious and repetitive manual intervention.
It has achieved automated component testing, improved testing efficiency, reduced manpower and time costs, and adapted to the rapid iteration needs of large batches and multiple types of interface components.
Smart Images

Figure CN123157597A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of software testing technology, and in particular to a component testing method, device and storage medium. Background Technology
[0002] With the rapid iteration of front-end development and visual interface technologies, the interface architecture of various software systems and visualization platforms is becoming increasingly modular and component-based. As the basic unit for interface construction, the functionality, integrity, and operational stability of components directly determine the overall user experience and product quality.
[0003] Currently, mainstream testing methods in the industry still heavily rely on manual testing. Specifically, testers need to go through all functional points such as clicks, inputs, linkages, and adaptations for each type of interface component, verifying whether the component's interface display and interaction logic conform to design specifications. This traditional manual testing method is cumbersome and involves a large amount of repetitive work, requiring significant investment of manpower and time, and also suffers from low testing efficiency, making it difficult to adapt to the current needs for rapid iteration testing of large batches and diverse types of interface components.
[0004] Therefore, improving the testing efficiency of UI components is an urgent problem that needs to be solved. Summary of the Invention
[0005] The main purpose of this application is to provide a component testing method, device and storage medium, which aims to improve the testing efficiency of interface components.
[0006] To achieve the above objectives, this application provides a component testing method, the component testing method comprising: In response to a component test request, obtain the test parameters from the component test request; When the test parameters include component information and operation description information, the target component to be tested and the component type of the target component are determined based on the component information, and the operation element in the target component is determined based on the operation description information. Based on the component type and the operation description information, the operation to be executed is determined, and the operation to be executed is performed on the element to be operated on to obtain the test result for the target component.
[0007] In one embodiment, the step of determining the target component to be tested and the component type of the target component based on the component information includes: Identify the identity and type identifiers in the component information; Traverse each inline frame in the current interface, find the container DOM element that matches the identity identifier within each inline frame, and determine the component corresponding to the container DOM element as the target component to be tested. The component type of the target component is determined based on the type identifier.
[0008] In one embodiment, the method further includes: Check if there is an inline frame record corresponding to the identity identifier in the preset cache information; If it exists, then search for a container DOM element that matches the identity in the inline frame indicated by the inline frame record; If it does not exist, then the step of traversing each inline frame in the current interface, searching for the container DOM element that matches the identity within each inline frame, and storing the inline frame where the container DOM element is located in the preset cache information is performed.
[0009] In one embodiment, the step of determining the element to be operated on in the target component based on the operation description information includes: Identify the object to be executed from the operation description information; Based on the object to be executed, find the internal DOM element that matches the object to be executed within the target component; The internal DOM element is identified as the element to be operated on.
[0010] In one embodiment, the step of determining the operation to be performed based on the component type and the operation description information includes: The target operation type is determined based on the operation description information; Obtain the operation set corresponding to the target operation type, wherein the operation set includes at least one pre-encapsulated candidate operation; Based on the component type, determine the operation to be executed corresponding to the component type from the operation set.
[0011] In one embodiment, the step of performing the operation to be performed on the element to be operated on to obtain the test result for the target component includes: When the operation type to be performed is a UI operation, the operation to be performed is executed on the element to be operated based on a preset browser debugging protocol to obtain the test result; When the operation type to be executed is a function call, the corresponding function is called to execute the operation and the test result is obtained; When the operation type to be performed is a third-party operation, the execution result returned by the third-party platform after performing the operation is monitored, and the execution result is used as the test result.
[0012] In one embodiment, after the step of obtaining the test parameters in the component test request, the method further includes: When the test parameters only include operation description information, identify the business action information in the operation description information; The business action information is matched with the business meaning of each preset custom component; Custom components that match the business action information will be used as target components to be tested. The target component is tested according to the single-step business action and multi-step business process corresponding to the target component, and the test results are obtained.
[0013] In one embodiment, the method further includes: For each UI component in the interface to be tested, determine the first identification information and the second identification information of the UI component, wherein the first identification information identifies the identity information of the UI component, and the second identification information identifies the component type of the UI component; The first identification information and the second identification information are used as attribute information of the UI component, and the attribute information is written into the container DOM element of the UI component; Determine the executable operations supported by the UI component, and encapsulate the executable operations of each UI component in the interface to be tested into multiple operation sets according to preset operation types; For each custom component in the interface to be tested, encapsulate the atomic business operations of the custom component and / or the business process operations composed of multiple atomic business operations, wherein the custom component is composed of at least one UI component.
[0014] Furthermore, to achieve the above objectives, this application also provides a component testing apparatus, the component testing apparatus comprising: The acquisition module is used to acquire test parameters in the component test request in response to the component test request; The determination module is used to determine the target component to be tested and the component type of the target component based on the component information, and to determine the operable element in the target component based on the operation description information, when the test parameters include component information and operation description information. An execution module is used to determine the operation to be executed based on the component type and the operation description information, execute the operation to be executed on the element to be operated, and obtain the test result for the target component.
[0015] In addition, to achieve the above objectives, this application also proposes an electronic device, the device comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, the computer program being configured to implement the steps of the component testing method as described above.
[0016] In addition, to achieve the above objectives, this application also provides a storage medium, which is a computer-readable storage medium, on which a program implementing the component testing method is stored, and the program implementing the component testing method is executed by a processor to implement the steps of the component testing method as described above.
[0017] In addition, to achieve the above objectives, this application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the component testing method described above.
[0018] This application provides a component testing method. First, in response to a component testing request, the method obtains the test parameters in the component testing request. If the test parameters include component information and operation description information, the method determines the target component to be tested and the component type of the target component based on the component information, and determines the operation element to be operated in the target component based on the operation description information. Based on the component type and operation description information, the method determines the operation to be executed, executes the operation to be executed on the operation element, and obtains the test result for the target component.
[0019] In summary, this application obtains test parameters by responding to component test requests, locates the target component to be tested based on the identity and type identifiers in the component information, identifies its component type, determines the elements to be operated on from the target component based on the operation description information, and then matches the corresponding operation to be executed automatically by combining the component type and operation description information, finally outputting the test results for the target component. Throughout the entire testing process, the user only needs to input test parameters to trigger the system to automatically complete component identification, element location, operation matching, and execution. There is no need for manual traversal, clicking, inputting, and verification of each function point for each type of interface component, nor is there a need for manual determination of the correspondence between component type and operation. Therefore, compared to the repetitive traversal testing methods that heavily rely on manual intervention in traditional solutions, this application can automatically complete the software testing of the target component to be tested. Testers are not required to manually traverse all function points of each type of interface component for item-by-item verification, reducing the tedious operations and large amount of repetitive work caused by manual intervention, lowering labor and time costs, thereby improving the testing efficiency of interface components and adapting to the testing needs of large-scale, multi-type interface components with rapid iteration. Attached Figure Description
[0020] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.
[0021] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0022] Figure 1 This is a flowchart illustrating the first embodiment of the component testing method of this application; Figure 2 This is a schematic diagram of the DOM element search process involved in one embodiment of the component testing method of this application; Figure 3 This is a schematic diagram of the component testing process involved in one embodiment of the component testing method of this application; Figure 4 This is a schematic diagram of the UI component encapsulation process involved in one embodiment of the component testing method of this application; Figure 5 This is a schematic diagram of the custom component encapsulation process involved in one embodiment of the component testing method of this application; Figure 6 This is a schematic diagram of the module structure of the component testing device of this application; Figure 7 This is a schematic diagram of the device structure of the hardware operating environment involved in the component testing method in this application embodiment.
[0023] The purpose, features, and advantages of this application will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation
[0024] It should be understood that the specific embodiments described herein are merely illustrative of the technical solutions of this application and are not intended to limit this application.
[0025] To better understand the technical solution of this application, a detailed description will be provided below in conjunction with the accompanying drawings and specific implementation methods.
[0026] Currently, mainstream testing methods in the industry still heavily rely on manual testing. Specifically, testers need to go through all functional points such as clicks, inputs, linkages, and adaptations for each type of interface component, verifying whether the component's interface display and interaction logic conform to design specifications. This traditional manual testing method is cumbersome and involves a large amount of repetitive work, requiring significant investment of manpower and time, and also suffers from low testing efficiency, making it difficult to adapt to the current needs for rapid iteration testing of large batches and diverse types of interface components.
[0027] Therefore, improving the testing efficiency of UI components is an urgent problem that needs to be solved.
[0028] The main solution of this application is as follows: In response to a component test request, the test parameters in the component test request are obtained; if the test parameters include component information and operation description information, the target component to be tested and the component type of the target component are determined based on the component information, and the operation element to be operated in the target component is determined based on the operation description information; the operation to be executed is determined based on the component type and the operation description information, and the operation to be executed is performed on the operation element to obtain the test result for the target component.
[0029] This application obtains test parameters by responding to component test requests, locates the target component to be tested based on the identity and type identifiers in the component information, identifies its component type, and determines the elements to be operated on from the target component based on the operation description information. Then, it matches the component type with the operation description information to match the corresponding operation to be executed automatically, and finally outputs the test results for the target component. Throughout the testing process, the user only needs to input test parameters to trigger the system to automatically complete component identification, element location, operation matching, and execution. There is no need for manual traversal, clicking, inputting, and verification of each function point for each type of interface component, nor is there a need for manual determination of the correspondence between component types and operations. Therefore, compared to the repetitive traversal testing methods that heavily rely on manual intervention in traditional solutions, this application can automatically complete the software testing of the target component to be tested. Testers are not required to manually traverse all function points of each type of interface component for item-by-item verification, reducing the tedious operations and large amount of repetitive work caused by manual intervention, lowering labor and time costs, thereby improving the testing efficiency of interface components and adapting to the testing needs of large-scale, multi-type interface components with rapid iteration.
[0030] It should be noted that the execution subject of the component testing method in various embodiments of this application can be a testing system, or a computing service device with data processing, network communication, and program execution functions, such as a tablet computer, personal computer, or mobile phone, or a component testing device capable of performing the above functions. This embodiment does not specifically limit this. The following uses a testing system as the execution subject as an example to describe this embodiment and the following embodiments.
[0031] Based on this, this application proposes a component testing method according to the first embodiment, please refer to... Figure 1 The component testing method includes steps S10 to S30: Step S10: In response to the component test request, obtain the test parameters in the component test request.
[0032] A component test request is a call instruction initiated by testers or the upper-level testing platform to trigger automated testing of a specified interface component. Test parameters are a set of information carried in the component test request, describing "what to test" and "how to test." In this embodiment, test parameters include component information and operation description information. Component information is used to identify and locate the target component to be tested, and includes at least an identity identifier and a type identifier; the identity identifier is used to uniquely or substantially uniquely locate a specific component instance in the interface, and the type identifier is used to identify the category of the component. Operation description information describes what operation is expected to be performed on the target component; the testing system uses this information to determine the specific operation object and the action to be performed.
[0033] The testing system continuously listens for or receives component test requests initiated by testers or the upper-level testing platform; when a request is received, the testing system parses the request and extracts the test parameters from it.
[0034] In one feasible implementation, the tester inputs a test command through a graphical interface or command-line interface. The command includes component information (such as component ID "table_001" and component type "table") and operation description information (such as "click the export button"). The test system receives the command and parses the above information from it.
[0035] In another feasible implementation, the upper-layer automated testing platform generates multiple component test requests in batches, with each request corresponding to a test task. The testing system receives each request sequentially and obtains the corresponding test parameters to trigger batch testing.
[0036] Step S20: If the test parameters include component information and operation description information, determine the target component to be tested and the component type of the target component based on the component information, and determine the operable element in the target component based on the operation description information.
[0037] The target component refers to the instance of the UI component to be tested, i.e., the specific component object that the user expects to automate the testing of. The component type refers to the category to which the target component belongs, such as a table component, input box component, dropdown component, etc. The element to be operated on refers to the element within the target component that requires a specific operation, such as the "Export" button or "Sort" header within a table component, or the input area within an input box component. The identity identifier in the component information is used to locate the target component on the page, and the type identifier is used to determine the component type; the operation description information indicates the element to be operated on, which may include a description of the object to be executed (such as "Export button"), which the system uses to match and locate it within the target component.
[0038] The testing system first parses the identity identifier in the component information, then locates and identifies the corresponding component instance in the current interface based on this identity identifier, and determines it as the target component. Simultaneously, the testing system parses the type identifier in the component information to determine the component type of the target component, so that the corresponding operation logic can be loaded subsequently based on this type. On this basis, the testing system parses the operation description information to identify the description of the object to be executed (such as an "export button"), and then searches for the specific element corresponding to the object to be executed within the identified target component, determining it as the element to be operated on.
[0039] Step S30: Determine the operation to be executed based on the component type and the operation description information, execute the operation to be executed on the element to be operated on, and obtain the test result for the target component.
[0040] An operation to be executed refers to a specific action that the test system has finally determined and is ready to execute. This operation is an executable action supported by the target component and matches the user's expectations. It should be understood that the component type determines the component category context to which the operation belongs, and the operation description information indicates what operation the user expects to execute. The combination of the two can accurately match a unique operation to be executed from the candidate operations of the target component.
[0041] The test results obtained after performing the operation on the target element can include execution status information such as whether the operation was successful or failed (e.g., whether the click was successful or whether the export was successful), data content read from the target component (e.g., table data, input box values), and interface state change information or abnormal information captured during the operation.
[0042] The testing system obtains a set of operations corresponding to the determined component type. This set of operations contains all candidate operations supported by the component of that type. Then, based on the operation description information, the testing system matches the candidate operation that corresponds to the user's expectation from the set of operations and determines it as the operation to be executed. After determining the operation to be executed, the testing system calls the execution logic of the operation and executes the operation on the determined operation element. After execution, the testing system collects the execution status, return data or exception information generated during the execution process and outputs it as the test result.
[0043] Thus, this embodiment of the application obtains test parameters by responding to component test requests, locates the target component to be tested and identifies its component type based on the identity and type identifiers in the component information, determines the element to be operated from the target component based on the operation description information, and then matches the corresponding operation to be executed by combining the component type and the operation description information, and executes it automatically, finally outputting the test results for the target component. Throughout the entire testing process, the user only needs to input test parameters to trigger the system to automatically complete component identification, element location, operation matching, and execution. There is no need for manual traversal, clicking, input, and verification of each function point for each type of interface component, nor is there a need for manual determination of the correspondence between component type and operation.
[0044] Therefore, compared with the repetitive traversal testing method that relies heavily on manual labor in traditional solutions, the embodiments of this application can automatically complete the software testing of the target component to be tested. There is no need for testers to manually traverse all functional points of various interface components one by one to perform item-by-item verification, reducing the tedious operations and a large amount of repetitive work caused by manual intervention, reducing manpower and time costs, thereby improving the testing efficiency of interface components and adapting to the testing needs of rapid iteration of large batches and multiple types of interface components.
[0045] In this embodiment, step S20 may include: Step S201: Identify the identity identifier and type identifier in the component information; Step S202: Traverse each inline frame in the current interface, find the container DOM element that matches the identity identifier within each inline frame, and determine the component corresponding to the container DOM element as the target component to be tested. Step S203: Determine the component type of the target component based on the type identifier.
[0046] The identity identifier is information in the component information used to locate a specific component instance in the interface. In this embodiment, a randomly generated timestamp or a unique string can be used, as long as it can basically distinguish different components within the same interface, it does not need to be globally unique. The type identifier is information in the component information used to identify the category to which the component belongs, used to distinguish different types of components, such as table components, input box components, drop-down box components, etc.
[0047] A container DOM (Document Object Model) element is the outermost HTML (HyperText Markup Language) tag node that wraps the entire component. Identification and type identifiers are attached as custom attributes to this container DOM element, allowing the testing system to locate the corresponding component instance by searching for container DOM elements with specific identifiers. Inline frames are independent document contexts embedded in the current main page. Components may exist within the main page or be nested within inline frames at any level; therefore, searching for container DOM elements requires searching across inline frames.
[0048] The testing system identifies the identity and type identifiers from the component information. Then, using the identity identifier as the search criterion, the system traverses all inline frames present in the current interface, searching for a container DOM element that matches the identity identifier in the document context of each inline frame. When a matching container DOM element is found in an inline frame, the system identifies the component corresponding to that container DOM element as the target component to be tested. At the same time, the system determines the component type of the target component based on the identified type identifier.
[0049] In one feasible implementation, the current interface contains one or more inline frames, and the target component is located inside a second-level inline frame. The test system identifies the component with the identifier "input_003" and the type identifier "input" from the component information. Starting from the main page, the system sequentially traverses each inline frame, searching for a container DOM element matching "input_003" in the document context of each inline frame. When traversing to the second-level inline frame, the system finds a matching container DOM element, identifies the component corresponding to that container DOM element as the target component, and determines its component type as an input box component based on the type identifier "input".
[0050] In this embodiment, the component testing method of this application further includes: Step A10: Query the preset cache information to see if there is an inline frame record corresponding to the identity identifier; Step A20: If it exists, search for a container DOM element that matches the identity in the inline frame indicated by the inline frame record; Step A30: If it does not exist, then perform the step of traversing each inline frame in the current interface, searching for the container DOM element that matches the identity within each inline frame, and storing the inline frame record where the container DOM element is located in the preset cache information.
[0051] Pre-configured cache information is a storage space pre-configured or dynamically created in the testing system to record the correspondence between searched identities and their corresponding inline frames. An inline frame record is a data entry in the cache information, containing a reference or identifier of the identity and the inline frame containing the corresponding container DOM element. Its purpose is to allow the testing system to directly locate the target inline frame when searching for the same identity, avoiding repeated traversal of all inline frames. It should be understood that during UI automation testing, the same component is usually located within the same inline frame in multiple operations. Therefore, caching the frame location determined by the initial search allows subsequent searches to directly hit the frame without retracing all frames.
[0052] When the testing system needs to find container DOM elements based on an identity, it first checks the preset cache information to see if there is an inline frame (Iframe) record corresponding to that identity. If the corresponding inline frame record exists in the cache, the testing system directly searches based on the inline frame context indicated by the record, without traversing all inline frames. If the corresponding inline frame record does not exist in the cache, the testing system performs a search process that traverses each inline frame in the current interface, searching for container DOM elements that match the identity within each inline frame. When a matching container DOM element is successfully found in an inline frame, the testing system stores the correspondence between the identity and the inline frame as an inline frame record in the preset cache information for use when searching for the same identity in the future.
[0053] For example, such as Figure 2 The diagram illustrates the DOM element lookup process. First, it checks if an iframe cache exists. If it does, it searches for a container DOM element that matches the current identity within the cached iframes. If it does not exist, it iterates through all iframes on the current screen and searches for a container DOM element that matches the current identity. Finally, the component corresponding to the matched container DOM element is determined as the target component to be tested in this iteration.
[0054] It should be noted that traditional methods for element lookup require prior knowledge of the inline frame containing the element and manual context switching before performing the search. This is extremely cumbersome in scenarios with nested inline frames or variable component positions, making it difficult to support general encapsulation. To address this issue, this embodiment uses a method of traversing all inline frames in the current interface for the search, eliminating the need to know the target inline frame beforehand, thus improving the versatility and ease of use of the solution. Furthermore, to address the issue of the time-consuming process of traversing all inline frames, this embodiment introduces a caching strategy. The inline frame containing the container DOM element found for the first time is cached using its identifier as an index. Subsequent searches prioritize hitting the cache, and only when the cache is not found is the search process of traversing all inline frames executed. This effectively shortens the element lookup time while ensuring versatility, improving overall test execution efficiency.
[0055] In this embodiment, step S20 further includes: Step S204: Identify the object to be executed from the operation description information; Step S205: Based on the object to be executed, find the internal DOM element that matches the object to be executed within the target component; Step S206: Determine the internal DOM element as the element to be operated on.
[0056] The object to be executed is the specific target information in the operation description that indicates the user's expected operation. It identifies an operation target within the target component, such as an "export button" or a "query input box." The internal DOM element refers to the specific HTML tag node located within the container DOM element of the target component and corresponding to the object to be executed. This can be a button, input box, dropdown menu option, or other page element that the user can interact with. The element to be operated on is the specific internal DOM element that the test system ultimately determines will be the one to be operated on; it is the actual correspondence of the object to be executed within the target component.
[0057] The testing system identifies the object to be executed from the operation description information. This identification process includes semantic understanding or matching of the text description of the object to be executed, such as identifying "export button" from "click export button". Then, based on the object to be executed, it searches for an internal DOM element that matches the object to be executed among all internal DOM elements contained in the identified target component. Once found, the matched internal DOM element is identified as the element to be operated on, and the element to be operated on is used as the target object for subsequent operations.
[0058] Thus, the embodiments of this application can automatically complete the mapping from business description to specific DOM elements, thereby reducing the difficulty of writing automated interface tests, reducing script instability caused by errors in positioning information, and enabling cross-page operation reuse by allowing elements with the same business meaning in different pages to be independently searched and matched within their respective components.
[0059] In this embodiment, step S30 may include: Step S301: Determine the target operation type based on the operation description information; Step S302: Obtain the operation set corresponding to the target operation type, wherein the operation set includes at least one pre-encapsulated candidate operation; Step S303: Based on the component type, determine the operation to be executed corresponding to the component type from the operation set.
[0060] The target operation type refers to the operation category identified based on the operation description information, indicating which functional category the user expects the operation to belong to, such as click, double-click, export, and get data. The operation set refers to a pre-encapsulated collection of multiple candidate operations for the same target operation type. These candidate operations correspond to specific implementations under different component types. A candidate operation is a pre-encapsulated specific operation implementation for a particular component type within the operation set. For example, under the "get data" operation type, the table component corresponds to the implementation of "traverse table rows to extract data," and the input box component corresponds to the implementation of "read the input box value." Both are candidate operations under this operation type. The type identifier determines which candidate operation is selected from the operation set as the operation to be executed.
[0061] The testing system first parses and determines the target operation type from the operation description information; then it obtains the corresponding operation set based on the target operation type, which contains candidate operations pre-encapsulated for different component types; finally, based on the determined type identifier of the target component, it matches the candidate operation corresponding to the type identifier from the operation set and determines the candidate operation as the operation to be executed.
[0062] In one feasible implementation, the user inputs the operation description "Get table data," and the testing system determines the target operation type as "Get." The system retrieves a set of operations corresponding to the "Get" operation type, which includes multiple candidate operations such as the "Get data" implementation for table components, the "Get value" implementation for input box components, and the "Get selected item" implementation for dropdown components. Based on the target component's type identifier "table," the system matches and determines the "Get data" implementation corresponding to the table component as the operation to be executed from the operation set. Even if the same operation description is used for an input box component, the system will still match the "Get value" implementation corresponding to the input box component, achieving the technical effect of automatically adapting the same operation description to different execution logic under different component types.
[0063] In another feasible implementation, the user inputs the operation description "export data," and the testing system determines the target operation type to be "export." The system obtains the operation set corresponding to the "export" operation type, which may include candidate operations such as the "export Excel" implementation for table components and the "export image" implementation for chart components. Based on the type identifier of the target component, the system matches the candidate operations corresponding to the current component type from the operation set as the operations to be executed.
[0064] Thus, this embodiment of the application pre-encapsulates different implementations of the same operation type under different component types into candidate operations in the same operation set. During execution, the corresponding candidate operation is matched from the operation set based on the type identifier of the target component. This allows the same operation description information to automatically adapt to different types of components and execute the correct operation logic, avoiding the tedious process of testers writing different test instructions for different component types. This improves the versatility and writing efficiency of test scripts. At the same time, when a new component type is added under the same operation type, only the corresponding candidate operation needs to be added to the operation set, which has good scalability.
[0065] In this embodiment, step S30 further includes: Step S304: When the operation type of the operation to be performed is a UI operation, the operation to be performed is executed on the element to be operated based on a preset browser debugging protocol to obtain the test result; Step S305: When the operation type of the operation to be executed is a function call, call the corresponding function to execute the operation to be executed, and obtain the test result; Step S306: When the operation type of the operation to be performed is a third-party operation, monitor the execution result returned by the third-party platform after executing the operation to be performed, and use the execution result as the test result.
[0066] Operation type refers to the category of the operation to be executed at the execution level, indicating the execution environment or method through which the operation should be actually completed. Interface operation refers to performing browser-side interactive actions on the element to be operated, such as clicking, double-clicking, and entering text. This type of operation relies on the browser's debugging protocol to communicate and interact with the page. Function call refers to the operation being executed being encapsulated as an executable function; the test system can directly call this function to complete the operation without interacting with the browser interface. Third-party operation refers to the operation being executed by a third-party platform outside the test system. The test system itself does not directly execute this operation but waits for the third-party platform to complete the execution and then obtains the result.
[0067] The test system determines the type of operation to be performed. When the operation type is a UI operation, the test system establishes a communication connection with the current browser through the browser debugging protocol, executes the corresponding interactive action on the element to be operated in the browser environment, and obtains the execution result as the test result. When the operation type is a function call, the test system directly calls the function corresponding to the operation to be performed, which completes the internal logic and returns the execution result as the test result. When the operation type is a third-party operation, the test system pauses the current test process, the third-party platform executes the operation, the test system waits for and receives the execution result returned by the third-party platform, and uses the execution result as the test result.
[0068] In other words, the action execution in this embodiment supports a hybrid architecture and is not limited to a specific programming language. Any third-party platform capable of calling Python can execute the action. In practical applications, the third-party platform calls both the task initiation interface and the task execution interface to complete the action execution on its side. Specifically, when an action needs to be executed, it can be categorized into three types based on its type: UI actions (clicking, double-clicking, and acquiring UI elements based on browser debugging protocols); Python function actions (directly executing the corresponding Python function to complete the action); and non-Python, non-UI third-party actions (actions executed by the third-party platform). In this case, the test system pauses the current task execution until the third-party platform completes its task, at which point it calls the task restart interface to continue the subsequent actions. Through this hybrid architecture, the test system is compatible with multiple execution environments, allowing third-party platforms with different technology stacks to access this test system, and maximizing the integration of capabilities provided by Python and different self-developed platforms.
[0069] For example, after a user initiates a test request by passing in their identity identifier, type identifier, and operation description information through a unified call entry point, the testing system first determines the category of the target component based on the type identifier and dynamically loads the implementation class corresponding to that component type. This implementation class refers to a program module pre-encapsulated for a specific component type, containing all executable operations supported by that type of component and their specific execution logic. For example, the table component implementation class contains specific implementations of all operations such as sorting, pagination, exporting, and data retrieval; the input box component implementation class contains specific implementations of operations such as inputting text, clearing, and retrieving values. After loading the implementation class, the testing system creates a task containing all action sequences involved in the current operation. Then, the testing system iterates through each action in the task, executing them sequentially until all actions of the current operation are completed. Through the task creation and traversal mechanism, the testing system automatically decomposes a single test request input by the user into an executable action sequence and executes them one by one, achieving automatic conversion from request to execution without requiring testers to manually arrange each operation step.
[0070] For ease of understanding, please refer to Figure 3 , Figure 3 The diagram illustrates the component testing process. First, the user initiates a test request by passing in their identity identifier, type identifier, and operation description information through a unified entry point (which could be a shared control). The testing system then dynamically loads the implementation class corresponding to the component type based on the type identifier in the component information and locates the target component based on the identity identifier. Next, the system creates an operation task, which contains a sequence of actions consisting of multiple basic operation steps required to complete the current operation. Then, the system iterates through each basic operation in the operation task (click, double-click, right-click, execute JS, get property, etc.), executes each operation sequentially, and finally outputs the test results. Here, the basic operations refer to the operations to be executed. Through the above task creation and execution mechanism, the testing system automatically breaks down a single test request input by the user into an executable sequence of actions and executes them one by one, achieving automatic conversion from request to execution without requiring testers to manually arrange each operation step.
[0071] Based on the first embodiment of this application, in the second embodiment of this application, the content that is the same as or similar to that in the first embodiment described above can be referred to the above description and will not be repeated hereafter. Based on this, after step S10, the component testing method of this application further includes: Step B10: If the test parameters only include operation description information, identify the business action information in the operation description information.
[0072] It's important to note that the test inputs for UI (User Interface) components and custom components differ in component testing. UI components, as fundamental elements of the interface, typically exist as independent and identifiable component instances on the page. Therefore, the testing system can directly locate and manipulate specific UI component instances using their identity and type identifiers. Consequently, the test parameters for UI components include both component information (identity and type identifiers) and operation descriptions. Custom components, on the other hand, are upper-level components with independent business meanings, composed of multiple UI components. They do not exist as a single, locatable DOM element, and testers typically do not need to know which UI components they comprise; they only need to describe the expected business operation (e.g., "query employee information"). Therefore, in this embodiment's test scenario for custom components, the test parameters only include operation descriptions (business action information), excluding identity and type identifiers. The testing system determines the target component by matching the business action information with the business meaning of the custom component.
[0073] Business action information is the business-level operation description information used to express the user's expected action. It differs from UI-level operation descriptions (such as "click a button"), directly describing the business function the user expects to complete, such as "query employee information" or "export and authorize." Test parameters only include operation description information and not component information, indicating that the user has not specified a specific UI component instance, but rather directly describes the test intent using the semantics of the business action. The system needs to automatically determine the target component to be tested based on this business action information.
[0074] After obtaining the test parameters, the testing system first determines the composition of the test parameters. When it is determined that the test parameters only contain operation description information and not component information, the system determines that the current test request belongs to a custom component test scenario. Subsequently, the system parses the operation description information, identifies and extracts the business action information that the user expects to execute, and uses this business action information as the basis for subsequent matching of custom components.
[0075] Step B20: Match the business action information with the preset business meanings of each custom component.
[0076] A custom component is a higher-level component composed of at least one UI component, possessing independent business meaning. For example, an "Employee Information Query Panel" consists of multiple UI components such as input boxes, dropdown lists, and query buttons, providing the overall business function of "querying employee information." Business meaning is information pre-configured for each custom component, describing the business functions it can provide, and corresponding to business action information. The pre-configured business meanings of each custom component can be configured during the test system initialization phase or the custom component development phase, or dynamically updated as custom components are added or removed.
[0077] After the testing system identifies the business action information, it matches the business action information with the business meanings of each preset custom component one by one to find the custom component corresponding to the user's expected business action. During the matching process, the system can use methods such as text matching, semantic matching, or preset mapping relationships to determine the correspondence between the business action information and the business meaning. When a match is found, the system determines the target custom component for the user's expected operation.
[0078] Step B30: Select the custom component that matches the business action information as the target component to be tested.
[0079] The target component refers to the custom component instance ultimately determined by the current test request. Before determining the target component, the system needs to match the corresponding custom component through business action information. The matching basis for custom components is the correspondence between business action information and its business meaning, rather than positioning based on identity or type identifiers. The positioning method for custom components differs from that of UI components. UI components are located on the page through identity identifiers, while custom components are determined through business semantic matching.
[0080] After the testing system completes the matching of business action information with the business meaning of each custom component, it identifies the successfully matched custom component as the target component to be tested.
[0081] Step B40: Test the target component according to the single-step business action and multi-step business process corresponding to the target component, and obtain the test results.
[0082] A single-step business action is a single, indivisible business operation supported by a custom component, such as "query," "delete," "zoom in," or "zoom out." A multi-step business process is a business process composed of multiple single-step business actions combined in a preset order. For example, "export and authorize" is a complete business process composed of the two single-step business actions "export" and "authorize." Both single-step business actions and multi-step business processes are predefined and associated with the corresponding custom components during the custom component encapsulation phase.
[0083] After identifying the target custom component, the testing system determines whether a single-step business action or a multi-step business process needs to be executed based on the business action information input by the user. If the business action information corresponds to a single-step business action, the testing system obtains the execution logic of the single-step business action and executes the operation on the target component. If the business action information corresponds to a multi-step business process, the testing system executes the multiple single-step business actions in the process in the order they are preset. After execution, the testing system collects the execution status, returned data, or exception information during the execution process and outputs them as the test results.
[0084] This application embodiment identifies business action information in the operation description information and matches it with the business meaning of the custom component. This allows testers to directly describe their test intentions in business language when performing tests. They do not need to understand the internal structure of the custom component, nor do they need to locate and arrange the operation of each internal UI component. The system can automatically complete the component matching and operation execution, which greatly reduces the difficulty of writing automated interface tests.
[0085] Based on the first and second embodiments of this application, in the third embodiment of this application, the content that is the same as or similar to that in embodiments one and two above can be referred to the above description, and will not be repeated hereafter. In addition, the component testing method of this application further includes: Step C10: For each UI component in the interface to be tested, determine the first identification information and the second identification information of the UI component, wherein the first identification information identifies the identity information of the UI component, and the second identification information identifies the component type of the UI component; Step C20: Use the first identification information and the second identification information as attribute information of the UI component, and write the attribute information into the container DOM element of the UI component; Step C30: Determine the executable operations supported by the UI component, and encapsulate the executable operations of each UI component in the interface to be tested into multiple operation sets according to preset operation types.
[0086] The first identifier, or identity identifier, is used to uniquely or substantially uniquely identify a UI component instance within the interface. It can be a randomly generated timestamp or a unique string; it only needs to ensure that different components can be basically distinguished within the same interface, and does not need to be globally unique. The second identifier, or type identifier, is used to identify the category to which the UI component belongs, distinguishing different types of components, such as table components, input box components, dropdown components, etc. The container DOM element refers to the outermost HTML tag node that wraps the entire UI component. Attribute information is written as custom attributes to this container DOM element, allowing the testing system to locate the corresponding UI component instance by searching for the container DOM element with a specific identity identifier during subsequent execution. Preset operation types are classifications of the executable operations of UI components according to functional categories, such as click, double-click, export, and get data. The operation implementations of various UI components under the same operation type can be uniformly encapsulated into an operation set according to that type.
[0087] For each UI component in the interface under test, the testing system or encapsulation tool determines its identity and type identifier. Then, it writes these identity and type identifiers as attribute information of the UI component into the outermost container DOM element of the UI component, so that the UI component carries the above attribute information after the page is rendered. At the same time, the testing system or encapsulation tool determines all executable operations supported by the UI component, and classifies the executable operations of each UI component in the interface under test according to preset operation types, and encapsulates the executable operations belonging to the same operation type into an operation set.
[0088] In one feasible implementation, for each UI component in the interface to be tested, the encapsulation framework provides a unified Component base class for each UI component to inherit. This Component base class contains four variables. Three of these variables, all_top_click_info, all_middle_click_info, and all_bottom_click_info, correspond to the top, middle, and bottom areas of the UI component's layout, respectively, and are used to categorize and encapsulate operational actions according to the distribution area of operable elements within the component. Each variable contains a content property, which supports two data types: when content is a string, it represents positioning information used to locate and complete a single-step operation on a single DOM element; when content is a function, it encapsulates a combined action that performs multiple steps on multiple DOM elements in a preset order, used to complete complex operations involving multiple steps. Another variable, `all_data_info`, is a dictionary. Its keys are aliases for data items, and its values can be either strings or functions. When the value is a string, it represents location information used to locate and retrieve a single data item. When the value is a function, it encapsulates complex data retrieval logic, used to obtain data that requires multiple processing steps or spans multiple DOM elements. Through these four variables, all executable operations for each UI component are encapsulated according to operation type and layout position, forming an operation set corresponding to each UI component.
[0089] After completing the encapsulation of UI components and custom components, the testing system provides the operation sets of each encapsulated UI component as public operation resources for users to call. When using these resources, users only need to pass in the corresponding identity identifier, type identifier, and operation description information to complete the operation of interface elements and data retrieval through a unified call entry point, without needing to worry about the specific implementation differences of the underlying component types.
[0090] For example, such as Figure 4The diagram illustrates the UI component encapsulation process. For a UI component to be encapsulated, firstly, a class corresponding to the UI component is created, inheriting from a unified Component base class. Then, the UI component is categorized according to the types of operations it supports: For click operations, based on the position of the operable element in the component layout (divided into top, middle, and bottom areas), values for the variables all_top_click_info, all_middle_click_info, or all_bottom_click_info are assigned respectively. For input operations, the corresponding input function is overridden. For retrieval operations, depending on the complexity of the retrieval method, if it is a simple data retrieval, a positioning string is assigned as the value of the all_data_info variable; if it is a complex data retrieval, a custom function is assigned as the value of the all_data_info variable. Finally, the UIAction class is used to complete the specific UI action, thus encapsulating all operations of the UI component.
[0091] Step C40: For each custom component in the interface to be tested, encapsulate the atomic business operations of the custom component and / or the business process operations composed of multiple atomic business operations, wherein the custom component is composed of at least one UI component.
[0092] Custom components are upper-level components with independent business meaning, composed of at least one UI component combined according to business requirements. For example, an "Employee Information Query Panel" is composed of multiple UI components such as input boxes, dropdown boxes, and query buttons, providing the business function of "querying employee information" to the outside world. Atomic business operations are the most basic, indivisible single business actions supported by a custom component, such as "query," "delete," "zoom in," and "zoom out," corresponding to a complete business interaction process within the custom component. Business process operations are flows that combine multiple atomic business operations in a preset order to complete a complete business objective. For example, "export and authorize" is composed of the atomic business operations "export" and "authorize."
[0093] For each custom component in the interface under test, the encapsulation tool determines all atomic business operations supported by that custom component and encapsulates each atomic business operation into an executable operation unit. At the same time, if the custom component also supports business process operations composed of multiple atomic business operations, the encapsulation tool encapsulates the business process operation into a complete executable process according to a preset execution order. The encapsulated atomic business operations and business process operations are associated with and stored with the custom component for subsequent test execution.
[0094] Since custom components are upper-level components composed of at least one UI component and have independent business meaning, they have a higher degree of freedom and are much more complex than UI components. Therefore, their encapsulation methods are different from those of UI components.
[0095] In one feasible implementation, the encapsulation framework provides a unified `CustomComponent` base class for all custom components to inherit from. This class contains two basic methods to enable the encapsulation and integration of custom components. The `operation` method encapsulates a single atomic business operation, which is a basic business function unit supported by the custom component. This operation includes indivisible complete business actions, such as querying, deleting, zooming in, and zooming out. The specific execution logic of the operation is implemented within the `operation` method. After encapsulation, the atomic business operation becomes a callable function of the custom component. The `flow` method combines multiple atomic business operations in a preset order to encapsulate a business process operation with complete business meaning. For example, "export and authorize" is composed of two atomic business operations, "export" and "authorize." In many business scenarios, these two operations need to be executed consecutively. The `flow` method encapsulates them into a complete business process. After encapsulation, this business process operation becomes a callable function of the custom component. Through the `operation` and `flow` methods, the atomic business operations and business process operations of each custom component are encapsulated separately and associated with the corresponding custom component for storage.
[0096] For example, such as Figure 5 The diagram illustrates the custom component encapsulation process. For a custom component to be encapsulated, firstly, a class corresponding to the custom component is created, inheriting from a unified `CustomComponent` base class. Then, it is categorized according to the business operation types supported by the custom component: for atomic business operations, an `operation` method is written, organizing the corresponding operation code by operation type, and completing the specific UI action through `xui` or `UIAction`; for common business processes composed of multiple atomic business operations, a `flow` method is written, encapsulating the common process by combining atomic operations and / or other custom component operations. Finally, all business operations of the custom component are encapsulated.
[0097] Thus, this embodiment of the application lays the foundation for component location and type identification during subsequent test execution by configuring identity and type identifiers for UI components and writing them into the container DOM element. At the same time, the executable operations of UI components are pre-encapsulated into operation sets according to preset operation types, and the atomic business operations and business process operations of custom components are pre-encapsulated and associated with custom components. This allows testers to directly call the test functions of components by operation type or business action name during actual testing, without needing to understand the DOM structure, UI composition, or operation orchestration details of the component.
[0098] This application also provides a component testing apparatus, please refer to... Figure 6 The component testing apparatus includes: Module 10 is used to obtain test parameters in the component test request in response to the component test request; The determination module 20 is used to determine the target component to be tested and the component type of the target component based on the component information, and to determine the operable element in the target component based on the operation description information, when the test parameters include component information and operation description information. The execution module 30 is used to determine the operation to be executed based on the component type and the operation description information, execute the operation to be executed on the element to be operated, and obtain the test result for the target component.
[0099] Optionally, the determining module 20 is further configured to: Identify the identity and type identifiers in the component information; Traverse each inline frame in the current interface, find the container DOM element that matches the identity identifier within each inline frame, and determine the component corresponding to the container DOM element as the target component to be tested. The component type of the target component is determined based on the type identifier.
[0100] Optionally, the component testing apparatus further includes an update module, the update module being used for: Check if there is an inline frame record corresponding to the identity identifier in the preset cache information; If it exists, then search for a container DOM element that matches the identity in the inline frame indicated by the inline frame record; If it does not exist, then the step of traversing each inline frame in the current interface, searching for the container DOM element that matches the identity within each inline frame, and storing the inline frame where the container DOM element is located in the preset cache information is performed.
[0101] Optionally, the determining module 20 is further configured to: Identify the object to be executed from the operation description information; Based on the object to be executed, find the internal DOM element that matches the object to be executed within the target component; The internal DOM element is identified as the element to be operated on.
[0102] Optionally, the execution module 30 is further configured to: The target operation type is determined based on the operation description information; Obtain the operation set corresponding to the target operation type, wherein the operation set includes at least one pre-encapsulated candidate operation; Based on the component type, determine the operation to be executed corresponding to the component type from the operation set.
[0103] Optionally, the execution module 30 is further configured to: When the operation type to be performed is a UI operation, the operation to be performed is executed on the element to be operated based on a preset browser debugging protocol to obtain the test result; When the operation type to be executed is a function call, the corresponding function is called to execute the operation and the test result is obtained; When the operation type to be performed is a third-party operation, the execution result returned by the third-party platform after performing the operation is monitored, and the execution result is used as the test result.
[0104] Optionally, the component testing apparatus further includes a custom component testing module, which is used for: When the test parameters only include operation description information, identify the business action information in the operation description information; The business action information is matched with the business meaning of each preset custom component; Custom components that match the business action information will be used as target components to be tested. The target component is tested according to the single-step business action and multi-step business process corresponding to the target component, and the test results are obtained.
[0105] Optionally, the component testing apparatus further includes a preprocessing module, the preprocessing module being used for: For each UI component in the interface to be tested, determine the first identification information and the second identification information of the UI component, wherein the first identification information identifies the identity information of the UI component, and the second identification information identifies the component type of the UI component; The first identification information and the second identification information are used as attribute information of the UI component, and the attribute information is written into the container DOM element of the UI component; Determine the executable operations supported by the UI component, and encapsulate the executable operations of each UI component in the interface to be tested into multiple operation sets according to preset operation types; For each custom component in the interface to be tested, encapsulate the atomic business operations of the custom component and / or the business process operations composed of multiple atomic business operations, wherein the custom component is composed of at least one UI component.
[0106] The component testing apparatus provided in this application, employing the component testing method described in the above embodiments, can solve the technical problem of how to improve the testing efficiency of interface components. Compared with the prior art, the beneficial effects of the component testing apparatus provided in this application are the same as those of the component testing method described in the above embodiments, and other technical features in the component testing apparatus are the same as those disclosed in the methods of the above embodiments, and will not be repeated here.
[0107] This application provides a component testing device, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, which are executed by the at least one processor to enable the at least one processor to perform the component testing method in Embodiment 1 above.
[0108] The following is for reference. Figure 7 The diagram illustrates a structural schematic of a component testing device suitable for implementing embodiments of this application. The component testing device in the embodiments of this application may include, but is not limited to, mobile terminals such as mobile phones, laptops, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Description), PMPs (Portable Media Players), in-vehicle terminals (e.g., in-vehicle navigation terminals), and fixed terminals such as digital TVs and desktop computers. Figure 7 The component testing equipment shown is merely an example and should not impose any limitations on the functionality and scope of use of the embodiments of this application.
[0109] like Figure 7As shown, the component testing equipment may include a processing unit 1001 (e.g., a central processing unit, a graphics processing unit, etc.), which can perform various appropriate actions and processes according to a program stored in a read-only memory 1002 or a program loaded from a storage device 1003 into a random access memory 1004. The random access memory 1004 also stores various programs and data required for the operation of the component testing equipment. The processing unit 1001, the read-only memory 1002, and the random access memory 1004 are interconnected via a bus 1005. An input / output interface 1006 is also connected to the bus. Typically, the following systems can be connected to the input / output interface 1006: input devices 1007 including, for example, a touchscreen, touchpad, keyboard, mouse, image sensor, microphone, accelerometer, gyroscope, etc.; output devices 1008 including, for example, a liquid crystal display (LCD), speaker, vibrator, etc.; storage devices 1003 including, for example, magnetic tape, hard disk, etc.; and communication devices 1009. Communication device 1009 allows the component test equipment to communicate wirelessly or wiredly with other devices to exchange data. Although the figure shows a component test equipment with various systems, it should be understood that implementation or possession of all the systems shown is not required. More or fewer systems may be implemented alternatively.
[0110] Specifically, according to the embodiments disclosed in this application, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments disclosed in this application include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device, or installed from storage device 1003, or installed from read-only memory 1002. When the computer program is executed by processing device 1001, it performs the functions defined in the methods of the embodiments disclosed in this application.
[0111] The component testing equipment provided in this application, employing the component testing method described in the above embodiments, can solve the technical problem of how to improve the testing efficiency of interface components. Compared with the prior art, the beneficial effects of the component testing equipment provided in this application are the same as those of the component testing method provided in the above embodiments, and other technical features of the component testing equipment are the same as those disclosed in the previous embodiment method, and will not be repeated here.
[0112] It should be understood that the various parts disclosed in this application can be implemented using hardware, software, firmware, or a combination thereof. In the description of the above embodiments, specific features, structures, materials, or characteristics can be combined in any suitable manner in one or more embodiments or examples.
[0113] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
[0114] This application provides a computer-readable storage medium having computer-readable program instructions (i.e., a computer program) stored thereon, the computer-readable program instructions being used to execute the component testing method in the above embodiments.
[0115] The computer-readable storage medium provided in this application may be, for example, a USB flash drive, but is not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems or devices, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to: electrical connections having one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM or flash memory), optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system or device. The program code contained on the computer-readable storage medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (Radio Frequency), etc., or any suitable combination thereof.
[0116] The aforementioned computer-readable storage medium may be included in the component test equipment; or it may exist independently and not assembled into the component test equipment.
[0117] The aforementioned computer-readable storage medium carries one or more programs. When the one or more programs are executed by a component testing device, the component testing device causes the component testing device to: respond to a component testing request, acquire test parameters from the component testing request; if the test parameters include component information and operation description information, determine the target component to be tested and the component type of the target component based on the component information, and determine the element to be operated in the target component based on the operation description information; determine the operation to be executed based on the component type and the operation description information, execute the operation to be executed on the element to be operated, and obtain a test result for the target component.
[0118] Computer program code for performing the operations of this application can be written in one or more programming languages or a combination thereof, including object-oriented programming languages such as Java, Smalltalk, and C++, and conventional procedural programming languages such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a Local Area Network (LAN) or a Wide Area Network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0119] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0120] The modules described in the embodiments of this application can be implemented in software or hardware. The names of the modules do not necessarily limit the functionality of the unit itself.
[0121] The readable storage medium provided in this application is a computer-readable storage medium that stores computer-readable program instructions (i.e., computer programs) for executing the above-described component testing method, thereby solving the technical problem of how to improve the testing efficiency of interface components. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided in this application are the same as those of the component testing method provided in the above embodiments, and will not be repeated here.
[0122] This application provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the component testing method described above.
[0123] The computer program product provided in this application can improve the testing efficiency of interface components. Compared with the prior art, the beneficial effects of the computer program product provided in this application are the same as the beneficial effects of the component testing method provided in the above embodiments, and will not be repeated here.
[0124] The above are merely preferred embodiments of this application and do not limit the patent scope of this application. Any equivalent structural or procedural transformations made using the content of this application's specification and drawings, or direct or indirect applications in other related technical fields, are similarly included within the patent scope of this application.
Claims
1. A component testing method, characterized in that, The component testing method includes: In response to a component test request, obtain the test parameters from the component test request; When the test parameters include component information and operation description information, the target component to be tested and the component type of the target component are determined based on the component information, and the operation element in the target component is determined based on the operation description information. Based on the component type and the operation description information, the operation to be executed is determined, and the operation to be executed is performed on the element to be operated on to obtain the test result for the target component.
2. The component testing method as described in claim 1, characterized in that, The step of determining the target component to be tested and the component type of the target component based on the component information includes: Identify the identity and type identifiers in the component information; Traverse each inline frame in the current interface, find the container DOM element that matches the identity identifier within each inline frame, and determine the component corresponding to the container DOM element as the target component to be tested. The component type of the target component is determined based on the type identifier.
3. The component testing method as described in claim 2, characterized in that, The method further includes: Check if there is an inline frame record corresponding to the identity identifier in the preset cache information; If it exists, then search for a container DOM element that matches the identity in the inline frame indicated by the inline frame record; If it does not exist, then the step of traversing each inline frame in the current interface, searching for the container DOM element that matches the identity within each inline frame, and storing the inline frame where the container DOM element is located in the preset cache information is performed.
4. The component testing method as described in claim 1, characterized in that, The step of determining the element to be operated on in the target component based on the operation description information includes: Identify the object to be executed from the operation description information; Based on the object to be executed, find the internal DOM element that matches the object to be executed within the target component; The internal DOM element is identified as the element to be operated on.
5. The component testing method as described in claim 1, characterized in that, The step of determining the operation to be performed based on the component type and the operation description information includes: The target operation type is determined based on the operation description information; Obtain the operation set corresponding to the target operation type, wherein the operation set includes at least one pre-encapsulated candidate operation; Based on the component type, determine the operation to be executed corresponding to the component type from the operation set.
6. The component testing method as described in claim 1, characterized in that, The step of performing the operation on the element to be operated on to obtain the test result for the target component includes: When the operation type to be performed is a UI operation, the operation to be performed is executed on the element to be operated based on a preset browser debugging protocol to obtain the test result; When the operation type to be executed is a function call, the corresponding function is called to execute the operation and the test result is obtained; When the operation type to be performed is a third-party operation, the execution result returned by the third-party platform after performing the operation is monitored, and the execution result is used as the test result.
7. The component testing method as described in claim 1, characterized in that, After the step of obtaining the test parameters in the component test request, the method further includes: When the test parameters only include operation description information, identify the business action information in the operation description information; The business action information is matched with the business meaning of each preset custom component; Custom components that match the business action information will be used as target components to be tested. The target component is tested according to the single-step business action and multi-step business process corresponding to the target component, and the test results are obtained.
8. The component testing method according to any one of claims 1 to 7, characterized in that, The method further includes: For each UI component in the interface to be tested, determine the first identification information and the second identification information of the UI component, wherein the first identification information identifies the identity information of the UI component, and the second identification information identifies the component type of the UI component; The first identification information and the second identification information are used as attribute information of the UI component, and the attribute information is written into the container DOM element of the UI component; Determine the executable operations supported by the UI component, and encapsulate the executable operations of each UI component in the interface to be tested into multiple operation sets according to preset operation types; For each custom component in the interface to be tested, encapsulate the atomic business operations of the custom component and / or the business process operations composed of multiple atomic business operations, wherein the custom component is composed of at least one UI component.
9. A component testing device, characterized in that, The component testing device includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, the computer program being configured to implement the steps of the component testing method as described in any one of claims 1 to 8.
10. A storage medium, characterized in that, The storage medium is a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, it implements the steps of the component testing method as described in any one of claims 1 to 8.
