Web page logic state diagram automatic establishment and arbitrary state path test method
By constructing a logical state diagram of a web page, collecting evidence using browsers and web crawlers, and utilizing a semantic analysis model, the problem of automatically determining the state of a web application in existing technologies is solved, achieving efficient test coverage and verification.
Patent Information
- Application Number
- CN202611646540.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-10-23
- Publication Date
- 2026-11-24
AI Technical Summary
Existing web automation testing solutions struggle to convert runtime evidence of browser pages, data interfaces, user identities, and access permissions into automatically identifiable page logic state points, and they also struggle to establish executable state transition relationships and logical paths, resulting in incomplete test coverage.
By linking the browser execution end and the crawler end, page features, interface features, identity features and interaction snapshots are collected to construct structured evidence units. Semantic analysis models are used to generate candidate state points and transition relationships, establish page logical state diagrams, and automatically execute specified or divergent path tests.
It achieves unified modeling of the page state, interface state, user identity and permission state of web applications, and can automatically reach the specified state point, reducing manual operation and improving test coverage and review efficiency.
Smart Images

Figure CN123158014A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of automated testing of web applications and network security testing, specifically to a method for automatically establishing a logical state diagram of a web page and testing arbitrary state paths. Background Technology
[0002] As web applications increasingly adopt front-end / back-end separation, dynamic front-end routing, asynchronous API calls, and multi-role access control, the same page's Uniform Resource Locator (URL) may display different accessible content depending on the user's identity, session data, or business stage. Similarly, the same data interface may return different data ranges based on user roles, resource ownership, or business process location. Therefore, when testing web applications, relying solely on the page's URL or visual content is insufficient to fully represent the user's current state across the page, interface, identity, and permissions.
[0003] Existing web automation testing solutions typically discover pages and interfaces through web crawlers, replay existing paths by manually recording operation sequences, or perform parameter tests around a single interface. The navigation relationships generated by web crawlers mainly reflect changes in page entry points or document object models, and usually do not uniformly incorporate user identity, browser storage, interface response, and permission differences into the state definition; manual recording and playback can reproduce paths that have already been executed, but it is difficult to automatically generate unrecorded transition paths from a known state point; single interface testing is also prone to being separated from browser page state, dynamic tokens, front-end routing, and intermediate business states.
[0004] In complex web applications with multiple user groups, such as regular users, administrators, and tenants, testers often need to manually determine the current logical state, which states are legally accessible from the current state, and whether an unexpected redirect constitutes an unauthorized access. State determination, path organization, and evidence aggregation all require repeated manual operations and are prone to overlooking paths such as unauthorized access to sensitive pages, low-privilege users accessing high-privilege interfaces, cross-user reading of business data, and bypassing predetermined processes to reach business completion states.
[0005] Therefore, how to convert the operational evidence of browser pages, data interfaces, user identities, and access permissions into page logical state points that can be automatically determined, further establish executable state transition relationships and logical paths to any established state point, and uniformly execute specified path tests and unknown path divergence tests based on the established page logical state diagram are technical problems that need to be solved in web application automated testing. Summary of the Invention
[0006] The purpose of this invention is to provide a method for automatically building a logical state diagram of a web page and testing arbitrary state paths, so as to solve the problems of existing technologies that make it difficult to uniformly model the page state, interface state, user identity state and permission state of web applications, and difficult to automatically reach the specified state point and verify the legal path and the undefined path.
[0007] To achieve the above objectives, this invention provides a method for automatically establishing a logical state diagram of a web page and testing arbitrary state paths, comprising: The browser execution end and the crawler end are linked and launched to collect page features, interface features, identity features, permission features and interaction snapshots for the target website under multiple user themes, and construct structured evidence units according to user themes and operation sequence; The structured evidence unit is input into the semantic analysis model to obtain candidate state points and candidate transition relationships; The state judgment conditions and state judgment script descriptions of candidate state points are converted into executable state judgment scripts, and the page logic state points are solidified based on the consistency between the script execution results and the structured evidence units. Establish state transition edges based on the candidate transition relationships and the execution operations and state changes between logical state points of adjacent pages, and determine the set of legal targets based on user themes and preset legal business processes; The state transition edges are combined to generate a logical execution path and a state journey template leading to the target state point, and the page logical state point, state transition edges, logical execution path and state journey template are saved as a page logical state diagram file; Receive a path test task containing the target state point to be tested, and execute the corresponding logical execution path according to the state to reach the target state point to be tested; perform divergent path test or specified logical execution path test at the target state point to be tested, and determine the actual arrival state after state transition; The actual arrival state is compared with the set of legal targets; for actual arrival states that do not belong to the set of legal targets, an illegal state transition result or a result to be reviewed is generated based on the output of the executable state judgment script and the judgment result of the semantic analysis model.
[0008] Optionally, the page features include page Uniform Resource Locator, front-end routes, page title, page text summary, and document object model key nodes; The interface features include the interface Uniform Resource Locator, request method, request parameters, response status code, business error code, and response field summary; The identity features include Cookie, Identity Token, Authorization Request Header, LocalStorage, SessionStorage, User Identifier, Role Identifier, and Tenant Identifier; The permission features include differences in response status, data range, and permission fields when different user subjects access the same page or interface; The interaction snapshots include a sequence of browsing events, as well as page snapshots, interface snapshots, and identity snapshots before and after each browsing event.
[0009] Optionally, inputting the structured evidence unit into the semantic analysis model includes: A fixed task template is used to combine the structured evidence units, candidate state type definitions, transition condition definitions, account sets, legitimate business processes, and output structure constraints into model inputs; The semantic analysis model is controlled to output the state name, user topic, state type, state meaning, evidence, judgment conditions, script description, state label and confidence level of each candidate state point according to the preset structure, and output the starting state, target state, transition triggering method, required identity, required variables, success conditions, failure conditions and legality tendency of each candidate transition relationship. Candidate state points and candidate transition relationships that are below the confidence threshold or lack executable evidence are marked as pending manual confirmation.
[0010] Optionally, converting the state judgment condition and the state judgment script description into an executable state judgment script includes: The judgment conditions for page Uniform Resource Locator, page text, Document Object Model node, Cookie, Identity Token, browser storage items, interface response status and interface response field are respectively converted into corresponding read statements and comparison statements, and the fixed conditions for confirming page logical state points are preset. Generate Boolean judgment logic based on the conditional combination relationship of the candidate state points; execute the Boolean judgment logic and output the state identifier, matching result and evidence value of each judgment condition; When the matching result is true and the evidence value matches the structured evidence unit on which the candidate state point is based, the solidification condition is met, and the candidate state point is solidified as a page logical state point.
[0011] Optionally, establishing a state transition edge includes: Extract page jumps, button clicks, form submissions, front-end route changes, and API calls from the interaction snapshots as transition trigger events; The start and target state points are determined by the executable state judgment script before and after the execution of each transfer trigger event. Record the transfer conditions, transfer method, required identity, input variable template, success judgment conditions, and failure judgment conditions corresponding to the transfer trigger event; determine the set of legal targets for the starting state point under the corresponding user topic and transfer trigger event based on the legal business process; when the target state point belongs to the set of legal targets, mark the state transfer edge as legal; when the target state point does not belong to the set of legal targets and there is a transition from an unlogged-in state to a sensitive state, a transition from a low-privilege state to a high-privilege state, or the current user topic accessing other user topic data, mark the state transfer edge as illegal or pending confirmation.
[0012] Optionally, the combination of the state transition edges to generate a logical execution path includes: Filter the state transition edges that match the user topics and preconditions of the target state point, and generate multiple candidate paths according to the connection relationship of the state transition edges; The candidate paths are sorted sequentially based on the number of state transition edges contained in the path, historical execution success rate, state stability, and number of session resets; the candidate path ranked first is set as the default logical execution path, and the process is switched to the other candidate paths when the default logical execution path fails.
[0013] Optionally, the step of proceeding to the template to execute the corresponding logical execution path based on the state includes: Based on the current page logical state point, select a starting state from the available starting states recorded in the template; Fill the test account, business object identifier, and path parameters into the path variable; The transition methods recorded on each state transition edge are executed sequentially according to the logical execution path, and the executable state judgment script for the corresponding target state point is run after each state transition edge is executed. If any executable state judgment script fails, the failure rollback method is executed to restore to a known state point, and the current logic execution path is re-executed or switched to another candidate path.
[0014] Optionally, performing the divergence path test includes: Extract variable path parameters, request parameters, request methods, user identities, and page trigger events from the target state point to be tested to form a variable input set; and inject the business object values of the same user theme, the business object values of different user themes, boundary values, or alternative trigger methods into the corresponding transfer methods according to the variable template. After the injection, the transfer method is executed and the actual reached state is identified by the executable state judgment script of the solidified page logic state point. If no solidified page logic state point is matched, a candidate new state point is generated based on the structured evidence unit executed this time.
[0015] Optionally, the step of performing path testing according to the specified logical execution path includes: Read the start state point, end state point, intermediate state point sequence, transition conditions of each segment, transition methods of each segment, and executable state judgment script of each segment corresponding to the specified logical execution path; Execute state transitions segment by segment and verify the target state point after each segment is executed; When the actual reached state deviates from the intermediate state point sequence, an illegal state transition judgment is entered; the specified logical execution path test is recorded as complete only when all intermediate state points and state transition edges pass the verification.
[0016] Optionally, it also includes: For the illegal state transition result or the result to be reviewed, save the replayable execution path, the user topic corresponding to the test account, the request data, the response data, the page snapshot, the output of the executable state judgment script, and the output of the semantic analysis model as evidence of the problem; Receive the results of manual review, and confirm the legal status, confirm the illegal status, adjust the executable status judgment script or supplement the status transition conditions based on the results of manual review; write the results of manual review back to the page logic state diagram file, rule base and sample library, and use the review reason as the constraint information of the subsequent fixed task template.
[0017] The present invention has achieved the following beneficial effects: By associating and collecting operational evidence of browser pages, data interfaces, user identities, and access permissions, and verifying candidate states generated by the semantic analysis model using executable state judgment scripts, it is possible to form page logical state points centered on user themes and repeatedly judged by the program. By recording transition conditions, execution methods, input variables, and legality markers in state transition edges, and further generating logical execution paths and state progression templates, it is possible to automatically reach the specified state point from the initial or known state, reducing manual recording and repeated state location operations. After performing variable injection, identity switching, and trigger condition changes at the specified state point, the actual state is compared with the set of legal targets, which can simultaneously cover fixed business paths and undefined paths, and retain replayable page, interface, and script evidence for unexpected states, thereby improving the coverage and review efficiency of permission and business process testing for complex web applications. Attached Figure Description
[0018] Figure 1 This is the overall flowchart of the Web page logic state diagram automatic creation and arbitrary state path testing method of the present invention; Figure 2 This is a flowchart of the multi-source operational evidence collection and structured evidence unit construction process of the present invention; Figure 3 This is a flowchart of the candidate state point generation, script verification, and state solidification process of the present invention. Figure 4 This is a schematic diagram of the page logic state, logic execution path, and state-to-template relationship of the present invention. Figure 5 This is a flowchart of the test process for arbitrary target state travel and divergence paths in this invention; Figure 6 This is a flowchart illustrating the joint assessment and feedback update process for legal or illegal status transitions in this invention. Detailed Implementation
[0019] The present invention will be further described below with reference to the accompanying drawings and specific embodiments. The described embodiments are used to illustrate the technical solutions of the present invention, and are not intended to limit the scope of protection of the present invention. Without departing from the technical concept of the present invention, those skilled in the art can make equivalent substitutions for the data acquisition method, model deployment method, scripting language, and graph data storage method.
[0020] In this embodiment, the target website is a web application authorized to conduct automated testing. A user topic is an identity context that can influence page display, API responses, or business process permissions. It can correspond to an unlogged-in visitor, a regular logged-in user, a low-privilege user, a high-privilege user, a specific tenant user, or a user with specific business resource ownership. An arbitrary state point refers to a page logic state point that has been written into the page logic state diagram file and has at least one usable logical execution path; it is not an arbitrary abstract state that is detached from the operational constraints of the target website.
[0021] Page logical state points describe the state of a target website under a user topic that can be determined by runtime evidence. Page logical state points can correspond to page states, interface access states, or intermediate states in a business process. For example, an unlogged-in user accessing an order page and being redirected to the login portal can create a "login required" state; a regular user holding a valid identity token who can read their own orders but not the management interface can create a "low-priority" state for the order data interface; and a user submitting a business form but not yet confirming it can create an intermediate state in the business process.
[0022] A state transition edge represents the conditions and execution methods required for a target website to transition from one page logical state point to another. A logical execution path represents an ordered set of one or more interconnected state transition edges. A state journey template is an executable template compiled for a target state point, which at least records the available starting state, journey path, path variables, arrival judgment script, and failure fallback method. The set of legal targets is a pre-determined set of allowed reachable state points for a given starting state point and triggering method, based on legal business processes and the current user topic.
[0023] This embodiment can be deployed on a test server. The test server is equipped with a browser automation execution component, a web crawler component, a network request collection component, an evidence structuring component, a semantic analysis component, a script generation and execution component, a state graph construction component, a path execution component, and a result recording component. The browser automation execution component can control page opening, element clicks, text input, and wait events through browser drivers; the web crawler component is used to discover page entry points, front-end routes, and interface entry points; the network request collection component is used to record requests and responses; the state graph construction component can use a graph database, structured files, or a relational database to store state points and state transition edges.
[0024] Semantic analysis models are used to summarize pruned and evidence-based structured features into candidate state points and candidate transition relationships. These models can employ pre-trained language models capable of receiving structured textual input and outputting structured results. In one implementation, the semantic analysis model is a pre-trained model based on a Transformer architecture, including an input encoding layer, multiple self-attention units, a feedforward processing unit, and an output decoding layer. This method does not require retraining the model for the target website. Instead, it constrains the model output through fixed task templates, state type definitions, output structure constraints, and subsequent script validation, ensuring that executable conclusions in the state graph are still determined by runtime evidence and script results.
[0025] like Figure 1 As shown, the method for automatically establishing the logical state diagram of a web page and testing arbitrary state paths in this embodiment includes steps S101 to S107.
[0026] Step S101: Associate and launch the browser execution end and the crawler end, perform page access and interaction for the target website under multiple user themes, and collect page features, interface features, identity features, permission features, and interaction snapshots before and after execution.
[0027] Before the test begins, testers input the target website's starting Uniform Resource Locator (URL), the allowed domain range for testing, the set of accounts, and the scope of business objects. Each account in the account set is assigned a user subject identifier, such as anonymous, user_low, user_high, or tenant_A. Access without logging in is also treated as a separate user subject. For sites requiring dynamic CAPTCHAs or external authentication, a manual login can be performed once, after which the authorized session can be handed over to the browser execution end for further data collection.
[0028] The browser execution end and the crawler end are associated through the same test task identifier. Each time the browser execution end performs a page jump, element click, form submission, or script trigger operation, it generates an operation identifier and a timestamp; the pages, routes, and API entry points discovered by the crawler end are also written into the same test task identifier. The network request collection component writes the operation identifier into the corresponding request record, enabling page operations, request responses, and identity storage changes to be associated in chronological order.
[0029] like Figure 2 As shown, page features include at least the page's Uniform Resource Locator (URL), front-end routes, page title, main text summary, and key nodes in the Document Object Model (DOM). Key nodes in the DOM can be login forms, user avatars, role menus, order lists, management menus, business confirmation buttons, or error message nodes. For frequently changing time, random numbers, or advertising nodes on the page, preset ignore rules can be used to exclude them from status determination evidence, thereby reducing the probability of the same status being repeatedly split.
[0030] Interface characteristics include at least the interface Uniform Resource Locator (URI), HTTP request method, request parameters, request header digest, response status code, business error code, response field digest, and returned data range. The returned data range is used to distinguish between empty data, anonymized data, current user data, cross-user data, and management data. For interfaces with large response bodies, field paths, field types, user identifier fields, role fields, resource identifier fields, and corresponding digests can be retained; the complete response body does not need to be input into the semantic analysis model. The complete response body remains in the original evidence for replay verification.
[0031] Identity characteristics include at least cookies, identity tokens, Authorization request headers, LocalStorage, SessionStorage, Set-Cookie changes, user identifiers, role identifiers, and tenant identifiers. When collecting identity characteristics, passwords, full tokens, and personally sensitive fields can be anonymized, retaining only their existence, hash digest, field name, expiration time, and role information. The status judgment script reads the actual values from the current session during execution, but issue reports can save only the anonymized values.
[0032] Permission characteristics are obtained by different user topics accessing the same page or interface. The network request collection component records the response statuses (200, 302, 401, 403, etc.) for different user topics, as well as differences such as empty data, anonymized data, complete data, and the presence or absence of administrator fields. For data objects returned by the same interface, it can also record whether the resource owner's identifier matches the current user topic to support subsequent identification of cross-user access status.
[0033] Interaction snapshots include page snapshots, API snapshots, and identity snapshots before and after each operation. Page snapshots save the Uniform Resource Locator (URI), front-end routes, page title, existence of key nodes, and text digest; API snapshots save the request and response set related to this operation; and identity snapshots save the identity fields and browser storage changes before and after the operation. By using snapshots before and after execution, it's possible to determine whether an operation has triggered a state change, rather than solely relying on changes to the page's URI.
[0034] Step S102: Construct structured evidence units according to user topics, operation identifiers, and time relationships.
[0035] The evidence structure component uses a pre-execution snapshot, execution action, and post-execution snapshot corresponding to an operation identifier as basic evidence units. In cases where a single page operation triggers multiple asynchronous interface requests, request responses that are within a preset association time window and match the source page, request initiation stack, or business object identifier are merged into the same evidence unit. The preset association time window can be set based on the average response time of the target site, for example, lasting three to ten seconds from the moment the operation occurs; when a clear completion indicator appears on the page, the completion event can also be used as the window's end condition.
[0036] A structured evidence unit includes at least a task identifier, an operation identifier, a user topic, pre-execution page characteristics, pre-execution identity characteristics, an execution action, a request-response set, post-execution page characteristics, post-execution identity characteristics, known tags, and task constraints. Known tags are pre-defined tags provided by the rule component based on explicit evidence; for example, an `unauthorized` candidate tag is given when an API returns a 401 error, and a `login_required` candidate tag is given when a login form exists on the page. Task constraints include allowed legal processes, sensitive pages to be observed, account sets, and the scope of business objects.
[0037] To ensure that identical states can be merged across different data collection rounds, the page's Uniform Resource Locator (URL) can be standardized. Session random parameters, tracking parameters, or timestamp parameters can be separated from the state location information, while retaining business-related path parameters. Key nodes in the Document Object Model (DOM) are represented using node selectors, accessibility names, or stable attributes. For interface features, request path templates and specific business object values are stored separately, enabling subsequent identification of the interface's logical location while also allowing the specific business object values to be used as divergent test variables.
[0038] Step S103: Input the structured evidence unit into the semantic analysis model to obtain candidate state points and candidate transition relationships.
[0039] The fixed task template consists of a state recognition task description, state type definitions, transition condition definitions, output structure constraints, and decision requirements. The state recognition task description requires the model to identify page logical states centered on the user's theme, rather than merely identifying page visual styles. State types can include: not logged in, page requiring login, page logged in, low-priority data interface, high-priority data interface, intermediate business process state, completed business process state, permission exception state, and unknown state.
[0040] In one model input, the system fills a fixed task template with the target site identifier, the account's user topic, structured evidence units, legitimate business processes, and the sensitive states to be observed. The model output uses a preset structure, with candidate state point fields including at least the state identifier, state name, user topic, state type, state meaning, page or interface location, evidence, judgment conditions, script description, state label, confidence level, and reason for requiring manual confirmation. Candidate transfer relationship fields include at least the transfer identifier, starting state, target state, triggering method, transfer method, required identity, path, input variables, success conditions, failure conditions, legitimacy bias, and confidence level.
[0041] Fixed task templates can require the semantic analysis model to output only JSON, YAML, or other parsable structures, without outputting interpretable natural language. After receiving the model output, the system first performs a structure check: candidate state points lacking state identifiers, user topics, evidence, or judgment conditions are not included in script generation; candidate transition relationships where the starting or target state cannot correspond to a candidate state point are not included in transition edge creation. After the structure check passes, field type, enumeration value, and reference relationship checks are then performed.
[0042] The confidence level is used to determine the processing order of candidate results, but is not used as the sole basis for state solidification. In one configuration, candidate results with a confidence level of not less than 0.85 enter automatic script verification; candidate results with a confidence level between 0.60 and 0.85 are still marked as awaiting manual confirmation after the script verification passes; candidate results with a confidence level below 0.60 or lacking operational evidence are not written into the formal state diagram. The above thresholds can be adjusted based on historical review results.
[0043] Step S104: Convert the state judgment conditions and state judgment script description of the candidate state point into an executable state judgment script and execute it in the corresponding context; set the matching result of the script output as true and the evidence value matching the structured evidence unit on which the candidate state point is based as the solidification condition; when the solidification condition is met, solidify the candidate state point as a page logical state point.
[0044] The status judgment script generator has preset evidence reading interfaces. The page evidence reading interface is used to read the current Uniform Resource Locator, front-end route, page text, and Document Object Model nodes; the identity reading interface is used to read cookies, token existence, role identifiers, and browser stored items; the interface evidence reading interface is used to read the request-response status, business error code, and response fields associated with the current operation. The script generator maps the natural language judgment conditions given by the model to the above reading interfaces and comparison statements.
[0045] For example, the order status of a regular user can be determined by a combination of the following conditions: a valid identity token exists in the current session; the role identifier is a regular user; the page's Uniform Resource Locator (URL) or text indicates that the user is on the order page; the order interface returns success; and the management interface returns unauthorized or prohibited access. After script execution, it returns a status identifier, the matched result, and evidence values such as hasLogin, isOrderPage, orderApiOK, and adminDenied. Only when matched is true and the evidence value matches the structured evidence unit used to generate the candidate status point will the candidate status point be solidified as a page logical status point.
[0046] When multiple candidate status points are matched simultaneously in the same context, the system compares the user topic, location field, evidence completeness, and status type of each candidate status point. If one status point is a more specific state of another status point, such as the "logged-in" status on the page matching the low-weight status of the order data interface, the more specific status can be taken as the current status, while retaining the "logged-in" label on the page. If the candidate statuses are mutually exclusive, the conflicting results are marked as pending manual confirmation and are not forced to be selected.
[0047] After a status point is solidified, it contains the status name, user topic, status meaning, page or interface location, permission level, status label, metadata, status judgment conditions, and an executable status judgment script. Metadata may include the first discovery time, most recent verification time, discovery source, script version, historical matching count, and historical failure count. The script version increments when the judgment conditions or page element positioning method are adjusted to facilitate reproduction from historical test records.
[0048] Step S105: Establish state transition edges based on the executed operations and state change evidence between adjacent page logical state points, and generate logical execution paths and state transition templates.
[0049] Candidate transition relationships, after structural validation, serve only as initial descriptions of state transition edges and are confirmed by executed operations and state change evidence between adjacent page logical state points. The starting state point of a state transition edge is determined by the state judgment script corresponding to the pre-execution snapshot, and the target state point is determined by the state judgment script corresponding to the post-execution snapshot. Transition triggering methods can include page navigation, button clicks, form input and submission, API requests, front-end routing triggers, or template variable injection. State transition edges record transition conditions, transition methods, required identities, input variable templates, success judgment conditions, failure judgment conditions, and post-execution judgment scripts.
[0050] The legitimacy of state transition edges and the set of legitimate goals are first determined based on manually configured legitimate business processes. Legitimate business processes can define allowed starting states, triggering methods, and target states according to user themes. The set of legitimate goals consists of the target states that can be reached from the same starting state point under the corresponding user theme and triggering method. For example, accessing an order page from an unlogged-in state to a page requiring login is a legitimate transition; submitting ordinary user credentials to a logged-in ordinary user state from a page requiring login is a legitimate transition; and querying one's own orders from a logged-in ordinary user state to a low-priority state in the order data interface is a legitimate transition.
[0051] When a transfer relationship is not part of a legitimate business process, the system performs a preliminary classification based on status tags and user topics. Transfers from an unlogged-in state to a state labeled "sensitive" or "authenticated," low-privilege users to a state labeled "admin" or "high_privilege," and the current user topic reading data whose resource ownership identifier points to another user topic, can all be marked as transfers pending verification. Only after the corresponding state is actually reached in subsequent tests and the status judgment script passes will an illegal status transfer result or a result pending review be output.
[0052] like Figure 4As shown, the page logic state diagram file can contain states A through F. State A represents the unlogged-in state, state B represents the state where login is required, state C represents the state where a regular user is logged in, state D represents the state of the user's order interface with low privileges, and state F represents the state of the administrator's page with high privileges. The transitions from state A to state B, from state B to state C, and from state C to state D are marked as valid state transition edges; the transition from state C to state F is marked as a state transition edge that is pending verification or is invalid.
[0053] The state graph construction component generates logical execution paths based on the connection relationships of state transition edges. For the same target state point, it first filters state transition edges that match the user topic and preconditions, and then generates candidate paths for unique state points. When sorting paths, it first compares the number of state transition edges contained, prioritizing those with fewer edges; if the number of edges is the same, it prioritizes those with higher historical execution success rates; if still the same, it prioritizes those with higher historical stability of state judgment scripts and fewer session resets.
[0054] Each logical execution path records the starting state, ending state, intermediate state sequence, transition method for each segment, input variables for each segment, state judgment script for each segment, and failure rollback method. Logical execution paths A through B through C through D can be used to automatically transition from an unlogged-in state to a low-priority state of the user's order interface. For the same target state point, multiple candidate paths can be retained to accommodate situations such as changes to the login page, the existence of a session, or the temporary unavailability of a certain page entry point.
[0055] The status travel template is generated based on the target status point. When the target is status C, the template record can include the starting status A or B, the travel path A to B to C, the path variables low_user and low_pass, the arrival judgment script, and a method to clear the login status and reopen the homepage when failure occurs. When the target is status D, the template record can include the starting status A, B, or C, the travel path A to B to C to D, the path variables low_user, low_pass, and own_order_id, and a method to return to status C and re-request the order interface when failure occurs.
[0056] In addition to state points, state transition edges, logic execution paths, and state journey templates, the page logic state diagram file can also save state labels, path conditions, script versions, and test records. The page logic state diagram file is the output of the state discovery phase and serves as the input for subsequent phases including automatic journey to the target state, fixed logic path testing, divergent path testing, and illegal state discovery.
[0057] Step S106: Receive the path test task, automatically reach the target state point to be tested according to the status template, and perform divergent path test or specified logical path test.
[0058] like Figure 5As shown, the path execution component first reads the target state point, allowed user themes, business object scope, and test type. If the current browser context is already in an available starting state recorded in the state forwarding template, the current context is reused; otherwise, the page cache, session cookies, and related browser storage are cleared, the browser is restored to its initial state, and the default logic execution path is executed.
[0059] The path variables are populated with account information and business object information provided by the test task. After the variables are populated, the path execution component executes the state transition edges segment by segment. After each transition is completed, it waits for the page to stabilize or for the relevant interface to respond before executing the state judgment script for the target state point. Only after the target state script passes will the next segment be executed; if the script fails, the current evidence is saved, the failure fallback method is executed, and the current path is re-executed or switched to another candidate path based on the number of retries.
[0060] Upon reaching the target state point, perform a divergence path test. The variable input set for the divergence test includes at least path parameters, query parameters, request body fields, HTTP request methods, user identity, and page trigger events. Variable values can come from business object identifiers discovered by the crawler, business object identifiers of the current user's topic, business object identifiers of other user topics authorized for testing, boundary values, and null values. Page trigger events can include original page buttons, alternative buttons, direct navigation, or API calls.
[0061] Variable templates replace specific values in the original transfer methods with controllable variables. For example, in the order query transfer method, `order_id` is replaced with `own_order_id`, `other_user_order_id`, or `boundary_order_id`; a regular user's identity token can be replaced with the identity token of another authorized test account while keeping the page context unchanged; and GET requests can be replaced with POST or other candidate methods within the scope of the interface's testing requirements. Only one variable is changed at a time, or multiple related variables are changed according to a preset combination, in order to determine the input that triggers the state change.
[0062] After executing the injection-based transfer method, the system runs a set of state judgment scripts for the solidified state points. To reduce execution load, candidate scripts can be filtered based on page location, interface path, and user topic before execution. If at least one script matches, the matching result is determined as the actual reached state; if no script matches, the structured evidence unit generated in this execution is re-inputted into step S103 to generate new candidate state points, and a decision is made on whether to expand the state diagram after script verification.
[0063] The specified logical path test is used to verify predefined business processes. The path execution component reads the start state, end state, intermediate state sequence, transition conditions, transition methods, and judgment script of the specified logical execution path, and executes the state transition segment by segment. If each segment reaches the expected target state and is marked as valid, the logical path test is recorded as complete; if the actual state deviates from the intermediate state sequence, the original path is paused and an illegal state transition judgment is initiated.
[0064] Step S107: Compare the actual arrival status with the set of legitimate targets, and output the test results by combining script evidence and semantic analysis model.
[0065] like Figure 6 As shown, the inputs for joint analysis include the actual state and transfer evidence, the set of legitimate targets corresponding to the current transfer, user topics, permissions and sensitive tags, state judgment script output, and semantic analysis model analysis results. At this stage, the semantic analysis model receives actual state metadata, interface response summaries, current user topics, legitimate transfer definitions, and script evidence to determine whether unexpected states involve privilege escalation, cross-user access, process bypass, or are simply new legitimate business branches.
[0066] When the actual arrived state belongs to the set of legitimate targets, the current state transition verification is recorded as successful. When the actual arrived state does not belong to the set of legitimate targets but is confirmed as a new legitimate branch by business rules, it is written into the state graph as a legitimate candidate transition, and the discovery source is retained. When the actual state contains tags such as admin, high_privilege, and sensitive, and the current user's topic does not have the corresponding permissions, and the state judgment script confirms that the high-privilege page, interface, or data has actually appeared, an invalid state transition result is generated.
[0067] If the semantic analysis model has insufficient confidence, the model results conflict with the state judgment script results, multiple state scripts match mutually exclusively, or the actual state involves funds, orders, personal information, or other high-risk and sensitive business, a pending review result will be generated. The pending review result will not directly modify the formal legal process, but will instead be entered into the manual review queue along with complete evidence.
[0068] Evidence of the problem should include at least the replayable execution path, the user topic corresponding to the test account, variable values, request data, response data, page snapshots, identity snapshots, the version and output of the status judgment script, and the input summary and output results of the semantic analysis model. Testers can use this evidence to re-execute the same path to confirm whether the problem can be consistently reproduced.
[0069] Manual review can confirm legal states, identify illegal states, adjust state judgment scripts, supplement state transition conditions, or mark states as unstable. Manually entered review reasons and correction results are written back to the page logic state diagram file, rule base, and sample library. When generating fixed task templates subsequently, similar false alarm reasons or legal branches are extracted from the sample library as constraint information to reduce the repeated generation of review results under identical conditions.
[0070] The following example uses a target website that includes both regular user order functionality and administrator order functionality to illustrate the execution process of this method. The test task is configured with three user themes: logged-out users, regular users, and administrators, and the homepage, login page, user center page, order page, and administrator page are included in the allowed test scope.
[0071] The browser executes an application that opens the order page as an unauthenticated user. The page displays a login form, but the order API returns a 401 error, indicating that no valid authentication token exists in the browser's storage. Based on this, the system generates candidate evidence for state A and state B, where state A represents unauthenticated access and state B represents a login-required state. The script for state B checks for the absence of an authentication token and whether the page contains a login form or the order API returned a 401 error. After the script executes and matches the criteria, state B is permanently assigned.
[0072] The browser then accepts a login request with a regular user's username and password. The login API returns a 200 error, the browser stores a valid identity token, the role field shows "regular user," and the page redirects to the order page. The system generates status C, indicating that the regular user is logged in. The script that checks status C verifies the existence of the identity token, the user's role being "regular user," the presence of key nodes on the order page, the order API returning a 200 error, and the administrator API returning a 401 or 403 error.
[0073] When a regular user queries their own orders, the order interface returns order data that matches the current user's identifier, and the system generates status D, indicating a low-priority status for the user's own orders interface. The script for status D, in addition to checking the regular user's identity and the success of the order interface, also compares the user identifier in the returned order with the user identifier in the current user's identity. When an administrator user accesses the administrator order interface, status F is generated, indicating a high-priority status for the administrator page. The script for status F checks the administrator's role, the administrator menu or the high-priority interface response, and the management data fields.
[0074] The system establishes state transitions A to B, B to C, and C to D based on actual operations. The condition for state transition A to B is that an unlogged-in user accesses a page requiring login; the transition method is navigation to the order page, and the validity is marked as valid. The condition for state transition B to C is that a regular user enters their credentials and submits the login; the input variable template includes `low_user` and `low_pass`, and the validity is marked as valid. The condition for state transition C to D is that a regular user queries their own orders; the input variable template includes `own_order_id`, and the validity is marked as valid.
[0075] The system simultaneously generates a state transition relationship from C to F that needs to be verified. The starting state is C, the target state is F, the transition condition is that a regular user accesses the administrator's order interface by changing path parameters or request parameters, the transition method is to request the administrator interface with the regular user's session, the input variable template includes other_user_id or admin_path, the legality tendency is illegal or pending verification, and the judgment script after execution is the judgment script for state F.
[0076] For state C, the system generates a state travel template To-C. The starting state can be state A or state B, the travel path is A to B to C, the path variables are low_user and low_pass, the arrival judgment script is the same as the state C judgment script, and the failure rollback method is to clear the login state and reopen the homepage. For state D, a state travel template To-D is generated, the travel path is A to B to C to D, and the path variables also include own_order_id.
[0077] During divergence testing, the path execution component automatically reaches state C based on To-C. Subsequently, it extracts order_id, user_id, role, and method from the order path and API request to form a variable input set. The system injects the user's own order identifier, another authorized test user's order identifier, the administrator's path, and an alternative request method, and runs judgment scripts for states D and F after each execution.
[0078] In one test, a regular user session obtained the administrator order field by changing the request path and user identifier parameters. The judgment script for state F returned a match, but the actual state did not belong to the legitimate target set corresponding to state C. The joint judgment component read the current user topic, administrator field, interface response, state F script evidence, and legitimate transition definition, generated an illegal state transition result, and saved the complete replay path from state A to state B, state B to state C, and state C to state F.
[0079] In another test, the system automatically reached state B based on To-D, then reached state C after a regular user logged in, and finally reached state D after checking the user's own order. All state judgment scripts in the path passed, and the actual state matched each valid target segment. The system recorded the logical execution path A to B to C to D, indicating the test was complete.
[0080] For unknown page states discovered through divergent testing, the system does not immediately classify them as illegal. The system first generates candidate new state points and their judgment scripts. If the scripts can reliably match and the state belongs to a newly added legitimate function for ordinary users, the state diagram is expanded after manual or rule-based confirmation. If the scripts confirm that the state exposes data that the current user's topic does not have permission to access, an illegal state transition result is generated. Thus, the page logical state diagram can be incrementally updated as the legitimate business of the target website changes.
[0081] In a test log, the target web system contained 38 page entry points, 64 interface entry points, 3 types of user identities, and 6 intermediate business process states. Traditional manual methods recorded 28 page logical state points and 50 state transition paths, taking approximately 6 hours for manual operation and organization. Interface and static rule testing identified 9 interface-related state points and 11 interface access paths, requiring approximately 3 hours for manual configuration. The method described in this embodiment automatically generated 31 page logical state points and 86 state transition paths, requiring approximately 1 hour for manual configuration and review. The above log demonstrates that this method can establish a unified association between pages, interfaces, identities, storage, and intermediate business process states, while reducing the need for operation sequence organization and repetitive path replay.
[0082] The semantic analysis model in this method does not replace state script verification and manual high-risk review. The model is mainly used to summarize the meaning of candidate states, candidate transition conditions, and script descriptions from multi-source evidence. Formal state points are determined jointly by executable scripts and operational evidence. Even if the model's judgment speed for a single business problem is not higher than that of human experts, state diagram generation, script generation, state navigation, path replay, variable injection, and evidence merging can still be executed concurrently by the program. Human personnel only need to handle low-confidence, conflicting, or high-risk results.
[0083] In one operating configuration, the test server has 8GB of memory, a dual-core processor, and 512GB of storage, enabling the launch of four isolated browser processes to concurrently execute on four authorized targets or four user topics. Each browser process uses an independent user data directory and an independent session identifier to avoid identity contamination. The actual number of concurrent requests can be adjusted based on the target site's allowed access frequency, server resources, and the scope of the test authorization.
[0084] This method can also be used for continuous regression testing. After the target website version is updated, the system re-executes the existing state to proceed to the template and logic execution path, locating page elements, interface responses, or identity storage changes based on the script failure location. For state points that can still be matched, the original state identifier is retained; for state points where the page location has changed but the state meaning and permission evidence remain unchanged, their location and script version are updated; for newly added legitimate states, they are incrementally written into the state graph after verification.
[0085] The page logic state diagram file can be saved as a JSON file or a graph database. When using a JSON file, the `states` array stores state points, the `transitions` array stores state transition edges, the `routes` array stores the logic execution path, the `reachTemplates` array stores the state-to-templates, and the `testRecords` array stores test records. When using a graph database, state points are treated as nodes, state transition edges as edges, and the logic execution path and state-to-templates are treated as attributes or independent entities associated with the nodes and edges. Different storage methods do not change the state definition and test flow of this method.
[0086] Status assessment scripts can use JavaScript, TypeScript, Python, or other scripting languages supported by the testing framework. Scripts used for page status assessment execute in a controlled browser context, while scripts used for API status assessment read the collected responses within the test execution component and are not required to modify target site data. For test operations that may involve business logic writes, test accounts, test data, or isolated environments should be used, and the authorized scope of the target site should be adhered to.
[0087] Fixed task templates, status types, and legitimate business processes can all be configured according to the application domain. Financial web applications can add pending fund operation statuses and completed transaction statuses; government and enterprise systems can add organizational hierarchy and data domain statuses; and energy systems can add device ownership and regional permission statuses. Regardless of how status types are expanded, the user topic, executable judgment scripts, status transition conditions, and legitimate target set should all be retained to ensure that status paths can be repeatedly verified by the program.
[0088] It should be noted that the terms "first," "second," and similar expressions used in this specification are only used to distinguish different objects and do not imply a necessary order or quantity limitation between objects. Terms include those indicating that steps or components not explicitly listed may also exist. As long as it does not affect the aforementioned page logic state point fixing, state transition edge establishment, logic execution path generation, and path testing, each step can be executed in parallel during the data preparation phase or its execution sequence can be appropriately adjusted according to the target site's response process.
[0089] The above embodiments illustrate the technical solution of the present invention. Equivalent substitutions or combinations made by those skilled in the art based on the structured evidence unit, executable state judgment script, page logic state diagram, logic execution path, state journey template, and state path testing mechanism disclosed in this invention should all fall within the protection scope of this invention.
Claims
1. A method for automatically generating a logical state diagram of a web page and testing arbitrary state paths, characterized in that, include: The browser execution end and the crawler end are linked and launched to collect page features, interface features, identity features, permission features and interaction snapshots for the target website under multiple user themes, and construct structured evidence units according to user themes and operation sequence; The structured evidence unit is input into the semantic analysis model to obtain candidate state points and candidate transition relationships; The state judgment conditions and state judgment script descriptions of candidate state points are converted into executable state judgment scripts, and the page logic state points are solidified based on the consistency between the script execution results and the structured evidence units. Establish state transition edges based on the candidate transition relationships and the execution operations and state changes between logical state points of adjacent pages, and determine the set of legal targets based on user themes and preset legal business processes; The state transition edges are combined to generate a logical execution path and a state journey template leading to the target state point, and the page logical state point, state transition edges, logical execution path and state journey template are saved as a page logical state diagram file; Receive a path test task containing the target state point to be tested, and execute the corresponding logical execution path according to the state to reach the target state point to be tested; perform divergent path test or specified logical execution path test at the target state point to be tested, and determine the actual arrival state after state transition; Compare the actual arrival status with the set of legal targets; For actual arrival states that do not belong to the set of legal targets, based on the output of the executable state judgment script and the judgment result of the semantic analysis model, an illegal state transition result or a result to be reviewed is generated.
2. The method for automatically establishing a Web page logical state diagram and testing arbitrary state paths according to claim 1, characterized in that, The page features include page Uniform Resource Locator, front-end routes, page title, page text summary, and key nodes of the Document Object Model; The interface features include the interface Uniform Resource Locator, request method, request parameters, response status code, business error code, and response field summary; The identity features include Cookie, Identity Token, Authorization Request Header, LocalStorage, SessionStorage, User Identifier, Role Identifier, and Tenant Identifier; The permission features include differences in response status, data range, and permission fields when different user subjects access the same page or interface; The interaction snapshots include a sequence of browsing events, as well as page snapshots, interface snapshots, and identity snapshots before and after each browsing event.
3. The method for automatically establishing a Web page logical state diagram and testing arbitrary state paths according to claim 1, characterized in that, The step of inputting the structured evidence unit into the semantic analysis model includes: A fixed task template is used to combine the structured evidence units, candidate state type definitions, transition condition definitions, account sets, legitimate business processes, and output structure constraints into model inputs; The semantic analysis model is controlled to output the state name, user topic, state type, state meaning, evidence, judgment conditions, script description, state label and confidence level of each candidate state point according to the preset structure, and output the starting state, target state, transition triggering method, required identity, required variables, success conditions, failure conditions and legality tendency of each candidate transition relationship. Candidate state points and candidate transition relationships that are below the confidence threshold or lack executable evidence are marked as pending manual confirmation.
4. The method for automatically establishing a Web page logic state diagram and testing arbitrary state paths according to claim 1, characterized in that, The step of converting the state judgment conditions and state judgment script description of candidate state points into an executable state judgment script includes: The judgment conditions for page Uniform Resource Locator, page text, Document Object Model node, Cookie, Identity Token, browser storage items, interface response status and interface response field are respectively converted into corresponding read statements and comparison statements, and the fixed conditions for confirming page logical state points are preset. Generate Boolean judgment logic based on the conditional combination relationship of the candidate state points; execute the Boolean judgment logic and output the state identifier, matching result and evidence value of each judgment condition; When the matching result is true and the evidence value matches the structured evidence unit on which the candidate state point is based, the solidification condition is met, and the candidate state point is solidified as a page logical state point.
5. The method for automatically establishing a Web page logical state diagram and testing arbitrary state paths according to claim 1, characterized in that, The establishment of state transition edges includes: Extract page jumps, button clicks, form submissions, front-end route changes, and API calls from the interaction snapshots as transition trigger events; The start and target state points are determined by the executable state judgment script before and after the execution of each transfer trigger event. Record the transfer conditions, transfer method, required identity, input variable template, success judgment conditions, and failure judgment conditions corresponding to the transfer trigger event; determine the set of legal targets for the starting state point under the corresponding user topic and transfer trigger event based on the legal business process; when the target state point belongs to the set of legal targets, mark the state transfer edge as legal; when the target state point does not belong to the set of legal targets and there is a transition from an unlogged-in state to a sensitive state, a transition from a low-privilege state to a high-privilege state, or the current user topic accessing other user topic data, mark the state transfer edge as illegal or pending confirmation.
6. The method for automatically establishing a Web page logical state diagram and testing arbitrary state paths according to claim 1, characterized in that, The combination of the state transition edges generates a logical execution path, including: Filter the state transition edges that match the user topics and preconditions of the target state point, and generate multiple candidate paths according to the connection relationship of the state transition edges; The candidate paths are sorted sequentially based on the number of state transition edges contained in the path, historical execution success rate, state stability, and number of session resets; the candidate path ranked first is set as the default logical execution path, and the process is switched to the other candidate paths when the default logical execution path fails.
7. The method for automatically establishing a Web page logic state diagram and testing arbitrary state paths according to claim 1, characterized in that, The state-to-template record can include a starting state, path variables, arrival determination script, and failure rollback method. The execution of the corresponding logical execution path based on the state-to-template includes: Based on the current page logical state point, select a starting state from the available starting states recorded in the template; Fill the test account, business object identifier, and path parameters into the path variable; The transition methods recorded on each state transition edge are executed sequentially according to the logical execution path, and the executable state judgment script for the corresponding target state point is run after each state transition edge is executed. If any executable state judgment script fails, the failure rollback method is executed to restore to a known state point, and the current logic execution path is re-executed or switched to another candidate path.
8. The method for automatically establishing a Web page logical state diagram and testing arbitrary state paths according to claim 1, characterized in that, The execution of the divergence path test includes: Extract variable path parameters, request parameters, request methods, user identities, and page trigger events from the target state point to be tested to form a variable input set; and inject the business object values of the same user theme, the business object values of different user themes, boundary values, or alternative trigger methods into the corresponding transfer methods according to the variable template. After the injection, the transfer method is executed and the actual reached state is identified by the executable state judgment script of the solidified page logic state point. If no solidified page logic state point is matched, a candidate new state point is generated based on the structured evidence unit executed this time.
9. The method for automatically establishing a Web page logical state diagram and testing arbitrary state paths according to claim 1, characterized in that, The execution of the specified logical execution path test includes: Read the start state point, end state point, intermediate state point sequence, transition conditions of each segment, transition methods of each segment, and executable state judgment script of each segment corresponding to the specified logical execution path; Execute state transitions segment by segment and verify the target state point after each segment is executed; When the actual reached state deviates from the intermediate state point sequence, an illegal state transition judgment is entered; the specified logical execution path test is recorded as complete only when all intermediate state points and state transition edges pass the verification.
10. The method for automatically establishing a Web page logical state diagram and testing arbitrary state paths according to claim 1, characterized in that, Also includes: For the illegal state transition result or the result to be reviewed, save the replayable execution path, the user topic corresponding to the test account, the request data, the response data, the page snapshot, the output of the executable state judgment script, and the output of the semantic analysis model as evidence of the problem; Receive the results of manual review, and confirm the legal status, confirm the illegal status, adjust the executable status judgment script or supplement the status transition conditions based on the results of manual review; write the results of manual review back to the page logic state diagram file, rule base and sample library, and use the review reason as the constraint information of the subsequent fixed task template.
