Page testing method and device based on text positioning and computer equipment

By determining whether the control has text attributes in the Cypress web automation framework and recording its text index, the inaccurate element positioning problem caused by multiple identical texts in the front-end page is solved, and the reliability of page testing is improved.

CN119512964APending Publication Date: 2025-02-25GUANGZHOU PINWEI SOFTWARE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411736071.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-29
Publication Date
2025-02-25

AI Technical Summary

Technical Problem

In the Cypress web automation framework, when multiple identical texts exist in the front-end page, the element cannot be accurately positioned based on the text, resulting in low accuracy and poor reliability of element positioning.

Method used

During the recording of the test script, we judge whether the control has text attributes. If it exists, obtain the control's text content and DOM structure, determine the control's text index, and record it in the test script, so that the control is accurately positioned during playback of the test.

Benefits of technology

Improves the ability to accurately locate in multiple controls with the same text content, and enhances the reliability of text-based page testing.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119512964A_ABST
    Figure CN119512964A_ABST
Patent Text Reader

Abstract

The invention provides a page test method and device based on text positioning and computer equipment, and the method comprises the steps: determining a to-be-tested target page when a test script is triggered to be recorded, judging whether a control triggering a preset action has a text attribute or not if the preset action is detected to be triggered in the recording process, and if the preset action is detected to be triggered, determining the target page to be tested; if the control exists, the text can be used as a selector to locate the element, and the text index of the control relative to the control with the same text attribute and text content in the DOM structure is determined through the text content of the control and the DOM structure of the target page; the control to be tested can be accurately positioned in a plurality of controls with the same text content on the basis of the text index recorded in the test script, so that the reliability of the generated test script is improved, and the reliability of a page test based on text positioning can be improved when the test script is used for carrying out a playback test.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of front-end testing technology, and in particular to a page testing method, device and computer equipment based on text positioning. Background Art

[0002] In the Cypress web automation framework, in order to improve the accuracy and ease of locating elements, you can choose a text-based positioning strategy to simplify the identification process of control elements, so that non-technical personnel can also easily understand and modify the automation script.

[0003] However, when there are multiple identical texts in the front-end page, the Cypress web automation framework cannot accurately locate the element to be tested based on the text. The accuracy of element positioning during page testing is low, resulting in poor reliability of page testing based on text positioning. Summary of the invention

[0004] The purpose of the present application is to solve at least one of the above-mentioned technical defects, especially the technical defect that when there are multiple identical texts in the front-end page in the prior art, the Cypress web automation framework cannot accurately locate the element to be tested based on the text, and the accuracy of element positioning is low during the page testing process, resulting in poor reliability of page testing based on text positioning.

[0005] In a first aspect, the present application provides a page testing method based on text positioning, the method comprising:

[0006] When the test script recording is triggered, determine the target page to be tested;

[0007] During the process of recording the test script for the target page, if a preset action is detected to be triggered, it is determined whether the control that triggers the preset action has a text attribute;

[0008] If it exists, then obtain the text content of the control and the DOM structure of the target page, and determine the text index of the control relative to the control in the DOM structure whose text attribute is the same as the text content based on the text content and the DOM structure;

[0009] Record the text index of the control in the recorded test script;

[0010] When the test script is recorded, a playback test is performed on the target page according to the test script.

[0011] In one embodiment, the step of determining, based on the text content and the DOM structure, a text index of the control relative to a control in the DOM structure having a text attribute identical to the text content, comprises:

[0012] Traversing the DOM structure based on the text content to search for a control whose text attributes are consistent with the text content in the DOM structure, and determining the found control as a target control;

[0013] Number each target control to determine the text index of that control.

[0014] In one embodiment, before executing the step of traversing the DOM structure based on the text content, the method further includes:

[0015] The text content is preprocessed, and the text content is replaced according to the preprocessed text content.

[0016] In one embodiment, the step of numbering each target control to determine the text index of the control includes:

[0017] Get the location information of each target control;

[0018] Determine the position of each target control on the target page according to the position information of each target control, and number each target control based on the position of each target control on the target page;

[0019] Get the serial number of the control after numbering, and determine the serial number as the text index of the control.

[0020] In one embodiment, the step of performing a playback test on the target page according to the test script includes:

[0021] Playing back the test script in the target page;

