CN114036039A - Object layer construction method of automatic test framework and UI automatic test framework - Google Patents

Object layer construction method of automatic test framework and UI automatic test framework Download PDF

Info

Publication number
CN114036039A
CN114036039A CN202111181952.4A CN202111181952A CN114036039A CN 114036039 A CN114036039 A CN 114036039A CN 202111181952 A CN202111181952 A CN 202111181952A CN 114036039 A CN114036039 A CN 114036039A
Authority
CN
China
Prior art keywords
layer
page
positioning
selenium
class
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202111181952.4A
Other languages
Chinese (zh)
Inventor
谷双平
王帅
余泽超
谭虹
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Zhejiang Supcon Technology Co Ltd
Original Assignee
Zhejiang Supcon Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Zhejiang Supcon Technology Co Ltd filed Critical Zhejiang Supcon Technology Co Ltd
Priority to CN202111181952.4A priority Critical patent/CN114036039A/en
Publication of CN114036039A publication Critical patent/CN114036039A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3684Test management for test design, e.g. generating new test cases
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3688Test management for test execution, e.g. scheduling of test suites

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Computer Hardware Design (AREA)
  • Quality & Reliability (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Debugging And Monitoring (AREA)

Abstract

The application belongs to the technical field of software testing, and particularly relates to a method for constructing an object layer of a UI (user interface) automatic testing frame based on Selenium. The method comprises the following steps: acquiring one or more pages related to a UI automatic test task in a tested system; writing an object description document in an xml file format by adopting a preset rule, wherein the object description document takes a page and/or a key element as a node and comprises positioning 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; packaging the positioning and operation methods of the page object and/or the element object into a positioning function and an operation function; and taking the script file, the positioning function and the operation function as an object layer for the calling of a logic layer. The object layer constructed based on the method can be used for carrying out automatic testing, so that the script management and maintenance cost can be reduced, and the success rate of automatic testing is improved.

Description

Object layer construction method of automatic test framework and UI automatic test framework
Technical Field
The application belongs to the technical field of software testing, and particularly relates to an object layer construction method of a UI automation testing framework.
Background
User Interface (UI) automated testing is an important component of automated testing technology. The automatic test script of product UI is often comparatively huge, in order to make the script easily read and maintain, generally carries out the layered design to the realization of script, contains the three-layer: an object layer, a logic layer, a business and data layer. The object layer at the bottom layer comprises object management, object identification and object operation functions and is a basic stone of the UI automation test script. On the top, the logic layer encapsulates a function, such as a common login function, by a combined object operation; the service and data layer calls the method provided by the logic layer to organize the use case, for example, to verify the correctness of login when different user names and passwords are input.
web-type products, html authoring UI products, Selenium is the most common UI automation testing framework. When in test, the method is matched with other programming languages and use case frames, the programming languages call the method provided by the Selenium, and the logic layer module is organized by combining the functions of the languages; the case framework organizes services and test data, provides a case running environment, and the like, and for example, common collocation combinations are Selenium + python + robotframework, and Selenium + Java + macho.
Because the Selenium testing framework only provides a method for identifying and operating functions of basic objects of the web page, the finally formed testing technical scheme lacks an object uniform management function. The attribute, identification and operation of the UI object are mixed in an upper logic layer module, and scripts form chaos; when the page changes, the UI object positioning and operation modes need to be modified again, and objects need to be found out from the logic layer script one by one, which inevitably increases the script maintenance cost; when the number of pages and objects to be tested is large, the number of objects is large, and the number of script codes is large, the automatic test is prone to fail.
Disclosure of Invention
Technical problem to be solved
In view of the above disadvantages and shortcomings of the prior art, the present application provides an object layer building method of a Selenium-based UI automation test framework and a UI automation test framework.
(II) technical scheme
In order to achieve the purpose, the technical scheme is as follows:
in a first aspect, an embodiment of the present application provides a method for constructing an object layer of a Selenium-based UI automation test framework, where the UI automation test framework includes an object layer, a logic layer, a service layer, and a data layer, and the method includes:
s10, acquiring one or more pages related to the UI automation test task in the tested system;
s20, writing an object description document in an xml file format by adopting a preset rule aiming at the one or more pages, wherein the object description document takes the one or more pages and/or a plurality of key elements therein as nodes and comprises positioning information of the one or more pages and/or the plurality of key elements therein;
s30, converting the object description document into a script file of a page object and/or an element object following a page object design mode by adopting a pre-written conversion program;
s40, packaging the positioning and operation method of the page object and/or the element object into a positioning function and an operation function;
and S50, taking the script file, the positioning function and the operation function as an object layer, and calling the object layer when the logic layer executes the UI automation test task through the Selenium to realize the identification and operation of the object.
Optionally, the preset rule includes:
the hierarchy division rule comprises an xml node hierarchy corresponding to a UI page hierarchy and an element hierarchy;
the object definition rules comprise requirements of object naming, description and type;
and the object positioning rule comprises positioning the key elements through xpath and/or css to acquire positioning information of the key elements.
Optionally, the location information supports variable and expression formats, and the location information of the current object supports inheritance of parent object location information.
Optionally, S30 includes:
converting each xml node into a page class or a Control class according to the type attribute of the xml node, setting a parent class of the page class or the Control class according to the parent attribute of the xml node, and converting the name attribute, the description attribute and the positioning attribute of the xml node into a class member variable;
converting the father xml node into a class containing class instance member variables corresponding to the child xml node class, wherein the variable names of the class instance member variables are the same as the names of the child xml nodes for subsequent chained access;
and providing a method for batch verification of object positioning attributes in script files of page objects and/or element objects.
Alternatively, in S40:
the operation method of the page object and/or the element object comprises the following steps: open _ app, quick _ app, find _ element _ neutral _ exist, is _ element _ exist, click, double _ click, right _ click, set _ value, table _ cell _ click, table _ cell _ getValue, table _ getbelow count, and the like. Unlike the original methods for a single label provided by the selenium test framework, these methods are all methods of operation for controls.
Optionally, S40 includes: the control composed of a plurality of label elements only exposes the characteristic label element object of the control to the outside, and the characteristic label element object is used as a method for entering the control, the positioning and the operation of other associated labels in the control are packaged in the operation method, and the control is combined and packaged into an operation method aiming at the control.
Optionally, S40 further includes:
defining an error processing method so as to be called by the operation function when the operation method is abnormal; the error processing method comprises the following steps:
when the operation method is abnormal, throwing the abnormality; the abnormality occurring in the operation method includes: the elements cannot be found, cannot be interacted and are not unique;
and printing and outputting abnormal information, wherein the abnormal information comprises object name, description and positioning information.
In a second aspect, an embodiment of the present application provides a Selenium-based UI automation testing framework, where the UI automation testing framework includes an object layer, a logic layer, a service layer, and a data layer, and the object layer includes:
an object script module generated by S10-S30 of the object layer building method of the Selenium-based UI automation test framework of any of the first aspects;
the object localization 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 the first aspects.
Optionally, the UI automation test framework further comprises:
the error definition module is used for defining an error processing method so as to be called by an operation function when the object operation method is abnormal; the error processing method comprises the following steps:
when the operation method is abnormal, throwing the abnormality; the abnormality occurring in the operation method includes: the elements cannot be found, cannot be interacted and are not unique;
and printing and outputting abnormal information, wherein the abnormal information comprises object name, description and positioning information.
(III) advantageous effects
The beneficial effect of this application is: the application provides an object layer construction method of a Selenium-based UI automatic test framework, wherein the test framework comprises an object layer, a logic layer, a service layer and a data layer, and the method comprises the following steps: acquiring one or more pages related to a UI automatic test task in a tested system; generating an object description document in an xml file format by adopting a preset rule, wherein the object description document takes a page and/or a key element as a node and comprises positioning 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; packaging the positioning and operation methods of the page object and/or the element object into a positioning function and an operation function; and taking the script file, the positioning function and the operation function as an object layer for the calling of a logic layer.
By the object layer construction method of the Selenium-based UI automatic test framework, the UI automatic test script of the Selenium test framework can be used for conveniently constructing an independent object layer, the management is easy, the script management and maintenance cost is reduced, and the UI automatic test success rate is improved.
Drawings
The application is described with the aid of the following figures:
fig. 1 is a schematic flowchart of an object layer construction method of a Selenium-based UI automation test framework in an embodiment of the present application;
FIG. 2 is a diagram of an example object description document in an xml file format in one embodiment of the present application;
FIG. 3 is an exemplary diagram of a script file in one embodiment of the present application;
FIG. 4 is a schematic diagram illustrating a process of building a Selenium-based UI automation test framework according to another embodiment of the present application;
FIG. 5 is a diagram of an example code of an object location and operation basis function module in another embodiment of the present application.
Detailed Description
For the purpose of better explaining the present invention and to facilitate understanding, the present invention will be described in detail by way of specific embodiments with reference to the accompanying drawings. It is to be understood that the following specific examples are illustrative of the invention only and are not to be construed as limiting the invention. In addition, it should be noted that, in the case of no conflict, the embodiments and features in the embodiments in the present application may be combined with each other; for convenience of description, only portions related to the invention are shown in the drawings.
In an agile development mode, software releases new versions quickly and frequently, and plays an important role in ensuring the quality of products and efficient software testing, especially automatic testing. Aiming at the current situations that a Selenium testing framework lacks an object library unified management function, a script is not easy to maintain and automation testing failure is easily caused, the application provides an object layer construction method of a Selenium-based UI automation testing framework, and the following detailed description is given through specific embodiments.
Example one
Fig. 1 is a schematic flowchart of an object layer construction method of a Selenium-based UI automation test framework in an embodiment of the present application, where the UI automation test framework includes an object layer, a logic layer, a service layer, and a data layer. As shown in fig. 1, the object layer construction method of the Selenium-based UI automation test framework of the present embodiment includes:
s10, acquiring one or more pages related to the UI automation test task in the tested system;
s20, writing an object description document in an xml file format by adopting a preset rule aiming at one or more pages, wherein the object description document takes one or more pages and/or a plurality of key elements therein as nodes and comprises positioning information of one or more pages and/or a plurality of key elements therein;
s30, converting the object description document into a script file of a page object and/or an element object following a page object design mode by adopting a pre-written conversion program;
s40, packaging the positioning and operation method of the page object and/or the element object into a positioning function and an operation function;
and S50, taking the script file, the positioning function and the operation function as an object layer for the logic layer to call when executing the UI automation test task through the Selenium so as to realize the identification and operation of the object.
The object layer construction method of the Selenium-based UI automation test framework enables the UI automation test script of the Selenium test framework to be used for conveniently constructing an independent object layer, is easy to manage, reduces script management and maintenance cost, and improves the success rate of UI automation test.
In order to better understand the present invention, the steps in the present embodiment are explained below.
In this embodiment S10, the system under test may be a web system, or may be a desktop application program constructed by using Electron and html.
Understandably, a UI test task refers to a task for testing whether a user interface meets an expected functional requirement. The multiple pages associated with the UI test task may be multiple pages that complete the function to be tested, and are taken as pages to be tested. In some examples, the plurality of pages may include a login page, a content page. The login page refers to an interface when a user logs in, and the user needs to input a user name and a password on the login page and then enter a homepage. The service page may be accessed via a link provided by the home page. The content page may refer to an operation page for handling a business process.
The preset rule in this embodiment S20 may include:
the hierarchy division rule comprises an xml node hierarchy corresponding to a UI page hierarchy and an element hierarchy;
the object definition rules comprise requirements of object naming, description and type;
and the object positioning rule comprises positioning the key elements through xpath and/or css to acquire positioning information of the key elements.
Specifically, the location information supports variable and expression formats, and the location information of the current object supports inheritance of parent object location information, thereby matching UI multi-level features.
All the content on the Web page is called page element, and the automated test should be firstly positioned to the element of the test page, and then the corresponding test logic is realized by executing various operations on the element. For the positioning of page elements, the Selenium provides positioning modes including id, class, name, XPath and the like, and the present embodiment adopts an XPath and/or css positioning mode.
FIG. 2 is a diagram of an example object description document in an xml file format in one embodiment of the present application. As shown in FIG. 2, the present embodiment takes the form of a UI object organizational description in the xml document format. Further, the UI object is hierarchically structured and centrally managed in the xml document; in addition to containing positioning information, the positioning information supports variable expressions; and the system also contains auxiliary information such as object types, specification naming, description and the like, and is easy to maintain and edit. If the page is adjusted to cause the page element information to change, only the positioning information of the movable element needs to be modified in the XML file, and the source code in the page class does not need to be modified, so that the page class is convenient to maintain.
In this embodiment, the conversion program written in advance in S30 may be written in python.
FIG. 3 is an exemplary diagram of a script file in one embodiment of the present application, and as shown in FIG. 3, a conversion program converts an object description document into a script file of page objects and element objects that conform to a page object design model, i.e., converts nodes in an xml document into corresponding classes and class instances, such as page classes and object classes, in object module code.
S30 specifically includes:
converting each xml node into a page class or a Control class according to the type attribute of the xml node, setting a parent class of the page class or the Control class according to the parent attribute of the xml node, and converting the name attribute, the description attribute and the positioning attribute of the xml node into a class member variable;
converting the father xml node into a class containing class instance member variables corresponding to the child xml node class, wherein the variable names of the class instance member variables are the same as the names of the child xml nodes for subsequent chained access;
in the script file of the page object and/or the element object, a method for batch verification of the object positioning attribute is provided, so that the writing efficiency of the object attribute is improved.
In this embodiment, the operation method of the page object and/or the element object in S40 includes: opening an application open _ app, closing an application quick _ app, finding an object find _ element, finding and waiting for the object to exist find _ element _ uniform _ exist, judging whether the object exists is _ element _ exist, clicking an object click, double clicking the object double _ click, right clicking the object right _ click, acquiring an object attribute value set _ value, clicking a table cell table _ cell _ click, acquiring a table cell content table _ cell _ getValue, acquiring a table row number table _ getbelow count and the like.
By providing basic operation of a common Web UI, the engineering efficiency is improved, and the entrance threshold and the using threshold of seleniums are reduced. The provided find _ element function simultaneously supports two recognition grammars of xpath and css, so that a script logic layer writer does not need to be concerned about the specific content of the positioning attribute character string in xml. And supporting expression parameter processing. The xpath and css positioning modes can cover 100% of the object positioning scene.
In this embodiment, the method provided by the property of the page/control class in the module to be docked takes the instance of the page/control class as an input parameter, and is supplemented with parameters related to other methods.
Optionally, the object localization and operation basis functions may be extended as needed, particularly for each type of front-end framework.
Therefore, in some preferred embodiments, S40 may further include encapsulating the operation methods of multiple tab element objects into an operation function, where the operation methods of multiple tab elements are used to complete the operation of one control.
The object operations provided by selenium are all for a single tag element object (a single tag of html). However, in the currently popular front-end frameworks such as reach and ant, a web control is composed of a group of associated html tags, and the basic operation of the control can be completed only by combining the operations of the group of tags. The combination of the operations is packaged into a basic operation function and continuously accumulated, and the module is continuously expanded, so that the accumulation is remarkable.
In this embodiment, S40 further includes:
defining an error processing method so as to be called by an operation function when the operation method is abnormal; the error processing method comprises the following steps:
when the operation method is abnormal, throwing the abnormality; the abnormality occurring in the operation method includes: the elements cannot be found, cannot be interacted and are not unique;
and printing and outputting abnormal information, wherein the abnormal information comprises object name, description and positioning information.
In S50 of this embodiment, the class and the class instance in the script file include an identity attribute, which is an xpath or css syntax string, and is used as an input of a basic function provided by the selenium framework to implement identification and operation of the object.
Aiming at the current situations that a Selenium testing framework lacks an object library unified management function and scripts are difficult to maintain, the embodiment provides an object layer construction method matched with the Selenium testing framework, which comprises the functions of the structured centralized management of UI objects, the batch verification and updating of the objects, the unified management of identification and operation mode functions and the like, so that an independent object layer can be conveniently constructed by using the UI automation testing script of the Selenium testing framework, the management is easy, the script management and maintenance cost is reduced, and the automation testing success rate is improved.
Example two
In a second aspect, the present application provides a Selenium-based UI automation testing framework, where the UI automation testing framework includes an object layer, a logic layer, a service layer, and a data layer, and the object layer includes:
an object script module generated by S10-S30 of the object layer construction method of the Selenium-based UI automation test framework according to any of the above embodiments;
the 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 the above embodiments.
According to the method and the system, the object layer which is easy to be independent and easy to maintain can be quickly constructed, so that the UI automation script logic layer module is changed into a simple calling method and an object.
In this embodiment, the UI automation test framework further includes:
the error definition module is used for defining an error processing method so as to be called by an operation function when the object operation method is abnormal; the error processing method comprises the following steps:
when the operation method is abnormal, throwing the abnormality; the abnormality occurring in the operation method includes: the elements cannot be found, cannot be interacted and are not unique;
and printing and outputting abnormal information, wherein the abnormal information comprises object name, description and positioning information.
The error definition module can give out easy-to-understand and detailed prompts when the object identification operation is abnormal, and is more favorable for problem positioning and troubleshooting compared with the Selenium native error prompt.
In this embodiment, the UI automation test framework further includes a conversion module, and the conversion module is configured to convert the object description document into a script file of a page object and/or an element object that follows a page object design pattern.
In this embodiment, the UI automation test framework further includes a control general operation driver module, further encapsulates the basic object location and operation function provided by the Selenium, and interfaces the page class and the object class in the object layer module script. The engineering efficiency is improved, the entrance threshold is reduced, and the thresholds used by seleniums are reduced.
Fig. 4 is a schematic diagram illustrating a building flow of a Selenium-based UI automation testing framework in another embodiment of the present application. As shown in fig. 2, the Selenium-based UI automation test framework building flow includes:
(1) and writing an xml document, wherein the name and the attribute of an xml node (node) in the document need to be written according to a preset rule. The preset rule comprises:
dividing a hierarchy: one xml node corresponds to one html page or html tag and corresponds to the UI multi-level characteristics, and the xml node corresponding to the child control is located under the xml node corresponding to the parent page/control.
Code name: subsequently, in the upper layer script, the corresponding object is accessed by the node name. Must begin with letters. Renaming is allowed.
③ node attribute-desc: object description, must fill attributes.
Node attribute-type: the object type can be set as "page" or "control", and refers to whether the xml node corresponds to a page or a control. And selecting an optional attribute, and defaulting to be 'control' when the attribute is not set.
Node attribute-fast: the parent type of the object can be set as the node name of other xml nodes. The method is used for abstracting similar pages and objects, and reduces the object maintenance amount. If not, default to 'basepage' or 'basecontrol', and optional attribute.
Sixthly, node attribute-identity: object location information, and mandatory properties. The selective xpath or cs-selector syntax must be followed. In the same xml, both grammars are allowed to coexist.
Seventhly, node attribute-identity, variable and expression: an identification attribute value, allowing variables and expressions to be used, denoted "$ {. Variables are denoted by "args [0 ]" and must be placed in the expression; in the same expression, args numbers are accumulated as needed starting from 0. The following are use examples: the result is that if the parameter (3, 5) is transmitted in the subsequent use process, the final effect is: "// div [7]// span [13 ]".
The node attribute-identity, parent identity inherits: the identity attribute value supports the automatic replacement of the $ FATHER prefix in the child node with the identity of the parent node with the application effect. The prefix design makes xml more compact. Note that in this scenario, the parent and child nodes must belong to the same syntax.
(2) And converting the xml object description document into an object script module by one key by using a conversion module.
The conversion module converts the xml object description document into an object script module by one key, and the script module is directly called in a subsequent UI automation script upper layer module.
Through a conversion module, each xml node is converted into a page class or a Control class according to the type attribute of the xml node. Setting the parent class of the page/Control class according to the fast attribute of the xml node. Other attributes are converted into class member variables, and key information such as name, desc, location attribute, and the like is contained.
And the class converted from the parent xml node comprises class instance member variables corresponding to the child xml node class, and the variable names are the same as the child xml node name for subsequent chain access.
In the generated object script module, a method for batch verification of object positioning attributes is provided, and the writing efficiency of the object attributes is improved.
(3) And (5) error definition module description.
The error definition module defines common error types, such as an element (element notfound) cannot be found, an element is not interactive (element notinteractable), an element is not unique (element notunique), and the like, redefines printing information content during exception triggering, and comprises an object name, description, positioning information, and the like.
Optionally, the error definition module can be extended according to project requirements, and the error type can be extended.
Through the error module, when the object identification operation is abnormal, an easily understood and detailed prompt is given, and compared with a Selenium native error prompt, the problem positioning and troubleshooting are facilitated.
(4) Object location and operation basis function module specification.
The technical scheme provides an object positioning and operation basic function module. FIG. 5 is a diagram of an example code of an object location and operation basis function module in another embodiment of the present application, as shown in the figure:
firstly, the characteristics of the page/control class in the object module are butted, and the provided method takes the page/control class instance as an input parameter and is assisted by parameters related to other methods.
The method provided by the second step comprises the following steps: open _ app, quick _ app, find _ element _ uniform _ exist, is _ element _ exist, click, double _ click, right _ click, set _ value, and the like.
And the find _ element function provided by the third step supports two recognition grammars of xpath and css and supports expression parameter processing.
And fourthly, in the method, the error types provided in the step (3) are adopted when the abnormal throwing is carried out.
Optionally, the object localization and operation basis function modules are extended as needed, in particular to continuously accumulate for each type of front-end framework.
The embodiment adopts Object script module design, including Object class design, and follows Page Object design mode, the related objects are all put into one class, and the operation is uniformly packaged. Besides, auxiliary methods such as object batch verification and the like are also included.
Through the processes (1), (2), (3) and (4), an independent object layer which is easy to maintain is constructed. The xml object description file is easy to understand the extension update. The Object script module follows a Page Object design mode, related objects are all put into one class, the operation is packaged uniformly, the detail information is hidden outwards, and the logic layer script becomes simple Object and method calling and verifying operation. The functions of batch verification and updating of the object positioning attributes and an exception prompt mechanism superior to the original frame are provided, and debugging and maintenance of the UI automation script are facilitated.
It should be noted that in the claims, any reference signs placed 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 invention may be implemented by means of hardware comprising several distinct elements, and by means of a suitably programmed computer. The use of the terms first, second, third and the like are for convenience only and do not denote any order. These words are to be understood as part of the name of the component.
Furthermore, it should be noted that in the description of the present specification, the description of the term "one embodiment", "some embodiments", "examples", "specific examples" or "some examples", etc., means that a specific feature, structure, material or characteristic described in connection with the embodiment or example is included in at least one embodiment or example of the present invention. In this specification, the schematic representations of the terms used above are not necessarily intended to refer to the same embodiment or example. Furthermore, the particular features, structures, materials, or characteristics described may be combined in any suitable manner in any one or more embodiments or examples. Furthermore, various embodiments or examples and features of different embodiments or examples described in this specification can be combined and combined by one skilled in the art without contradiction.
While preferred embodiments of the present invention have been described, additional variations and modifications in those embodiments may occur to those skilled in the art once they learn of the basic inventive concepts. Therefore, the claims should be construed to include preferred embodiments and all changes and modifications that fall within the scope of the invention.
It will be apparent to those skilled in the art that various modifications and variations can be made in the present invention without departing from the spirit or scope of the invention. Thus, if such modifications and variations of the present invention fall within the scope of the claims of the present invention and their equivalents, the present invention should also include such modifications and variations.

Claims (9)

1. A method for constructing an object layer of a UI automation test frame based on a Selenium is characterized in that the UI automation test frame comprises an object layer, a logic layer, a business layer and a data layer, and the method comprises the following steps:
s10, acquiring one or more pages related to the UI automation test task in the tested system;
s20, writing an object description document in an xml file format by adopting a preset rule aiming at the one or more pages, wherein the object description document takes the one or more pages and/or a plurality of key elements therein as nodes and comprises positioning information of the one or more pages and/or the plurality of key elements therein;
s30, converting the object description document into a script file of a page object and/or an element object following a page object design mode by adopting a pre-written conversion program;
s40, packaging the positioning and operation method of the page object and/or the element object into a positioning function and an operation function;
and S50, taking the script file, the positioning function and the operation function as an object layer, and calling the object layer when the logic layer executes the UI automation test task through the Selenium to realize the identification and operation of the object.
2. The object layer construction method of the Selenium-based UI automation test framework according to claim 1, characterized in that the preset rules comprise:
the hierarchy division rule comprises an xml node hierarchy corresponding to a UI page hierarchy and an element hierarchy;
the object definition rules comprise requirements of object naming, description and type;
and the object positioning rule comprises positioning the key elements through xpath and/or css to acquire positioning information of the key elements.
3. The method of claim 2, wherein the positioning information supports variable and expression formats, and the positioning information of the current object supports inheritance of parent object positioning information to embody an object hierarchy relationship.
4. The object layer construction method of the Selenium-based UI automation test framework according to claim 1, wherein S30 includes:
converting each xml node into a page class or a Control class according to the type attribute of the xml node, setting a parent class of the page class or the Control class according to the parent attribute of the xml node, and converting the name attribute, the description attribute and the positioning attribute of the xml node into a class member variable;
converting the father xml node into a class containing class instance member variables corresponding to the child xml node class, wherein the variable names of the class instance member variables are the same as the names of the child xml nodes for subsequent chained access;
and providing auxiliary methods such as automatically generated batch verification of object positioning attributes in script files of page objects and/or element objects.
5. The object layer construction method of the Selenium-based UI automation test framework according to claim 1, characterized in that in S40:
the operation method of the page object and/or the element object comprises the following steps: open _ app, quick _ app, find _ element _ neutral _ exist, is _ element _ exist, click, double _ click, right _ click, set _ value, table _ cell _ click, table _ cell _ getValue, table _ getbelow count, and the like. Unlike the original methods for a single label provided by the selenium test framework, these methods are all methods of operation for controls.
6. The control-based object layer object manipulation method of claim 5, wherein S40 comprises: the control comprises a plurality of label elements, the characteristic label elements of the control are used as an entry object, the positioning and operation of other associated labels in the control are packaged in the operation method, and the control is combined and packaged into an operation method for the control.
7. The object layer construction method of the Selenium-based UI automation test framework according to claim 5, wherein S40 further comprises:
defining an error processing method so as to be called by the operation function when the operation method is abnormal; the error processing method comprises the following steps:
when the operation method is abnormal, throwing the abnormality; the abnormality occurring in the operation method includes: the elements cannot be found, cannot be interacted and are not unique;
and printing and outputting abnormal information, wherein the abnormal information comprises object name, description and positioning information.
8. A Selenium-based UI automation test framework, characterized in that the UI automation test framework comprises an object layer, a logic layer, a business and data layer, the object layer comprising:
an object script module generated by S10-S30 in the object layer building method of the Selenium-based UI automation test framework of any of claims 1-7;
the object localization and manipulation function module generated by S40 in the object layer construction method of the Selenium-based UI automation test framework of any of claims 1-7.
9. The Selenium-based UI automation test framework of claim 8, further comprising:
the error definition module is used for defining an error processing method so as to be called by an operation function when the object operation method is abnormal; the error processing method comprises the following steps:
when the operation method is abnormal, throwing the abnormality; the abnormality occurring in the operation method includes: the elements cannot be found, cannot be interacted and are not unique;
and printing and outputting abnormal information, wherein the abnormal information comprises object name, description and positioning information.
CN202111181952.4A 2021-10-11 2021-10-11 Object layer construction method of automatic test framework and UI automatic test framework Pending CN114036039A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202111181952.4A CN114036039A (en) 2021-10-11 2021-10-11 Object layer construction method of automatic test framework and UI automatic test framework

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202111181952.4A CN114036039A (en) 2021-10-11 2021-10-11 Object layer construction method of automatic test framework and UI automatic test framework

Publications (1)

Publication Number Publication Date
CN114036039A true CN114036039A (en) 2022-02-11

Family

ID=80134937

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202111181952.4A Pending CN114036039A (en) 2021-10-11 2021-10-11 Object layer construction method of automatic test framework and UI automatic test framework

Country Status (1)

Country Link
CN (1) CN114036039A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117591438A (en) * 2024-01-19 2024-02-23 易方信息科技股份有限公司 Automatic testing method and related device for UI component atomization

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN117591438A (en) * 2024-01-19 2024-02-23 易方信息科技股份有限公司 Automatic testing method and related device for UI component atomization
CN117591438B (en) * 2024-01-19 2024-05-14 易方信息科技股份有限公司 Automatic testing method and related device for UI component atomization

Similar Documents

Publication Publication Date Title
CN1938690B (en) Method and system for conversion of automation test scripts into abstract test case representation with persistence
CN100511176C (en) Method and system for rule-based generation of automation test scripts from abstract test case representation
US9465590B2 (en) Code generation framework for application program interface for model
US7941461B2 (en) System and method for developing and enabling model-driven XML transformation framework for e-business
CN102096588B (en) Control-containing page establishing method
US20060168557A1 (en) Methods and apparatus for implementing model-based software solution development and integrated change management
US20040158820A1 (en) System for generating an application framework and components
CN106293664A (en) Code generating method and device
CN104484269A (en) Method for automatically generating testing script
CN104407863A (en) Abstract control model programming device and method
CN111399828B (en) Model-driven logic device modeling method and terminal
CN102306122A (en) Automated testing method and equipment
CN112699055A (en) Software automation test method and system with low maintenance cost
US20040117333A1 (en) Method and apparatus for building algorithms
CN114064213A (en) Kubernets container environment-based rapid arranging service method and system
Drath AutomationML: the industrial cookbook
CN114036039A (en) Object layer construction method of automatic test framework and UI automatic test framework
US7712073B1 (en) Software development artifact creation tool
US20230041718A1 (en) Automated code generation based on pseudo-code
CN110806973A (en) Automatic generation method and device of interface message
CN114356430B (en) DAG dependent configuration tool based on airflow scheduling system
CN109840197A (en) A kind of system and method for automatic test library of object
US20050177788A1 (en) Text to XML transformer and method
Younis et al. Systems variability modeling: a textual model mixing class and feature concepts
US20050268291A1 (en) Specifying user interface interactions for controls in a data driven system

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination