[go: up one dir, main page]

CN115185852A - UI automation testing method and system, computer equipment - Google Patents

UI automation testing method and system, computer equipment Download PDF

Info

Publication number
CN115185852A
CN115185852A CN202210890679.0A CN202210890679A CN115185852A CN 115185852 A CN115185852 A CN 115185852A CN 202210890679 A CN202210890679 A CN 202210890679A CN 115185852 A CN115185852 A CN 115185852A
Authority
CN
China
Prior art keywords
preset
interface
tested
node
test
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
CN202210890679.0A
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.)
Shenzhen Wangxu Technology Co ltd
Original Assignee
Shenzhen Wangxu 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 Shenzhen Wangxu Technology Co ltd filed Critical Shenzhen Wangxu Technology Co ltd
Priority to CN202210890679.0A priority Critical patent/CN115185852A/en
Publication of CN115185852A publication Critical patent/CN115185852A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Prevention of errors by analysis, debugging or testing of software
    • G06F11/3668Testing of software
    • G06F11/3672Test management
    • G06F11/3688Test management for test execution, e.g. scheduling of test suites
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Prevention of errors by analysis, debugging or testing of software
    • G06F11/3668Testing of software
    • G06F11/3696Methods or tools to render software testable

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

本申请提供了一种UI自动化测试方法,包括:加载自动测试行为脚本,自动测试行为脚本包含预设路径和调用接口;根据预设路径获取预设xml文件,预设xml文件包括若干步骤节点,步骤节点包括一个或者若干子节点,每一子节点包括预设属性值,预设属性值包括操作参数;根据调用接口调用并加载相应的待测试UI界面;在待测试UI界面触发执行步骤节点所对应的操作;以及根据操作的执行结果生成测试报告。此外,本申请还提供了一种UI自动化测试系统及计算机设备。本申请提供的UI自动化测试方法使得UI自动化测试简单易行,从而提高测试效率。

Figure 202210890679

The present application provides an automated UI testing method, including: loading an automatic testing behavior script, where the automatic testing behavior script includes a preset path and a calling interface; obtaining a preset xml file according to the preset path, and the preset xml file includes several step nodes, The step node includes one or several subnodes, each subnode includes a preset attribute value, and the preset attribute value includes operation parameters; the corresponding UI interface to be tested is called and loaded according to the calling interface; the execution step node is triggered on the UI interface to be tested. corresponding operations; and generating a test report based on the execution results of the operations. In addition, the present application also provides a UI automation testing system and computer equipment. The UI automated testing method provided by the present application makes the UI automated testing simple and easy to implement, thereby improving the testing efficiency.

Figure 202210890679

Description

UI自动化测试方法及其系统、计算机设备UI automation testing method and system, computer equipment

技术领域technical field

本申请涉及计算机技术领域,尤其涉及一种UI自动化测试方法及其系统、计算机设备。The present application relates to the field of computer technology, and in particular, to a UI automation testing method, system, and computer equipment.

背景技术Background technique

软件开发过程中,软件测试是不可或缺的一个环节。开发及测试都需要通过工具去辅助软件测试,从而提升软件质量。其中UI(用户界面)自动化作为模拟用户界面行为的操作,起到举足轻重的地位。目前测试的执行脚本框架有很多种,比如:appium脚本框架、calabash脚本框架、IOS UIAutomation脚本框架、robotium脚本框架等。每个框架都有着各自的编写规范及环境,都需要编写对应的脚本。目前的UI自动化大多是需要通过测试员根据对应框架的编写规范来编写对应脚本,对测试员的技能有一定的要求,需要测试员具备一定的语言编码能力。随着对应框架的升级,测试员还需要针对历史脚本进行针对性维护,如果涉及脚本量级多的话,维护成本会随之提升。Software testing is an integral part of the software development process. Both development and testing require tools to assist software testing to improve software quality. Among them, UI (user interface) automation plays a pivotal role as an operation that simulates user interface behavior. There are many kinds of execution script frameworks currently tested, such as: appium script framework, calabash script framework, IOS UIAutomation script framework, robotium script framework, etc. Each framework has its own writing specifications and environment, and corresponding scripts need to be written. Most of the current UI automation requires the tester to write the corresponding script according to the writing specification of the corresponding framework, which has certain requirements on the tester's skills and requires the tester to have a certain language coding ability. With the upgrade of the corresponding framework, testers also need to perform targeted maintenance on historical scripts. If there are many scripts involved, the maintenance cost will increase accordingly.

发明内容SUMMARY OF THE INVENTION

有鉴于此,实有必要提供一种UI自动化测试方法及其系统、计算机设备,使得UI自动化测试简单易行,从而提高测试效率。In view of this, it is necessary to provide a UI automation testing method, system, and computer equipment, so as to make the UI automation testing simple and easy, thereby improving the testing efficiency.

第一方面,本申请实施例提供一种UI自动化测试方法,所述UI自动化测试方法包括:In the first aspect, an embodiment of the present application provides a UI automation testing method, and the UI automation testing method includes:

加载自动测试行为脚本,其中,所述自动测试行为脚本包含预设路径和调用接口;Loading an automatic test behavior script, wherein the automatic test behavior script includes a preset path and a calling interface;

根据所述预设路径获取预设xml文件,其中,所述预设xml文件包括若干步骤节点,所述步骤节点包括一个或者若干子节点,当所述步骤节点包括一个子节点时,一个所述子节点对应一个第一操作,当所述步骤节点包括若干子节点时,每一所述子节点对应一个第二操作,所述第一操作与所述第二操作不同;每一所述子节点包括预设属性值,所述预设属性值包括操作参数;Acquire a preset xml file according to the preset path, wherein the preset xml file includes several step nodes, the step node includes one or several sub-nodes, and when the step node includes one sub-node, one of the step nodes A child node corresponds to a first operation, and when the step node includes several child nodes, each of the child nodes corresponds to a second operation, and the first operation is different from the second operation; each of the child nodes corresponds to a second operation. including preset attribute values, the preset attribute values including operation parameters;

根据所述调用接口调用并加载相应的待测试UI界面;Invoke and load the corresponding UI interface to be tested according to the invocation interface;

在所述待测试UI界面触发执行所述步骤节点所对应的操作;以及Trigger and execute the operation corresponding to the step node on the UI interface to be tested; and

根据所述操作的执行结果生成测试报告。A test report is generated based on the execution result of the operation.

第二方面,本申请实施例提供一种计算机设备,所述计算机设备包括:In a second aspect, an embodiment of the present application provides a computer device, where the computer device includes:

存储器,用于存储程序指令;以及memory for storing program instructions; and

处理器,用于执行所述程序指令以实现如上所述的UI自动化测试方法。The processor is configured to execute the program instructions to implement the UI automation testing method described above.

第三方面,本申请实施例提供一种UI自动化测试系统,所述UI自动化测试系统包括:In a third aspect, an embodiment of the present application provides a UI automated testing system, the UI automated testing system includes:

第一加载模块,用于加载自动测试行为脚本,其中,所述自动测试行为脚本包含预设路径和调用接口;a first loading module for loading an automatic test behavior script, wherein the automatic test behavior script includes a preset path and a calling interface;

获取模块,用于根据所述预设路径获取预设xml文件,其中,所述预设xml文件包括若干步骤节点,所述步骤节点包括一个或者若干子节点,当所述步骤节点包括一个子节点时,一个所述子节点对应一个第一操作,当所述步骤节点包括若干子节点时,每一所述子节点对应一个第二操作,所述第一操作与所述第二操作不同;每一所述子节点包括预设属性值,所述预设属性值包括操作参数;an obtaining module, configured to obtain a preset xml file according to the preset path, wherein the preset xml file includes several step nodes, and the step node includes one or several sub-nodes, when the step node includes a sub-node , one of the child nodes corresponds to a first operation, and when the step node includes several child nodes, each of the child nodes corresponds to a second operation, and the first operation is different from the second operation; each - the child node includes a preset attribute value, and the preset attribute value includes an operation parameter;