[0022] During playback, if a preset action is triggered, the control to be tested that triggers the preset action is determined, and whether the control to be tested has a text attribute is determined;

[0023] If it exists, then obtaining the text index corresponding to the control to be tested from the test script, obtaining the text content of the control to be tested, and determining the page text corresponding to the control to be tested in the target page based on the text index and text content of the control to be tested;

[0024] The test result of the control to be tested is determined according to the text content of the control to be tested and the page text.

[0025] In one embodiment, the step of determining the test result of the control to be tested according to the text content of the control to be tested and the page text includes:

[0026] Acquire a first control parameter corresponding to the text content of the control to be tested, and acquire a second control parameter of the page text in the target page;

[0027] Comparing the first control parameter with the second control parameter;

[0028] If the comparison is consistent, a test result indicating that the test passed is generated;

[0029] If the comparison is inconsistent, a test result indicating that the test failed is generated.

[0030] In one embodiment, the step of determining whether the control that triggers the preset action has a text attribute includes:

[0031] Call the jQuery library to obtain the text content of the control. If the returned text content is an empty string, it means that the control that triggers the preset action does not have a text attribute.

[0032] If the returned text content is a non-empty string, it means that the control that triggers the preset action has text attributes.

[0033] In a second aspect, the present application provides a page testing device based on text positioning, the device comprising:

[0034] The page determination module is used to determine the target page to be tested when the test script recording is triggered;

[0035] The property judgment module is used to judge whether the control that triggers the preset action has a text attribute if a preset action is detected to be triggered during the process of recording the test script for the target page;

[0036] An index determination module, for obtaining the text content of the control and the DOM structure of the target page if it exists, and determining the text index of the control relative to the control in the DOM structure whose text attributes are the same as the text content based on the text content and the DOM structure;

[0037] An index recording module, used to record the text index of the control in the recorded test script;

[0038] The playback test module is used to perform a playback test on the target page according to the test script when the test script recording is completed.

[0039] In a third aspect, the present application provides a storage medium storing computer-readable instructions. When the computer-readable instructions are executed by one or more processors, the one or more processors execute the steps of the page testing method based on text positioning as described in any of the above embodiments.

[0040] In a fourth aspect, the present application provides a computer device, comprising: one or more processors, and a memory;

[0041] The memory stores computer-readable instructions, and when the one or more processors execute the computer-readable instructions, the steps of the page testing method based on text positioning as described in any of the above embodiments are performed.

[0042] It can be seen from the above technical solutions that the embodiments of the present application have the following advantages:

[0043] The present application provides a page testing method, apparatus and computer equipment based on text positioning, the method comprising: determining a target page to be tested when triggering the recording of a test script; during the recording process, if a preset action is detected to be triggered, determining whether the control that triggers the preset action has a text attribute; if so, the text can be used as a selector to locate the element; the text index of the control relative to the control with the same text attribute and text content in the DOM structure is determined through the text content of the control and the DOM structure of the target page; based on the text index recorded in the test script, the control to be tested can be accurately located among multiple controls with the same text content, so as to improve the reliability of the generated test script; and playback testing with such a test script can improve the reliability of page testing based on text positioning. BRIEF DESCRIPTION OF THE DRAWINGS

[0044] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.

[0045] Figure 1 A flowchart of a page testing method based on text positioning provided in an embodiment of the present application;

[0046] Figure 2 A flowchart of the steps of determining the text index of the control relative to the control with the same text attributes and text content in the DOM structure provided by the embodiment of the present application;

[0047] Figure 3A flowchart of the steps of performing a playback test on a target page according to a test script provided in an embodiment of the present application;

[0048] Figure 4 A schematic diagram of the structure of a page testing device based on text positioning provided in an embodiment of the present application;

[0049] Figure 5 An internal structure diagram of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0050] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.

[0051] In one embodiment, the present application provides a page testing method based on text positioning, and the following embodiment is described by applying the method to a server. It can be understood that the page testing method based on text positioning can be performed by a single server or a server cluster composed of multiple servers, and the present application does not make specific restrictions on this.

[0052] like Figure 1 As shown, the present application provides a page testing method based on text positioning, the method comprising:

[0053] S101: When the test script recording is triggered, a target page to be tested is determined.

