Element positioning method and device
Through a large model, scan the page HTML source code and generate corresponding categories, configure element expressions and encapsulation methods, the accuracy and stability of complex element positioning are solved, and the efficiency and maintainability of automated scripts are improved.
Patent Information
- Application Number
- CN202510177562.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-18
- Publication Date
- 2025-05-23
AI Technical Summary
In the prior art, it is difficult to achieve accurate and stable page element positioning when facing complex or deep-level elements, as well as elements with inconspicuous attribute characteristics.
Get the HTML source code of the page through large model timing or real-time scanning, generate page classes and modal box classes, and configure element expressions and encapsulation methods for different components to realize the positioning and operation of target elements in automated folders.
It significantly improves the efficiency of element expression writing, reduces the maintenance difficulty and workload of automated scripts, and achieves accurate and stable positioning of complex or deep-level elements.
Smart Images

Figure CN120029666A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to a method and device for element positioning. Background Art
[0002] In the process of building user interface (UI) automation, it is crucial to accurately identify and operate each element on the page. Among them, locating page elements is not only tedious, but also frequently occurs during project iterations. As the front-end code changes, the page structure and element properties may change, requiring the elements to be relocated.
[0003] In the prior art, there are browsers that support querying page elements and obtaining the XPath (XML Path) expression of the elements, which can basically meet the simple element positioning requirements. However, when encountering complex or deep-level elements, or elements with unclear attribute characteristics, the XPath expression generated by this method will result in inaccurate and unstable positioning. Therefore, how to accurately and stably locate elements on the page when facing complex or deep-level elements, or elements with unclear attribute characteristics, has become a problem that needs to be solved in this draft. Summary of the invention
[0004] Based on the above problems, the present application provides a method and device for element positioning, so as to accurately and stably locate elements on a page when faced with complex or deeply layered elements, as well as elements with unclear attribute characteristics.
[0005] The present application discloses a method for locating an element, the method comprising:
[0006] The large model obtains the HTML source code of the page through scheduled or real-time scanning;
[0007] The large model generates page classes of different pages and modal box classes of different modal boxes existing in the pages based on the HTML source code;
[0008] The large model configures corresponding element expressions for different components, and generates the element expressions in the page class and the modal box class respectively;
[0009] The large model configures corresponding encapsulation methods for different components, and when there is no method identical to the encapsulation method, the encapsulation method is generated in the page class and the modal box class respectively;
[0010] The large model generates a sample class under an automation folder, locates a target element according to an input operation instruction, and generates a target operation for the target element to the sample class; the target element is the page and / or the modal box.
[0011] Optionally, before the large model obtains the HTML source code of the page by means of scheduled or real-time scanning, the method further includes:
[0012] The front-end code of the system under test is imported into the big model library so that the big model can understand the logic of the front-end code.
[0013] Optionally, the large model configures corresponding element expressions for different components, including:
[0014] The large model is trained by front-end codes including various component types, so that the large model can recognize the rules of different components;
[0015] The large model configures the element expressions corresponding to different components respectively; the element expression is a formula including an XPath expression and an element naming specification.
[0016] Optionally, when there is a method identical to the encapsulation method, the encapsulation method is extracted into a public method class, the large model generates a sample class under an automation folder, and locates the target element according to the input operation instruction, including:
[0017] The public method class is introduced into the sample class, and the encapsulation method in the public method class is called.
[0018] Optionally, the large model obtains the HTML source code of the page by means of scheduled or real-time scanning, including:
[0019] The large model scans the front-end code by means of timed or real-time scanning to obtain the HTML source code;
[0020] The preceding code segment is compared with the element operation in the sample class, and the element expression and encapsulation method are updated according to the comparison result.
[0021] Optionally, the large model generates a sample class in an automation folder, including:
[0022] The large model responds to the instruction to generate the automation sample and generates a directory corresponding to the instruction to generate the automation sample under the automation folder;
[0023] Generate sample classes in the said directory.
[0024] Optionally, locating the target element according to the input operation instruction includes:
[0025] The large model responds to the operation instruction and locates the target page class and the target page under the target page class, or locates the target modal box class and the target modal box under the target modal box class according to the operation instruction.
[0026] Optionally, generating a target operation for the target element to the sample class includes:
[0027] According to the operation instruction, generate an operation to call the target element;
[0028] The operation and the process of locating the target element are taken as the target operation and saved in the sample class.
[0029] Optionally, the page class generated by the large model inherits from a basic page class, and the modal box class generated by the large model inherits from a basic modal box class.
[0030] Based on the above-mentioned element positioning method, the present application also discloses an element positioning device, including: a scanning unit, a generating unit, a configuring unit, a packaging unit and a positioning unit;
[0031] The scanning unit is used for obtaining the HTML source code of the page through a timed or real-time scanning method for the large model;
[0032] The generating unit is used for the large model to generate page classes of different pages and modal box classes of different modal boxes existing in the pages based on the HTML source code;
[0033] The configuration unit is used for configuring corresponding element expressions for different components in the large model, and generating the element expressions in the page class and the modal box class respectively;
[0034] The encapsulation unit is used for configuring corresponding encapsulation methods for different components in the large model, and when there is no method identical to the encapsulation method, the encapsulation method is generated in the page class and the modal box class respectively;
[0035] The positioning unit is used for the large model to generate a sample class under the automation folder, locate the target element according to the input operation instruction, and generate a target operation for the target element to the sample class; the target element is the page and / or the modal box.
[0036] Optionally, the device further comprises:
[0037] The import unit is used to import the front-end code of the tested system into the large model library so that the large model can understand the logic of the front-end code.
[0038] Optionally, the configuration unit includes:
[0039] A training subunit, used for training the large model by using front-end codes including various component types, so that the large model can recognize different rules of the components;
[0040] The configuration subunit is used for configuring the corresponding element expressions for different components in the large model respectively; the element expression is a formula including an XPath expression and an element naming specification.
[0041] Optionally, when there is a method identical to the encapsulation method, the encapsulation method is extracted into a common method class, and the positioning unit includes:
[0042] The public subunit is used to introduce the public method class into the sample class and call the encapsulated method in the public method class.
[0043] Optionally, the scanning unit includes:
[0044] The scanning subunit is used for scanning the front-end code of the large model through a timed or real-time scanning method to obtain the HTML source code;
[0045] The comparison subunit is used to compare the preceding code segment with the element operation in the sample class, and update the element expression and encapsulation method according to the comparison result.
[0046] Optionally, the positioning unit includes:
[0047] A response subunit, used for the large model to respond to the instruction of generating the automation sample, and to generate a directory corresponding to the instruction of generating the automation sample under the automation folder;
[0048] The generation subunit is used to generate sample classes under the directory.
[0049] Optionally, the positioning unit includes:
[0050] The positioning subunit is used for the large model to respond to the operation instruction, locate the target page class and the target page under the target page class according to the operation instruction, or locate the target modal box class and the target modal box under the target modal box class.
[0051] Optionally, the positioning unit includes:
[0052] A calling subunit, used for generating an operation of calling the target element according to the operation instruction;
[0053] The saving subunit is used to save the operation and the process of locating the target element as the target operation to the sample class.
[0054] Optionally, the page class generated by the large model inherits from a basic page class, and the modal box class generated by the large model inherits from a basic modal box class.
[0055] The present application discloses a method and device for element positioning. The large model obtains the HTML source code of the page by means of timed or instant scanning, realizes artificially controllable front-end code scanning, and effectively saves system performance. Based on the source code, the page class of different pages and the modal box class of different modal boxes existing in the page are generated. The large model automatically identifies different components and intelligently configures corresponding element expressions for them, and generates them in the page class and modal box class respectively. Combined with the large model, the automatic capture of elements that can be identified by rules significantly improves the efficiency of element expression writing. The large model automatically identifies different components and intelligently configures corresponding encapsulation methods for them. When there is no method that is the same as the encapsulation method, the encapsulation method is generated in the page class and modal box class respectively. The large model generates a sample class under the automation folder, locates the target element according to the input operation instruction, and generates the target operation for the target element to the sample class. The variable separation of content in the class is realized, so that the pop-up window and the page can perform different operations, and the parent class elements are easily accessed through subclass inheritance, avoiding the impact of automatic capture on other pages, and significantly reducing the maintenance difficulty and workload of the automation script. BRIEF DESCRIPTION OF THE DRAWINGS
[0056] 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 embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying any creative work.
[0057] Figure 1 A schematic flow chart of a method for locating an element disclosed in an embodiment of the present application;
[0058] Figure 2 A schematic flow chart of another element positioning method disclosed in an embodiment of the present application;
[0059] Figure 3 A schematic diagram of the structure of an element positioning device disclosed in an embodiment of the present application. DETAILED DESCRIPTION
[0060] 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.
[0061] Embodiment 1: This application discloses a method for locating an element.
[0062] For details, please refer to Figure 1 , a method for locating an element disclosed in this embodiment includes the following steps:
[0063] Step 101: The large model obtains the HTML source code of the page through a timed or real-time scanning method.
[0064] In the method described in this embodiment, as an optional method, all the front-end codes of the system under test are imported into the large model library, so that the large model can deeply understand and analyze the logical structure, component relationship and page interaction process of the front-end code, thereby laying a solid foundation for subsequent work. After importing the front-end code, the large model will perform a series of processing and analysis work. For example, code files such as Hypertext Markup Language HTML (HyperText Markup Language), Cascading Style Sheets CSS (Cascading Style Sheets) and JavaScript are parsed to identify various elements, styles and functional logic in the page. In this way, the large model can build a detailed page structure model, which provides strong support for subsequent element capture and element expression generation.
[0065] At the same time, the big model can also identify and classify components in the front-end code. It can distinguish different types of components, such as buttons, input boxes, drop-down lists, etc. In addition, the big model can also analyze the event processing and interaction logic in the front-end code, identify various events triggered by user operations, such as clicks, inputs, drags, etc., and understand how these events affect the state and behavior of the page.
[0066] In the method described in this embodiment, the large model can use a timed scanning or an instant scanning method to ensure comprehensive and timely monitoring and updating of the front-end code, thereby improving the efficiency and accuracy of code scanning. Among them, the timed scanning can be set at a fixed time interval, such as every hour, every day, or every week. During the scanning process, the large model will traverse each project in the code base and extract the corresponding HTML source code for each project. Through timed scanning, the large model can timely discover and update changes in the front-end code. Instant scanning can be controlled manually to capture and respond to changes in the code base in real time. For example, when a developer submits a new code change in the code base, the instant scanning mechanism can be triggered immediately, or the mechanism can be triggered after the developer enters an instant scanning instruction to scan and analyze the newly added or modified code. Through instant scanning, the large model can quickly perceive the latest dynamics of the front-end code. At the same time, the front-end code can also be scanned in a combination of timed scanning and instant scanning. I will not go into details here, and it is sufficient to be able to perceive the latest dynamics of the front-end code in a timely manner.
[0067] Step 102: The large model generates page classes of different pages and modal box classes of different modal boxes in the pages based on the HTML source code.
[0068] In the method described in this embodiment, after obtaining the HTML source code of each page of the system, the large model will further parse and process these source codes. As an optional method, the large model first generates a unique name for each page based on the identifier of the page in the front-end code (such as URL path, page title or specific HTML element, etc.). For example, a page for user login is named "LoginPage". After that, the large model will establish a corresponding page class (PAGE class) for different pages. These PAGE classes will be used to encapsulate the HTML structure, element attributes, interaction logic, test cases and other key information of the page. Each PAGE class will be automatically generated according to the HTML source code of the page to ensure consistency with the actual page.
[0069] In the method described in this embodiment, when there are modal boxes in the page, the large model will also deeply identify and process these modal boxes. As a common interactive component in the front-end page, the modal box is usually used to display important information, obtain user input or perform specific operations. First, the large model can name them according to the content and function of the modal box. For example, a modal box for displaying user login information is named "Logi nMode l". After that, the large model will create a corresponding modal box class (MODEL class) for different modal boxes, and these MODEL classes will be used to encapsulate the structure, behavior and logic required for interaction with the modal box. Similar to the PAGE class, the MODEL class will also be automatically generated according to the HTML source code of the modal box to ensure consistency with the actual modal box.
[0070] In the method described in the present embodiment, the PAGE class can inherit from the basic page class (BASEPAGE class), which is a general page base class, and can define the general methods and properties related to the page, such as the search method of the page element, the verification method of the page state, the triggering method of the page event, etc. Similarly, the MODEL class can also inherit from the basic modal frame class (BASEMODEL class). Wherein the general methods and properties related to the modal frame can be defined, such as the opening and closing method of the modal frame, the positioning method of the elements in the modal frame, the verification method of the modal frame state, etc. Wherein, the BASEPAGE class and the BASEMODEL class can also define parameters such as interfaces, and the PAGE class and the MODEL class can be expanded and implemented.
[0071] Step 103: The large model configures corresponding element expressions for different components, and generates the element expressions in the page class and the modal box class respectively.
[0072] In the method described in this embodiment, the front-end code has various components, such as a text box (for inputting a single line of text), a drop-down check box (providing a series of options for the user to select), a check box (allowing the user to select multiple options), a rich text box (supporting formatted multi-line text input), etc. As an optional method, the large model is trained by including front-end codes of various component types, so that the large model can recognize the rules and characteristics of different components.
[0073] In the method described in this embodiment, after the large model can understand the components, element expressions can be configured for different components. This element expression can be a formula containing an XPath expression and an element naming specification. Among them, XPath is a language for finding information in XML documents, which is also applicable to HTML documents and can accurately locate elements in the page. By configuring element expressions for different components, it can be ensured that each component can be accurately located. Among them, the element naming specification can be formulated according to needs to ensure that the naming of different components in the code is consistent and readable. These naming specifications are usually based on information such as the type, purpose, and position of the component in the page. The content of the element naming specification is not specifically limited here, and it is sufficient to enable people to understand the meaning and purpose of each element.
[0074] In the method described in this embodiment, the generated element expression will be stored in the PAGE class and the MODEL class to correspond to each component on the page in the PAGE class and each component in the modal box.
[0075] Step 104: the large model configures corresponding encapsulation methods for different components. When there is no method identical to the encapsulation method, the encapsulation method is generated in the page class and the modal box class respectively.
[0076] Different components involve various specific actions due to their different functions and user interaction methods. For example, a text box usually requires an action to fill in the input text, a button requires an action to click, and a radio button requires both a click action to select or unselect, and a check action to record the user's choice. In order to provide a variety of interaction methods, in the method described in this embodiment, the large model configures corresponding encapsulation methods for different component types, which can specifically be encapsulation formulas for general methods. The logic required to interact with the components is encapsulated so that the interaction can be performed in a standardized and reusable manner. For example, a method named click is encapsulated for a button to simulate a user's click operation.
[0077] As an optional method, the big model can automatically identify the types and characteristics of different components by learning and understanding the HTML structure, CSS style, and JavaScript behavior patterns of various components in the front-end code. It can automatically generate corresponding encapsulation methods for different components and save them in the PAGE class and MODEL class respectively.
[0078] In the method described in this embodiment, in the PAGE class, the large model generates one or more corresponding encapsulation methods for each component on the page. The logic, interface, etc. required for interacting with the component can be encapsulated. Taking the text box as an example, the PAGE class may include a fill Username method for filling the user name. Similarly, in the MODEL class, the large model also generates corresponding encapsulation methods for each component in the modal box to interact with the elements in the modal box. For example, for a radio button in the modal box, the MODEL class may include a selectOption method for selecting or deselecting the option.
[0079] In the method described in this embodiment, as an optional method, when the large model generates an encapsulation method, if it recognizes that a method identical to the encapsulation method already exists, it will extract the encapsulation method (or two identical methods together) into a specially designed common method class (COMMON class). The COMMON class stores encapsulation methods that can be shared by multiple elements. In order to manage common methods, there are multiple categories under the COMMON class, including but not limited to PAGE, MODEL, SELECT (methods involving data selection and query), I FRAME (methods related to processing embedded frames), etc.
[0080] In the method described in this embodiment, after extracting the public method, the elements called inside the public method can also be adjusted accordingly. This includes automatically identifying and introducing the class where the element is located to ensure that the public method can run correctly in the new context. At the same time, the writing method of calling elements in the public method can be modified to ensure accurate syntax and avoid compilation errors or abnormal operation due to context changes.
[0081] In the method described in this embodiment, the application scenarios that directly call the encapsulated method instead of calling from the COMMON class can also be updated, and the methods directly referenced in these application scenarios are replaced with public methods in the COMMON class. Specifically, the COMMON class package can be introduced, that is, corresponding statements are added to the files that need to use the public methods, and the directly called methods are adjusted to call the public methods in the COMMON class, ensuring that all calls are made through the COMMON class.
[0082] Step 105: the large model generates a sample class under the automation folder, locates the target element according to the input operation instruction, and generates a target operation for the target element to the sample class.
[0083] In the method described in this embodiment, the target element is a page and / or a modal box. The big model responds to the instruction to generate an automation sample, generates a directory corresponding to the instruction to generate the automation sample under the automation folder, and the big model generates a sample class (CASE class) file under the directory according to the instruction. The file includes relevant code and logic, and may also include necessary comments and documents.
[0084] In the method described in this embodiment, the large model responds to the operation instruction, searches for the corresponding CASE class, and automatically generates the operation code for the target element on the target page. The process of operating and locating the target element is saved as the target operation to the sample class. For example, the operation instruction is to perform a login operation on the login page. The large model searches or creates a specified CASE class according to the operation instruction, specifically the "Logi nCase" class. The code for the login operation is generated under the CASE class, specifically, the code for calling the "log in" method in the "Log in" page class is generated in the "Log i nCase" class.
[0085] In the method described in this embodiment, the final large model can locate the target page class and the target page under the target page class, or locate the target modal box class and the target modal box under the target modal box class according to the operation instruction. As an optional method, after the public method class is introduced in the sample class, the method in the public method class is also called to perform the operation.
[0086] In the method described in this embodiment, when the front-end code changes, such as adding a new element, modifying the ID or class name of the element, etc., the large model can traverse the front-end code by means of timed or instant scanning, compare the front-end code with the element operation in the sample class, and update the element expression and encapsulation method according to the comparison result. This process is incremental, that is, only the changed elements are updated, rather than regenerating the element location information of the entire page. As an optional method, the large model can also be configured with a switch to allow the scanning and updating process to be manually triggered.
[0087] The method described in this embodiment imports all the front-end codes of the system under test into the large model library, fully utilizes the powerful analysis ability of the large model, and automatically captures elements in combination with the large model. It also supports the methods of timed scanning and instant scanning, realizes human control through switch configuration, and effectively saves system performance. The front-end code is fully and timely monitored and updated. When the element positioning fails due to the change of the front-end code, it can be restored by re-capturing the element, which improves the efficiency and accuracy of code scanning and reduces the maintenance difficulty and workload. The automatically generated PAGE class and MODEL class enable the modal box and page to be executed as different classes, and easily access the parent class elements through JAVA class inheritance, avoiding the impact of automatic capture on other pages. And the PAGE class and MODEL class are inherited from the basic BASEPAGE class and BASEMODEL class respectively, ensuring the consistency and maintainability of the whole method. The corresponding element expressions are automatically identified and generated for different types of components, without manual writing, which improves the efficiency and quality of obtaining element expressions and encapsulation methods.
[0088] Embodiment 2: This application discloses another method for locating an element. Figure 2 , the method described in this embodiment introduces the process of element positioning.
[0089] Step 201: Import the front-end code of the system under test into the large model library.
[0090] Step 202: The large model obtains the HTML source code of the page by means of scheduled or real-time scanning.
[0091] Step 203: Generate PAGE class and MODEL class based on HTML source code.
[0092] Step 204: Configure corresponding element expressions for different components, and generate the element expressions in the PAGE class and the MODEL class respectively.
[0093] Step 205: Configure corresponding packaging methods for different components.
[0094] Step 206: Determine whether there is a method that is the same as the packaging method. If yes, proceed to step 207. If no, proceed to step 208.
[0095] Step 207: Extract the same method into the COMMON class.
[0096] Step 208: Generate the encapsulation method in the PAGE class and the MODEL class respectively.
[0097] Step 209: Generate a sample class in the automation folder, call the methods in the PAGE class, the MODEL class and the COMMON class according to the operation instruction, and generate the operation code for locating the target element.
[0098] Step 210: Store the operation code and positioning process into the sample class for use.
[0099] Based on the method for locating an element disclosed in the above embodiment, this embodiment correspondingly discloses a device for locating an element. Figure 3 , the element positioning device includes: a scanning unit 301, a generating unit 302, a configuring unit 303, a packaging unit 304 and a positioning unit 305;
[0100] The scanning unit 301 is used for the large model to obtain the HTML source code of the page through a timed or real-time scanning method;
[0101] The generating unit 302 is used for the large model to generate page classes of different pages and modal box classes of different modal boxes existing in the pages based on the HTML source code;
[0102] The configuration unit 303 is used for configuring corresponding element expressions for different components in the large model, and generating the element expressions in the page class and the modal box class respectively;
[0103] The encapsulation unit 304 is used for configuring corresponding encapsulation methods for different components in the large model, and when there is no method identical to the encapsulation method, generating the encapsulation method in the page class and the modal box class respectively;
[0104] The positioning unit 305 is used for the large model to generate a sample class under the automation folder, locate the target element according to the input operation instruction, and generate a target operation for the target element to the sample class; the target element is the page and / or the modal box.
[0105] Optionally, the device further comprises:
[0106] The import unit is used to import the front-end code of the tested system into the large model library so that the large model can understand the logic of the front-end code.
[0107] Optionally, the configuration unit 303 includes:
[0108] A training subunit, used for training the large model by using front-end codes including various component types, so that the large model can recognize the rules of different components;
[0109] The configuration subunit is used for configuring the corresponding element expressions for different components in the large model respectively; the element expression is a formula including an XPath expression and an element naming specification.
[0110] Optionally, when there is a method identical to the encapsulation method, the encapsulation method is extracted into a common method class, and the positioning unit 305 includes:
[0111] The public subunit is used to introduce the public method class into the sample class and call the encapsulated method in the public method class.
[0112] Optionally, the scanning unit 301 includes:
[0113] The scanning subunit is used for scanning the front-end code of the large model through a timed or real-time scanning method to obtain the HTML source code;
[0114] The comparison subunit is used to compare the preceding code segment with the element operation in the sample class, and update the element expression and encapsulation method according to the comparison result.
[0115] Optionally, the positioning unit 305 includes:
[0116] A response subunit, used for the large model to respond to the instruction of generating the automation sample, and to generate a directory corresponding to the instruction of generating the automation sample under the automation folder;
[0117] The generation subunit is used to generate sample classes under the directory.
[0118] Optionally, the positioning unit 305 includes:
[0119] The positioning subunit is used for the large model to respond to the operation instruction, locate the target page class and the target page under the target page class according to the operation instruction, or locate the target modal box class and the target modal box under the target modal box class.
[0120] Optionally, the positioning unit 305 includes:
[0121] A calling subunit, used for generating an operation of calling the target element according to the operation instruction;
[0122] The saving subunit is used to save the operation and the process of locating the target element as the target operation to the sample class.
[0123] Optionally, the page class generated by the large model inherits from a basic page class, and the modal box class generated by the large model inherits from a basic modal box class.
[0124] The embodiments in this specification are described in a progressive manner. As for the devices disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the description is relatively simple, and the relevant parts can be referred to the description of the methods.
[0125] It should also be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.
[0126] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
[0127] The features described in the embodiments of this specification can be replaced or combined with each other, so that professional and technical personnel in this field can implement or use the present application.
[0128] 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 method for locating an element, characterized in that: include: The large model obtains the HTML source code of the page through scheduled or real-time scanning; The large model generates page classes of different pages and modal box classes of different modal boxes existing in the pages based on the HTML source code; The large model configures corresponding element expressions for different components, and generates the element expressions in the page class and the modal box class respectively; The large model configures corresponding encapsulation methods for different components, and when there is no method identical to the encapsulation method, the encapsulation method is generated in the page class and the modal box class respectively; The large model generates a sample class under an automation folder, locates a target element according to an input operation instruction, and generates a target operation for the target element to the sample class; the target element is the page and / or the modal box.
2. The method according to claim 1, characterized in that: Before the large model obtains the HTML source code of the page by means of scheduled or real-time scanning, the method further includes: The front-end code of the system under test is imported into the big model library so that the big model can understand the logic of the front-end code.
3. The method according to claim 2, characterized in that The large model configures corresponding element expressions for different components, including: The large model is trained by front-end codes including various component types, so that the large model can recognize the rules of different components; The large model configures the element expressions corresponding to different components respectively; the element expression is a formula including an XPath expression and an element naming specification.
4. The method according to claim 1, characterized in that: When there is a method that is the same as the encapsulation method, the encapsulation method is extracted into a public method class, the large model generates a sample class under an automation folder, and locates the target element according to the input operation instruction, including: The public method class is introduced into the sample class, and the encapsulation method in the public method class is called.
5. The method according to claim 1, characterized in that The large model obtains the HTML source code of the page by means of scheduled or real-time scanning, including: The large model scans the front-end code by means of timed or real-time scanning to obtain the HTML source code; The preceding code segment is compared with the element operation in the sample class, and the element expression and encapsulation method are updated according to the comparison result.
6. The method according to claim 1, characterized in that The large model generates sample classes in the automation folder, including: The large model responds to the instruction to generate the automation sample and generates a directory corresponding to the instruction to generate the automation sample under the automation folder; Generate sample classes in the said directory.
7. The method according to claim 1, characterized in that The step of locating the target element according to the input operation instruction includes: The large model responds to the operation instruction and locates the target page class and the target page under the target page class, or locates the target modal box class and the target modal box under the target modal box class according to the operation instruction.
8. The method according to claim 7, characterized in that The generating a target operation for the target element to the sample class includes: According to the operation instruction, generate an operation to call the target element; The operation and the process of locating the target element are taken as the target operation and saved in the sample class.
9. The method according to any one of claims 1 to 8, characterized in that: The page class generated by the large model inherits from the basic page class, and the modal box class generated by the large model inherits from the basic modal box class.
10. A device for positioning an element, characterized in that: include: A scanning unit, a generating unit, a configuring unit, a packaging unit and a positioning unit; The scanning unit is used for obtaining the HTML source code of the page through a timed or real-time scanning method for the large model; The generating unit is used for the large model to generate page classes of different pages and modal box classes of different modal boxes existing in the pages based on the HTML source code; The configuration unit is used for configuring corresponding element expressions for different components in the large model, and generating the element expressions in the page class and the modal box class respectively; The encapsulation unit is used for configuring corresponding encapsulation methods for different components in the large model, and when there is no method identical to the encapsulation method, the encapsulation method is generated in the page class and the modal box class respectively; The positioning unit is used for the large model to generate a sample class under the automation folder, locate the target element according to the input operation instruction, and generate a target operation for the target element to the sample class; the target element is the page and / or the modal box.