调用模块,用于根据所述调用接口调用并加载相应的待测试UI界面;a calling module for calling and loading the corresponding UI interface to be tested according to the calling interface;

执行模块,用于在所述待测试UI界面触发执行所述步骤节点所对应的操作;以及an execution module, configured to trigger the execution of an operation corresponding to the step node on the UI interface to be tested; and

第一生成模块,用于根据所述操作的执行结果生成测试报告。The first generating module is configured to generate a test report according to the execution result of the operation.

上述UI自动化测试方法及其系统、计算机设备,利用自动测试行为脚本中的预设路径获取预设xml文件,利用自动测试行为脚本中的调用接口调用待测试UI界面,在待测试UI界面触发执行步骤节点对应的操作,从而完成UI自动化测试过程。其中,预设xml文件根据待测试UI界面生成。通过预设xml文件使得逻辑与行为分离,即开发脚本的脚本开发员无需关心具体的测试场景,测试软件的测试员无需关心自动测试行为脚本的逻辑,两个部分的衔接通过预设xml文件完成。即是说,测试员无需熟练使用脚本编写语言,也无需知道程序的代码内容即可实现UI自动化测试,从而优化了UI自动化测试存在的难题,以低学习成本的方式提高测试员的测试效率,重复性的工作尽可能交给计算机本身来执行。使得UI自动化测试简单易行,从而提高测试效率。同时,当需求有变动时,测试员只需要修改相应的预设xml文件,更有利于、便于维护。The above-mentioned UI automation testing method, system, and computer equipment, use the preset path in the automatic testing behavior script to obtain the preset xml file, use the calling interface in the automatic testing behavior script to call the UI interface to be tested, and trigger execution on the UI interface to be tested The operation corresponding to the step node to complete the UI automation testing process. The preset xml file is generated according to the UI interface to be tested. The logic and behavior are separated by the preset xml file, that is, the script developer who develops the script does not need to care about the specific test scenario, and the tester of the testing software does not need to care about the logic of the automatic test behavior script. The connection between the two parts is completed by the preset xml file. . That is to say, testers do not need to be proficient in using scripting languages, nor do they need to know the code content of the program to implement UI automation testing, which optimizes the difficulties existing in UI automation testing and improves the tester's testing efficiency with low learning costs. Repetitive work is left to the computer itself to perform as much as possible. It makes UI automation testing simple and easy, thereby improving testing efficiency. At the same time, when the requirements change, the tester only needs to modify the corresponding preset xml file, which is more beneficial and easy to maintain.

附图说明Description of drawings

为了更清楚地说明本申请实施例或现有技术中的技术方案,下面将对实施例或现有技术描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本申请的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动的前提下,还可以根据这些附图示出的结构获得其他的附图。In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the following briefly introduces the accompanying drawings required for the description of the embodiments or the prior art. Obviously, the drawings in the following description are only These are some embodiments of the present application. For those of ordinary skill in the art, other drawings can also be obtained according to the structures shown in these drawings without any creative effort.

图1为本申请实施例提供的UI自动化测试方法的流程图。FIG. 1 is a flowchart of a UI automation testing method provided by an embodiment of the present application.

图2为本申请实施例提供的UI自动化测试方法的第一子流程图。FIG. 2 is a first sub-flow chart of the UI automation testing method provided by the embodiment of the present application.

图3为本申请实施例提供的UI自动化测试方法的第二子流程图。FIG. 3 is a second sub-flow chart of the UI automation testing method provided by the embodiment of the present application.

图4为本申请实施例提供的UI自动化测试方法的第三子流程图。FIG. 4 is a third sub-flow chart of the UI automation testing method provided by the embodiment of the present application.

图5为本申请实施例提供的UI自动化测试方法的第四子流程图。FIG. 5 is a fourth sub-flow chart of the UI automation testing method provided by the embodiment of the present application.

图6为本申请实施例提供的计算机设备的内部结构示意图。FIG. 6 is a schematic diagram of an internal structure of a computer device provided by an embodiment of the present application.

图7为本申请实施例提供的UI自动化测试系统的第一内部结构示意图。FIG. 7 is a schematic diagram of a first internal structure of a UI automated testing system provided by an embodiment of the present application.

图8为本申请实施例提供的UI自动化测试系统的第二内部结构示意图。FIG. 8 is a schematic diagram of a second internal structure of the UI automated testing system provided by the embodiment of the present application.

本申请目的的实现、功能特点及优点将结合实施例,参照附图做进一步说明。The realization, functional characteristics and advantages of the purpose of the present application will be further described with reference to the accompanying drawings in conjunction with the embodiments.

具体实施方式Detailed ways

为了使本申请的目的、技术方案及优点更加清楚明白,以下结合附图及实施例,对本申请进行进一步详细说明。应当理解,此处所描述的具体实施例仅用以解释本申请,并不用于限定本申请。基于本申请中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本申请保护的范围。In order to make the purpose, technical solutions and advantages of the present application more clearly understood, the present application will be described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application, but not to limit the present application. Based on the embodiments in this application, all other embodiments obtained by those of ordinary skill in the art without creative efforts shall fall within the protection scope of this application.

本申请的说明书和权利要求书及上述附图中的术语“第一”、“第二”、“第三”、“第四”等(如果存在)是用于区别类似的规划对象,而不必用于描述特定的顺序或先后次序。应该理解这样使用的数据在适当情况下可以互换,换句话说,描述的实施例根据除了这里图示或描述的内容以外的顺序实施。此外,术语“包括”和“具有”以及他们的任何变形,还可以包含其他内容,例如,包含了一系列步骤或单元的过程、方法、系统、产品或设备不必限于只清楚地列出的那些步骤或单元,而是可包括没有清楚地列出的或对于这些过程、方法、产品或设备固有的其它步骤或单元。The terms "first", "second", "third", "fourth", etc. (if any) in the description and claims of the present application and the above-mentioned drawings are used to distinguish similar planning objects and do not necessarily Used to describe a specific order or sequence. It is to be understood that the data so used are interchangeable under appropriate circumstances, in other words, the described embodiments are implemented in accordance with sequences other than those illustrated or described herein. Furthermore, the terms "comprising" and "having" and any variations thereof may also encompass other content, for example, a process, method, system, product or device comprising a series of steps or units is not necessarily limited to only those expressly listed steps or units, but may include other steps or units not expressly listed or inherent to these processes, methods, products or devices.

需要说明的是,在本申请中涉及“第一”、“第二”等的描述仅用于描述目的,而不能理解为指示或暗示其相对重要性或者隐含指明所指示的技术特征的数量。由此,限定有“第一”、“第二”的特征可以明示或者隐含地包括一个或者多个该特征。另外,各个实施例之间的技术方案可以相互结合,但是必须是以本领域普通技术人员能够实现为基础,当技术方案的结合出现相互矛盾或无法实现时应当认为这种技术方案的结合不存在,也不在本申请要求的保护范围之内。It should be noted that the descriptions involving "first", "second", etc. in this application are only for the purpose of description, and should not be construed as indicating or implying their relative importance or implying the number of indicated technical features . Thus, a feature defined as "first" or "second" may expressly or implicitly include one or more of that feature. In addition, the technical solutions between the various embodiments can be combined with each other, but must be based on the realization by those of ordinary skill in the art. When the combination of technical solutions is contradictory or cannot be realized, it should be considered that the combination of such technical solutions does not exist. , is not within the scope of protection claimed in this application.