[0054] The target page refers to the front-end page to be tested. The test script refers to the script generated by recording the user's operation process on the front-end page through the automated testing tool.

[0055] In this step, when the tester needs to test a certain page, he can first check whether there is a pre-recorded test script that meets the requirements. If so, he can directly use the test script. If not, he can record the test script for the page and send the recording instruction to the server. When the server receives the recording instruction, it triggers the test script recording and determines the target page to be tested according to the recording instruction.

[0056] S102: During the process of recording the test script for the target page, if a preset action is detected to be triggered, it is determined whether the control that triggers the preset action has a text attribute.

[0057] The preset action refers to a preset interactive operation, for example, the preset action can be set to click a control on the target page. The text attribute refers to the characteristics of the text displayed by the control.

[0058] Specifically, after the test script recording is triggered and the target page is determined, if the server detects that a preset action is triggered on the target page, it can obtain the user's current cursor position to determine the control that triggers the preset action, and then determine whether the control has a text attribute. Then, different recording strategies can be adopted according to whether the control has a text attribute.

[0059] Furthermore, an event listener may be set to detect in real time whether a preset action is triggered in the target page.

[0060] S103: If it exists, then obtain the text content of the control and the DOM structure of the target page, and determine the text index of the control relative to the control with the same text attributes and text content in the DOM structure based on the text content and the DOM structure.

[0061] The DOM structure refers to the structure of the Document Object Model, which is the programming interface for HTML and XML documents. The DOM structure represents a page as a tree structure consisting of nodes and node objects, and each node represents an object in the document. The DOM structure includes but is not limited to document nodes, element nodes, attribute nodes, text nodes, comment nodes, and so on. The text index is used to identify controls with the same text content in the DOM structure.

[0062] In this step, when the control has a text attribute, the text content in the text attribute of the control is obtained, and the DOM structure corresponding to the target page is obtained, and then based on the text content and the DOM structure, the text index of the control relative to the control whose text attribute and text content are the same in the DOM structure is determined, that is, the index of the control in the control whose text attribute and text content are the same in the DOM structure is determined.

[0063] S104: Record the text index of the control in the recorded test script.

[0064] After the text index of the control is determined, the text index can be saved in the test script being recorded, so that the unique control can be directly determined in the target page according to the text index when the test script is played back.

[0065] S105: When the test script is recorded, a playback test is performed on the target page according to the test script.

[0066] Specifically, during the test script recording process, the recording can be performed according to the pre-set test case document. When the interactive operations in the test case document are executed, the test script recording can be considered completed, and the test script can be used to replay the target page. Among them, the test case document refers to a document that records the test steps, expected results and test conditions. The test case document includes but is not limited to the test environment, test case description, test data, test steps, etc.

[0067] S106: If it does not exist, obtain the control identifier of the control, and record the control identifier in the recorded test script. When the test script is recorded, perform a playback test on the target page according to the test script.

[0068] The control identifier refers to a parameter that uniquely identifies a control, such as a control ID, etc., which is not specifically limited in this application.

[0069] In this step, when the control does not have a text attribute, the control identifier of the control can be obtained, and then the control identifier can be recorded in the test script being recorded, so that the corresponding control can be located in the target page according to the control identifier when the test is played back. When the test script is recorded, the test script can be used to play back the target page.

[0070] It is understandable that when the control has text attributes, the text can be used as a selector to locate the control on the target page, and when the control does not have text attributes, some inherent parameters of the control can be used as selectors to locate the control on the target page. In this way, different recording strategies are determined by judging whether the control has text attributes. When text can be used for positioning, text positioning is used first. When text positioning is used, it is not affected by changes in control parameters, which is convenient for maintenance and can also improve the flexibility and efficiency of page testing.

[0071] The present application provides a page testing method, apparatus and computer equipment based on text positioning, the method comprising: determining a target page to be tested when triggering the recording of a test script; during the recording process, if a preset action is detected to be triggered, determining whether the control that triggers the preset action has a text attribute; if so, the text can be used as a selector to locate the element; the text index of the control relative to the control with the same text attribute and text content in the DOM structure is determined through the text content of the control and the DOM structure of the target page; based on the text index recorded in the test script, the control to be tested can be accurately located among multiple controls with the same text content, so as to improve the reliability of the generated test script; and playback testing with such a test script can improve the reliability of page testing based on text positioning.

