Page loading completion identifier adding method and device, equipment and medium
By monitoring the page loading progress and adding logos, we ensure that the H5 page executes test cases after full loading, solving the problem of low accuracy caused by the page not fully loading in UI automation tests, improving the stability of the test and simplifying the script logic.
Patent Information
- Application Number
- CN202510659426.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-21
- Publication Date
- 2025-08-26
AI Technical Summary
In existing UI automation tests, the H5 page fails to obtain elements because it is not fully loaded, the test accuracy is low, and the existing solutions have problems such as unnecessary delay, increased complexity or affecting the page functionality.
By obtaining test requirements data, extracting the text language files and page elements of the target test page, monitoring the loading progress, and adding identifications according to the loading status attributes, ensuring that the test cases are executed after the page is fully loaded, and using the identification addition function to add preset identifications to the resource network address.
Improve the stability and reliability of the test, reduce unnecessary waiting time, simplify the test script logic, enhance maintainability, and ensure the normal operation of the page and the integrity of the access address structure.
Smart Images

Figure CN120540965A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of automated testing technology, and in particular to a method, device, equipment and medium for adding a mark indicating that page loading is complete. Background Art
[0002] Automated testing of HTML5 (H5) page UIs is a crucial quality assurance technology in the software testing field. Leveraging automated tools and scripts, it simulates user actions like clicks and input on a page. Using pre-set rules, it automatically verifies the display quality, layout rationality, and smooth interaction of page elements. This testing method can quickly and efficiently complete a large number of repetitive testing tasks, ensuring that the H5 page UI performs well across different devices and browser environments.
[0003] In the healthcare sector, HTML5 pages often experience resource loading delays exceeding the preset wait thresholds of automated test scripts due to issues such as delayed response times for medical data interfaces, time-consuming encrypted transmission of sensitive patient information, and complex rendering logic for dynamic charts. In these cases, test cases executed according to a fixed process can reduce test case accuracy due to unready page elements or unupdated data.
[0004] In the fintech business field, during the loan approval process testing of mobile banking apps, automated scripts may trigger submission operations before the risk control rule H5 component is fully initialized. This can cause high-risk applications that should have been blocked to be incorrectly marked as passed. This not only distorts the test report but also reflects the low accuracy of test case execution on the H5 page during automated testing.
[0005] In existing UI automation testing scenarios for HTML5 pages, test cases often execute before the page is fully loaded, resulting in element retrieval failures and test failures. Existing methods primarily rely on timed waits or complex logical judgments to confirm page loading. However, timed waits can cause unnecessary delays and extend testing time; complex logical judgments not only increase the complexity of test scripts but are also subject to interference from factors such as network and server responses, leading to poor reliability. Furthermore, some solutions require modifying the page source code or introducing additional dependencies, which not only increases implementation difficulty but can also affect the page's normal functionality and even cause crashes. Summary of the Invention
[0006] The present invention provides a method, device, equipment and medium for adding a page loading completion identifier to solve the problem of low accuracy when executing test cases on H5 pages in UI automation testing.
[0007] In a first aspect, a method for adding a page loading completion indicator is provided, comprising:
[0008] Acquire test requirement data for the automated test, and extract the target test page for the automated test according to the test requirement data;
[0009] Extracting the text language file and page elements corresponding to the target test page;
[0010] Monitoring the loading progress of the target test page according to the text language file and the loading status attributes of the page elements;
[0011] Determine a logo adding strategy for the target test page according to the loading progress, and call a logo adding function according to the logo adding strategy;
[0012] By means of the identifier adding function, a preset target identifier is added to the resource network address of the target test page.
[0013] In a second aspect, a device for adding a mark after page loading is completed is provided, comprising:
[0014] A target test page extraction module is used to obtain test requirement data of the automated test and extract the target test page of the automated test according to the test requirement data;
[0015] A text language file and page element extraction module, used to extract the text language file and page elements corresponding to the target test page;
[0016] A loading progress monitoring module, configured to monitor the loading progress of the target test page according to the loading status attributes of the text language file and the page elements;
[0017] an identification adding function calling module, configured to determine an identification adding strategy for the target test page according to the loading progress, and call an identification adding function according to the identification adding strategy;
[0018] The target identifier adding module is used to add a preset target identifier to the resource network address of the target test page through the identifier adding function.
[0019] In a third aspect, a computer device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the steps of the method for adding an identifier indicating that the page has been loaded are implemented.
[0020] In a fourth aspect, a computer-readable storage medium is provided, which stores a computer program. When the computer program is executed by a processor, the steps of the method for adding an identifier indicating that the page loading is completed are implemented.
[0021] In the scheme implemented by the above-mentioned page loading completion identifier adding method, device, equipment and medium, the test requirement data of the automated test can be obtained through the client, and the target test page of the automated test can be extracted according to the test requirement data; the text language file and page elements corresponding to the target test page are extracted; the loading progress of the target test page is monitored according to the loading status attributes of the text language file and the page elements; the identifier adding strategy of the target test page is determined according to the loading progress, and the identifier adding function is called according to the identifier adding strategy; through the identifier adding function, a preset target identifier is added to the resource network address of the target test page. In the present invention, a specific loading completion identifier is added after the page access address after the page loading is completed; by detecting the specific identifier after the page access address, it is ensured that the test case is only executed after all resources of the page are loaded, effectively avoiding element acquisition failure caused by the page not being fully ready, improving test stability and reliability, reducing unnecessary waiting time, shortening the test execution time, simplifying the test script logical architecture, and enhancing the maintainability of the test script; at the same time, the identifier adding operation has no effect on the original function of the page, ensuring the normal operation of the page and the integrity of the page access address structure. Therefore, the method, device, equipment and medium for adding a page loading completion identifier proposed in the present invention can solve the problem of low accuracy when executing test cases on H5 pages in UI automation testing. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments of the present invention. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative labor.
[0023] Figure 1 This is a schematic diagram of an application environment of a method for adding a mark after page loading is completed according to an embodiment of the present invention;
[0024] Figure 2 This is a flow chart of a method for adding a markup after page loading is completed according to an embodiment of the present invention;
[0025] Figure 3 yes Figure 1 A schematic flow chart of a specific implementation of step S2;
[0026] Figure 4 yes Figure 1 A schematic flow chart of a specific implementation of step S3;
[0027] Figure 5This is a structural diagram of a device for adding a mark after page loading is completed in one embodiment of the present invention;
[0028] Figure 6 is a structural diagram of a computer device in one embodiment of the present invention;
[0029] Figure 7 FIG. 2 is another structural diagram of a computer device according to an embodiment of the present invention. DETAILED DESCRIPTION
[0030] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of them. All other embodiments obtained by ordinary technicians in this field based on the embodiments of the present invention without making any creative efforts shall fall within the scope of protection of the present invention.
[0031] The embodiment of the present invention provides a method for adding a mark indicating that a page has been loaded, which can be applied to Figure 1 In an application environment, the client communicates with the server through a network. The server can obtain the test requirement data of the automated test through the client, extract the target test page of the automated test according to the test requirement data; extract the text language file and page elements corresponding to the target test page; monitor the loading progress of the target test page according to the loading status attributes of the text language file and the page elements; determine the identification adding strategy of the target test page according to the loading progress, and call the identification adding function according to the identification adding strategy; add a preset target identification to the resource network address of the target test page through the identification adding function. In the present invention, after the page loading is completed, a specific loading completion identification is added after the page access address; by detecting the specific identification after the page access address, it is ensured that the test case is only executed after all resources of the page are loaded, effectively avoiding the failure of element acquisition caused by the page not being fully ready, improving the stability and reliability of the test, reducing unnecessary waiting time, shortening the test execution time, simplifying the logical architecture of the test script, and enhancing the maintainability of the test script; at the same time, the identification adding operation has no effect on the original function of the page, ensuring the normal operation of the page and the integrity of the page access address structure. The client can be, but is not limited to, various personal computers, laptops, smartphones, tablet computers, and portable wearable devices. The server can be implemented as an independent server or a server cluster consisting of multiple servers. The present invention is described in detail below through specific embodiments.
[0032] See also Figure 2 As shown, Figure 2A flow chart of a method for adding a page loading completion indicator provided by an embodiment of the present invention includes the following steps:
[0033] S1. Acquire test requirement data of an automated test, and extract a target test page of the automated test according to the test requirement data.
[0034] In this embodiment of the present invention, test requirement data refers to a collection of information collected from multiple sources, such as the software product's functional specifications, business process documentation, and user demand feedback, prior to automated testing. This information is used to clarify the specific tasks and objectives of automated testing. This information covers key points such as the functional modules to be tested, the expected performance indicators, and the user interaction specifications to be followed.
[0035] In detail, the scattered test requirement data can be collected from designated data sources, such as project management systems and requirement document repositories, through specific technical means, such as writing special data collection scripts and using data crawling tools.
[0036] Furthermore, in order to more accurately obtain the target test page corresponding to the test requirement data, achieve precise positioning and efficient execution of the automated testing process, ensure that the testing work can be carried out around the core business scenarios, avoid invalid testing, and improve test coverage and effectiveness, it is necessary to analyze the test requirement data.
[0037] In an embodiment of the present invention, the target test page refers to a specific page that needs to be tested in automated testing based on test requirement data. It is also the main object of the testing work. It includes functional modules, user interaction interfaces and other elements related to the test requirements in the software product, and carries specific functions and business processes that need to be tested.
[0038] In an embodiment of the present invention, extracting the target test page of the automated test according to the test requirement data includes:
[0039] Extracting test page type features corresponding to the test requirement data;
[0040] Identifying the test page content of the automated test according to the test page type feature;
[0041] The target test page of the automated test is determined according to the test page content.
[0042] Specifically, test page type features refer to the key attributes and identifiers used to distinguish and identify different categories of test pages. These features can help the automated test system accurately determine the type of the current test page, thereby performing the corresponding test operations. Feature extraction is usually completed by combining static code analysis and dynamic page detection. First, the requirements document is parsed to establish a requirements-page mapping relationship. Then, the URL pattern, DOM structure, and content features of the target page are collected through automated tools. Finally, these features are encoded and stored to form a feature library that can be recognized by the test system, providing a basis for subsequent page type identification and test case execution.
[0043] Specifically, based on the extracted page type features (such as technical architecture, business scenarios, performance indicators, etc.), the actual content of the candidate pages is scanned and matched through automated tools. Specific operations include using features as screening conditions to detect whether the page's DOM structure, network requests, interaction logic, etc. contain elements or functional modules corresponding to the features. For example, by identifying whether there are multilingual tags, dynamically loaded API interfaces or specific business buttons on the page, it is determined whether the page belongs to the content category to be tested, thereby locating the specific page elements, data flows or interaction logic related to the test requirements, providing a direct basis for determining the final target test page.
[0044] Furthermore, based on the identified specific content of the test page (such as page elements, interaction logic, data flow, etc.), combined with multiple factors such as test requirements, business priorities, and test resources, the pages that will ultimately undergo automated testing are screened out from the numerous pages containing test-related content.
[0045] For example, in a medical scenario, first, according to the test requirements of the electronic medical record system (such as patient information entry, medical order issuance, test report viewing and other functions), the corresponding page type features are extracted, including the specific form structure of the medical record editing page (such as the patient ID input box, the medical history multiple-choice box), the drug selection pop-up window of the medical order page and other key elements; then, the current test page content is identified in real time through feature matching. For example, when the system detects that the page contains the "Medical Order" title, the drug search box and the dosage input field, it is automatically determined to be a medical order page and verifies whether the drug incompatibility prompt function is triggered normally; finally, the priority of the target test page is determined according to the verification results, such as giving priority to ensuring the accuracy of the dosage calculation of the intensive care medical order page, and temporarily skipping the non-core health education page, so as to achieve accurate testing of the key business processes of the medical information system and ensure the reliability and safety of the system during the patient diagnosis and treatment process.
[0046] S2. Extracting the text language file and page elements corresponding to the target test page.
[0047] In an embodiment of the present invention, the text language file refers to a standardized file in a software system that stores text content displayed on a page. It is usually organized in a specific format (such as JSON, XML, properties, etc.), and contains interface text information in different language environments, and is used to support text display and switching in multilingual scenarios; the page elements are various basic units that constitute a software page, including but not limited to interactive controls (such as buttons, input boxes, drop-down lists), display components (such as text, pictures, tables) and layout containers (such as partition containers, pop-up modules), which are the basic carriers for realizing user interaction with the interface and information display. Extracting the text language file and page elements corresponding to the target test page is intended to provide basic data for text content verification and element interaction verification for subsequent automated testing, ensuring the accuracy and consistency of the text in a multilingual environment, as well as the correctness of the page element functions, attributes and interaction logic.
[0048] In the embodiment of the present invention, referring to Figure 3 As shown, the extracting of the text language file and page elements corresponding to the target test page includes:
[0049] S31, determining an automated test framework according to the test requirement data corresponding to the target test page;
[0050] S32: Query the text attributes and element attributes of the target test page using the automated testing framework;
[0051] S33, identifying the text position corresponding to the text attribute and the element position corresponding to the element attribute;
[0052] S34, combining the text attributes according to the text position to obtain a text language file corresponding to the target test page;
[0053] S35. Extract page elements corresponding to the target test page according to the element positions.
[0054] Specifically, an automated testing framework is a collection of standardized tools, processes, and code structures designed to automate the testing of target test pages. It integrates functional modules such as test execution, assertion verification, data management, and report generation. Based on the target test page's business logic, technical characteristics (such as front-end frameworks and interface protocols), and testing requirements (such as functional verification and performance testing), it provides unified test script writing specifications, execution strategies, and results analysis methods. The framework uses predefined location strategies to precisely locate specified elements within the target page's DOM tree. It then extracts the text content and various attribute values of these elements, while also verifying interactive properties such as visibility and operability.
[0055] Specifically, through the positioning function of the automated testing framework, the document object model of the target test page is traversed layer by layer, the tag node containing specific text content is locked, and the hierarchical path or coordinate position of the node in the page is recorded; for element attributes, the search mechanism provided by the framework is also used to accurately locate the element with the specified attribute value, obtain the position coordinates of the element in the page rendering or the unique path identifier in the DOM tree, and compare the position information of the text and element with the expected position in the test case to verify whether its display position meets the design specifications or business logic requirements, thereby completing the automatic identification and verification of position accuracy.
[0056] Furthermore, when combining text attributes according to text position, the hierarchical path or coordinate position of each text content in the page DOM tree is first obtained through the automated testing framework, and the scattered text attributes are classified and integrated according to the position order or business logic grouping. After removing duplicate or redundant content, a text language file that conforms to the target test page language specification is generated; when extracting page elements, based on the unique identifier of the element position, elements with specific attributes are accurately screened from the page, and grouped and organized according to element type or functional module to form a page element collection containing element position information and attribute details, providing structured data support for element operations in subsequent automated testing.
[0057] For example, in a financial scenario, in the "foreign exchange exchange" function test of a bank's mobile terminal, the testing team needs to extract the text content and interactive elements of the page to build an automated test. First, based on the testing requirements of the function (such as real-time refresh of exchange rates, amount conversion logic, compliance prompts, etc.), an automation framework that supports dynamic data capture is selected and combined with a multilingual adaptation module. The framework parses the page structure, identifies key texts (such as "exchange rate update time" and "handling fee calculation formula") and functional elements (such as currency selection drop-down box, amount input field, confirmation button), and records their specific coordinates and attributes in the interface. Subsequently, text content in different languages (such as "minimum exchange amount" in Chinese and "MinimumAmount" in English) is classified into corresponding language configuration files, and a page element library is established to save the positioning path and operation rules of each element.
[0058] S3. Monitoring the loading progress of the target test page according to the text language file and the loading status attributes of the page elements.
[0059] In an embodiment of the present invention, the loading status attribute uses the document.readyState attribute as a core means to accurately monitor the loading status of the target test page. This attribute is provided by the browser and can dynamically return the loading status of the current document based on the loading and parsing process of the page resources. The loading progress has three valid states: loading state, i.e., the loading state; interactive state, i.e., the partially loaded state; and complete state, i.e., the fully loaded state. By continuously monitoring changes in this attribute value, the page loading progress can be accurately determined in real time, providing a reliable time reference for subsequent operations.
[0060] In the embodiment of the present invention, referring to Figure 4 As shown, monitoring the loading progress of the target test page according to the text language file and the loading status attribute of the page element includes:
[0061] S41, using the page operation script program corresponding to the target test page to determine the page control object corresponding to the target test page;
[0062] S42, querying the attribute content corresponding to the loading status attribute according to the page control object;
[0063] S43, matching the attribute content with the preset page loading state content to obtain a matching loading state;
[0064] S44: Determine the loading progress of the target test page according to the matching loading status.
[0065] In detail, a page operation script program refers to a set of test instructions written in a programming language. Based on the analysis of the structure of the web page being tested, it encapsulates the operation methods and verification logic of various interface components; the page control object is an abstract instance created when the script is executed. It encapsulates the actual web page components and their interactive functions into programming objects with properties and methods. By establishing a corresponding relationship with the interface elements, the test program can manage and operate various functional modules on the page in an object-oriented manner.
[0066] Specifically, when the test script triggers a status query request, the page control object will initiate a native API call to the browser environment, capture and return the document loading status value (including three status values: "loading", "interactive" or "complete") in real time, and then encapsulate these original status data into standardized attribute content, including status enumeration values, timestamps, and metadata such as the loading status of associated sub-resources. Finally, these structured status attributes are returned to the test script through the method interface of the control object, enabling the automated testing process to perform subsequent page operations based on accurate loading status judgment.
[0067] Furthermore, the preset page loading status content is a set of standard loading stage identifiers predefined in the automated testing framework, which are used to compare with the actual document.readyState return value. By matching the real-time page loading status with the preset page loading status, the system can accurately locate the specific loading stage of the current page, thereby dynamically understanding the actual loading progress of the target test page and providing precise timing control for subsequent test operations.
[0068] S4. Determine a logo adding strategy for the target test page according to the loading progress, and call a logo adding function according to the logo adding strategy.
[0069] In an embodiment of the present invention, the identification adding strategy refers to the rules, methods and processes formulated on how to add specific identification (such as unique identifiers, attribute tags, class names, data tags, etc.) to page elements (such as HTML tags, components, modules, etc.) in order to achieve accurate identification, positioning, monitoring or operation of the target test page.
[0070] In an embodiment of the present invention, determining a strategy for adding an identifier to the target test page according to the loading progress includes:
[0071] When the loading progress is in a preset first loading state, monitoring a page triggering event, and generating a first identification adding strategy corresponding to the target test page according to the page triggering event;
[0072] When the loading progress is in a preset second loading state, a preset timer is used to periodically monitor the loading change state of the target test page and the number of monitoring times of the timer, and a second identification adding strategy corresponding to the target test page is determined according to the loading change state and the number of monitoring times;
[0073] When the loading progress is in a preset third loading state, a function call condition is triggered, and a third identification adding strategy corresponding to the target test page is determined according to the function call condition;
[0074] The first identification adding strategy, the second identification adding strategy, and the third identification adding strategy are collected to generate an identification adding strategy for the target test page.
[0075] In detail, the preset loading state refers to the page loading stage divided based on the document.readyState attribute, which specifically includes three states: the first loading state (loading) indicates that the browser is parsing the HTML document but has not yet completed DOM construction. At this time, external resources may still be loading; the second loading state (interactive) indicates that the DOM tree has been built, but some asynchronous resources (such as images or scripts) may still be loading; the third loading state (complete) indicates that the page and all its dependent resources have been completely loaded. These three states correspond to different identification adding strategies, which dynamically generate identification by listening to events, timed polling, or directly triggering functions, and are finally integrated into a complete strategy system to ensure that the status of the test page can be accurately marked under different loading progress.
[0076] Specifically, the identification strategy dynamically determines the timing of identification for the target test page based on the different states of document.readyState: The first identification strategy involves monitoring the page load event when the state is loading, adding the identification after all resources are fully loaded to ensure complete page presentation; the second identification strategy involves starting a timer to check the state every 500 milliseconds until it becomes complete or the maximum number of checks is reached six times, and then adding the identification; the third identification strategy involves adding the identification immediately when the state is complete. At this point, the page and all sub-resources are ready, and the identification operation can be performed directly. This strategy ensures the accuracy of identification addition and the efficiency of system response by adapting to the loading progress in stages.
[0077] In the embodiment of the present invention, calling the identifier adding function according to the identifier adding strategy includes:
[0078] When the identification adding strategy is the first identification adding strategy, determining the page loading state according to the page triggering event in the first identification adding strategy, and when the page loading state is the third loading state, calling the identification adding function;
[0079] When the identification adding strategy is the second identification adding strategy, identifying the loading change state and monitoring times in the second identification adding strategy, and when the loading change state is the third loading state or the monitoring times reaches a preset monitoring times threshold, calling the identification adding function;
[0080] When the identifier adding strategy is the third identifier adding strategy, the identifier adding function is called according to the function calling condition in the third identifier adding strategy.
[0081] In detail, when the first identification adding strategy is adopted, the system judges the loading status by monitoring the page triggering event. If it is detected that the page enters the third loading state (that is, the loading is completely completed), the identification adding function is called immediately; when the second identification adding strategy is adopted, the system continuously monitors the loading status changes through a timer. If it is found that the state has changed to the third loading state or the monitoring times reaches the preset threshold (6 times), the identification adding function is also triggered; when the third identification adding strategy is adopted, the system directly executes the identification adding operation according to the function call conditions without the need for additional judgment.
[0082] Specifically, these three identification adding strategies together constitute a complete dynamic identification adding mechanism, ensuring that no matter what loading stage the page is in, the identification adding function can be called at the appropriate time to accurately add the identification.
[0083] S5. Add a preset target identifier to the resource network address of the target test page through the identifier adding function.
[0084] In an embodiment of the present invention, the resource network address refers to the network access path of various resources (such as pictures, style sheets, script files, font files, etc.) in the target test page, which usually exists in the form of a URL (Uniform Resource Locator) and is used to identify the specific location of the resource in the network; the preset target identifier refers to a pre-defined specific symbol, string or parameter, and its function is to inject it into the network address of the resource through the identifier addition function, so as to carry out targeted monitoring, control or differentiation of scenarios such as resource loading, request link tracking, and test tag injection of the target test page.
[0085] In the embodiment of the present invention, the step of adding a preset target identifier to the resource network address of the target test page through the identifier adding function includes:
[0086] Extracting a first position corresponding to a first symbol preset in the resource network address of the target test page, and extracting a second position corresponding to a second symbol preset in the target test page;
[0087] identifying a relative positional relationship between the first position and the second position;
[0088] Determining identification content corresponding to a preset target identification according to the relative position relationship;
[0089] The identification content is added to the end of the resource network address through the identification adding function.
[0090] In detail, the preset first symbol is "?" (query parameter start symbol), and the corresponding first position is the index position where "?" appears for the first time in the resource network address, representing the beginning of the query parameter part; the preset second symbol is "#" (anchor symbol), and the corresponding second position is the index position where "#" appears for the first time in the resource network address, representing the beginning of the anchor segment. By locating the index positions of "?" and "#" through the string search function, the first position and the second position can be obtained. By detecting the positions of these two symbols, the relative position relationship between the two is identified: if the position of "#" is after "?" (that is, the second position is greater than the first position), it means that there are both query parameters and anchor points in the resource network address and the parameters are in front and the anchor point is in the back; if the position of "?" is after "#" or "?" does not exist, it means that the anchor point is in front of the resource network address or there is only an anchor point / no anchor point.
[0091] Specifically, the identifier content is determined based on the relative position: when the "#" is later than the "?", the resource network address already has query parameters but the anchor point is at the end. At this time, you need to add "?load=true" (starting with "?" as a new query parameter) at the end of the resource network address; when the "?" is later than the "#" or there is no "?", it means that there is already an anchor point or no parameters in the resource network address. At this time, add "&load=true" (connect the existing parameters with "&" or use it as the first parameter). Through the identifier addition function, according to the above logical judgment results, the corresponding target identifier content ("?load=true" or "&load=true") is spliced at the end of the resource network address to ensure that the resource network address syntax is correct and avoid page loading failure due to format errors.
[0092] Furthermore, this technical solution fully considers various compatibility and security factors when implementing the URL identifier addition function: first, it ensures consistent performance in mainstream browsers such as Chrome, Firefox, Safari, Edge, while taking into account the compatibility support of older browsers; it uses the window.history.replaceState method to update the URL to avoid interfering with the user's navigation history, and ensures that security certificate verification is not affected in the HTTPS environment; it strictly avoids the risk of sensitive information leakage and ensures that URL modifications do not involve user privacy data; it designs a compatible routing processing mechanism for single-page application frameworks such as React and Vue to avoid routing conflicts; it avoids unnecessary resource re-requests by optimizing the caching strategy, and maximizes page performance while ensuring functional integrity.
[0093] It can be seen that in the above scheme, after the page loading is completed, a specific loading completion identifier is added after the page access address; by detecting the specific identifier after the page access address, it is ensured that the test case is executed only after all resources of the page are loaded, effectively avoiding the failure of element acquisition caused by the page not being fully ready, improving the stability and reliability of the test, reducing unnecessary waiting time, shortening the test execution time, simplifying the logical structure of the test script, and enhancing the maintainability of the test script; at the same time, the operation of adding the identifier has no effect on the original function of the page, ensuring the normal operation of the page and the integrity of the page access address structure.
[0094] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present invention.
[0095] In one embodiment, a device for adding a mark indicating that a page has been loaded is provided, and the device for adding a mark indicating that a page has been loaded corresponds to the method for adding a mark indicating that a page has been loaded in the above embodiment. Figure 5 As shown, the device for adding a mark after page loading is completed includes a target test page extraction module 101, a text language file and page element extraction module 102, a loading progress monitoring module 103, a mark adding function calling module 104 and a target mark adding module 105. The functional modules are described in detail as follows:
[0096] The target test page extraction module 101 is used to obtain test requirement data of the automated test and extract the target test page of the automated test according to the test requirement data;
[0097] A text language file and page element extraction module 102 is used to extract the text language file and page elements corresponding to the target test page;
[0098] A loading progress monitoring module 103 is configured to monitor the loading progress of the target test page according to the loading status attributes of the text language file and the page elements;
[0099] The identification adding function calling module 104 is used to determine the identification adding strategy of the target test page according to the loading progress, and call the identification adding function according to the identification adding strategy;
[0100] The target identifier adding module 105 is configured to add a preset target identifier to the resource network address of the target test page through the identifier adding function.
[0101] In one embodiment, the target test page extraction module 101, when extracting the target test page of the automated test according to the test requirement data, is configured to:
[0102] Extracting test page type features corresponding to the test requirement data;
[0103] Identifying the test page content of the automated test according to the test page type feature;
[0104] The target test page of the automated test is determined according to the test page content.
[0105] In one embodiment, the text language file and page element extraction module 102, when extracting the text language file and page elements corresponding to the target test page, is configured to:
[0106] Determine an automated testing framework based on the test requirement data corresponding to the target test page;
[0107] Querying the text attributes and element attributes of the target test page using the automated testing framework;
[0108] Identifying a text position corresponding to the text attribute and an element position corresponding to the element attribute;
[0109] Combining the text attributes according to the text position to obtain a text language file corresponding to the target test page;
[0110] The page elements corresponding to the target test page are extracted according to the element positions.
[0111] In one embodiment, the loading progress monitoring module 103, when monitoring the loading progress of the target test page based on the text language file and the loading status attribute of the page element, is configured to:
[0112] Determine the page control object corresponding to the target test page using the page operation script program corresponding to the target test page;
[0113] Querying the attribute content corresponding to the loading status attribute according to the page control object;
[0114] Matching the attribute content with the preset page loading state content to obtain a matching loading state;
[0115] The loading progress of the target test page is determined according to the matching loading status.
[0116] In one embodiment, the identifier adding function calling module 104, when executing the identifier adding strategy for determining the target test page according to the loading progress, is configured to:
[0117] When the loading progress is in a preset first loading state, monitoring a page triggering event, and generating a first identification adding strategy corresponding to the target test page according to the page triggering event;
[0118] When the loading progress is in a preset second loading state, a preset timer is used to periodically monitor the loading change state of the target test page and the number of monitoring times of the timer, and a second identification adding strategy corresponding to the target test page is determined according to the loading change state and the number of monitoring times;
[0119] When the loading progress is in a preset third loading state, a function call condition is triggered, and a third identification adding strategy corresponding to the target test page is determined according to the function call condition;
[0120] The first identification adding strategy, the second identification adding strategy, and the third identification adding strategy are collected to generate an identification adding strategy for the target test page.
[0121] In one embodiment, the identifier adding function calling module 104, when calling the identifier adding function according to the identifier adding policy, is further configured to:
[0122] When the identification adding strategy is the first identification adding strategy, determining the page loading state according to the page triggering event in the first identification adding strategy, and when the page loading state is the third loading state, calling the identification adding function;
[0123] When the identification adding strategy is the second identification adding strategy, identifying the loading change state and monitoring times in the second identification adding strategy, and when the loading change state is the third loading state or the monitoring times reaches a preset monitoring times threshold, calling the identification adding function;
[0124] When the identifier adding strategy is the third identifier adding strategy, the identifier adding function is called according to the function calling condition in the third identifier adding strategy.
[0125] In one embodiment, the target identifier adding module 105, when executing the identifier adding function to add a preset target identifier to the resource network address of the target test page, is configured to:
[0126] Extracting a first position corresponding to a first symbol preset in the resource network address of the target test page, and extracting a second position corresponding to a second symbol preset in the target test page;
[0127] identifying a relative positional relationship between the first position and the second position;
[0128] Determining identification content corresponding to a preset target identification according to the relative position relationship;
[0129] The identification content is added to the end of the resource network address through the identification adding function.
[0130] The present invention provides a device for adding a page loading completion identifier, which adds a specific loading completion identifier after the page access address after the page loading is completed; by detecting the specific identifier after the page access address, it is ensured that the test case is only executed after all resources of the page are loaded, effectively avoiding element acquisition failure caused by the page not being fully ready, improving test stability and reliability, reducing unnecessary waiting time, shortening test execution time, simplifying the test script logical architecture, and enhancing the maintainability of the test script; at the same time, the addition of the identifier operation has no effect on the original function of the page, ensuring the normal operation of the page and the integrity of the page access address structure.
[0131] For the specific limitations of the device for adding an identifier after page loading is completed, please refer to the limitations of the method for adding an identifier after page loading is completed above, and no further details will be given here. Each module in the above-mentioned device for adding an identifier after page loading is completed can be implemented in whole or in part by software, hardware, and a combination thereof. The above-mentioned modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.
[0132] In one embodiment, a computer device is provided. The computer device may be a server, and its internal structure diagram may be as follows: Figure 6 As shown. The computer device includes a processor, memory, network interface and database connected via a system bus. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes non-volatile and / or volatile storage media and internal memory. The non-volatile storage medium stores an operating system, a computer program and a database. The internal memory provides an environment for the operation of the operating system and computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external client via a network connection. When the computer program is executed by the processor, it implements the functions or steps on the server side of an intelligent question-answering processing method.
[0133] In one embodiment, a computer device is provided. The computer device may be a client, and its internal structure diagram may be as follows: Figure 7As shown. The computer device includes a processor, memory, network interface, display screen and input device connected via a system bus. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external server via a network connection. When the computer program is executed by the processor, it realizes the functions or steps of the client side of an intelligent question-answering processing method.
[0134] In one embodiment, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, the following steps are performed:
[0135] Acquire test requirement data for the automated test, and extract the target test page for the automated test according to the test requirement data;
[0136] Extracting the text language file and page elements corresponding to the target test page;
[0137] Monitoring the loading progress of the target test page according to the text language file and the loading status attributes of the page elements;
[0138] Determine a logo adding strategy for the target test page according to the loading progress, and call a logo adding function according to the logo adding strategy;
[0139] By means of the identifier adding function, a preset target identifier is added to the resource network address of the target test page.
[0140] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the following steps are implemented:
[0141] Acquire test requirement data for the automated test, and extract the target test page for the automated test according to the test requirement data;
[0142] Extracting the text language file and page elements corresponding to the target test page;
[0143] Monitoring the loading progress of the target test page according to the text language file and the loading status attributes of the page elements;
[0144] Determine a logo adding strategy for the target test page according to the loading progress, and call a logo adding function according to the logo adding strategy;
[0145] By means of the identifier adding function, a preset target identifier is added to the resource network address of the target test page.
[0146] It should be noted that the above functions or steps that can be implemented by the computer-readable storage medium or computer device can be found in the relevant descriptions of the server side and the client side in the aforementioned method embodiment. To avoid repetition, they will not be described one by one here.
[0147] Those skilled in the art will appreciate that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through a computer program. The computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in various forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
[0148] Those skilled in the art will clearly understand that for the sake of convenience and brevity of description, only the division of the above-mentioned functional units and modules is used as an example. In actual applications, the above-mentioned functions can be distributed and completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above.
[0149] It should be noted that if any software tools or components not from our company appear in the embodiments of this application,
[0150] It is for illustration purposes only and does not represent actual use.
[0151] The above-described embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit the same. If any software tools or components other than those of the company appear in the application embodiments, they are merely used for illustration and do not represent actual use. Although the present invention has been described in detail with reference to the above-mentioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the above-mentioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be included in the scope of protection of the present invention.
Claims
1. A method for adding a mark indicating that a page has been loaded, characterized in that: include: Acquire test requirement data for the automated test, and extract the target test page for the automated test according to the test requirement data; Extracting the text language file and page elements corresponding to the target test page; Monitoring the loading progress of the target test page according to the text language file and the loading status attributes of the page elements; Determine a logo adding strategy for the target test page according to the loading progress, and call a logo adding function according to the logo adding strategy; By means of the identifier adding function, a preset target identifier is added to the resource network address of the target test page.
2. The method for adding a mark indicating that page loading is completed according to claim 1, wherein: The step of extracting the target test page for the automated test according to the test requirement data includes: Extracting test page type features corresponding to the test requirement data; Identifying the test page content of the automated test according to the test page type feature; The target test page of the automated test is determined according to the test page content.
3. The method for adding a mark indicating that page loading is completed according to claim 1, wherein: The extracting of the text language file and page elements corresponding to the target test page includes: Determine an automated testing framework based on the test requirement data corresponding to the target test page; Querying the text attributes and element attributes of the target test page using the automated testing framework; Identifying a text position corresponding to the text attribute and an element position corresponding to the element attribute; Combining the text attributes according to the text position to obtain a text language file corresponding to the target test page; The page elements corresponding to the target test page are extracted according to the element positions.
4. The method for adding a mark indicating that page loading is completed according to claim 1, wherein: The step of monitoring the loading progress of the target test page according to the text language file and the loading status attribute of the page element includes: Determine the page control object corresponding to the target test page using the page operation script program corresponding to the target test page; Querying the attribute content corresponding to the loading status attribute according to the page control object; Matching the attribute content with the preset page loading state content to obtain a matching loading state; The loading progress of the target test page is determined according to the matching loading status.
5. The method for adding a mark indicating that page loading is completed according to claim 1, wherein: The determining of a strategy for adding an identifier to the target test page according to the loading progress includes: When the loading progress is in a preset first loading state, monitoring a page triggering event, and generating a first identification adding strategy corresponding to the target test page according to the page triggering event; When the loading progress is in a preset second loading state, a preset timer is used to periodically monitor the loading change state of the target test page and the number of monitoring times of the timer, and a second identification adding strategy corresponding to the target test page is determined according to the loading change state and the number of monitoring times; When the loading progress is in a preset third loading state, a function call condition is triggered, and a third identification adding strategy corresponding to the target test page is determined according to the function call condition; The first identification adding strategy, the second identification adding strategy, and the third identification adding strategy are collected to generate an identification adding strategy for the target test page.
6. The method for adding a mark indicating that page loading is completed according to claim 1, wherein: The calling of the identifier adding function according to the identifier adding strategy includes: When the identification adding strategy is the first identification adding strategy, determining the page loading state according to the page triggering event in the first identification adding strategy, and when the page loading state is the third loading state, calling the identification adding function; When the identification adding strategy is the second identification adding strategy, identifying the loading change state and the monitoring times in the second identification adding strategy, and when the loading change state is the third loading state or the monitoring times reaches a preset monitoring times threshold, calling the identification adding function; When the identifier adding strategy is the third identifier adding strategy, the identifier adding function is called according to the function calling condition in the third identifier adding strategy.
7. The method for adding a mark indicating that page loading is completed according to claim 1, wherein: The adding of a preset target identifier to the resource network address of the target test page by the identifier adding function includes: Extracting a first position corresponding to a first symbol preset in the resource network address of the target test page, and extracting a second position corresponding to a second symbol preset in the target test page; identifying a relative positional relationship between the first position and the second position; Determining identification content corresponding to a preset target identification according to the relative position relationship; The identification content is added to the end of the resource network address through the identification adding function.
8. A device for adding a mark after page loading is completed, characterized in that: include: A target test page extraction module is used to obtain test requirement data of the automated test and extract the target test page of the automated test according to the test requirement data; A text language file and page element extraction module, used to extract the text language file and page elements corresponding to the target test page; A loading progress monitoring module, configured to monitor the loading progress of the target test page according to the loading status attributes of the text language file and the page elements; an identification adding function calling module, configured to determine an identification adding strategy for the target test page according to the loading progress, and call an identification adding function according to the identification adding strategy; The target identifier adding module is used to add a preset target identifier to the resource network address of the target test page through the identifier adding function.
9. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein: When the processor executes the computer program, the method for adding a page loading completion identifier as described in any one of claims 1 to 7 is implemented.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method for adding a page loading completion identifier as described in any one of claims 1 to 7 is implemented.