请结合参看图1,其为本申请实施例提供的UI自动化测试方法的流程图。UI自动化测试方法用于对用户界面(User Interface,UI)进行自动化测试。UI自动化测试方法具体包括如下步骤。Please refer to FIG. 1 , which is a flowchart of the UI automation testing method provided by the embodiment of the present application. The UI automation testing method is used to automate the testing of the user interface (User Interface, UI). The UI automation testing method specifically includes the following steps.

步骤S102,加载自动测试行为脚本。其中,自动测试行为脚本包含预设路径和调用接口。Step S102, load an automatic test behavior script. Among them, the automatic test behavior script includes a preset path and a calling interface.

在本实施例中,自动测试行为脚本由脚本开发员利用脚本语言编写形成。脚本语言包括但不限于Python、Java、JavaScript等。优选地,脚本语言为Python。预设路径和调用接口可以根据实际测试情况进行设置,在此不做限定。In this embodiment, the automatic test behavior script is written and formed by a script developer using a script language. Scripting languages include, but are not limited to, Python, Java, JavaScript, and the like. Preferably, the scripting language is Python. The preset path and calling interface can be set according to the actual test situation, which is not limited here.

在本实施例中,加载自动测试行为脚本之前,UI自动化测试方法包括:提供脚本模板。其中,脚本模板包括路径元素和接口元素。当路径元素替换为预设路径且接口元素替换为调用接口时,脚本模板转换成自动测试行为脚本。可以理解的是,脚本模板中的内容已经全部编写好,脚本开发员只需要根据实际测试情况将路径元素替换为预设路径、接口元素替换为调用接口即可形成自动测试行为脚本。同一自动测试行为脚本中的预设路径和调用接口相对应。In this embodiment, before loading the automatic testing behavior script, the UI automatic testing method includes: providing a script template. The script template includes path elements and interface elements. When the path element is replaced with the preset path and the interface element is replaced with the calling interface, the script template is converted into an automatic test behavior script. It is understandable that the content in the script template has been completely written, and the script developer only needs to replace the path element with the preset path and the interface element with the calling interface according to the actual test situation to form an automatic test behavior script. The preset path in the same automatic test behavior script corresponds to the calling interface.

步骤S104,根据预设路径获取预设xml文件。在本实施例中,预设xml文件为预先根据实际测试需求编写的文件,预设路径与预设xml文件一一对应。预设xml文件的具体生成方法将在下文详细描述。Step S104, obtaining a preset xml file according to a preset path. In this embodiment, the preset xml file is a file prepared in advance according to actual test requirements, and the preset path corresponds to the preset xml file one-to-one. The specific generation method of the preset xml file will be described in detail below.

在本实施例中,预设xml文件包括若干步骤节点,每一步骤节点包括一个或者若干子节点。当步骤节点包括一个子节点时,一个子节点对应一个第一操作;当步骤节点包括若干子节点时,每一子节点对应一个第二操作。其中,第一操作和第二操作不同。每一子节点包括预设属性值,预设属性值包括操作参数。其中,操作包括但不限于鼠标操作、键盘操作等。预设属性值包括但不限于路径参数、位置参数、时间参数、操作参数以及键值等。In this embodiment, the preset xml file includes several step nodes, and each step node includes one or several child nodes. When the step node includes one child node, one child node corresponds to one first operation; when the step node includes several child nodes, each child node corresponds to one second operation. Wherein, the first operation and the second operation are different. Each child node includes a preset attribute value, and the preset attribute value includes an operation parameter. The operations include but are not limited to mouse operations, keyboard operations, and the like. Preset attribute values include but are not limited to path parameters, location parameters, time parameters, operation parameters, and key values.

步骤S106,根据调用接口调用并加载相应的待测试UI界面。在本实施例中,调用接口与待测试UI界面一一对应。Step S106, calling and loading the corresponding UI interface to be tested according to the calling interface. In this embodiment, the calling interface is in one-to-one correspondence with the UI interface to be tested.

步骤S108,在待测试UI界面触发执行步骤节点所对应的操作。在本实施例中,待测试UI界面加载完毕后,识别并解析预设xml文件的步骤节点,从而得出相应的第一操作和/或第二操作集合,并顺序触发执行第一操作和/或第二操作。其中,识别预设xml文件中的步骤节点的方法为常用方法,在此不再赘述。Step S108, triggering the execution of the operation corresponding to the step node on the UI interface to be tested. In this embodiment, after the UI interface to be tested is loaded, the step nodes of the preset xml file are identified and parsed, so as to obtain the corresponding first operation and/or second operation set, and trigger the execution of the first operation and/or in sequence. or the second operation. The method for identifying the step node in the preset xml file is a common method, which will not be repeated here.

步骤S110,根据操作的执行结果生成测试报告。在待测试UI界面执行操作的过程中,可以将所有操作所对应的执行结果都记录下来,形成测试报告。Step S110, generating a test report according to the execution result of the operation. In the process of performing operations on the UI interface to be tested, the execution results corresponding to all operations can be recorded to form a test report.

上述实施例中,利用自动测试行为脚本中的预设路径获取预设xml文件,利用自动测试行为脚本中的调用接口调用待测试UI界面,在待测试UI界面触发执行步骤节点对应的操作,从而完成UI自动化测试过程。其中,预设xml文件根据待测试UI界面生成。通过预设xml文件使得逻辑与行为分离,即开发脚本的脚本开发员无需关心具体的测试场景,测试软件的测试员无需关心自动测试行为脚本的逻辑,两个部分的衔接通过预设xml文件完成。即是说,测试员无需熟练使用脚本编写语言,也无需知道程序的代码内容即可实现UI自动化测试,从而优化了UI自动化测试存在的难题,以低学习成本的方式提高测试员的测试效率,重复性的工作尽可能交给计算机本身来执行。使得UI自动化测试简单易行,从而提高测试效率。同时,当需求有变动时,测试员只需要修改相应的预设xml文件,更有利于、便于维护。In the above embodiment, the preset xml file is obtained by using the preset path in the automatic test behavior script, the UI interface to be tested is called by using the calling interface in the automatic test behavior script, and the operation corresponding to the execution step node is triggered on the UI interface to be tested, thereby Complete the UI automation testing process. The preset xml file is generated according to the UI interface to be tested. The logic and behavior are separated by the preset xml file, that is, the script developer who develops the script does not need to care about the specific test scenario, and the tester of the testing software does not need to care about the logic of the automatic test behavior script. The connection between the two parts is completed by the preset xml file. . That is to say, testers do not need to be proficient in using scripting languages, nor do they need to know the code content of the program to implement UI automation testing, which optimizes the difficulties existing in UI automation testing and improves the tester's testing efficiency with low learning costs. Repetitive work is left to the computer itself to perform as much as possible. It makes UI automation testing simple and easy, thereby improving testing efficiency. At the same time, when the requirements change, the tester only needs to modify the corresponding preset xml file, which is more beneficial and easy to maintain.

此外,自动测试行为脚本根据脚本模板生成,只需要将脚本模板中的路径元素和接口元素分别替换成实际测试中预设xml文件的预设路径和待测试UI界面的调用接口即可,使得自动测试行为脚本能够适配各种不同的应用。预设xml文件在各个操作系统上都可以实现,解开了脚本开发和不同应用程序需要不同的逻辑之间的耦合。In addition, the automatic test behavior script is generated according to the script template. It only needs to replace the path element and interface element in the script template with the preset path of the preset xml file in the actual test and the calling interface of the UI interface to be tested. Test behavior scripts can be adapted to a variety of different applications. The preset xml files can be implemented on various operating systems, which uncouples script development and different logics required by different applications.

请结合参看图2,其为本申请实施例提供的UI自动化测试方法的第一子流程图。执行步骤S102之前,UI自动化测试方法还包括如下步骤。Please refer to FIG. 2 , which is a first sub-flow chart of the UI automation testing method provided by the embodiment of the present application. Before performing step S102, the UI automation testing method further includes the following steps.