[0072] like Figure 2As shown, in one embodiment, based on the text content and the DOM structure, the step of determining the text index of the control relative to the control with the same text attribute and text content in the DOM structure includes:

[0073] S201: Traversing the DOM structure based on the text content to search for a control whose text attributes are consistent with the text content in the DOM structure, and determining the found control as a target control.

[0074] In this step, the DOM structure is traversed to search for a control whose text attributes are consistent with the text content in the DOM structure, and then the found control is determined as the target control. It can be understood that this control is also one of the found target controls.

[0075] For example, assuming that there are three "Submit" buttons in the target page A, if one of the "Submit" buttons is clicked to trigger the preset action, the text content obtained at this time is "Submit", and a tree traversal is performed in the DOM structure of the target page A. At this time, the three "Submit" buttons can be determined as target controls.

[0076] S202: Number each target control to determine the text index of the control.

[0077] In this step, after each target control is determined, each target control is numbered, and then the text index of the control is determined according to the sequence number of the numbered control.

[0078] Furthermore, each target control may be numbered according to a preset numbering strategy, for example, each target control may be numbered according to its position on the target page, or according to its type and position, and this application does not impose any specific restrictions on this.

[0079] It is understandable that by numbering controls with the same text content to determine the text index of the control to be tested, the unique control can be directly determined in the target page based on the text index when the test script is played back, thereby improving the reliability of page testing based on text positioning.

[0080] In one embodiment, before executing the step of traversing the DOM structure based on the text content, the page testing method based on text positioning further includes:

[0081] S1: preprocessing the text content, and replacing the text content according to the preprocessed text content.

[0082] Specifically, since there may be blank characters or line breaks before and after the acquired text content, in order to ensure that subsequent traversal can accurately query the corresponding text content, the text content can be preprocessed to check whether there are blank characters or line breaks before and after the text content. If so, the blank characters or line breaks before and after the text content are removed, and the preprocessed text content is used to replace the original text content. The preprocessed text content is then used to traverse the DOM structure.

[0083] It is understandable that by preprocessing the text content and then traversing based on the preprocessed text content, it is possible to ensure that no qualified controls are missed during the traversal search, thereby further ensuring the reliability of page testing based on text positioning.

[0084] In one embodiment, the step of numbering each target control to determine the text index of the control includes:

[0085] S1: Get the location information of each target control.

[0086] The position information refers to the position and size of a control relative to its parent container or the entire interface in the user interface (UI).

[0087] S2: Determine the position of each target control on the target page according to the position information of each target control, and number each target control based on the position of each target control on the target page.

[0088] In this step, the position of each target control on the target page is determined according to the position information of each control, so as to number each target control. In this process, if the position information of each control is not relative to the target page, the position information of each control can be converted to determine the position information of each control relative to the target page, and then determine the position of each target control on the target page.

[0089] Specifically, when numbering each target control according to its position on the target page, a specific numbering rule can be set. For example, according to the position of each target control on the target page, each target control is sorted in order from top to bottom and from left to right, and then the sorted target controls are numbered in sequence.

[0090] S3: Obtain the serial number of the control after numbering, and determine the serial number as the text index of the control.

[0091] For example, assuming that the target page can represent an 8*5 grid area, where 8 represents the horizontal coordinate and 5 represents the vertical coordinate, target control A is located at position (1, 4) on the target page, target control B is located at position (3, 4) on the target page, and target control C is located at position (5, 1) on the target page. After sorting, the order of target control A, target control B, and target control C can be obtained. At this time, target control A, target control B, and target control C can be numbered as 1, 2, and 3 respectively. When the control is target control B, the serial number of target control B can be obtained, that is, 2, and the serial number can be used as the text index of the control.

[0092] In this embodiment, text indexes are used to distinguish controls with the same text content, and then a corresponding control can be uniquely determined based on the text index, thereby avoiding the inability to locate the control to be tested when there are multiple controls with the same text content, thereby improving the reliability of page testing based on text positioning.

[0093] like Figure 3 As shown, in one embodiment, the step of performing a playback test on a target page according to a test script includes:

[0094] S301: Play back the test script in the target page.

[0095] S302: During playback, if a preset action is triggered, the control to be tested that triggers the preset action is determined, and whether the control to be tested has a text attribute is determined.

