Object Layer Construction Method of Automated Test Framework and UI Automated Test Framework
By building an object layer in the Selenium test framework, generating object description documents and converting them into script files, the problem of missing unified management functions of the object library is solved, and the ease of maintenance of scripts and the success rate of automated testing is improved.
Patent Information
- Application Number
- CN202111181952.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-10-11
- Publication Date
- 2025-06-24
- Estimated Expiration
- 2041-10-11
AI Technical Summary
The existing Selenium test framework lacks the unified management function of object library, which makes UI automation test scripts difficult to maintain and lead to failure of automation tests.
A method for building an object layer based on Selenium's UI automation testing framework is proposed. By obtaining the page of the system to be tested, an object description document in the XML file format is generated, and a script file is converted into a page object and an element object, and encapsulated into a positioning function and an operation function for the logical layer to call.
It realizes independent management of the object layer, reduces script maintenance costs, and increases the success rate of UI automation testing.
Smart Images

Figure CN114036039B_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the field of software testing technology, and specifically relates to an object layer construction method for a UI automation testing framework. Background Art
[0002] User Interface (UI) automated testing is an important part of automated testing technology. Product UI automated testing scripts are often large. In order to make the scripts easy to read and maintain, the scripts are generally designed in layers, including three layers: object layer, logic layer, and business and data layer. The bottom object layer includes object management, object identification, and object operation functions, and is the cornerstone of UI automated testing scripts. On top of this, the logic layer encapsulates functional functions by combining object operations, such as common login functions; the business and data layers call the methods provided by the logic layer to organize use cases, such as verifying the correctness of login when entering different usernames and passwords.
[0003] Selenium is the most commonly used UI automation testing framework for web products and products written in HTML. It is used with other programming languages and use case frameworks during testing. The programming language calls the methods provided by Selenium and organizes the logic layer modules in combination with the functions of the language itself; the use case framework organizes business and test data, provides a use case running environment, etc. For example, common combinations are Selenium+python+RobotFramwork, Selenium+Java+macho.
[0004] Since the Selenium test framework only provides identification and operation function methods for basic objects of web pages, the final test technology solution lacks the unified object management function. The UI object attributes, identification and operation are mixed in the upper logic layer module, and the script structure is chaotic; when the page changes, the UI object positioning and operation method need to be modified again, and the objects need to be found one by one from the logic layer script, which is bound to increase the script maintenance cost; when there are many pages and objects to be tested, objects are used in multiple places, and there are many script codes, it is easy to cause the failure of automated testing. Summary of the invention
[0005] 1. Technical issues to be resolved
[0006] In view of the above-mentioned shortcomings and deficiencies of the prior art, the present application provides an object layer construction method of a UI automation test framework based on Selenium and a UI automation test framework.
[0007] (II) Technical solution
[0008] In order to achieve the above objectives, this application adopts the following technical solutions:
[0009] In a first aspect, an embodiment of the present application provides a method for constructing an object layer of a UI automation test framework based on Selenium. The UI automation test framework includes an object layer, a logic layer, and a business and data layer. The method includes:
[0010] S10. Obtain one or more pages associated with a UI automation test task in the system under test;
[0011] S20. For the one or more pages, write an object description document in xml file format according to preset rules. The object description document uses the one or more pages and / or several key elements therein as nodes and includes the positioning information of the one or more pages and / or several key elements therein;
[0012] S30. Use a pre-written conversion program to convert the object description document into a script file of page objects and / or element objects that follow the page object design pattern;
[0013] S40. Package the positioning and operation methods of page objects and / or element objects into positioning functions and operation functions;
[0014] S50. Use the script file and the positioning functions and operation functions as the object layer for the logic layer to call when executing the UI automation test task through Selenium to achieve object recognition and operation.
[0015] Optionally, the preset rules include:
[0016] Hierarchical division rules, including the correspondence between the node hierarchy of xml and the UI page hierarchy and element hierarchy;
[0017] Object definition rules, including requirements for object naming, description, and type;
[0018] Object positioning rules, including obtaining the positioning information of the several key elements by positioning the several key elements through xpath and / or css.
[0019] Optionally, the positioning information supports variable and expression formats, and the positioning information of the current object supports inheritance from the positioning information of the parent object.
[0020] Optionally, S30 includes:
[0021] According to the type attribute of the xml node, convert each xml node into a page class or a Control class, set the parent class of the page class or Control class according to the parent attribute of the xml node, and convert the name attribute, description attribute, and positioning attribute of the xml node into class member variables;
[0022] The class converted from the parent XML node contains class instance member variables corresponding to the classes of the child XML nodes. The variable names of the class instance member variables are the same as the child XML node names for subsequent chained access.
[0023] In the script file of the page object and / or element object, a method for batch verification of object positioning attributes is provided.
[0024] Optionally, in S40:
[0025] The operation methods of the page object and / or element object include: open_app, quit_app, find_element, find_element_until_exist, is_element_exist, click, double_click, right_click, set_value, table_cell_click, table_cell_getValue, table_getRowCount, etc. Different from the original methods provided by the Selenium test framework for individual tags, these methods are all operation methods for controls.
[0026] Optionally, S40 includes: A control composed of multiple tag elements only exposes the characteristic tag element object of the control as the method input parameter. The positioning and operation of other associated tags in the control are encapsulated in the operation method, and combined and encapsulated into an operation method for the control.
[0027] Optionally, S40 also includes:
[0028] Define an error handling method for the operation function to call when an exception occurs in the operation method; the error handling method includes:
[0029] When an exception occurs in the operation method, throw the exception; the exceptions that occur in the operation method include: unable to find the element, the element is not interactive, the element is not unique;
[0030] Print and output the exception information, and the exception information includes the object name, description, and positioning information.
[0031] In a second aspect, an embodiment of the present application provides a Selenium-based UI automation test framework. The UI automation test framework includes an object layer, a logic layer, and a business and data layer. The object layer includes:
[0032] An object script module generated by S10 - S30 in the object layer construction method of the Selenium-based UI automation test framework according to any one of the first aspects;
[0033] The object location and operation function module generated by S40 in the object layer construction method of the Selenium-based UI automation test framework described in any one of the first aspects.
[0034] Optionally, the UI automation test framework further includes:
[0035] An error definition module, configured to define an error handling method for being called by an operation function when an exception occurs in an object operation method; the error handling method includes:
[0036] When an exception occurs in the operation method, throw an exception; the exceptions that occur in the operation method include: unable to find an element, the element is not interactive, the element is not unique;
[0037] Print and output the exception information, where the exception information includes the object name, description, and location information.
[0038] (III) Beneficial effects
[0039] The beneficial effects of this application are as follows: This application proposes an object layer construction method for a Selenium-based UI automation test framework. The test framework includes an object layer, a logic layer, and a business and data layer. The method includes: obtaining one or more pages associated with the UI automation test task in the system under test; generating an object description document in xml file format using a preset rule, where the object description document uses a page and / or a key element as a node and includes the location information of the page and / or the key element; converting the object description document into a script file of a page object and / or an element object; encapsulating the location and operation methods of the page object and / or the element object into a location function and an operation function; using the script file and the location function and the operation function as the object layer for the logic layer to call.
[0040] Through the object layer construction method of the Selenium-based UI automation test framework of this application, the UI automation test script using the Selenium test framework can conveniently construct an independent object layer, which is easy to manage, reduces the script management and maintenance cost, and improves the success rate of UI automation testing. Description of the drawings
[0041] This application is described with the aid of the following drawings:
[0042] Figure 1 It is a schematic flowchart of the object layer construction method of the Selenium-based UI automation test framework in an embodiment of this application;
[0043] Figure 2 It is an example diagram of an object description document in xml file format in an embodiment of this application;
[0044] Figure 3Schematic diagram of a script file example in an embodiment of the present application;
[0045] Figure 4 Schematic diagram of the process for building a Selenium-based UI automation test framework in another embodiment of the present application;
[0046] Figure 5 Schematic diagram of the code example of the object location and operation basic function module in another embodiment of the present application. Detailed implementation manners
[0047] For better explaining the present invention for easy understanding, the present invention will be described in detail below in conjunction with the accompanying drawings through specific implementation manners. It can be understood that the specific embodiments described below are only used to explain the related invention and do not limit the invention. In addition, it should be noted that, without conflict, the embodiments in the present application and the features in the embodiments can be combined with each other; for the convenience of description, only the parts related to the invention are shown in the drawings.
[0048] In the agile development mode, new software versions are released quickly and frequently. To ensure the quality of the product, efficient software testing, especially automated testing, plays an important role. In view of the current situation that the Selenium test framework lacks the unified management function of the object library, the scripts are not easy to maintain, and it is easy to cause automated test failures, the present application proposes a method for constructing the object layer of a Selenium-based UI automation test framework, which will be described in detail below through specific embodiments.
[0049] Embodiment 1
[0050] Figure 1 Schematic diagram of the method for constructing the object layer of a Selenium-based UI automation test framework in an embodiment of the present application, wherein the UI automation test framework includes an object layer, a logic layer, and a business and data layer. As Figure 1 shown, the method for constructing the object layer of the Selenium-based UI automation test framework in this embodiment includes:
[0051] S10. Obtain one or more pages associated with the UI automation test task in the system under test;
[0052] S20. For one or more pages, write an object description document in the xml file format according to a preset rule. The object description document takes one or more pages and / or several key elements therein as nodes and includes the location information of one or more pages and / or several key elements therein;
[0053] S30. Use a pre-written conversion program to convert the object description document into a script file of a page object and / or an element object that follows the page object design pattern;
[0054] S40. Package the positioning and operation methods of page objects and / or element objects into positioning functions and operation functions;
[0055] S50. Use the script file, positioning functions, and operation functions as the object layer for the logic layer to call when performing UI automation testing tasks through Selenium, so as to realize the recognition and operation of objects.
[0056] The method for constructing the object layer of the UI automation testing framework based on Selenium in this embodiment enables the UI automation testing script of the Selenium testing framework to conveniently construct an independent object layer, which is easy to manage, reduces the script management and maintenance cost, and improves the success rate of UI automation testing.
[0057] To better understand the present invention, the following elaborates on each step in this embodiment.
[0058] In S10 of this embodiment, the system under test can be a web system or a desktop application built using Electron and html.
[0059] Understandably, the UI testing task refers to a task for testing whether the user interface meets the expected functional requirements. The multiple pages associated with the UI testing task can be multiple pages that complete the function to be tested, and these pages are used as the pages to be tested. In some examples, the multiple pages can include a login page and a content page. The login page refers to the interface when the user logs in. The user needs to enter the username and password on the login page and then enter the home page. The business page can be accessed through the link provided on the home page. The content page can refer to the operation page for handling the business process.
[0060] The preset rules in S20 of this embodiment may include:
[0061] Hierarchical division rules, including the correspondence between the node hierarchy of xml and the UI page hierarchy and element hierarchy;
[0062] Object definition rules, including requirements for object naming, description, and type;
[0063] Object positioning rules, including positioning the several key elements through xpath and / or css to obtain the positioning information of the several key elements.
[0064] Specifically, the positioning information supports variable and expression formats, and the positioning information of the current object supports inheritance from the positioning information of the parent object, so as to match the UI multi-level features.
[0065] All the content on the Web page is called page elements. For automated testing, the elements of the test page should be located first, and then the corresponding test logic should be implemented by performing various operations on the elements. For the location of page elements, Selenium provides location methods including id, class, name, XPath, etc. In this embodiment, the xpath and / or css location methods are adopted.
[0066] Figure 2 This is an example diagram of an object description document in xml file format in an embodiment of the present application. As Figure 2 shown, this embodiment adopts the UI object organization description form in xml document format. Further, the UI objects are hierarchically structured and centrally managed in the xml document; in addition to containing location information, the location information supports variable expressions; it also contains auxiliary information such as object type, standard naming, description, etc., which is easy to maintain and edit. If the page is adjusted, resulting in changes in the page element information, only the location information of the changed elements needs to be modified in the XML file, and there is no need to modify the source code in the page class, which is convenient for the maintenance of the page class.
[0067] In this embodiment, the conversion program pre-written in S30 can be written in python.
[0068] Figure 3 This is an example diagram of a script file in an embodiment of the present application. As Figure 3 shown, the conversion program converts the object description document into a script file of page objects and element objects that follow the page object design pattern, that is, the nodes in the xml document are converted into corresponding classes and class instances in the object module code, such as page classes and object classes.
[0069] Specifically, S30 includes:
[0070] According to the type attribute of the xml node, each xml node is converted into a page class or a Control class. According to the parent attribute of the xml node, the parent class of the page class or Control class is set. The name attribute, description attribute, and location attribute of the xml node are converted into class member variables;
[0071] The class converted from the parent xml node contains class instance member variables corresponding to the child xml node classes. The variable names of the class instance member variables are the same as the child xml node names for subsequent chained access;
[0072] In the script file of the page object and / or element object, a method for batch verification of object location attributes is provided, thereby improving the writing efficiency of object attributes.
[0073] In this embodiment, the operation methods of the page object and / or element object in S40 include: opening an application open_app, closing an application quit_app, finding an object find_element, finding and waiting for an object to exist find_element_until_exist, determining whether an object exists is_element_exist, clicking an object click, double-clicking an object double_click, right-clicking an object right_click, obtaining the attribute value of an object set_value, clicking a table cell table_cell_click, obtaining the content of a table cell table_cell_getValue, obtaining the number of rows in a table table_getRowCount, etc.
[0074] By providing the basic operations of the common Web UI, the engineering efficiency is improved, and the entry threshold and the usage threshold of selenium are reduced. The provided find_element function supports both xpath and css recognition grammars, so that the script logic layer writer does not need to care about the specific content of the positioning attribute string in xml. It supports expression parameter processing. The xpath and css positioning methods can cover 100% of the object positioning scenarios.
[0075] In this embodiment, for the page / control class features in the docking object module, the provided methods all use the page / control class instance as the input parameter, supplemented by other method-related parameters.
[0076] Optionally, the basic functions of object positioning and operation can be expanded as needed, especially for continuous accumulation of various types of front-end frameworks.
[0077] Therefore, in some preferred embodiments, S40 may further include encapsulating the operation methods of multiple label element objects into an operation function, and the operation methods of the multiple label elements are used to complete the operation of a control.
[0078] The object operations provided by selenium are all for a single label element object (a single tag of html). For current popular front-end frameworks such as React and ant, a web control is composed of a group of associated html tags, and the operations of this group of tags need to be combined to complete the basic operations of a control. Encapsulating these operations into basic operation functions and continuously accumulating and continuously expanding this module is of great significance.
[0079] In this embodiment, S40 further includes:
[0080] Defining an error handling method for the operation function to call when an exception occurs in the operation method; the error handling method includes:
[0081] When an exception occurs in the operation method, an exception is thrown; the exceptions that occur in the operation method include: unable to find an element, the element is not interactive, and the element is not unique;
[0082] Print and output the exception information, where the exception information includes the object name, description, and location information.
[0083] In S50 of this embodiment, the classes and class instances in the script file contain an identify attribute, which is a string in xpath or css syntax and is used as the input for the basic functions provided by the selenium framework to implement object identification and operation.
[0084] In view of the current situation that the Selenium test framework lacks a unified management function for the object library and the scripts are not easy to maintain, this embodiment provides a method for constructing an object layer that matches the Selenium test framework, including functions such as structured centralized management of UI objects, batch verification and update of objects, and unified management of identification and operation method functions, enabling the UI automation test scripts using the Selenium test framework to conveniently construct an independent object layer, which is easy to manage, reduces the script management and maintenance costs, and improves the success rate of automated testing.
[0085] Embodiment 2
[0086] In a second aspect, the present application provides a UI automation test framework based on Selenium. The UI automation test framework includes an object layer, a logic layer, and a business and data layer. The object layer includes:
[0087] An object script module generated by S10 - S30 in the object layer construction method of the UI automation test framework based on Selenium according to any one of the above embodiments;
[0088] An object positioning and operation function module generated by S40 in the object layer construction method of the UI automation test framework based on Selenium according to any one of the above embodiments.
[0089] This embodiment can quickly construct an object layer that is easy to be independent and maintain, making the UI automation script logic layer module simply call objects and methods.
[0090] In this embodiment, the UI automation test framework further includes:
[0091] An error definition module for defining error handling methods for the operation function to call when an exception occurs in the object operation method; the error handling methods include:
[0092] When an exception occurs in the operation method, an exception is thrown; the exceptions that occur in the operation method include: unable to find an element, the element is not interactable, the element is not unique;
[0093] Print and output the exception information, and the exception information includes the object name, description, and positioning information.
[0094] The error definition module can give an easy-to-understand and detailed prompt when an exception occurs in the object recognition operation. Compared with the native error prompt of Selenium, it is more conducive to problem location and troubleshooting.
[0095] In this embodiment, the UI automation test framework further includes a conversion module, which is used to convert the object description document into a script file of a page object and / or an element object that follows the page object design pattern.
[0096] In this embodiment, the UI automation test framework further includes a control general operation driver module, which further encapsulates the basic object positioning and operation functions provided by Selenium and docks with the page class and object class in the object layer module script. It improves the engineering efficiency and reduces the entry threshold and the usage threshold of Selenium.
[0097] Figure 4 It is a schematic diagram of the process for building a Selenium-based UI automation test framework in another embodiment of this application. As Figure 2 shown, the process for building a Selenium-based UI automation test framework includes:
[0098] (1) Write an xml document, and the xml node names and attributes in the document need to be written according to preset rules. The preset rules include:
[0099] ① Hierarchical division: One xml node corresponds to one html page or html tag, corresponding to the multi-level characteristics of the UI. The xml node corresponding to the sub-control is located under the xml node corresponding to the parent page / control.
[0100] ② Node name: Subsequently, in the upper-layer script, the corresponding object will be accessed by the node name. It must start with a letter. Duplicate names are allowed.
[0101] ③ Node attribute--desc: Object description, a required attribute.
[0102] ④ Node attribute--type: Object type, which can be set to "page" or "control", indicating whether the xml node corresponds to a page or a control. It is an optional attribute. If not set, the default value is "control".
[0103] ⑤node attribute--father: The father type of the object, which can be set to the nodename of other xml nodes. It is used to abstract similar pages and objects, reducing the object maintenance amount. If not set, the default value is "basepage" or "basecontrol", which is an optional attribute.
[0104] ⑥node attribute--identify: The object location information, which is a required attribute. It must follow the selenium xpath or css - selector syntax. In the same xml, the co - existence of the two syntaxes is allowed.
[0105] ⑦node attribute--identify, variables and expressions: The value of the identify attribute allows the use of variables and expressions, represented by "${...}"; variables are represented by "args[0]". Variables must be placed in expressions. In the same expression, the args number starts from 0 and accumulates as needed. The following is a usage example: identity = " / / div[${args[0]*2 + 1}] / / span[${args[1]*2 + args[0]}]". In the subsequent usage process, with the input parameters (3, 5), the final result is: " / / div[7] / / span
[13] ".
[0106] ⑧node attribute--identify, father identify inheritance: The value of the identify attribute supports the use of the $FATHER prefix. The application effect is that the identity of the parent node automatically replaces the $FATHER prefix in the child node. This prefix design makes the xml more concise. Note that in this scenario, the parent and child nodes must belong to the same syntax.
[0107] (2) Use the conversion module to convert the xml object description document into an object script module in one click.
[0108] The conversion module converts the xml object description document into an object script module in one click. In the subsequent upper - layer module of the UI automation script, this script module is directly called.
[0109] ①Through the conversion module, according to the type attribute of the xml node, each xml node is converted into a page class or a Control class. The parent class of the page / Control class is set according to the father attribute of the xml node. Other attributes are converted into class member variables, including key information such as name, desc, and the location attribute identify.
[0110] ② The class converted from the parent xml node contains the class instance member variables corresponding to the child xml node classes, and the variable names are the same as the child xml node names for subsequent chained access.
[0111] In the generated object script module, a method for batch verification of object positioning attributes is provided to improve the writing efficiency of object attributes.
[0112] (3) Description of the error definition module.
[0113] The error definition module defines common error types, such as ElementNotFound, ElementNotInteractable, ElementNotUnique, etc., and redefines the information content printed when an exception is triggered, including the object name, description, positioning information, etc., which is easy to understand. Compared with the native error prompts of Selenium, it is more conducive to problem location and troubleshooting.
[0114] Optionally, the error definition module can be expanded according to project needs to expand error types.
[0115] Through the error module, when an exception occurs in object recognition operations, an easy-to-understand and detailed prompt is given. Compared with the native error prompts of Selenium, it is more conducive to problem location and troubleshooting.
[0116] (4) Description of the basic function module for object positioning and operations.
[0117] The technical solution provides a basic function module for object positioning and operations. Figure 5 This is a code example diagram of the basic function module for object positioning and operations in another embodiment of this application, as shown in the figure:
[0118] ① For the page / control class features in the docking object module, the provided methods all take page / control class instances as input parameters, supplemented by other method-related parameters.
[0119] ② The provided methods include: open_app, quit_app, find_element, find_element_until_exist, is_element_exist, click, double_click, right_click, set_value, etc.
[0120] ③ The provided find_element function supports both xpath and css recognition grammars and supports expression parameter processing.
[0121] ④In the method, when an exception is thrown, the error types provided in (3) are all adopted.
[0122] Optionally, expand the object location and operation basic function module as needed, especially for continuous accumulation of various types of front-end frameworks.
[0123] This embodiment adopts the object script module design, including the design of object classes, following the Page Object design pattern. Related objects are placed in a class, and operations are uniformly encapsulated. In addition, it also includes auxiliary methods such as object batch verification.
[0124] Through the above processes (1), (2), (3), and (4), an easy-to-maintain independent object layer is constructed. The xml object description file is easy to understand, expand, and update. The object script module follows the Page Object design pattern. Related objects are placed in a class, and operations are uniformly encapsulated. The detailed information is hidden from the outside, and the logic layer script becomes simple object and method calls and verification operations. It provides the functions of batch verification and update of object location attributes, and an exception prompt mechanism superior to the original framework, facilitating the debugging and maintenance of UI automation scripts.
[0125] It should be noted that in the claims, any reference signs between parentheses shall not be construed as limiting the claim. The word "comprising" does not exclude the presence of elements or steps not listed in a claim. The word "a" or "an" preceding an element does not exclude the presence of a plurality of such elements. The present invention can be implemented by means of hardware including several different elements and by means of a suitably programmed computer. The use of the words first, second, third, etc. is only for convenience of expression and does not denote any order. These words can be construed as part of the element name.
[0126] In addition, it should be noted that in the description of this specification, the descriptions of terms such as "one embodiment", "some embodiments", "embodiment", "example", "specific example", or "some examples" mean that the specific features, structures, materials, or characteristics described in connection with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials, or characteristics described can be combined in a suitable manner in any one or more embodiments or examples. In addition, without contradiction, those skilled in the art can combine and combine the different embodiments or examples described in this specification and the features of different embodiments or examples.
[0127] Although the preferred embodiments of the present invention have been described, those skilled in the art can make additional changes and modifications after learning the basic creative concepts. Therefore, the claims should be construed to cover the preferred embodiments as well as all changes and modifications falling within the scope of the present invention.
[0128] Obviously, those skilled in the art can make various modifications and variations to the present invention without departing from the spirit and scope of the present invention. Thus, if these modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalent technologies, the present invention should also cover these modifications and variations.
Claims
1. A method for constructing an object layer of a UI automation testing framework based on Selenium, characterized in that, The UI automation test framework includes an object layer, a logic layer, and a business and data layer. The method includes: S10. Obtain one or more pages associated with the UI automation test task in the system under test; S20. For the one or more pages, write an object description document in the xml file format according to preset rules. The object description document takes the one or more pages and / or several key elements therein as nodes and includes the positioning information of the one or more pages and / or several key elements therein; the positioning information supports variable and expression formats, and the positioning information of the current object supports inheritance from the positioning information of the parent object to reflect the object hierarchy relationship; S30. Use a pre-written conversion program to convert the object description document into a script file of page objects and / or element objects that follow the page object design pattern; S40. Package the positioning and operation methods of page objects and / or element objects into positioning functions and operation functions; the operation methods are operation methods for controls composed of multiple tag elements, and the characteristic tag elements of the control are input parameter objects, and the operation methods package the positioning and operation of the associated tags in the control; S50. Use the script file and the positioning functions and operation functions as the object layer for the logic layer to call when executing the UI automation test task through Selenium to achieve object recognition and operation.
2. The method for constructing the object layer of the Selenium-based UI automation testing framework according to claim 1, wherein The preset rules include: Hierarchical division rules, including the correspondence between the node hierarchy of xml and the page hierarchy and element hierarchy of the UI page; Object definition rules, including requirements for object naming, description, and type; Object positioning rules, including obtaining the positioning information of the several key elements by positioning the several key elements through xpath and / or css.
3. The method for constructing the object layer of the UI automation test framework based on Selenium according to claim 1, characterized in that, S30 includes: According to the type attribute of the xml node, convert each xml node into a page class or a Control class, set the parent class of the page class or Control class according to the parent attribute of the xml node, and convert the name attribute, description attribute, and positioning attribute of the xml node into class member variables; The class converted from the parent xml node contains class instance member variables corresponding to the sub xml node classes, and the variable names of the class instance member variables are the same as the sub xml node names for subsequent chained access; In the script file of page objects and / or element objects, provide auxiliary methods such as automatic generation of batch verification of object positioning attributes.
4. The method for constructing the object layer of the Selenium-based UI automation testing framework according to claim 1, characterized in that, In S40: The operation methods of page objects and / or element objects include: open_app, quit_app, find_element, find_element_until_exist, is_element_exist, click, double_click, right_click, set_value, table_cell_click, table_cell_getValue, table_getRowCount.
5. The method for constructing the object layer of the UI automation test framework based on Selenium according to claim 4, wherein S40 also includes: Define an error handling method for the operation function to call when an exception occurs in the operation method; the error handling method includes: When an exception occurs in the operation method, throw the exception; the exceptions that may occur in the operation method include: unable to find an element, the element is not interactive, the element is not unique; Print and output the exception information, which includes the object name, description, and location information.
6. A UI automation testing framework based on Selenium, characterized in that, The UI automation test framework includes an object layer, a logic layer, and a business and data layer. The object layer includes: An object script module generated by S10 - S30 in the object layer construction method of the Selenium - based UI automation test framework according to any one of claims 1 - 5; An object location and operation function module generated by S40 in the object layer construction method of the Selenium - based UI automation test framework according to any one of claims 1 - 5.
7. The UI automation test framework based on Selenium according to claim 6, wherein The UI automation test framework further includes: An error definition module for defining an error handling method for the operation function to call when an exception occurs in the object operation method; the error handling method includes: When an exception occurs in the operation method, throw the exception; the exceptions that may occur in the operation method include: unable to find an element, the element is not interactive, the element is not unique; Print and output the exception information, which includes the object name, description, and location information.
Citation Information
Patent Citations
Web automation test method and method-based system
CN108491319A
Web test platform and Web test method based on hybrid automatic test framework
CN110321281A
Selenium-based Web application automatic test framework and construction method and system thereof
CN110851356A