步骤S202,加载预设编写规则和待测试UI界面的测试用例。在本实施例中,预设编写规则包括所有标识字段和相应的预设属性值,测试用例包括若干测试操作。其中,测试操作为实际测试过程中需要执行的操作。Step S202, loading preset writing rules and test cases of the UI interface to be tested. In this embodiment, the preset writing rule includes all identification fields and corresponding preset attribute values, and the test case includes several test operations. The test operation is an operation that needs to be performed in the actual test process.

在本实施例中,预设编写规则为人为规定的编写规则。预设编写规则包括若干可配置项。可配置项包括但不限于Session、StepAction、Location、LocationXY、VisualImagePath、Duration以及Action等。具体地,Session表示会话,StepAction表示执行步骤,Location表示地址,LocationXY表示地址坐标,VisualImagePath表示图片地址,Duration表示停止持续时间,Action表示事件。其中,一个会话包括多个执行步骤;执行步骤可以包括一个第一操作,也可以包括至少一个第二操作。具体地,Location、LocationXY、VisualImagePath以及Duration均表示第一操作。In this embodiment, the preset writing rule is an artificially prescribed writing rule. Preset authoring rules include several configurable items. Configurable items include but are not limited to Session, StepAction, Location, LocationXY, VisualImagePath, Duration, and Action. Specifically, Session represents a session, StepAction represents an execution step, Location represents an address, LocationXY represents an address coordinate, VisualImagePath represents an image address, Duration represents a stop duration, and Action represents an event. Wherein, a session includes multiple execution steps; the execution step may include a first operation or at least one second operation. Specifically, Location, LocationXY, VisualImagePath, and Duration all represent the first operation.

在本实施例中,StepAction包括编号参数(StepNumber)。编号参数用于描述执行步骤的唯一性。In this embodiment, StepAction includes a number parameter (StepNumber). The number parameter is used to describe the uniqueness of the execution step.

Action包括若干事件类型,事件类型包括left_mouse_click、right_mouse_click、mouse_move、key_down以及loop。具体地,left_mouse_click表示点击鼠标左键,right_mouse_click表示点击鼠标右键,mouse_move表示移动鼠标,key_down表示输入键值,loop表示循环事件。left_mouse_click、right_mouse_click、mouse_move、key_down以及loop均表示第二操作。可以理解的是,执行步骤可以包括一个事件,一个事件包括至少一个第二操作。Action includes several event types, including left_mouse_click, right_mouse_click, mouse_move, key_down, and loop. Specifically, left_mouse_click means clicking the left mouse button, right_mouse_click means clicking the right mouse button, mouse_move means moving the mouse, key_down means entering a key value, and loop means a loop event. left_mouse_click, right_mouse_click, mouse_move, key_down, and loop all represent the second operation. It can be understood that the execution step may include an event, and an event includes at least one second operation.

在本实施例中,标识字段包括但不限于Location、LocationXY、VisualImagePath、Duration、Action、left_mouse_click、right_mouse_click、mouse_move、key_down以及loop。In this embodiment, the identification fields include but are not limited to Location, LocationXY, VisualImagePath, Duration, Action, left_mouse_click, right_mouse_click, mouse_move, key_down, and loop.

相应地,Location的预设属性值包括absolute和visualization。LocationXY的预设属性值包括坐标值,即位置参数。VisualImagePath的预设属性值包括路径,即路径参数。其中,当Location的预设属性值为absolute时,LocationXY必须包括预设属性值;当Location的预设属性值为visualization时,VisualImagePath必须包括预设属性值。具体地,LocationXY的预设属性值格式为(x,y),VisualImagePath的预设属性值为图片的相对路径或者绝对路径。Correspondingly, the preset attribute values of Location include absolute and visualization. The preset property values of LocationXY include coordinate values, that is, location parameters. The default property value of VisualImagePath includes the path, that is, the path parameter. Wherein, when the preset attribute value of Location is absolute, LocationXY must include the preset attribute value; when the preset attribute value of Location is visualization, VisualImagePath must include the preset attribute value. Specifically, the preset attribute value format of LocationXY is (x, y), and the preset attribute value of VisualImagePath is a relative path or an absolute path of the image.

Duration的预设属性值包括秒数,即时间参数。具体地,Duration表示每个事件执行后停止的时间,预设属性值的单位为秒。The default property value of Duration includes the number of seconds, that is, the time parameter. Specifically, Duration represents the stop time after each event is executed, and the unit of the preset attribute value is seconds.

Action的预设属性值包括left_mouse_click、right_mouse_click、mouse_move、key_down以及loop。The default attribute values of Action include left_mouse_click, right_mouse_click, mouse_move, key_down and loop.

其中,left_mouse_click和right_mouse_click的预设属性值包括次数,即操作参数。left_mouse_click的预设属性值用于表示点击鼠标左键的次数,right_mouse_click的预设属性值用于表示点击鼠标右键的次数。Among them, the preset attribute values of left_mouse_click and right_mouse_click include the number of times, that is, operation parameters. The default attribute value of left_mouse_click is used to indicate the number of clicks of the left mouse button, and the default attribute value of right_mouse_click is used to indicate the number of clicks of the right mouse button.

mouse_move的预设属性值包括坐标值,即位置参数。mouse_move的预设属性值格式为(x,y),用于表示鼠标移动到相应坐标处。The preset attribute values of mouse_move include coordinate values, that is, position parameters. The default attribute value format of mouse_move is (x, y), which is used to indicate that the mouse moves to the corresponding coordinate.

key_down的预设属性值包括键值。具体地,键值可以参考pyautogui.KEYBOARD_KEYS进行赋值。The default property value of key_down includes the key value. Specifically, the key value can be assigned by referring to pyautogui.KEYBOARD_KEYS.

Loop的预设属性值包括loopBegin、vars以及loopEnd。其中,loopBegin表示循环事件中的开始部分,vars表示循环事件中的循环部分,loopEnd表示循环事件中的结尾部分。循环事件中,开始部分和结尾部分均为不变的部分,循环部分为变化的部分。loopBegin、vars以及loopEnd均包括预设属性值。具体地,loopBegin和loopEnd的预设属性值的格式均为"int,...,int",vars的预设属性值的格式为"int,...,int;...;int,...,int"。其中,分号用于分割一次循环,逗号用于分割每次循环需要走的变化部分的方法。Loop's preset property values include loopBegin, vars, and loopEnd. Among them, loopBegin represents the beginning part of the loop event, vars represents the loop part of the loop event, and loopEnd represents the end part of the loop event. In a cyclic event, the beginning part and the end part are both constant parts, and the cyclic part is the changing part. loopBegin, vars, and loopEnd all include preset property values. Specifically, the format of the preset attribute values of loopBegin and loopEnd is "int,...,int", and the format of the preset attribute values of vars is "int,...,int;...;int,. ..,int". Among them, the semicolon is used to separate a loop, and the comma is used to separate the method of changing the part that needs to go through each loop.

步骤S204,根据测试用例和预设编写规则生成预设xml文件。其中,步骤节点和子节点的名称均为标识字段。可以理解的是,测试用例规定了预设xml文件的内容,预设编写规则规定了预设xml文件的编写规范。Step S204, generating a preset xml file according to the test case and the preset writing rule. Among them, the names of step nodes and child nodes are both identification fields. It can be understood that the test case specifies the content of the preset xml file, and the preset writing rule specifies the writing specification of the preset xml file.