[0096] The preset action in this step can be determined according to the test script, that is, the preset action in the step is equivalent to the preset action in the recording process.

[0097] S303: If it exists, obtain the text index corresponding to the control to be tested from the test script, obtain the text content of the control to be tested, and determine the page text corresponding to the control to be tested in the target page based on the text index and text content of the control to be tested.

[0098] The same steps and definitions in this embodiment can refer to the description of S102 and S103.

[0099] S304: Determine the test result of the control to be tested according to the text content of the control to be tested and the page text.

[0100] By determining the page text, the control corresponding to the page text in the target page can be determined, and the control can be compared with the control to be tested to determine the test result of the control to be tested. After the test script is played back, the test results of each test control can be summarized to finally generate the test result of the target page.

[0101] If the control to be tested does not have a text attribute, you can obtain the control identifier corresponding to the control to be tested from the test script, and then determine the corresponding control in the target page based on the control identifier, and then compare the control with the control to be tested to determine the test result of the control to be tested.

[0102] It is understandable that since text changes less frequently than control parameters, prioritizing text positioning to determine the corresponding control can avoid frequent modifications to the recorded script due to changes in control parameters, thereby reducing test maintenance costs and improving the reliability of page testing methods based on text positioning.

[0103] In one embodiment, the step of determining the test result of the control to be tested according to the text content of the control to be tested and the page text includes:

[0104] S1: Obtain a first control parameter corresponding to the text content of the control to be tested, and obtain a second control parameter of the page text in the target page.

[0105] The first control parameter refers to the control parameter of the control to be tested corresponding to the text content, and the second control parameter refers to the control parameter of the control corresponding to the page text in the target page.

[0106] S2: Compare the first control parameter and the second control parameter.

[0107] S3: If the comparison is consistent, a test result indicating that the test passed is generated.

[0108] S4: If the comparison is inconsistent, a test result indicating that the test failed is generated.

[0109] In this embodiment, by comparing the parameters of the control to be tested and the control corresponding to the page text, the control parameters of the control when the test script is recorded can be used as a reference to check whether the control is consistent during recording and playback, and then the recorded test script can be used to complete the automated testing of the front-end page controls.

[0110] In one embodiment, the step of determining whether a control that triggers a preset action has a text attribute includes:

[0111] S1: Call the jQuery library to obtain the text content of the control. If the returned text content is an empty string, it means that the control that triggers the preset action does not have a text attribute.

[0112] Among them, jQuery library is a JavaScript library, which can provide an easy-to-use interface to operate HTML DOM elements, execute AJAX requests, handle events and animations, etc. In this embodiment, the text content of the control can be obtained through the jQuery library, and then it is determined whether the control that triggers the preset action has a text attribute based on whether the text content is empty.

[0113] S2: If the returned text content is a non-empty string, it means that the control that triggers the preset action has text attributes.

[0114] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.

[0115] The following is a description of a page testing device based on text positioning provided in an embodiment of the present application. The page testing device based on text positioning described below and the page testing method based on text positioning described above can refer to each other.

[0116] like Figure 4 As shown, the present application provides a page testing device 400 based on text positioning, the device comprising:

[0117] The page determination module 401 is used to determine the target page to be tested when the test script recording is triggered;

[0118] The attribute judgment module 402 is used to judge whether the control that triggers the preset action has a text attribute if a preset action is detected to be triggered during the process of recording the test script for the target page;

[0119] The index determination module 403 is used to obtain the text content of the control and the DOM structure of the target page if it exists, and determine the text index of the control relative to the control with the same text attributes and text content in the DOM structure based on the text content and the DOM structure;

[0120] An index recording module 404, used to record the text index of the control in the recorded test script;

[0121] The playback test module 405 is used to perform a playback test on the target page according to the test script when the test script recording is completed.

[0122] In one embodiment, the index determination module includes:

[0123] A control determination submodule is used to traverse the DOM structure based on the text content to find a control whose text attributes are consistent with the text content in the DOM structure, and determine the found control as the target control;

[0124] The index determination submodule is used to number each target control to determine the text index of the control.

[0125] In one embodiment, before executing the control determination submodule, the page testing device based on text positioning further includes:

[0126] The preprocessing submodule is used to preprocess the text content and replace the text content according to the preprocessed text content.