在本实施例中,测试员可以通过编写一些界面程序来完成预设xml文件的生成与修改,也可以直接根据测试用例和预设编写规则手动编写预设xml文件。其中,测试用例中的测试操作与待测试UI界面相对应,使得生成的预设xml文件中的第一操作和/或第二操作均与待测试UI界面相对应。In this embodiment, the tester can complete the generation and modification of the preset xml file by writing some interface programs, or can manually write the preset xml file directly according to the test case and the preset writing rules. Wherein, the test operation in the test case corresponds to the UI interface to be tested, so that the first operation and/or the second operation in the generated preset xml file corresponds to the UI interface to be tested.

通过界面程序根据测试用例和预设编写规则生成预设xml文件的具体过程将在下文详细描述。The specific process of generating the preset xml file according to the test case and the preset writing rule through the interface program will be described in detail below.

上述实施例中,根据测试用例和预设编写规则生成预设xml文件,使得预设xml文件与实际测试用例相匹配。可以理解的是,不同测试过程中,预设xml文件的内容根据实际测试需求设置,而自动测试行为脚本的内容大致相同,自动测试行为脚本中仅用于获取预设xml文件的预设路径不同,使得自动测试行为脚本一经编写即可重复使用。同时,预设编写规则极大降低了测试员编写预设xml文件的难度,使得预设xml文件均有统一的编写风格。In the above embodiment, the preset xml file is generated according to the test case and the preset writing rule, so that the preset xml file matches the actual test case. It is understandable that in different testing processes, the content of the preset xml file is set according to the actual test requirements, while the content of the automatic test behavior script is roughly the same, and the preset path only used to obtain the preset xml file in the automatic test behavior script is different. , making automated test behavior scripts reusable once written. At the same time, the preset writing rules greatly reduce the difficulty for testers to write preset xml files, so that the preset xml files have a unified writing style.

请结合参看图3,其为本申请实施例提供的UI自动化测试方法的第二子流程图。步骤S204具体包括如下步骤。Please refer to FIG. 3 , which is a second sub-flow chart of the UI automation testing method provided by the embodiment of the present application. Step S204 specifically includes the following steps.

步骤S302,从步骤记录器中获取操作数据。在本实施例中,操作数据为步骤记录器中记录用户根据测试用例的测试步骤进行操作的数据。其中,用户可以为测试员。步骤记录器为Windows系统自带的界面程序。在一些可行的实施例中,步骤记录器也可以为测试员编写的其它界面程序。Step S302, obtain operation data from the step recorder. In this embodiment, the operation data is data recorded in the step recorder that the user performs operations according to the test steps of the test case. Among them, the user can be a tester. The step recorder is an interface program that comes with the Windows system. In some possible embodiments, the step recorder may also be other interface programs written by the tester.

可以理解的是,当操作开始时,测试员需要先启动步骤记录器,之后测试员根据测试用例中的测试步骤进行操作,使步骤记录器能够记录下相应的操作数据。其中,操作数据的文件格式为*.mht。It is understandable that when the operation starts, the tester needs to start the step recorder first, and then the tester operates according to the test steps in the test case, so that the step recorder can record the corresponding operation data. The file format of the operation data is *.mht.

步骤S304,根据预设编写规则将操作数据转换为预设xml文件。可以理解的是,预设xml文件中的步骤节点与测试用例中的测试步骤相对应。Step S304, converting the operation data into a preset xml file according to the preset writing rule. It can be understood that the step nodes in the preset xml file correspond to the test steps in the test case.

上述实施例中,在Windows系统中,可以通过Windows系统自带的步骤记录器记录用户操作生成操作数据,再根据预设编写规则将操作数据转换为预设xml文件,使得预设xml文件的编写更加简单可行,极大降低了测试员的工作难度,有效提高了测试员的测试效率。In the above embodiment, in the Windows system, the operation data can be generated by recording user operations through the step recorder that comes with the Windows system, and then the operation data can be converted into a preset xml file according to preset writing rules, so that the writing of the preset xml file can be performed. It is simpler and more feasible, greatly reduces the difficulty of the tester's work, and effectively improves the tester's testing efficiency.

请结合参看图4,其为本申请实施例提供的UI自动化测试方法的第三子流程图。执行步骤S108之后,UI自动化测试方法还包括如下步骤。Please refer to FIG. 4 , which is a third sub-flow chart of the UI automation testing method provided by the embodiment of the present application. After step S108 is performed, the UI automation testing method further includes the following steps.

步骤S402,判断在待测试UI界面执行操作是否出现异常。Step S402, it is judged whether an abnormality occurs in the execution of the operation on the UI interface to be tested.

当在待测试UI界面执行操作出现异常时,执行步骤S404。When an abnormality occurs in the execution of the operation on the UI interface to be tested, step S404 is performed.

步骤S404,中止或者跳过操作。Step S404, suspend or skip the operation.

上述实施例中,在自动测试行为脚本中加入执行异常的事件,用于中止或者跳过执行异常的操作或者事件,从而保证测试过程能够顺利完成。In the above-mentioned embodiment, an abnormal execution event is added to the automatic test behavior script to abort or skip the abnormal execution operation or event, so as to ensure that the test process can be successfully completed.

请结合参看图5,其为本申请实施例提供的UI自动化测试方法的第四子流程图。执行步骤S108之后,UI自动化测试方法还包括如下步骤。Please refer to FIG. 5 , which is a fourth sub-flow chart of the UI automation testing method provided by the embodiment of the present application. After step S108 is performed, the UI automation testing method further includes the following steps.

步骤S502,启动屏幕记录工具来记录操作的执行过程。其中,屏幕记录工具可以为Windows系统自带的程序,也可以为测试员编写的程序。Step S502, start the screen recording tool to record the execution process of the operation. Among them, the screen recording tool can be a program that comes with the Windows system, or can be a program written by a tester.

步骤S504,根据屏幕记录工具记录的内容生成记录结果。启动屏幕记录工具将测试过程录制下来,并形成记录结果,以供测试员回看。Step S504, generating a recording result according to the content recorded by the screen recording tool. Start the screen recording tool to record the test process and form a recorded result for the tester to review.

在一些可行的实施例中,记录结果可以为日志文件。其中,可以按照相应的规范生成日志文件,将日志文件也作为测试报告,以供测试员回看。In some possible embodiments, the recorded result may be a log file. Among them, a log file can be generated according to the corresponding specification, and the log file can also be used as a test report for the tester to review.

请结合参看图6,其为本申请实施例提供的计算机设备的内部结构示意图。计算机设备10包括存储器11和处理器12。存储器11用于存储程序指令,处理器12用于执行程序指令以实现上述UI自动化测试方法。Please refer to FIG. 6 , which is a schematic diagram of an internal structure of a computer device according to an embodiment of the present application. Computer device 10 includes memory 11 and processor 12 . The memory 11 is used for storing program instructions, and the processor 12 is used for executing the program instructions to implement the above-mentioned UI automation testing method.

其中,处理器12在一些实施例中可以是一中央处理器(Central ProcessingUnit,CPU)、控制器、微控制器、微处理器或其它数据处理芯片,用于运行存储器11中存储的程序指令。The processor 12 may be a central processing unit (Central Processing Unit, CPU), a controller, a microcontroller, a microprocessor or other data processing chips in some embodiments, and is used to execute program instructions stored in the memory 11 .

存储器11至少包括一种类型的可读存储介质,该可读存储介质包括闪存、硬盘、多媒体卡、卡型存储器(例如,SD或DX存储器等)、磁性存储器、磁盘、光盘等。存储器11在一些实施例中可以是计算机设备的内部存储单元,例如计算机设备的硬盘。存储器11在另一些实施例中也可以是计算机设备的外部存储设备,例如计算机设备上配备的插接式硬盘、智能存储卡(Smart Media Card,SMC)、安全数字(Secure Digital,SD)卡、闪存卡(FlashCard)等。进一步地,存储器11还可以既包括计算机设备的内部存储单元也包括外部存储设备。存储器11不仅可以用于存储安装于计算机设备的应用软件及各类数据,例如实现UI自动化测试方法的代码等,还可以用于暂时地存储已经输出或者将要输出的数据。The memory 11 includes at least one type of readable storage medium including flash memory, hard disk, multimedia card, card-type memory (eg, SD or DX memory, etc.), magnetic memory, magnetic disk, optical disk, and the like. The memory 11 may in some embodiments be an internal storage unit of the computer device, such as a hard disk of the computer device. In other embodiments, the memory 11 may also be an external storage device of the computer device, such as a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a Secure Digital (Secure Digital, SD) card equipped on the computer device, Flash card (FlashCard) and so on. Further, the memory 11 may also include both an internal storage unit of a computer device and an external storage device. The memory 11 can not only be used to store application software installed on the computer device and various data, such as codes for implementing the UI automation testing method, etc., but also can be used to temporarily store data that has been output or will be output.

请结合参看图7,其为本申请实施例提供的UI自动化测试系统的第一内部结构示意图。UI自动化测试系统20包括第一加载模块21、获取模块22、调用模块23、执行模块24以及第一生成模块25。Please refer to FIG. 7 , which is a schematic diagram of the first internal structure of the UI automated testing system provided by the embodiment of the present application. The UI automated testing system 20 includes a first loading module 21 , an acquiring module 22 , a calling module 23 , an executing module 24 and a first generating module 25 .

第一加载模块21,用于加载自动测试行为脚本。其中,自动测试行为脚本包含预设路径和调用接口。The first loading module 21 is used to load the automatic test behavior script. Among them, the automatic test behavior script includes a preset path and a calling interface.

在本实施例中,自动测试行为脚本由脚本开发员利用脚本语言编写形成。脚本语言包括但不限于Python、Java、JavaScript等。优选地,脚本语言为Python。预设路径和调用接口可以根据实际测试情况进行设置,在此不做限定。In this embodiment, the automatic test behavior script is written and formed by a script developer using a script language. Scripting languages include, but are not limited to, Python, Java, JavaScript, and the like. Preferably, the scripting language is Python. The preset path and calling interface can be set according to the actual test situation, which is not limited here.

在本实施例中,第一加载模块21加载自动测试行为脚本之前,UI自动化测试系统20还需要提供脚本模板。其中,脚本模板包括路径元素和接口元素。当路径元素替换为预设路径且接口元素替换为调用接口时,脚本模板转换成自动测试行为脚本。可以理解的是,脚本模板中的内容已经全部编写好,脚本开发员只需要根据实际测试情况将路径元素替换为预设路径、接口元素替换为调用接口即可形成自动测试行为脚本。同一自动测试行为脚本中的预设路径和调用接口相对应。In this embodiment, before the first loading module 21 loads the automatic testing behavior script, the UI automatic testing system 20 also needs to provide a script template. The script template includes path elements and interface elements. When the path element is replaced with the preset path and the interface element is replaced with the calling interface, the script template is converted into an automatic test behavior script. It is understandable that the content in the script template has been completely written, and the script developer only needs to replace the path element with the preset path and the interface element with the calling interface according to the actual test situation to form an automatic test behavior script. The preset path in the same automatic test behavior script corresponds to the calling interface.

获取模块22,用于根据预设路径获取预设xml文件。在本实施例中,预设xml文件为预先根据实际测试需求编写的文件,预设路径与预设xml文件一一对应。The obtaining module 22 is configured to obtain the preset xml file according to the preset path. In this embodiment, the preset xml file is a file prepared in advance according to actual test requirements, and the preset path corresponds to the preset xml file one-to-one.

在本实施例中,预设xml文件包括若干步骤节点,每一步骤节点包括一个或者若干子节点。当步骤节点包括一个子节点时,一个子节点对应一个第一操作;当步骤节点包括若干子节点时,每一子节点对应一个第二操作。其中,第一操作与第二操作不同。每一子节点包括预设属性值,预设属性值包括操作参数。其中,操作包括但不限于鼠标操作、键盘操作等。预设属性值包括但不限于路径参数、位置参数、时间参数、操作参数以及键值等。In this embodiment, the preset xml file includes several step nodes, and each step node includes one or several child nodes. When the step node includes one child node, one child node corresponds to one first operation; when the step node includes several child nodes, each child node corresponds to one second operation. Wherein, the first operation is different from the second operation. Each child node includes a preset attribute value, and the preset attribute value includes an operation parameter. The operations include but are not limited to mouse operations, keyboard operations, and the like. Preset attribute values include but are not limited to path parameters, location parameters, time parameters, operation parameters, and key values.

调用模块23,用于根据调用接口调用并加载相应的待测试UI界面。在本实施例中,调用接口与待测试UI界面一一对应。The calling module 23 is used for calling and loading the corresponding UI interface to be tested according to the calling interface. In this embodiment, the calling interface is in one-to-one correspondence with the UI interface to be tested.

执行模块24,用于在待测试UI界面触发执行步骤节点所对应的操作。在本实施例中,调用模块23加载完待测试UI界面后,执行模块24识别并解析预设xml文件的步骤节点,从而得出相应的第一操作和/或第二操作集合,并顺序触发执行第一操作和/或第二操作。其中,识别预设xml文件中的步骤节点的方法为常用方法,在此不再赘述。The execution module 24 is configured to trigger the operation corresponding to the execution step node on the UI interface to be tested. In this embodiment, after the calling module 23 loads the UI interface to be tested, the execution module 24 identifies and parses the step nodes of the preset xml file, thereby obtaining the corresponding first operation and/or second operation set, and triggers them in sequence Perform the first operation and/or the second operation. The method for identifying the step node in the preset xml file is a common method, which will not be repeated here.

第一生成模块25,用于根据操作的执行结果生成测试报告。执行模块24在待测试UI界面执行操作的过程中,第一生成模块25可以将所有操作所对应的执行结果都记录下来,形成测试报告。The first generating module 25 is configured to generate a test report according to the execution result of the operation. When the execution module 24 performs an operation on the UI interface to be tested, the first generation module 25 can record the execution results corresponding to all the operations to form a test report.

请结合参看图8,其为本申请实施例提供的UI自动化测试系统的第二内部结构示意图。UI自动化测试系统20还包括第二加载模块26和第二生成模块27。Please refer to FIG. 8 , which is a schematic diagram of the second internal structure of the UI automated testing system provided by the embodiment of the present application. The UI automation testing system 20 further includes a second loading module 26 and a second generating module 27 .

第二加载模块26,用于加载预设编写规则和待测试UI界面的测试用例。在本实施例中,预设编写规则包括所有标识字段和相应的预设属性值,测试用例包括若干测试操作。其中,测试操作为实际测试过程中需要执行的操作。The second loading module 26 is used for loading preset writing rules and test cases of the UI interface to be tested. In this embodiment, the preset writing rule includes all identification fields and corresponding preset attribute values, and the test case includes several test operations. The test operation is an operation that needs to be performed in the actual test process.

在本实施例中,预设编写规则为人为规定的编写规则。预设编写规则包括若干可配置项。可配置项包括但不限于Session、StepAction、Location、LocationXY、VisualImagePath、Duration以及Action等。具体地,Session表示会话,StepAction表示执行步骤,Location表示地址,LocationXY表示地址坐标,VisualImagePath表示图片地址,Duration表示停止持续时间,Action表示事件。其中,一个会话包括多个执行步骤;执行步骤可以包括一个第一操作,也可以包括至少一个第二操作。具体地,Location、LocationXY、VisualImagePath以及Duration均表示第一操作。In this embodiment, the preset writing rule is an artificially prescribed writing rule. Preset authoring rules include several configurable items. Configurable items include but are not limited to Session, StepAction, Location, LocationXY, VisualImagePath, Duration, and Action. Specifically, Session represents a session, StepAction represents an execution step, Location represents an address, LocationXY represents an address coordinate, VisualImagePath represents an image address, Duration represents a stop duration, and Action represents an event. Wherein, a session includes multiple execution steps; the execution step may include a first operation or at least one second operation. Specifically, Location, LocationXY, VisualImagePath, and Duration all represent the first operation.