[0127] In one embodiment, the index determination submodule includes:

[0128] An information acquisition unit, used to acquire the position information of each target control;

[0129] A position determination unit, used to determine the position of each target control on the target page according to the position information of each target control, and number each target control based on the position of each target control on the target page;

[0130] The index determination unit is used to obtain the serial number of the control after being numbered, and determine the serial number as the text index of the control.

[0131] In one embodiment, the playback test module includes:

[0132] The playback submodule is used to play back the test script in the target page;

[0133] The attribute judgment submodule is used to determine the control to be tested that triggers the preset action and judge whether the control to be tested has text attributes if the preset action is triggered during the playback process;

[0134] A text determination submodule, for obtaining a text index corresponding to the control to be tested from the test script, if it exists, and obtaining the text content of the control to be tested, and determining the page text corresponding to the control to be tested in the target page based on the text index and text content of the control to be tested;

[0135] The result determination submodule is used to determine the test result of the control to be tested according to the text content of the control to be tested and the page text.

[0136] In one embodiment, the result determination submodule includes:

[0137] A parameter acquisition unit, used to acquire a first control parameter corresponding to the text content of the control to be tested, and to acquire a second control parameter of the page text in the target page;

[0138] A parameter comparison unit, used to compare the first control parameter with the second control parameter;

[0139] A first judgment unit, configured to generate a test result indicating that the test has passed if the comparison is consistent;

[0140] The second judgment unit is used to generate a test result indicating that the test has not passed if the comparison is inconsistent.

[0141] In one embodiment, the attribute determination module includes:

[0142] The library call submodule is used to call the jQuery library to obtain the text content of the control. If the returned text content is an empty string, it means that the control that triggers the preset action does not have a text attribute;

[0143] The judgment submodule is used to determine if the returned text content is a non-empty string, indicating that the control that triggers the preset action has text attributes.

[0144] The division of each module in the above-mentioned page testing device based on text positioning is only used for illustration. In other embodiments, the page testing device based on text positioning can be divided into different modules as needed to complete all or part of the functions of the above-mentioned page testing device based on text positioning. Each module in the above-mentioned page testing device based on text positioning 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 in the computer device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.

[0145] In one embodiment, the present application also provides a storage medium storing computer-readable instructions. When the computer-readable instructions are executed by one or more processors, the one or more processors execute the steps of the page testing method based on text positioning as described in any of the above embodiments.

[0146] In one embodiment, the present application also provides a computer device having computer-readable instructions stored therein. When the computer-readable instructions are executed by one or more processors, the one or more processors execute the steps of the page testing method based on text positioning as described in any of the above embodiments.

[0147] Indicatively, Figure 5 As shown, Figure 5 This is a schematic diagram of the internal structure of a computer device provided in an embodiment of the present application. The computer device 500 may be provided as a server. Figure 5 , the computer device 500 includes a processing component 502, which further includes one or more processors, and a memory resource represented by a memory 501, for storing instructions executable by the processing component 502, such as an application. The application stored in the memory 501 may include one or more modules, each corresponding to a set of instructions. In addition, the processing component 502 is configured to execute instructions to perform the page testing method based on text positioning of any of the above embodiments.

[0148] The computer device 500 may further include a power supply component 503 configured to perform power management of the computer device 500, a wired or wireless network interface 504 configured to connect the computer device 500 to a network, and an input / output (I / O) interface 505. The computer device 500 may operate based on an operating system stored in the memory 501, such as Windows Server TM, Mac OS X TM, Unix TM, Linux TM, Free BSD TM, or the like.

[0149] Those skilled in the art will understand that Figure 5 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0150] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish an entity or operation from another entity or operation, and do not necessarily require or imply that there is any such actual relationship or order between these entities or operations. Moreover, the term "include", "comprise" or any other variant thereof is intended to cover non-exclusive inclusion, so that the process, method, article or equipment including a series of elements not only include those elements, but also include other elements that are not clearly listed, or also include elements inherent to such process, method, article or equipment. In the absence of more restrictions, the elements limited by the sentence "comprise one..." do not exclude the existence of other identical elements in the process, method, article or equipment including the elements. Herein, the singular "one", "one" and "described / the" may also include plural forms, unless the context clearly indicates another way. It should also be understood that the terms "include / comprise" or "have" etc. specify the existence of stated features, wholes, steps, operations, components, parts or combinations thereof, but do not exclude the possibility of the existence or addition of one or more other features, wholes, steps, operations, components, parts or combinations thereof. At the same time, the term "and / or" used in this specification includes any and all combinations of the relevant listed items.