在本实施例中,StepAction包括编号参数(StepNumber)。编号参数用于描述执行步骤的唯一性。In this embodiment, StepAction includes a number parameter (StepNumber). The number parameter is used to describe the uniqueness of the execution step.

Action包括若干事件类型,事件类型包括left_mouse_click、right_mouse_click、mouse_move、key_down以及loop。具体地,left_mouse_click表示点击鼠标左键,right_mouse_click表示点击鼠标右键,mouse_move表示移动鼠标,key_down表示输入键值,loop表示循环事件。left_mouse_click、right_mouse_click、mouse_move、key_down以及loop均表示第二操作。可以理解的是,执行步骤可以包括一个事件,一个事件包括至少一个第二操作。Action includes several event types, including left_mouse_click, right_mouse_click, mouse_move, key_down, and loop. Specifically, left_mouse_click means clicking the left mouse button, right_mouse_click means clicking the right mouse button, mouse_move means moving the mouse, key_down means entering a key value, and loop means a loop event. left_mouse_click, right_mouse_click, mouse_move, key_down, and loop all represent the second operation. It can be understood that the execution step may include an event, and an event includes at least one second operation.

在本实施例中,标识字段包括但不限于Location、LocationXY、VisualImagePath、Duration、Action、left_mouse_click、right_mouse_click、mouse_move、key_down以及loop。In this embodiment, the identification fields include but are not limited to Location, LocationXY, VisualImagePath, Duration, Action, left_mouse_click, right_mouse_click, mouse_move, key_down, and loop.

相应地,Location的预设属性值包括absolute和visualization。LocationXY的预设属性值包括坐标值,即位置参数。VisualImagePath的预设属性值包括路径,即路径参数。其中,当Location的预设属性值为absolute时,LocationXY必须包括预设属性值;当Location的预设属性值为visualization时,VisualImagePath必须包括预设属性值。具体地,LocationXY的预设属性值格式为(x,y),VisualImagePath的预设属性值为图片的相对路径或者绝对路径。Correspondingly, the preset attribute values of Location include absolute and visualization. The preset property values of LocationXY include coordinate values, that is, location parameters. The default property value of VisualImagePath includes the path, that is, the path parameter. Wherein, when the preset attribute value of Location is absolute, LocationXY must include the preset attribute value; when the preset attribute value of Location is visualization, VisualImagePath must include the preset attribute value. Specifically, the preset attribute value format of LocationXY is (x, y), and the preset attribute value of VisualImagePath is a relative path or an absolute path of the image.

Duration的预设属性值包括秒数,即时间参数。具体地,Duration表示每个事件执行后停止的时间,预设属性值的单位为秒。The default property value of Duration includes the number of seconds, that is, the time parameter. Specifically, Duration represents the stop time after each event is executed, and the unit of the preset attribute value is seconds.

Action的预设属性值包括left_mouse_click、right_mouse_click、mouse_move、key_down以及loop。The default attribute values of Action include left_mouse_click, right_mouse_click, mouse_move, key_down and loop.

其中,left_mouse_click和right_mouse_click的预设属性值包括次数,即操作参数。left_mouse_click的预设属性值用于表示点击鼠标左键的次数,right_mouse_click的预设属性值用于表示点击鼠标右键的次数。Among them, the preset attribute values of left_mouse_click and right_mouse_click include the number of times, that is, operation parameters. The default attribute value of left_mouse_click is used to indicate the number of clicks of the left mouse button, and the default attribute value of right_mouse_click is used to indicate the number of clicks of the right mouse button.

mouse_move的预设属性值包括坐标值,即位置参数。mouse_move的预设属性值格式为(x,y),用于表示鼠标移动到相应坐标处。The preset attribute values of mouse_move include coordinate values, that is, position parameters. The default attribute value format of mouse_move is (x, y), which is used to indicate that the mouse moves to the corresponding coordinate.

key_down的预设属性值包括键值。具体地,键值可以参考pyautogui.KEYBOARD_KEYS进行赋值。The default property value of key_down includes the key value. Specifically, the key value can be assigned by referring to pyautogui.KEYBOARD_KEYS.

Loop的预设属性值包括loopBegin、vars以及loopEnd。其中,loopBegin表示循环事件中的开始部分,vars表示循环事件中的循环部分,loopEnd表示循环事件中的结尾部分。循环事件中,开始部分和结尾部分均为不变的部分,循环部分为变化的部分。loopBegin、vars以及loopEnd均包括预设属性值。具体地,loopBegin和loopEnd的预设属性值的格式均为"int,...,int",vars的预设属性值的格式为"int,...,int;...;int,...,int"。其中,分号用于分割一次循环,逗号用于分割每次循环需要走的变化部分的方法。Loop's preset property values include loopBegin, vars, and loopEnd. Among them, loopBegin represents the beginning part of the loop event, vars represents the loop part of the loop event, and loopEnd represents the end part of the loop event. In a cyclic event, the beginning part and the end part are both constant parts, and the cyclic part is the changing part. loopBegin, vars, and loopEnd all include preset property values. Specifically, the format of the preset attribute values of loopBegin and loopEnd is "int,...,int", and the format of the preset attribute values of vars is "int,...,int;...;int,. ..,int". Among them, the semicolon is used to separate a loop, and the comma is used to separate the method of changing the part that needs to go through each loop.

第二生成模块27,用于根据测试用例和预设编写规则生成所述预设xml文件。其中,步骤节点和子节点的名称均为标识字段。可以理解的是,测试用例规定了预设xml文件的内容,预设编写规则规定了预设xml文件的编写规范。在本实施例中,测试用例中的测试操作与待测试UI界面相对应,使得生成的预设xml文件中的第一操作和/或第二操作均与待测试UI界面相对应。The second generating module 27 is configured to generate the preset xml file according to the test case and the preset writing rule. Among them, the names of step nodes and child nodes are both identification fields. It can be understood that the test case specifies the content of the preset xml file, and the preset writing rule specifies the writing specification of the preset xml file. In this embodiment, the test operation in the test case corresponds to the UI interface to be tested, so that the first operation and/or the second operation in the generated preset xml file corresponds to the UI interface to be tested.

显然,本领域的技术人员可以对本申请进行各种改动和变型而不脱离本申请的精神和范围。这样,倘且本申请的这些修改和变型属于本申请权利要求及其等同技术的范围之内,则本申请也意图包含这些改动和变型在内。Obviously, those skilled in the art can make various changes and modifications to the present application without departing from the spirit and scope of the present application. Thus, if these modifications and variations of the present application fall within the scope of the claims of the present application and their equivalents, the present application is also intended to include these modifications and variations.

以上所列举的仅为本申请较佳实施例而已,当然不能以此来限定本申请之权利范围,因此依本申请权利要求所作的等同变化,仍属于本申请所涵盖的范围。The above enumeration is only the preferred embodiment of the present application, of course, the scope of the right of the present application cannot be limited by this, so the equivalent changes made according to the claims of the present application still belong to the scope covered by the present application.

Claims (10)

1. A UI automation test method is characterized by comprising the following steps:
loading an automatic testing behavior script, wherein the automatic testing behavior script comprises a preset path and a calling interface;
acquiring a preset xml file according to the preset path, wherein the preset xml file comprises a plurality of step nodes, each step node comprises one or a plurality of sub-nodes, when the step node comprises one sub-node, one sub-node corresponds to one first operation, when the step node comprises a plurality of sub-nodes, each sub-node corresponds to one second operation, and the first operation is different from the second operation; each child node comprises a preset attribute value, and the preset attribute value comprises an operation parameter;
calling and loading a corresponding UI to be tested according to the calling interface;
triggering and executing the operation corresponding to the step node on the UI interface to be tested; and
and generating a test report according to the execution result of the operation.
2. The UI automation test method of claim 1, wherein prior to loading an automation test behavior script, the UI automation test method further comprises:
loading a preset compiling rule and a test case of the UI interface to be tested, wherein the preset compiling rule comprises all identification fields and corresponding preset attribute values, and the test case comprises a plurality of test operations; and
and generating the preset xml file according to the test case and a preset writing rule, wherein the names of the step node and the child node are the identification fields.
3. The UI automation test method of claim 2, wherein the generating the preset xml file according to the test case and the preset writing rule specifically comprises:
acquiring operation data from a step recorder, wherein the operation data is data recorded in the step recorder by a user according to the test steps of the test case; and
and converting the operation data into the preset xml file according to the preset compiling rule.
4. The method for automatically testing a UI according to claim 1, wherein after the UI interface to be tested triggers the operation corresponding to the step node, the method for automatically testing a UI further comprises:
starting a screen recording tool to record the execution process of the operation; and
and generating a recording result according to the content recorded by the screen recording tool.
5. The UI automated testing method according to claim 1, wherein after the UI interface to be tested triggers execution of the operation corresponding to the step node, the UI automated testing method further comprises:
judging whether the operation executed on the UI interface to be tested is abnormal or not; and
and when the operation executed on the UI interface to be tested is abnormal, stopping or skipping the operation.
6. The UI automation test method of claim 1 wherein prior to loading the automation test behavior script, the UI automation test method further comprises:
providing a script template, wherein the script template comprises path elements and interface elements, and when the path elements are replaced by the preset paths and the interface elements are replaced by the calling interfaces, the script template is converted into the automatic test behavior script.
7. The UI automation test method of claim 1 wherein the preset attribute values include a path parameter, a location parameter, a time parameter, an operation parameter, and a key value.
8. A computer device, characterized in that the computer device comprises:
a memory for storing program instructions; and
a processor for executing the program instructions to implement the UI automation test method of any one of claims 1 to 7.
9. A UI automation test system, the UI automation test system comprising:
the system comprises a first loading module, a second loading module and a control module, wherein the first loading module is used for loading an automatic testing behavior script, and the automatic testing behavior script comprises a preset path and a calling interface;
an obtaining module, configured to obtain a preset xml file according to the preset path, where the preset xml file includes a plurality of step nodes, each step node includes one or a plurality of child nodes, when the step node includes one child node, one child node corresponds to one first operation, when the step node includes a plurality of child nodes, each child node corresponds to one second operation, and the first operation is different from the second operation; each child node comprises a preset attribute value, and the preset attribute value comprises an operation parameter;
the calling module is used for calling and loading the corresponding UI interface to be tested according to the calling interface;
the execution module is used for triggering and executing the operation corresponding to the step node on the UI interface to be tested; and
and the first generation module is used for generating a test report according to the execution result of the operation.
10. The UI automation test system of claim 9 wherein the UI automation test system further comprises:
the second loading module is used for loading a preset compiling rule and a test case of the UI interface to be tested, wherein the preset compiling rule comprises all identification fields and corresponding preset attribute values, and the test case comprises a plurality of test operations; and
and the second generation module is used for generating the preset xml file according to the test case and a preset writing rule, wherein the names of the step node and the child node are the identification fields.
CN202210890679.0A 2022-07-27 2022-07-27 UI automation testing method and system, computer equipment Pending CN115185852A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202210890679.0A CN115185852A (en) 2022-07-27 2022-07-27 UI automation testing method and system, computer equipment

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202210890679.0A CN115185852A (en) 2022-07-27 2022-07-27 UI automation testing method and system, computer equipment

Publications (1)

Publication Number Publication Date
CN115185852A true CN115185852A (en) 2022-10-14

Family

ID=83521370

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202210890679.0A Pending CN115185852A (en) 2022-07-27 2022-07-27 UI automation testing method and system, computer equipment

Country Status (1)

Country Link
CN (1) CN115185852A (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115629979A (en) * 2022-10-27 2023-01-20 在线途游(北京)科技有限公司 UI automation test method, system, equipment and storage medium

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110287095A (en) * 2019-05-20 2019-09-27 深圳壹账通智能科技有限公司 A kind of automated testing method, device and storage medium
CN110309061A (en) * 2019-05-24 2019-10-08 深圳壹账通智能科技有限公司 Automated testing method, device, storage medium, and computer equipment
WO2020233331A1 (en) * 2019-05-20 2020-11-26 深圳壹账通智能科技有限公司 User interface automated testing method and apparatus, and computer-readable storage medium
CN113326193A (en) * 2021-06-03 2021-08-31 深圳前海微众银行股份有限公司 Applet testing method and device
CN114398283A (en) * 2022-01-18 2022-04-26 平安健康保险股份有限公司 Automatic testing method and device for user interface, electronic equipment and storage medium

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110287095A (en) * 2019-05-20 2019-09-27 深圳壹账通智能科技有限公司 A kind of automated testing method, device and storage medium
WO2020233331A1 (en) * 2019-05-20 2020-11-26 深圳壹账通智能科技有限公司 User interface automated testing method and apparatus, and computer-readable storage medium
CN110309061A (en) * 2019-05-24 2019-10-08 深圳壹账通智能科技有限公司 Automated testing method, device, storage medium, and computer equipment
CN113326193A (en) * 2021-06-03 2021-08-31 深圳前海微众银行股份有限公司 Applet testing method and device
CN114398283A (en) * 2022-01-18 2022-04-26 平安健康保险股份有限公司 Automatic testing method and device for user interface, electronic equipment and storage medium

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115629979A (en) * 2022-10-27 2023-01-20 在线途游(北京)科技有限公司 UI automation test method, system, equipment and storage medium

Similar Documents

Publication Publication Date Title
CN108170611B (en) Automated testing method and device, storage medium, electronic equipment
US10146672B2 (en) Method and system for automated user interface (UI) testing through model driven techniques
CN1938690B (en) Method and system for continuously converting automatic test script into abstract test case representation
CN106649103A (en) Android application program automatically black box testing method and system
WO2019227708A1 (en) Online debugging apparatus and method for test case, and computer-readable storage medium
CN103150249A (en) Automatic testing method and system
CN115658529A (en) Automatic testing method for user page and related equipment
CN110781091B (en) Application program testing method and device, electronic equipment and storage medium
CN111026670B (en) Test case generation method, test case generation device and storage medium
CN105912460A (en) Software test method and system based on QTP
CN110659197B (en) Application test case generation method and device and software test system
CN112506923B (en) Method, device and electronic device for determining link of method call corresponding to business
CN117648257A (en) Web automatic test method and system under Linux operating system
CN115185852A (en) UI automation testing method and system, computer equipment
CN111881056A (en) Automatic test framework and test method
CN115757100A (en) Automated testing framework facing user interface, method, equipment and medium
CN111078529B (en) Client writing module testing method and device and electronic equipment
CN117762802A (en) Automatic test method, device, equipment and storage medium
CN114461514A (en) Automatic testing method and system based on low codes
CN118606211A (en) Test script generation method, device, electronic equipment and vehicle
CN113468050B (en) Canvas-based testing method, device, computer equipment and storage medium
CN113672509A (en) Automated test method, device, test platform and storage medium
CN116185826A (en) Test method, device, equipment and storage medium
CN115905020A (en) Application testing method and device, electronic equipment and storage medium
CN115904973A (en) Test method and device based on data driving

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