[0151] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The various embodiments can be combined as needed, and the same or similar parts can refer to each other.

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

Claims

1. A page testing method based on text positioning, characterized in that: The method comprises: When the test script recording is triggered, determine the target page to be tested; During the process of recording the test script for the target page, if a preset action is detected to be triggered, it is determined whether the control that triggers the preset action has a text attribute; If it exists, then obtain the text content of the control and the DOM structure of the target page, and determine the text index of the control relative to the control in the DOM structure whose text attribute is the same as the text content based on the text content and the DOM structure; Record the text index of the control in the recorded test script; When the test script is recorded, a playback test is performed on the target page according to the test script.

2. The page testing method based on text positioning according to claim 1, characterized in that: The step of determining, based on the text content and the DOM structure, a text index of the control relative to a control in the DOM structure having the same text attribute as the text content, comprises: Traversing the DOM structure based on the text content to search for a control whose text attributes are consistent with the text content in the DOM structure, and determining the found control as a target control; Number each target control to determine the text index of that control.

3. The page testing method based on text positioning according to claim 2 is characterized in that: Before executing the step of traversing the DOM structure based on the text content, the method further includes: The text content is preprocessed, and the text content is replaced according to the preprocessed text content.

4. The page testing method based on text positioning according to claim 2 is characterized in that: The step of numbering each target control to determine the text index of the control includes: Get the location information of each target control; Determine the position of each target control on the target page according to the position information of each target control, and number each target control based on the position of each target control on the target page; Get the serial number of the control after numbering, and determine the serial number as the text index of the control.

5. The page testing method based on text positioning according to any one of claims 1 to 4, characterized in that: The step of performing a playback test on the target page according to the test script includes: Playing back the test script in the target page; During playback, if a preset action is triggered, the control to be tested that triggers the preset action is determined, and whether the control to be tested has a text attribute is determined; If it exists, then obtaining the text index corresponding to the control to be tested from the test script, obtaining the text content of the control to be tested, and determining the page text corresponding to the control to be tested in the target page based on the text index and text content of the control to be tested; The test result of the control to be tested is determined according to the text content of the control to be tested and the page text.

6. The page testing method based on text positioning according to claim 5, characterized in that: The step of determining the test result of the control to be tested according to the text content of the control to be tested and the page text includes: Acquire a first control parameter corresponding to the text content of the control to be tested, and acquire a second control parameter of the page text in the target page; Comparing the first control parameter with the second control parameter; If the comparison is consistent, a test result indicating that the test passed is generated; If the comparison is inconsistent, a test result indicating that the test failed is generated.

7. The page testing method based on text positioning according to claim 1 is characterized in that: The step of determining whether the control that triggers the preset action has a text attribute includes: Call the jQuery library to obtain the text content of the control. If the returned text content is an empty string, it means that the control that triggers the preset action does not have a text attribute. If the returned text content is a non-empty string, it means that the control that triggers the preset action has text attributes.

8. A page testing device based on text positioning, characterized in that: The device comprises: The page determination module is used to determine the target page to be tested when the test script recording is triggered; The property judgment module is used to judge whether the control that triggers the preset action has a text attribute if a preset action is detected to be triggered during the process of recording the test script for the target page; An index determination module, for obtaining the text content of the control and the DOM structure of the target page if it exists, and determining the text index of the control relative to the control in the DOM structure whose text attributes are the same as the text content based on the text content and the DOM structure; An index recording module, used to record the text index of the control in the recorded test script; The playback test module is used to perform a playback test on the target page according to the test script when the test script recording is completed.

9. A storage medium, characterized in that: The storage medium stores computer-readable instructions, and when the computer-readable instructions are executed by one or more processors, the one or more processors execute the steps of the page testing method based on text positioning as described in any one of claims 1 to 7.

10. A computer device, characterized in that: include: one or more processors, and memory; The memory stores computer-readable instructions, and when the computer-readable instructions are executed by the one or more processors, the steps of the page testing method based on text positioning as described in any one of claims 1 to 7 are performed.