CN108388513A - A kind of automated testing method and device - Google Patents
A kind of automated testing method and device Download PDFInfo
- Publication number
- CN108388513A CN108388513A CN201810153211.7A CN201810153211A CN108388513A CN 108388513 A CN108388513 A CN 108388513A CN 201810153211 A CN201810153211 A CN 201810153211A CN 108388513 A CN108388513 A CN 108388513A
- Authority
- CN
- China
- Prior art keywords
- test
- current
- key information
- active component
- component element
- 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.)
- Granted
Links
Classifications
-
- G—PHYSICS
- G06—COMPUTING OR CALCULATING; COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F11/00—Error detection; Error correction; Monitoring
- G06F11/36—Prevention of errors by analysis, debugging or testing of software
- G06F11/3668—Testing of software
- G06F11/3672—Test management
- G06F11/3688—Test 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)
- User Interface Of Digital Computer (AREA)
- Medical Treatment And Welfare Office Work (AREA)
Abstract
本发明公开了一种自动化测试方法及装置,涉及计算机技术领域,方法包括:解析测试器得到解析结果,根据解析结果从已连接到计算机上的设备中定位被测设备;从解析结果中获取测试器中的当前测试操作;根据当前测试操作得到当前测试操作类型、视图类型和关键信息;在被测设备上生成与被测设备上的当前被测应用的当前页面对应的活动组件元素集合文件;将活动组件元素集合文件转移到计算机上;根据视图类型和关键信息在活动组件元素集合文件中获取与视图类型和关键信息匹配的活动组件元素;根据获取结果和当前测试操作类型对被测设备进行测试。本发明公开的自动化测试方法及装置提高了测试的效率。
The invention discloses an automatic testing method and device, which relate to the technical field of computers. The method includes: analyzing a tester to obtain an analysis result, and locating a device under test from devices connected to a computer according to the analysis result; obtaining a test device from the analysis result. The current test operation in the device; according to the current test operation, the current test operation type, view type and key information are obtained; on the device under test, an active component element set file corresponding to the current page of the current application under test on the device under test is generated; Transfer the active component element collection file to the computer; obtain the active component elements that match the view type and key information in the active component element collection file according to the view type and key information; perform a test on the device under test according to the obtained result and the current test operation type test. The automatic testing method and device disclosed by the invention improve the testing efficiency.
Description
技术领域technical field
本发明涉及计算机技术领域,特别涉及一种自动化测试方法及装置。The invention relates to the field of computer technology, in particular to an automatic testing method and device.
背景技术Background technique
现有技术中,对移动设备上的应用程序的测试过程中,主要是采用手工测试的方式进行的,这种方式非常的耗费时间和人力,测试效率低。In the prior art, the testing process of the application program on the mobile device is mainly carried out by manual testing, which is very time-consuming and labor-intensive, and the testing efficiency is low.
发明内容Contents of the invention
本发明提供了一种自动化测试方法及装置,解决了上述技术问题。The invention provides an automatic testing method and device, which solve the above-mentioned technical problems.
本发明的提供了一种自动化测试方法,包括:The present invention provides an automated testing method, comprising:
步骤s1:解析测试器得到解析结果,根据解析结果从已连接到计算机上的设备中定位被测设备;Step s1: The analysis tester obtains the analysis result, and locates the device under test from the devices connected to the computer according to the analysis result;
步骤s2:从所述解析结果中获取所述测试器中的当前测试操作;根据所述当前测试操作得到当前测试操作类型、视图类型和关键信息;Step s2: Obtain the current test operation in the tester from the analysis result; obtain the current test operation type, view type and key information according to the current test operation;
步骤s3:在所述被测设备上生成与所述被测设备上的当前被测应用的当前页面对应的活动组件元素集合文件;将所述活动组件元素集合文件转移到计算机上;Step s3: generating on the device under test an active component element set file corresponding to the current page of the current application under test on the device under test; transferring the active component element set file to a computer;
步骤s4:根据所述视图类型和所述关键信息在所述活动组件元素集合文件中获取与所述视图类型和所述关键信息匹配的活动组件元素;根据获取结果和当前测试操作类型对所述被测设备进行测试。Step s4: According to the view type and the key information, obtain the active component elements matching the view type and the key information in the active component element set file; according to the obtained result and the current test operation type, the The device under test is tested.
本发明还提供了一种自动化测试装置,包括:包括:第一解析模块、第一定位模块、第一获取模块、第二获取模块、第一生成模块、第一转移模块、第三获取模块和第一测试模块;The present invention also provides an automated testing device, comprising: a first analysis module, a first positioning module, a first acquisition module, a second acquisition module, a first generation module, a first transfer module, a third acquisition module and first test module;
所述第一解析模块,用于解析测试器得到解析结果;The first parsing module is used for parsing the tester to obtain parsing results;
所述第一定位模块,用于根据所述第一解析模块得到的解析结果从已连接到计算机上的设备中定位被测设备;所述计算机上安装有所述测试器;The first positioning module is used to locate the device under test from the devices connected to the computer according to the analysis result obtained by the first analysis module; the tester is installed on the computer;
所述第一获取模块,用于从所述第一解析模块得到的解析结果中获取测试器中的当前测试操作;The first acquisition module is configured to acquire the current test operation in the tester from the analysis result obtained by the first analysis module;
所述第二获取模块,用于根据所述第一获取模块获取到的当前测试操作得到当前测试操作类型、视图类型和关键信息;The second obtaining module is configured to obtain the current test operation type, view type and key information according to the current test operation obtained by the first obtaining module;
所述第一生成模块,用于在所述被测设备上生成与所述被测设备上的当前被测应用的当前页面对应的活动组件元素集合文件;The first generation module is configured to generate, on the device under test, an active component element set file corresponding to the current page of the current application under test on the device under test;
所述第一转移模块,用于将所述第一生成模块生成的所述活动组件元素集合文件转移到所述计算机上;The first transfer module is configured to transfer the active component element set file generated by the first generation module to the computer;
所述第三获取模块,用于根据所述第二获取模块获取到的所述视图类型和所述关键信息在所述活动组件元素集合文件中获取与所述视图类型和所述关键信息匹配的活动组件元素;The third obtaining module is configured to obtain, in the active component element collection file, the view type and the key information matching the view type and the key information according to the view type and the key information obtained by the second obtaining module. Activity component element;
所述第一测试模块,用于根据所述第三获取模块获取到的获取结果和所述第二获取模块获取到的当前测试操作类型对所述被测设备进行测试。The first test module is configured to test the device under test according to the acquisition result acquired by the third acquisition module and the current test operation type acquired by the second acquisition module.
本发明的有益效果:提供了一种自动化测试方法及装置,通过解析测试器,根据测试器中的当前测试操作获取当前测试操作类型、视图类型和关键信息,通过对被测设备的应用程序的界面分析获取界面中的与视图类型和关键信息匹配的活动组件元素,根据获取到活动组件元素中的信息和当前测试操作类型完成对被测设备的应用程序界面的测试操作,提高了测试的效率。Beneficial effects of the present invention: provide an automated test method and device, by analyzing the tester, according to the current test operation in the tester to obtain the current test operation type, view type and key information, through the application program of the device under test Interface analysis obtains the active component elements in the interface that match the view type and key information, and completes the test operation of the application program interface of the device under test according to the information obtained in the active component elements and the current test operation type, which improves the test efficiency. .
附图说明Description of drawings
图1为本发明实施例1提供的一种自动化测试方法的流程图;Fig. 1 is a flow chart of a kind of automated testing method provided by embodiment 1 of the present invention;
图2-1、图2-2和图2-3为本发明实施例2提供的一种在测试移动设备上的挑战应答型的动态令牌应用时的方法流程图;Figure 2-1, Figure 2-2 and Figure 2-3 are a flow chart of a method for testing a challenge-response dynamic token application on a mobile device provided by Embodiment 2 of the present invention;
图3为本发明实施例2提供的当前页面为被测设备上的当前被测应用的选择动态口令类型的页面示意图;3 is a schematic diagram of a page where the current page provided by Embodiment 2 of the present invention is the selected dynamic password type of the current application under test on the device under test;
图4为本发明实施例2提供的被测设备上的当前被测应用的等待输入挑战值的当前页面的页面示意图;FIG. 4 is a schematic page diagram of the current page of the current application under test waiting to input a challenge value provided by Embodiment 2 of the present invention;
图5为本发明实施例2提供的输入挑战值“123456”之后的被测设备上的当前被测应用的等待输入挑战值的当面页面的页面示意图;Fig. 5 is a page schematic diagram of the face-to-face page of the currently tested application on the device under test after inputting the challenge value "123456" provided by Embodiment 2 of the present invention, waiting for the challenge value to be input;
图6为本发明实施例2提供的被测设备上的当前被测应用的显示动态口令的当前页面的页面示意图;FIG. 6 is a schematic diagram of a current page displaying a dynamic password of the current application under test on the device under test provided in Embodiment 2 of the present invention;
图7-1和图7-2为本发明实施例3提供的一种在测试当前被测应用的当前页面为登录页面时的工作方法的流程图;Figure 7-1 and Figure 7-2 are a flowchart of a working method provided by Embodiment 3 of the present invention when the current page of the current application under test is a login page;
图8为本发明实施例3提供的当前页面为被测设备上的当前被测应用的等待输入用户名和密钥的登录页面的页面示意图;8 is a schematic diagram of a page where the current page provided by Embodiment 3 of the present invention is the login page of the current application under test waiting for input of a user name and key on the device under test;
图9为本发明实施例3提供的被测设备上的当前被测应用的输入文本内容“张三”之后的登录当前页面的页面示意图;FIG. 9 is a schematic diagram of the login current page after the input text content "Zhang San" of the current application under test on the device under test according to Embodiment 3 of the present invention;
图10为本发明实施例3提供的被测设备上的当前被测应用的输入文本内容“123456”之后的登录当前页面的页面示意图;Fig. 10 is a schematic diagram of the login current page after the input text content "123456" of the current application under test on the device under test according to Embodiment 3 of the present invention;
图11为本发明实施例4提供的一种自动化测试装置的结构方框图。Fig. 11 is a structural block diagram of an automatic testing device provided by Embodiment 4 of the present invention.
具体实施方法Specific implementation method
下面将结合本发明实施例中的附图,对本发明实施例中的技术方案进行清楚、完整地描述,显然,所描述的实施例仅仅是本发明一部分实施例,而不是全部的实施例。基于本发明中的实施例,本领域普通技术人员在没有做出创造性劳动前提下所获得的所有其他实施例,都属于本发明保护的范围。The following will clearly and completely describe the technical solutions in the embodiments of the present invention with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only some, not all, embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by persons of ordinary skill in the art without making creative efforts belong to the protection scope of the present invention.
实施例1Example 1
本实施例提供一种自动化测试方法,适用于安装有测试器的计算机上,如图1所示,包括:This embodiment provides an automated testing method, which is applicable to a computer equipped with a tester, as shown in Figure 1, including:
步骤s1:解析测试器得到解析结果,根据解析结果从已连接到计算机上的设备中定位被测设备;Step s1: The analysis tester obtains the analysis result, and locates the device under test from the devices connected to the computer according to the analysis result;
步骤s2:从解析结果中获取测试器中的当前测试操作;根据当前测试操作得到当前测试操作类型、视图类型和关键信息;Step s2: Obtain the current test operation in the tester from the analysis result; obtain the current test operation type, view type and key information according to the current test operation;
步骤s3:在被测设备上生成与被测设备上的当前被测应用的当前页面对应的活动组件元素集合文件;将活动组件元素集合文件转移到计算机上;Step s3: generating on the device under test an active component element set file corresponding to the current page of the current application under test on the tested device; transferring the active component element set file to the computer;
步骤s4:根据视图类型和关键信息在活动组件元素集合文件中获取与视图类型和关键信息匹配的活动组件元素;根据获取结果和当前测试操作类型对被测设备进行测试。Step s4: Obtain active component elements matching the view type and key information in the active component element collection file according to the view type and key information; test the device under test according to the obtained result and the current test operation type.
本实施例中,步骤s4中还可以包括:根据获取结果得到测试报告。In this embodiment, step s4 may further include: obtaining a test report according to the obtained result.
本实施例中,若当前测试操作类型为点击操作,则根据获取结果和当前测试操作类型对被测设备进行测试,可以具体包括:In this embodiment, if the current test operation type is a click operation, the device under test is tested according to the obtained result and the current test operation type, which may specifically include:
步骤a1:判断是否获取到与视图类型和关键信息匹配的活动组件元素,如果是,则执行步骤a2;Step a1: Determine whether the active component element matching the view type and key information has been obtained, and if so, execute step a2;
步骤a2:根据与视图类型和关键信息匹配的活动组件元素的元素坐标信息得到当前页面上的待点击区域的焦点位置,在焦点位置上点击当前页面上的待点击区域;Step a2: Obtain the focus position of the area to be clicked on the current page according to the element coordinate information of the active component element matching the view type and key information, and click the area to be clicked on the current page at the focus position;
相应地,根据获取结果得到测试报告,具体为:若步骤a1判断为否,则组织包括匹配失败信息的测试报告;若步骤a1判断为是,则组织包括匹配成功信息的测试报告。Correspondingly, the test report is obtained according to the obtained result, specifically: if the judgment in step a1 is no, organize the test report including matching failure information; if the judgment in step a1 is yes, organize the test report including matching success information.
本实施例中,若当前测试操作类型为输入操作,则:In this embodiment, if the current test operation type is an input operation, then:
步骤s2中还包括:根据当前测试操作获取文本内容;Step s2 also includes: obtaining text content according to the current test operation;
根据获取结果和当前测试操作类型对被测设备进行测试,具体包括:Test the device under test according to the obtained results and the current test operation type, including:
步骤b1:判断是否获取到与视图类型和关键信息匹配的活动组件元素,如果是,则执行步骤b2;Step b1: Determine whether the active component element matching the view type and key information is obtained, and if so, execute step b2;
步骤b2:根据与视图类型和关键信息匹配的活动组件元素中的元素坐标信息得到当前页面上的文本输入区域的焦点位置,在焦点位置点击当前页面上的文本输入区域;将文本内容输入到当前页面上的文本输入区域中;Step b2: Obtain the focus position of the text input area on the current page according to the element coordinate information in the active component element matching the view type and key information, click the text input area on the current page at the focus position; input the text content into the current page In the text input area on the page;
相应地,根据获取结果得到测试报告,具体为:若步骤b1判断为否,则组织包括匹配失败信息的测试报告;若步骤b1判断为是,则组织包括匹配成功信息的测试报告。Correspondingly, the test report is obtained according to the obtained result, specifically: if the judgment in step b1 is no, organize the test report including the matching failure information; if the judgment in step b1 is yes, organize the test report including the matching success information.
本实施例中,若当前测试操作类型为断言操作,则根据获取结果和当前测试操作类型对被测设备进行测试具体为:判断是否获取到与视图类型和关键信息匹配的活动组件元素;In this embodiment, if the current test operation type is an assertion operation, testing the device under test according to the obtained result and the current test operation type specifically includes: judging whether an active component element matching the view type and key information is obtained;
相应地,根据获取结果得到测试报告,具体为:当判断出获取到与视图类型和关键信息匹配的活动组件元素时,则组织包括匹配成功信息的测试报告;当判断出没有获取到与视图类型和关键信息匹配的活动组件元素时,则组织包括匹配失败信息的测试报告。Correspondingly, the test report is obtained according to the obtained results, specifically: when it is judged that the active component elements that match the view type and key information are obtained, organize a test report that includes matching success information; When there are active component elements that match key information, the organization includes test reports that match failure information.
本实施例中,步骤s2可以具体包括:In this embodiment, step s2 may specifically include:
步骤s21:从解析结果中获取测试器中的测试操作,将测试器中的第一测试操作作为当前测试操作;Step s21: Obtain the test operation in the tester from the analysis result, and use the first test operation in the tester as the current test operation;
步骤s22:根据当前测试操作得到当前测试操作类型,根据当前测试操作获取视图类型和关键信息;当前测试操作类型包括:点击操作、输入操作和断言操作中的至少一种;Step s22: Obtain the current test operation type according to the current test operation, obtain the view type and key information according to the current test operation; the current test operation type includes: at least one of click operation, input operation and assertion operation;
步骤s4可以具体包括:Step s4 may specifically include:
步骤s41:根据视图类型和关键信息在活动组件元素集合文件中获取与视图类型和关键信息匹配的活动组件元素;Step s41: Obtain active component elements matching the view type and key information in the active component element set file according to the view type and key information;
步骤s42:判断是否获取到与视图类型和关键信息匹配的活动组件元素,如果是,则执行步骤s43;否则,结束;Step s42: Judging whether the active component element matching the view type and key information is obtained, if yes, execute step s43; otherwise, end;
步骤s43:若当前测试操作为点击操作,根据与视图类型和关键信息匹配的活动组件元素的元素坐标信息得到当前页面上的待点击区域的焦点位置,在焦点位置上点击当前页面上的待点击区域;执行步骤s44;Step s43: If the current test operation is a click operation, obtain the focus position of the area to be clicked on the current page according to the element coordinate information of the active component element matching the view type and key information, and click the area to be clicked on the current page at the focus position area; execute step s44;
若当前测试操作为输入操作,根据与视图类型和关键信息匹配的活动组件元素的元素坐标信息得到当前页面上的文本输入区域的焦点位置,在焦点位置点击当前页面上的文本输入区域;将文本内容输入到当前页面上的文本输入区域中;执行步骤s44;If the current test operation is an input operation, the focus position of the text input area on the current page is obtained according to the element coordinate information of the active component element matching the view type and key information, and the text input area on the current page is clicked at the focus position; the text The content is input into the text input area on the current page; execute step s44;
若当前测试操作为断言操作,则执行步骤s44;If the current test operation is an assertion operation, execute step s44;
步骤s44:判断当前测试操作是否为测试器中的最后一个测试操作,如果是,则结束;否则,将测试器中的当前测试操作的下一个测试操作作为当前测试操作,返回步骤s22。Step s44: Determine whether the current test operation is the last test operation in the tester, if yes, end; otherwise, take the next test operation of the current test operation in the tester as the current test operation, and return to step s22.
进一步地,当步骤s42中判断为否后,还包括:保存获取结果,根据已保存的所有获取结果得到测试报告;Further, when it is judged as No in step s42, it also includes: saving the obtained results, and obtaining a test report according to all saved obtained results;
步骤s43中若当前测试操作为点击操作,执行步骤s44前,还包括:保存获取结果;In step s43, if the current test operation is a click operation, before performing step s44, it also includes: saving the obtained result;
步骤s43中若当前测试操作为输入操作,执行步骤s44前,还包括:保存获取结果;In step s43, if the current test operation is an input operation, before performing step s44, it also includes: saving the obtained result;
步骤s43中若当前测试操作为断言操作,执行步骤s44前,还包括:保存获取结果;In step s43, if the current test operation is an assertion operation, before performing step s44, it also includes: saving the obtained result;
步骤s44中判断为是后,还包括:根据已保存的所有获取结果得到测试报告。After the determination in step s44 is yes, the method further includes: obtaining a test report according to all the saved acquisition results.
本实施例中,点击操作可以包括文本点击操作和按钮点击操作。In this embodiment, the click operation may include a text click operation and a button click operation.
本实施例中,在焦点位置上点击当前页面上的待点击区域,具体为:根据焦点位置组织点击命令,将点击命令发送给被测设备点击当前页面上的待点击区域。In this embodiment, clicking the area to be clicked on the current page at the focus position specifically includes: organizing click commands according to the focus position, and sending the click command to the device under test to click the area to be clicked on the current page.
进一步地,根据焦点位置组织点击命令,将点击命令发送给被测设备点击当前页面上的待点击区域具体为:根据焦点位置的坐标组织点击命令,将点击命令发送给被测设备的操作系统,被测设备的操作系统接收到点击命令后,根据点击命令中的焦点位置的坐标点击当前页面上的待点击区域。Further, the click command is organized according to the focus position, and the click command is sent to the device under test to click the area to be clicked on the current page. Specifically, the click command is organized according to the coordinates of the focus position, and the click command is sent to the operating system of the device under test, After receiving the click command, the operating system of the device under test clicks the area to be clicked on the current page according to the coordinates of the focus position in the click command.
本实施例中,在焦点位置点击当前页面上的文本输入区域;将文本内容输入到当前页面上的文本输入区域中;可以具体包括:In this embodiment, click the text input area on the current page at the focus position; input the text content into the text input area on the current page; it may specifically include:
步骤c1:根据焦点位置组织点击命令,将点击命令发送给被测设备点击当前页面上的文本输入区域;Step c1: Organize the click commands according to the focus position, and send the click commands to the device under test to click the text input area on the current page;
步骤c2:组织包括文本内容的文本输入命令,将文本输入命令发送给被测设备将文本内容输入到当前页面上的文本输入区域中。Step c2: Organizing text input commands including text content, sending the text input command to the device under test to input the text content into the text input area on the current page.
进一步地,步骤c1具体为:根据焦点位置的坐标组织点击命令,将点击命令发送给被测设备的操作系统,被测设备的操作系统接收到点击命令后,根据点击命令中的焦点位置的坐标点击当前页面上的文本输入区域;Further, step c1 is specifically: organize the click command according to the coordinates of the focus position, and send the click command to the operating system of the device under test. After the operating system of the device under test receives the click command, it Click on the text input area on the current page;
步骤c2具体为:组织包括文本内容的文本输入命令,将文本输入命令发送给被测设备的操作系统,被测设备的操作系统接收到文本输入命令后,将文本输入命令中的文本内容本输入到当前页面上的文本输入区域中。Step c2 is specifically: organize the text input command including the text content, send the text input command to the operating system of the device under test, after the operating system of the device under test receives the text input command, input the text content in the text input command into the text input area on the current page.
本实施例中,当当前测试操作为输入操作时,步骤s22中还包括:根据当前测试操作获取文本内容。In this embodiment, when the current test operation is an input operation, step s22 further includes: acquiring text content according to the current test operation.
本实施例中,根据当前测试操作得到当前测试操作类型,具体为:判断测试器中的当前测试代码类型,若当前测试代码为第一函数或第四函数,则当前测试操作类型为点击操作;若当前测试代码为第二函数,则当前测试操作类型为输入操作;若当前测试代码为第三函数,则当前测试操作类型为断言操作。In this embodiment, the current test operation type is obtained according to the current test operation, specifically: judging the current test code type in the tester, if the current test code is the first function or the fourth function, the current test operation type is a click operation; If the current test code is the second function, the current test operation type is an input operation; if the current test code is the third function, the current test operation type is an assertion operation.
进一步地,根据当前测试操作得到视图类型和关键信息,具体为:Further, the view type and key information are obtained according to the current test operation, specifically:
若当前测试代码为第一函数时,获取第一函数中第一参数和第二参数,将第一参数作为视图类型,将第二参数作为关键信息;If the current test code is the first function, obtain the first parameter and the second parameter in the first function, use the first parameter as the view type, and use the second parameter as the key information;
若当前测试代码为第二函数时,获取第二函数中第三参数和第四参数,将第三参数作为视图类型,将第四参数作为关键信息;If the current test code is the second function, obtain the third parameter and the fourth parameter in the second function, use the third parameter as the view type, and use the fourth parameter as the key information;
若当前测试代码为第三函数时,获取第三函数中第五参数和第六参数,将第五参数作为视图类型,将第六参数作为关键信息;If the current test code is the third function, obtain the fifth parameter and the sixth parameter in the third function, use the fifth parameter as the view type, and use the sixth parameter as the key information;
若当前测试代码为第四函数时,获取第四函数中第七参数和第八参数,将第七参数作为视图类型,将第八参数作为关键信息。If the current test code is the fourth function, obtain the seventh parameter and the eighth parameter in the fourth function, use the seventh parameter as the view type, and use the eighth parameter as key information.
本实施例中,步骤s3具体包括:In this embodiment, step s3 specifically includes:
步骤s31:根据被测设备的设备标识组织第一生成命令,将第一生成命令发送给被测设备的操作系统;Step s31: organize the first generation command according to the device identification of the device under test, and send the first generation command to the operating system of the device under test;
步骤s32:判断是否接收到来自被测设备的操作系统的生成失败应答,如果是,则判断出没有在被测设备上生成与当前被测应用的当前页面对应的活动组件元素集合文件,报错结束;否则,判断出在被测设备上成功生成与当前被测应用的当前页面对应的活动组件元素集合文件,执行步骤s33;Step s32: Judging whether a generation failure response from the operating system of the device under test has been received, if yes, judging that the active component element set file corresponding to the current page of the current application under test has not been generated on the device under test, and the end of error reporting ; Otherwise, it is determined that the active component element set file corresponding to the current page of the current application under test is successfully generated on the device under test, and step s33 is executed;
步骤s33:根据被测设备的设备标识组织第一转移命令,将第一转移命令发送给被测设备的操作系统;Step s33: organize the first transfer command according to the device identification of the device under test, and send the first transfer command to the operating system of the device under test;
步骤s34:判断是否接收到来自被测设备的操作系统的转移失败应答,如果是,则判断出没有将活动组件元素集合文件成功转移到计算机上,报错结束;否则,判断出将活动组件元素集合文件成功转移到计算机上,执行步骤s4。Step s34: Judging whether a transfer failure response from the operating system of the device under test has been received, if yes, it is judged that the active component element set file has not been successfully transferred to the computer, and the error report ends; otherwise, it is judged that the active component element set file The file is successfully transferred to the computer, and step s4 is executed.
本实施例中,关键信息包括关键信息标识和关键信息值;In this embodiment, the key information includes a key information identifier and a key information value;
根据视图类型和关键信息在活动组件元素集合文件中获取与视图类型和关键信息匹配的活动组件元素,具体为:According to the view type and key information, obtain the active component elements that match the view type and key information in the active component element collection file, specifically:
根据视图类型和关键信息标识和关键信息值在活动组件元素集合文件中查找元素属性中的元素类型与视图类型匹配且元素属性为关键信息标识,元素属性值为关键信息值的活动组件元素,若查找到,则判断出获取到与视图类型和关键信息匹配的活动组件元素;否则,判断出没有获取到与视图类型和关键信息匹配的活动组件元素。According to the view type, key information ID and key information value, search for active component elements whose element type in the element attribute matches the view type, whose element attribute is the key information ID, and whose element attribute value is the key information value in the active component element collection file. If found, it is judged that the active component element matching the view type and key information has been obtained; otherwise, it is judged that no active component element matching the view type and key information has been obtained.
本实施例提供了一种自动化测试方法:通过解析测试器,根据测试器中的当前测试操作获取当前测试操作类型、视图类型和关键信息,通过对被测设备的被测应用程序的界面分析获取界面中的与视图类型和关键信息匹配的活动组件元素,根据获取到活动组件元素中的信息和当前测试操作类型完成对被测设备的被测应用程序界面的测试操作,提高了测试的效率。This embodiment provides an automated testing method: by analyzing the tester, the current test operation type, view type and key information are obtained according to the current test operation in the tester, and obtained by analyzing the interface of the application program under test of the device under test The active component element in the interface that matches the view type and key information completes the test operation of the tested application program interface of the device under test according to the information obtained in the active component element and the current test operation type, thereby improving the test efficiency.
实施例2Example 2
本实施例提供的自动化测试方法为在测试移动设备上的挑战应答型的动态令牌应用时的方法,如图2-1、图2-2和图2-3所示,包括:The automated testing method provided in this embodiment is a method for testing a challenge-response dynamic token application on a mobile device, as shown in Figure 2-1, Figure 2-2 and Figure 2-3, including:
步骤201:解析测试器得到解析结果,从解析结果中获取计算机的数据配置文件,从计算机的数据配置文件中获取目标设备序列号,并枚举出连接到计算机的所有设备的设备序列号;Step 201: The analysis tester obtains the analysis result, obtains the data configuration file of the computer from the analysis result, obtains the serial number of the target device from the data configuration file of the computer, and enumerates the device serial numbers of all devices connected to the computer;
本实施例中,测试器安装在计算机上。In this embodiment, the tester is installed on a computer.
步骤202:判断获取到的目标设备序列号是否为空,如果是,则将枚举到的第一个设备的设备序列号对应的设备作为当前被测设备,执行步骤205;否则,执行步骤203;Step 202: Determine whether the acquired target device serial number is empty, if yes, use the device corresponding to the device serial number of the first enumerated device as the current device under test, and execute step 205; otherwise, execute step 203 ;
步骤203:判断枚举到的所有设备的设备序列号中是否存在和目标设备序列号对应的设备序列号,如果是,则执行步骤204;否则,报错;Step 203: Determine whether there is a device serial number corresponding to the target device serial number among the device serial numbers of all the enumerated devices, if yes, perform step 204; otherwise, report an error;
步骤204:将目标设备序列号对应的设备作为当前被测设备,执行步骤205;Step 204: take the device corresponding to the serial number of the target device as the current device under test, and execute step 205;
步骤205:从解析结果中获取测试器中的第一测试操作,将第一测试操作作为当前测试操作,根据当前测试操作获取当前测试操作类型为文本点击操作、根据当前测试操作获取视图类型和关键信息;Step 205: Obtain the first test operation in the tester from the parsing result, use the first test operation as the current test operation, obtain the current test operation type as text click operation according to the current test operation, and obtain the view type and key according to the current test operation information;
具体地,从解析结果中获取测试器中的与第一测试操作对应的第一测试代码,将第一测试代码作为当前测试代码,判断当前测试代码类型,若当前测试代码为第一函数,则当前测试操作类型为文本点击操作,获取第一函数中第一参数和第二参数,将第一参数作为视图类型,将第二参数作为关键信息。Specifically, the first test code corresponding to the first test operation in the tester is obtained from the analysis result, and the first test code is used as the current test code to determine the type of the current test code. If the current test code is the first function, then The current test operation type is a text click operation, obtain the first parameter and the second parameter in the first function, use the first parameter as the view type, and use the second parameter as the key information.
例如:从解析结果中获取测试器中的与第一测试操作对应的第一测试代码,将第一测试代码作为当前测试代码,获取到当前测试代码为第一函数“Then press text"挑战应答型"{…..view_class="android.widget.TextView"…..},则当前测试操作类型为文本点击操作,将第一参数view_class="android.widget.TextView"作为视图类型,将第二参数“text"挑战应答型"”作为关键信息。For example: obtain the first test code corresponding to the first test operation in the tester from the parsing result, use the first test code as the current test code, and obtain the current test code as the first function "Then press text" challenge-response type "{.....view_class="android.widget.TextView".....}, the current test operation type is text click operation, the first parameter view_class="android.widget.TextView" is the view type, and the second parameter "text"challenge-response"" as key information.
步骤206:在被测设备上生成与当前被测应用的当前页面对应的当前活动组件元素集合文件;Step 206: Generate a current active component element set file corresponding to the current page of the current application under test on the device under test;
本步骤中,当前页面为当前被测应用的选择动态口令类型的页面,可以但不限于如图3所示。In this step, the current page is the page for selecting the dynamic password type of the current application under test, which may be, but not limited to, as shown in FIG. 3 .
具体地,根据被测设备的设备序列号androiddevsn组织第一生成命令<adb-sandroiddevsn shell uiautomator dump>发送给被测设备的操作系统,判断是否接收到来自被测设备的操作系统的生成失败应答,如果是,则判断没有在被测设备上生成与当前被测应用的当前页面对应的活动组件元素集合文件,报错结束;否则,判断在被测设备上成功生成与当前被测应用的当前页面对应的活动组件元素集合文件,执行步骤207;Specifically, according to the device serial number androiddevsn of the device under test, the first generation command <adb-sandroiddevsn shell uiautomator dump> is sent to the operating system of the device under test to determine whether a generation failure response from the operating system of the device under test has been received, If so, it is judged that the active component element set file corresponding to the current page of the current application under test has not been generated on the device under test, and the error report ends; otherwise, it is judged that the file corresponding to the current page of the current application under test has been successfully generated on the device under test The active component element set file, execute step 207;
步骤207:将当前活动组件元素集合文件转移到计算机上;Step 207: Transfer the current active component element set file to the computer;
具体地,根据被测设备的设备序列号androiddevsn组织第一转移命令<adb-sandroiddevsn shell pull>发送给被测设备的操作系统,将当前活动组件元素集合文件“window_dump1.xml”转移到计算机上。Specifically, according to the device serial number androiddevsn of the device under test, the first transfer command <adb-sandroiddevsn shell pull> is sent to the operating system of the device under test, and the current active component element set file "window_dump1.xml" is transferred to the computer.
更加具体地,根据被测设备的设备序列号androiddevsn组织第一转移命令<adb-sandroiddevsn shell pull>发送给被测设备的操作系统,之后,还包括:判断是否接收到来自被测设备的操作系统的转移失败应答,如果是,则判断出没有将活动组件元素集合文件成功转移到计算机上,报错结束;否则,判断出将活动组件元素集合文件成功转移到计算机上,执行步骤208。More specifically, according to the device serial number androiddevsn of the device under test, the first transfer command <adb-sandroiddevsn shell pull> is sent to the operating system of the device under test. If yes, it is judged that the active component element set file has not been successfully transferred to the computer, and an error is reported; otherwise, it is determined that the active component element set file has been successfully transferred to the computer, and step 208 is executed.
本实施例中,当前活动组件元素集合文件“window_dump1.xml”中包含当前页面的多个活动组件元素,每个活动组件元素中包括多个元素属性,元素属性可以具体为:元素索引、元素文本、元素类型和元素坐标等信息;例如: 当前活动组件元素集合文件“window_dump1.xml”为:In this embodiment, the current active component element collection file "window_dump1.xml" contains multiple active component elements of the current page, and each active component element includes multiple element attributes, and the element attributes can be specifically: element index, element text , element type, element coordinates and other information; for example: The current active component element collection file "window_dump1.xml" is:
其中,<node index="0"text="挑战应答型"resource-id=""class="android.widget.TextView"package="com.ftsafe.otp.activity"content-desc=""checkable="false"checked="false"clickable="false"enabled="true"focusable="false"focused="false"scrollable="false"long-clickable="false"password="false"selected="false"bounds="[105,569][330,630]"/>为一个活动组件元素,node中的class为活动组件元素的元素类型、text为活动组件元素的元素文本、index为活动组件元素的元素索引,bounds为活动组件元素的元素坐标。Among them, <node index="0"text="Challenge-response"resource-id=""class="android.widget.TextView"package="com.ftsafe.otp.activity"content-desc=""checkable=" "false" checked="false" clickable="false" enabled="true" focusable="false" focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[105,569][330,630]"/> is an active component element, class in node is the element type of the active component element, text is the element text of the active component element, index is the element index of the active component element, bounds is The element coordinates of the active component element.
步骤208:根据视图类型和关键信息在活动组件元素集合文件中获取与视图类型和关键信息匹配的活动组件元素;若未获取到,则当前测试失败,报错;若获取到,则执行步骤209;Step 208: Obtain the active component element matching the view type and key information in the active component element collection file according to the view type and key information; if not obtained, the current test fails and an error is reported; if obtained, execute step 209;
其中,关键信息中包括关键信息标识和关键信息值。Wherein, the key information includes a key information identifier and a key information value.
具体地,根据视图类型和关键信息标识和关键信息值在活动组件元素集合文件中查找元素属性中的元素类型与视图类型匹配且元素属性为关键信息标识,元素属性值为关键信息值的活动组件元素,若查找到,则判断出在活动组件元素集合文件中查找与视图类型和关键信息匹配的活动组件元素,执行步骤209;否则,判断出在活动组件元素集合文件中没有查找与视图类型和关键信息匹配的活动组件元素,当前测试失败,报错;Specifically, according to the view type, the key information identifier and the key information value, look for the active component whose element type in the element attribute matches the view type and whose element attribute is the key information identifier, and whose element attribute value is the key information value in the active component element collection file element, if it is found, it is judged that the active component element matching the view type and key information is searched in the active component element collection file, and step 209 is performed; otherwise, it is judged that there is no active component element matching the view type and Active component elements that match the key information, the current test fails, and an error is reported;
例如:根据预设的视图类型“TextView”和关键信息标识text和关键信息值“挑战应答型”在活动组件元素集合文件“window_dump1.xml”中查找到元素类型class"=android.widget.TextView"为与视图类型TextView匹配且元素属性为关键信息标识text的元素属性值为“挑战应答型”的活动组件元素<node index="0"text="挑战应答型"resource-id=""class="android.widget.TextView"package="com.ftsafe.otp.activity"content-desc=""checkable="false"checked="false"clickable="false"enabled="true"focusable="false"focused="false"scrollable="false"long-clickable="false"password="false"selected="false"bounds="[105,569][330,630]"/>,执行步骤209;For example: according to the preset view type "TextView", the key information identifier text and the key information value "challenge-response type", the element type class "=android.widget.TextView" is found in the activity component element collection file "window_dump1.xml". An activity component element that matches the view type TextView and whose element attribute is the key information identifier text. The element attribute value is "challenge-response type"<node index="0"text="challenge-response"resource-id=""class=" "android.widget.TextView"package="com.ftsafe.otp.activity"content-desc=""checkable="false"checked="false"clickable="false"enabled="true"focusable="false"focused ="false"scrollable="false"long-clickable="false"password="false"selected="false"bounds="[105,569][330,630]"/>, execute step 209;
步骤208中根据视图类型和关键信息在活动组件元素集合文件中获取与视图类型和关键信息匹配的活动组件元素之后,还可以包括:保存获取结果;相应地,After obtaining the active component elements matching the view type and key information in the active component element set file according to the view type and key information in step 208, it may also include: saving the obtained result; correspondingly,
若步骤208中若未获取到与视图类型和关键信息匹配的活动组件元素,还包括:根据已保存的所有获取结果得到测试报告。例如,已保存的没有获取到元素类型class"=android.widget.TextView"为与视图类型TextView匹配且元素属性为关键信息标识text的元素属性值为“挑战应答型”的活动组件元素;组织包括匹配失败信息的测试报告。If no active component element matching the view type and key information is obtained in step 208, the method further includes: obtaining a test report according to all obtained obtained results. For example, the saved active component element whose element type class "=android.widget.TextView" matches the view type TextView and whose element attribute is the key information identifier text has an attribute value of "challenge-response type" has not been obtained; the organization includes Test report with matching failure information.
步骤209:获取与视图类型和关键信息匹配的活动组件元素的元素坐标信息;Step 209: Obtain the element coordinate information of the active component element matching the view type and key information;
例如:获取与视图类型“TextView”和关键信息“挑战应答型”匹配的活动组件元素<node index="0"text="挑战应答型"resource-id=""class="android.widget.TextView"package="com.ftsafe.otp.activity"content-desc=""checkable="false"checked="false"clickable="false"enabled="true"focusable="false"focused="false"scrollable="false"long-clickable="false"password="false"selected="false"bounds="[105,569][330,630]"/>的元素坐标信息:bounds="[105,569][330,630]。For example: Get the active component element matching the view type "TextView" and the key information "challenge-response"<node index="0"text="challenge-response"resource-id=""class="android.widget.TextView "package="com.ftsafe.otp.activity"content-desc=""checkable="false"checked="false"clickable="false"enabled="true"focusable="false"focused="false"scrollable="false"scrollable="false" "false"long-clickable="false"password="false"selected="false"bounds="[105,569][330,630]"/> element coordinate information: bounds="[105,569][330,630].
步骤210:根据与视图类型和关键信息匹配的活动组件元素的元素坐标信息计算第一焦点位置;Step 210: Calculate the first focus position according to the element coordinate information of the active component element matching the view type and key information;
具体地,根据第一算法对与视图类型和关键信息匹配的活动组件元素的元素坐标信息进行计算得到第一焦点位置。Specifically, the element coordinate information of the active component element matching the view type and key information is calculated according to the first algorithm to obtain the first focus position.
例如,根据第一算法对与视图类型和关键信息匹配的活动组件元素的元素坐标信息进行计算得到元素坐标信息的中心点坐标位置,并将元素坐标信息的中心点坐标位置作为第一焦点位置。For example, the element coordinate information of the active component element matching the view type and key information is calculated according to the first algorithm to obtain the center point coordinate position of the element coordinate information, and the center point coordinate position of the element coordinate information is used as the first focus position.
步骤211:在第一焦点位置上点击当前页面上的待点击区域。Step 211: Click the area to be clicked on the current page at the first focus position.
具体地,根据第一焦点位置组织第一点击命令,将第一点击命令发送给被测设备点击当前页面上的待点击区域。Specifically, the first click command is organized according to the first focus position, and the first click command is sent to the device under test to click the area to be clicked on the current page.
更加具体地,根据第一焦点位置的坐标positionX positionY组织点击命令<adb-s androiddevsn shell input tap positionX positionY>,将第一点击命令发送给被测设备的操作系统,被测设备的操作系统接收到第一点击命令后,根据点击命令中的第一焦点位置点击当前页面上的待点击区域。More specifically, organize the click command <adb-s androiddevsn shell input tap positionX positionY> according to the coordinates positionX positionY of the first focus position, and send the first click command to the operating system of the device under test, and the operating system of the device under test receives After the first click command, click the area to be clicked on the current page according to the first focus position in the click command.
例如,当被测设备的当前被测应用检测到当前页面的“挑战应答型”的活动组件元素的点击操作时,当前被测应用跳转到如图4所示的等待输入挑战值的页面,等待输入挑战值;For example, when the current application under test of the device under test detects the click operation of the "challenge-response" active component element of the current page, the current application under test jumps to the page waiting for the input of the challenge value as shown in Figure 4, Waiting for the challenge value to be entered;
步骤211之后,还包括:根据解析结果判断当前测试操作是否为测试器中的最后一个测试操作,如果是,则结束;否则,将测试器中的当前测试操作的下一个测试操作作为当前测试操作,执行步骤212。After step 211, it also includes: judging whether the current test operation is the last test operation in the tester according to the parsing result, if yes, then ending; otherwise, using the next test operation of the current test operation in the tester as the current test operation , go to step 212.
步骤212:从解析结果中获取测试器中的第二测试操作,将第二测试操作作为当前测试操作,根据当前测试操作获取当前测试操作类型为输入操作,根据当前测试操作获取视图类型、关键信息和当前文本信息;Step 212: Obtain the second test operation in the tester from the analysis result, use the second test operation as the current test operation, obtain the current test operation type as the input operation according to the current test operation, and obtain the view type and key information according to the current test operation and current text information;
具体地,从解析结果中获取测试器中的与第二测试操作对应的第二测试代码并请其作为当前测试代码,若当前测试代码为第二函数,则当前测试操作类型为输入操作,获取第二函数中第三参数、第四参数和第九参数,将第三参数作为视图类型,将第四参数作为关键信息,将第九参数作为文本内容。Specifically, obtain the second test code corresponding to the second test operation in the tester from the parsing result and use it as the current test code, if the current test code is the second function, then the current test operation type is an input operation, and obtain In the third parameter, the fourth parameter and the ninth parameter in the second function, the third parameter is used as the view type, the fourth parameter is used as the key information, and the ninth parameter is used as the text content.
例如:从解析结果中获取测试器中的与第二测试操作对应的第二测试代码并请其作为当前测试代码,获取到当前测试代码为第二函数“Then enter"123456"into editextwith index 0For example: Obtain the second test code corresponding to the second test operation in the tester from the parsing result and use it as the current test code, and the current test code obtained is the second function "Then enter"123456"into editextwith index 0
"{…..view_class="android.widget.EditText"….."{…..view_class="android.widget.EditText"…..
}则当前测试操作类型为输入操作,将第三参数view_class="android.widget.EditText"作为视图类型,将第四参数“index 0”作为关键信息,将第九参数"123456"作为文本内容。} Then the current test operation type is an input operation, the third parameter view_class="android.widget.EditText" is used as the view type, the fourth parameter "index 0" is used as the key information, and the ninth parameter "123456" is used as the text content.
步骤213:当前被测应用跳转到等待输入挑战值的当前页面后,在被测设备上生成与当前被测应用显示的当前页面对应的当前活动组件元素集合文件;Step 213: After the current application under test jumps to the current page waiting for input of the challenge value, generate a current active component element set file corresponding to the current page displayed by the current application under test on the device under test;
本步骤中,等待输入挑战值的当面页面可以但不限于如图4所示。In this step, the face-to-face page waiting for input of the challenge value may be, but not limited to, as shown in FIG. 4 .
具体地,根据被测设备的设备序列号androiddevsn组织第一生成命令<adb-sandroiddevsn shell uiautomator dump>发给被测设备的操作系统,在被测设备上生成与当前被测应用的当前页面对应的当前活动组件元素集合文件。Specifically, according to the device serial number androiddevsn of the device under test, the first generation command <adb-sandroiddevsn shell uiautomator dump> is sent to the operating system of the device under test, and the corresponding to the current page of the current application under test is generated on the device under test. The currently active component element collection file.
更加具体地,根据被测设备的设备序列号androiddevsn组织第一生成命令<adb-sandroiddevsn shell uiautomator dump>发送给被测设备的操作系统,判断是否接收到来自被测设备的操作系统的生成失败应答,如果是,则判断没有在被测设备上生成与当前被测应用的当前页面对应的活动组件元素集合文件,报错结束;否则,判断在被测设备上成功生成与当前被测应用的当前页面对应的活动组件元素集合文件。More specifically, according to the device serial number androiddevsn of the device under test, the first generation command <adb-sandroiddevsn shell uiautomator dump> is sent to the operating system of the device under test, and it is judged whether a generation failure response from the operating system of the device under test is received , if yes, it is judged that the active component element set file corresponding to the current page of the current application under test has not been generated on the device under test, and the error report ends; otherwise, it is judged that the current page of the current application under test is successfully generated on the device under test The corresponding activity component element collection file.
步骤214:将当前活动组件元素集合文件转移到计算机上;Step 214: Transfer the current active component element set file to the computer;
具体地,根据被测设备的设备序列号androiddevsn组织第一转移命令<adb-sandroiddevsn shell pull>发送给被测设备的操作系统,将当前活动组件元素集合文件“window_dump2.xml”转移到计算机上。Specifically, according to the device serial number androiddevsn of the device under test, the first transfer command <adb-sandroiddevsn shell pull> is sent to the operating system of the device under test, and the current active component element set file "window_dump2.xml" is transferred to the computer.
更加具体地,根据被测设备的设备序列号androiddevsn组织第一转移命令<adb-sandroiddevsn shell pull>发送给被测设备的操作系统,之后,还包括:判断是否接收到来自被测设备的操作系统的转移失败应答,如果是,则判断出没有将活动组件元素集合文件成功转移到计算机上,报错结束;否则,判断出将活动组件元素集合文件成功转移到计算机上。More specifically, according to the device serial number androiddevsn of the device under test, the first transfer command <adb-sandroiddevsn shell pull> is sent to the operating system of the device under test. If yes, it is determined that the active component element set file has not been successfully transferred to the computer, and an error is reported; otherwise, it is determined that the active component element set file has been successfully transferred to the computer.
本实施例中,当前活动组件元素集合文件“window_dump1.xml”中包含当前页面的多个活动组件元素,每个活动组件元素中包括多个元素属性,元素属性可以具体为:元素索引、元素文本、元素类型和元素坐标等信息。例如:当前活动组件元素集合文件“window_dump2.xml”为:In this embodiment, the current active component element collection file "window_dump1.xml" contains multiple active component elements of the current page, and each active component element includes multiple element attributes, and the element attributes can be specifically: element index, element text , element type and element coordinates and other information. For example: the current active component element collection file "window_dump2.xml" is:
其中,<node index="0"text="输入挑战值"Among them, <node index="0"text="Enter challenge value"
resource-id="com.ftsafe.otp.activity:id/challenge_code"resource-id="com.ftsafe.otp.activity:id/challenge_code"
class="android.widget.EditText"package="com.ftsafe.otp.activity"content-desc=""checkable="false"checked="false"clickable="true"enabled="true"focusable="true"focused="true"scrollable="false"long-clickable="true"password="false"class="android.widget.EditText"package="com.ftsafe.otp.activity"content-desc=""checkable="false"checked="false"clickable="true"enabled="true"focusable="true "focused="true" scrollable="false" long-clickable="true" password="false"
selected="false"bounds="[60,321][1020,427]"/>为一个活动组件元素,node中的class为活动组件元素的元素类型、text为活动组件元素的元素文本、index为活动组件元素的元素索引,bounds为活动组件元素的元素坐标。selected="false" bounds="[60,321][1020,427]"/> is an active component element, class in node is the element type of the active component element, text is the element text of the active component element, and index is the active component The element index of the element, and bounds is the element coordinates of the active component element.
步骤215:根据视图类型和关键信息在活动组件元素集合文件中获取与视图类型和关键信息匹配的活动组件元素;若未获取到,则当前测试失败,报错;若获取到,则执行步骤216;Step 215: Obtain the active component element matching the view type and key information in the active component element set file according to the view type and key information; if not obtained, the current test fails and an error is reported; if obtained, execute step 216;
其中,关键信息中包括关键信息标识和关键信息值。Wherein, the key information includes a key information identifier and a key information value.
具体地,根据预设的视图类型“EditText”和关键信息标识“index”和关键信息值“0”在活动组件元素集合文件中查找元素属性中的元素类型与视图类型匹配且元素属性为关键信息标识的元素属性值为关键信息值的活动组件元素,若查找到,判断出在活动组件元素集合文件中查找与视图类型和关键信息匹配的活动组件元素,执行步骤208;否则,判断出在活动组件元素集合文件中没有查找与视图类型和关键信息匹配的活动组件元素,当前测试失败,报错;Specifically, according to the preset view type "EditText", the key information identifier "index" and the key information value "0", the element type in the element attribute matches the view type and the element attribute is the key information in the element collection file of the active component. If an active component element whose identified element attribute value is a key information value is found, it is judged that the active component element matching the view type and key information is searched in the active component element collection file, and step 208 is performed; The active component element matching the view type and key information is not found in the component element collection file, the current test fails and an error is reported;
例如:根据预设的视图类型“EditText”和关键信息标识“index”和关键信息值“0”在活动组件元素集合文件“window_dump2.xml”中查找到元素类型class"=android.widget.EditText"为与视图类型EditText匹配且元素属性为关键信息标识index的元素属性值为“0”的活动组件元素<node index="0"text="输入挑战值"resource-id="com.ftsafe.otp.activity:id/challenge_code"class="android.widget.EditText"package="com.ftsafe.otp.activity"content-desc=""checkable="false"checked="false"clickable="true"enabled="true"focusable="true"focused="true"scrollable="false"long-clickable="true"password="false"selected="false"bounds="[60,321][1020,427]"/>,执行步骤216;For example: according to the preset view type "EditText", the key information identifier "index" and the key information value "0", the element type class "=android.widget.EditText" is found in the active component element collection file "window_dump2.xml" It is an active component element that matches the view type EditText and the element attribute is the key information identifier index. The element attribute value is "0". <node index="0"text="Enter challenge value" resource-id="com.ftsafe.otp .activity:id/challenge_code"class="android.widget.EditText"package="com.ftsafe.otp.activity"content-desc=""checkable="false"checked="false"clickable="true"enabled=" "true" focusable="true" focused="true" scrollable="false" long-clickable="true" password="false" selected="false" bounds="[60,321][1020,427]"/>, Execute step 216;
步骤215中根据视图类型和关键信息在活动组件元素集合文件中获取与视图类型和关键信息匹配的活动组件元素之后,还可以包括:保存获取结果;相应地,After obtaining the active component elements matching the view type and key information in the active component element set file according to the view type and key information in step 215, it may also include: saving the obtained result; correspondingly,
若步骤215中若未获取到与视图类型和关键信息匹配的活动组件元素,还包括:根据已保存的所有获取结果得到测试报告。If no active component element matching the view type and key information is obtained in step 215, the method further includes: obtaining a test report according to all obtained obtained results.
例如,根据步骤208中已保存的没有获取到元素类型class"=android.widget.TextView"为与视图类型TextView匹配且元素属性为关键信息标识text的元素属性值为“挑战应答型”的活动组件元素;和步骤215中已保存的没有获取到元素类型class"=android.widget.EditText"为与视图类型EditText匹配且元素属性为关键信息标识index的元素属性值为“0”的活动组件元素的信息,组织测试报告。For example, according to the saved element type class "=android.widget.TextView" in step 208, the active component whose element attribute value is "challenge-response type" is matched with the view type TextView and the element attribute is the key information identification text is not obtained. element; and the element type class "=android.widget.EditText" that has not been saved in step 215 matches the view type EditText and the element attribute value is "0" for the element attribute value of the key information identifier index Information, organization test report.
步骤216:获取与视图类型和关键信息匹配的活动组件元素的元素坐标信息;Step 216: Obtain the element coordinate information of the active component element matching the view type and key information;
例如:获取与视图类型“TextView”和关键信息“挑战应答型”匹配的活动组件元素<node index="0"text="输入挑战值"resource-id="com.ftsafe.otp.activity:id/challenge_code"class="android.widget.EditText"package="com.ftsafe.otp.activity"content-desc=""checkable="false"checked="false"clickable="true"enabled="true"focusable="true"focused="true"scrollable="false"long-clickable="true"password="false"selected="false"bounds="[60,321][1020,427]"/>的元素坐标信息:bounds="[60,321][1020,427]"。For example: get the activity component element matching the view type "TextView" and the key information "challenge-response type"<node index="0"text="input challenge value"resource-id="com.ftsafe.otp.activity:id /challenge_code"class="android.widget.EditText"package="com.ftsafe.otp.activity"content-desc=""checkable="false"checked="false"clickable="true"enabled="true"focusable ="true"focused="true"scrollable="false"long-clickable="true"password="false"selected="false"bounds="[60,321][1020,427]"/> element coordinate information: bounds="[60,321][1020,427]".
步骤217:根据与视图类型和关键信息匹配的活动组件元素的元素坐标信息计算第二焦点位置;Step 217: Calculate the second focus position according to the element coordinate information of the active component element matching the view type and key information;
具体地,根据第二算法对与视图类型和关键信息匹配的活动组件元素的元素坐标信息进行计算得到第二焦点位置。Specifically, the element coordinate information of the active component element matching the view type and key information is calculated according to the second algorithm to obtain the second focus position.
例如,根据第二算法对与视图类型和关键信息匹配的活动组件元素的元素坐标信息进行计算得到元素坐标信息的中心点坐标位置,并将元素坐标信息的中心点坐标位置作为第二焦点位置。For example, the element coordinate information of the active component element matching the view type and key information is calculated according to the second algorithm to obtain the center point coordinate position of the element coordinate information, and the center point coordinate position of the element coordinate information is used as the second focus position.
步骤218:判断与视图类型和关键信息匹配的活动组件元素的元素文本值是否为空,如果是,则执行步骤219;否则,清空与视图类型和关键信息匹配的活动组件元素的元素文本值,执行步骤219;Step 218: Determine whether the element text value of the active component element matching the view type and key information is empty, if yes, perform step 219; otherwise, clear the element text value of the active component element matching the view type and key information, Execute step 219;
步骤219:根据第二焦点位置将文本内容输入到当前页面的文本输入区域;Step 219: Input text content into the text input area of the current page according to the second focus position;
步骤219具体包括:Step 219 specifically includes:
步骤219-1:根据焦点位置组织第二点击命令,将第二点击命令发送给被测设备点击当前页面上的文本输入区域;Step 219-1: Organize the second click command according to the focus position, and send the second click command to the device under test to click the text input area on the current page;
具体地,根据第二焦点位置的坐标positionX positionY组织点击命令<adb-sandroiddevsn shell input tap positionX positionY>,将点击命令发送给被测设备的操作系统,被测设备的操作系统接收到第二点击命令后,根据第二点击命令中的第二焦点位置点击当前页面上的待点击区域。Specifically, organize the click command <adb-sandroiddevsn shell input tap positionX positionY> according to the coordinate positionX positionY of the second focus position, and send the click command to the operating system of the device under test, and the operating system of the device under test receives the second click command After that, click the area to be clicked on the current page according to the second focus position in the second click command.
步骤219-2:组织包括文本内容的第一文本输入命令,将第一文本输入命令发送给被测设备将文本内容输入到当前页面上的文本输入区域中。Step 219-2: Organize the first text input command including the text content, and send the first text input command to the device under test to input the text content into the text input area on the current page.
具体地,组织包括文本内容content的第一文本输入命令<adb-s androiddevsnshell input text content>,将第一文本输入命令发送给被测设备的操作系统,被测设备的操作系统接收到第一文本输入命令后,将第一文本输入命令中的文本内容本输入到当前页面上的文本输入区域中。Specifically, organize the first text input command <adb-s androiddevsnshell input text content> including the text content, send the first text input command to the operating system of the device under test, and the operating system of the device under test receives the first text After the command is input, the text content in the first text input command is input into the text input area on the current page.
例如:根据第二焦点位置将文本内容123456输入到当前页面的文本输入区域。For example: input text content 123456 into the text input area of the current page according to the second focus position.
本实施例中,文本内容还可以是生成的。In this embodiment, the text content may also be generated.
本实施例中,输入挑战值“123456”之后的等待输入挑战值的当面页面可以但不限于如图5所示。In this embodiment, after entering the challenge value "123456", the face-to-face page waiting for the input of the challenge value may be, but not limited to, as shown in FIG. 5 .
步骤219之后,还包括:根据解析结果判断当前测试操作是否为测试器中的最后一个测试操作,如果是,则结束;否则,将测试器中的当前测试操作的下一个测试操作作为当前测试操作,执行步骤220。After step 219, it also includes: judging whether the current test operation is the last test operation in the tester according to the parsing result, if yes, then ending; otherwise, using the next test operation of the current test operation in the tester as the current test operation , go to step 220.
步骤220:从解析结果中获取测试器中的第三测试操作,将第三测试操作作为当前测试操作,根据当前测试操作获取当前测试操作类型为按钮点击操作,根据当前测试操作获取视图类型和关键信息;Step 220: Obtain the third test operation in the tester from the analysis result, use the third test operation as the current test operation, obtain the current test operation type as button click operation according to the current test operation, and obtain the view type and key according to the current test operation information;
具体地,从解析结果中获取测试器中与第三测试操作对应的第三测试代码并请其作为当前测试代码,若当前测试代码为第四函数,则当前测试操作类型为按钮点击操作,获取第四函数中第七参数和第八参数,将第七参数作为视图类型,将第八参数作为关键信息。Specifically, obtain the third test code corresponding to the third test operation in the tester from the parsing result and use it as the current test code, if the current test code is the fourth function, then the current test operation type is a button click operation, and obtain For the seventh parameter and the eighth parameter in the fourth function, the seventh parameter is used as the view type, and the eighth parameter is used as the key information.
例如:从解析结果中获取测试器中与第三测试操作对应的第三测试代码并请其作为当前测试代码,,获取到当前测试代码为第四函数“Then press button with index 1"For example: obtain the third test code corresponding to the third test operation in the tester from the analysis result and use it as the current test code, and obtain the current test code as the fourth function "Then press button with index 1"
{…..view_class="android.widget.Button"…..{…..view_class="android.widget.Button"…..
},则当前测试操作类型为按键点击操作,将第七参数view_class="android.widget. Button "作为视图类型,将第八参数“index1”作为关键信息。}, the current test operation type is a button click operation, the seventh parameter view_class="android.widget.Button" is used as the view type, and the eighth parameter "index1" is used as the key information.
步骤221:在被测设备上生成与当前被测应用的当前页面对应的当前活动组件元素集合文件;Step 221: Generate a current active component element set file corresponding to the current page of the current application under test on the device under test;
具体地,根据被测设备的设备序列号androiddevsn组织第一生成命令<adb -sandroiddevsn shell uiautomator dump>发给被测设备的操作系统,在被测设备上生成与当前被测应用的当前页面对应的当前活动组件元素集合文件。Specifically, according to the device serial number androiddevsn of the device under test, the first generated command <adb -sandroiddevsn shell uiautomator dump> is sent to the operating system of the device under test, and a corresponding to the current page of the current application under test is generated on the device under test. The currently active component element collection file.
步骤222:将当前活动组件元素集合文件转移到计算机上;Step 222: transferring the current active component element set file to the computer;
具体地,根据被测设备的设备序列号androiddevsn组织第一转移命令<adb -sandroiddevsn shell pull>发给被测设备的操作系统,将当前活动组件元素集合文件“window_dump3.xml”转移到计算机上。Specifically, according to the device serial number androiddevsn of the device under test, the first transfer command <adb -sandroiddevsn shell pull> is sent to the operating system of the device under test, and the current active component element set file "window_dump3.xml" is transferred to the computer.
具体地,根据被测设备的设备序列号androiddevsn组织第一生成命令<adb -sandroiddevsn shell uiautomator dump>发送给被测设备的操作系统,判断是否接收到来自被测设备的操作系统的生成失败应答,如果是,则判断没有在被测设备上生成与当前被测应用的当前页面对应的活动组件元素集合文件,报错结束;否则,判断在被测设备上成功生成与当前被测应用的当前页面对应的活动组件元素集合文件。Specifically, according to the device serial number androiddevsn of the device under test, the first generation command <adb -sandroiddevsn shell uiautomator dump> is sent to the operating system of the device under test to determine whether a generation failure response from the operating system of the device under test has been received, If so, it is judged that the active component element set file corresponding to the current page of the current application under test has not been generated on the device under test, and the error report ends; otherwise, it is judged that the file corresponding to the current page of the current application under test has been successfully generated on the device under test The active component element collection file.
本实施例中,当前活动组件元素集合文件“window_dump3.xml”中包含当前页面的多个活动组件元素,每个活动组件元素中包括多个元素属性,元素属性可以具体为:元素索引、元素文本、元素类型和元素坐标等信息;例如: 当前活动组件元素集合文件“window_dump3.xml”为:In this embodiment, the current active component element collection file "window_dump3.xml" contains multiple active component elements of the current page, and each active component element includes multiple element attributes, and the element attributes can be specifically: element index, element text , element type, element coordinates and other information; for example: The current active component element collection file "window_dump3.xml" is:
其中,node index="1"text="确定"resource-id=""class="android.widget.Button"package="com.ftsafe.otp.activity"content-desc=""checkable="false"checked="false"clickable="true"enabled="true"focusable="true"focused="false"scrollable="false"long-clickable="false"password="false"selected="false"bounds="[375,472][705,616]"/>为一个活动组件元素,node中的class为活动组件元素的元素类型、text为活动组件元素的元素文本、index为活动组件元素的元素索引,bounds为活动组件元素的元素坐标范围。Among them, node index="1"text="OK"resource-id=""class="android.widget.Button"package="com.ftsafe.otp.activity"content-desc=""checkable="false" checked="false"clickable="true"enabled="true"focusable="true"focused="false"scrollable="false"long-clickable="false"password="false"selected="false"bounds="false"bounds="false" [375,472][705,616]"/> is an active component element, class in node is the element type of the active component element, text is the element text of the active component element, index is the element index of the active component element, bounds is the active component element The element coordinate range of .
步骤223:根据视图类型和关键信息在活动组件元素集合文件中获取与视图类型和关键信息匹配的活动组件元素;若未获取到,则当前测试失败,报错;若获取到,则执行步骤224;Step 223: Obtain the active component element matching the view type and key information in the active component element collection file according to the view type and key information; if not obtained, the current test fails and an error is reported; if obtained, execute step 224;
其中,关键信息中包括关键信息标识和关键信息值。Wherein, the key information includes a key information identifier and a key information value.
具体地,根据预设的视图类型“Button”和关键信息标识“index”和关键信息值“1”在活动组件元素集合文件中查找元素属性中的元素类型与视图类型匹配且元素属性为关键信息标识的元素属性值为关键信息值的活动组件元素,若查找到,判断出在活动组件元素集合文件中查找与视图类型和关键信息匹配的活动组件元素,执行步骤223;否则,判断出在活动组件元素集合文件中没有查找与视图类型和关键信息匹配的活动组件元素,当前测试失败,报错;Specifically, according to the preset view type "Button", the key information identifier "index" and the key information value "1", the element type in the element attribute matches the view type and the element attribute is the key information in the element collection file of the active component. If the identified element attribute value is an active component element with a key information value, if it is found, it is determined that the active component element matching the view type and key information is found in the active component element collection file, and step 223 is performed; The active component element matching the view type and key information is not found in the component element collection file, the current test fails and an error is reported;
例如:根据预设的视图类型“Button”和关键信息标识“index”和关键信息值“0”在活动组件元素集合文件“window_dump3.xml”中查找到元素类型class"=android.widget.Button"为与视图类型Button匹配且元素属性为关键信息标识index的元素属性值为“1”的活动组件元素<node index="1"text="确定"resource-id=""class="android.widget.Button"package="com.ftsafe.otp.activity"content-desc=""checkable="false"checked="false"clickable="true"enabled="true"focusable="true"focused="false"scrollable="false"long-clickable="false"password="false"selected="false"bounds="[375,472][705,616]"/>,执行步骤224;For example: according to the preset view type "Button", the key information identifier "index" and the key information value "0", the element type class "=android.widget.Button" is found in the active component element collection file "window_dump3.xml". It is an active component element that matches the view type Button and whose element attribute is the key information identifier index. The element attribute value is "1". .Button"package="com.ftsafe.otp.activity"content-desc=""checkable="false"checked="false"clickable="true"enabled="true"focusable="true"focused="false" scrollable="false" long-clickable="false" password="false" selected="false" bounds="[375,472][705,616]"/>, execute step 224;
步骤223中根据视图类型和关键信息在活动组件元素集合文件中获取与视图类型和关键信息匹配的活动组件元素之后,还可以包括:保存获取结果;相应地,After obtaining the active component elements matching the view type and key information in the active component element set file according to the view type and key information in step 223, it may also include: saving the obtained result; correspondingly,
若步骤223中若未获取到与视图类型和关键信息匹配的活动组件元素,还包括:根据已保存的所有获取结果得到测试报告。If no active component element matching the view type and key information is obtained in step 223, the method further includes: obtaining a test report according to all obtained obtained results.
例如,根据步骤208中已保存的没有获取到元素类型class"=android.widget.TextView"为与视图类型TextView匹配且元素属性为关键信息标识text的元素属性值为“挑战应答型”的活动组件元素;和步骤215中已保存的获取到元素类型class"=android.widget.EditText"为与视图类型EditText匹配且元素属性为关键信息标识index的元素属性值为“0”的活动组件元素以及步骤223中已保存的没有获取到元素类型class"=android.widget.Button"为与视图类型Button匹配且元素属性为关键信息标识index的元素属性值为“1”的活动组件元素的信息,组织测试报告。For example, according to the saved element type class "=android.widget.TextView" in step 208, the active component whose element attribute value is "challenge-response type" is matched with the view type TextView and the element attribute is the key information identification text is not obtained. element; and the obtained element type class "=android.widget.EditText" that has been saved in step 215 is an active component element that matches the view type EditText and the element attribute is the element attribute value "0" of the key information identification index and steps In 223, the saved information of the active component element whose element type class "=android.widget.Button" matches the view type Button and whose element attribute is the key information identification index is "1" has not been obtained, organize the test Report.
步骤224:获取与视图类型和关键信息匹配的活动组件元素的元素坐标信息;Step 224: Obtain the element coordinate information of the active component element matching the view type and key information;
例如:获取与视图类型“TextView”和关键信息“挑战应答型”匹配的活动组件元素<node index="0"text="挑战应答型"resource-id=""class="android.widget.TextView"package="com.ftsafe.otp.activity"content-desc=""checkable="false"checked="false"clickable="false"enabled="true"focusable="false"focused="false"scrollable="false"long-clickable="false"password="false"selected="false"bounds="[105,569][330,630]"/>的元素坐标信息:bounds="[105,569][330,630]。For example: Get the active component element matching the view type "TextView" and the key information "challenge-response"<node index="0"text="challenge-response"resource-id=""class="android.widget.TextView "package="com.ftsafe.otp.activity"content-desc=""checkable="false"checked="false"clickable="false"enabled="true"focusable="false"focused="false"scrollable="false"scrollable="false" "false"long-clickable="false"password="false"selected="false"bounds="[105,569][330,630]"/> element coordinate information: bounds="[105,569][330,630].
步骤225:根据与视图类型和关键信息匹配的活动组件元素的元素坐标信息计算第三焦点位置;Step 225: Calculate the third focus position according to the element coordinate information of the active component element matching the view type and key information;
具体地,根据第三算法对与视图类型和关键信息匹配的活动组件元素的元素坐标信息进行计算得到第三焦点位置。Specifically, the element coordinate information of the active component element matching the view type and key information is calculated according to the third algorithm to obtain the third focus position.
例如,根据第三算法对与视图类型和关键信息匹配的活动组件元素的元素坐标信息进行计算得到元素坐标信息的中心点坐标位置,并将元素坐标信息的中心点坐标位置作为第三焦点位置。For example, the element coordinate information of the active component element matching the view type and key information is calculated according to the third algorithm to obtain the center point coordinate position of the element coordinate information, and the center point coordinate position of the element coordinate information is used as the third focus position.
步骤226:根据在第三焦点位置上点击当前页面上的待点击区域。Step 226: According to clicking on the area to be clicked on the current page at the third focus position.
具体地,根据第三焦点位置组织第三点击命令,将第三点击命令发送给被测设备点击当前页面上的待点击区域。Specifically, the third click command is organized according to the third focus position, and the third click command is sent to the device under test to click the area to be clicked on the current page.
更加具体地,根据第三焦点位置的坐标positionX positionY组织点击命令<adb-s androiddevsn shell input tap positionX positionY>,将第三点击命令发送给被测设备的操作系统,被测设备的操作系统接收到第三点击命令后,根据点击命令中的第三焦点位置点击当前页面上的待点击区域。More specifically, organize the click command <adb-s androiddevsn shell input tap positionX positionY> according to the coordinate positionX positionY of the third focus position, and send the third click command to the operating system of the device under test, and the operating system of the device under test receives After the third click command, click the area to be clicked on the current page according to the third focus position in the click command.
例如:当被测设备的当前被测应用检测到当前页面的“确定”的活动组件元素的点击操作时,当前被测应用跳转到下一页面;即跳转到显示动态口令的当前页面,本实施例中,显示动态口令的当前页面可以但不限于如图6所示。For example: when the current application under test of the device under test detects the click operation of the "OK" active component element of the current page, the current application under test jumps to the next page; that is, jumps to the current page displaying the dynamic password, In this embodiment, the current page displaying the dynamic password may be, but not limited to, as shown in FIG. 6 .
步骤226之后,还包括:根据解析结果判断当前测试操作是否为测试器中的最后一个测试操作,如果是,则结束;否则,将测试器中的当前测试操作的下一个测试操作作为当前测试操作,执行步骤227。After step 226, also include: judging whether the current test operation is the last test operation in the tester according to the parsing result, if yes, then end; otherwise, using the next test operation of the current test operation in the tester as the current test operation , go to step 227.
步骤227:从解析结果中获取测试器中的第四测试操作,将第四测试操作作为当前测试操作,根据当前测试操作获取当前测试操作类型为断言操作,根据当前测试操作获取视图类型和关键信息;Step 227: Obtain the fourth test operation in the tester from the analysis result, use the fourth test operation as the current test operation, obtain the current test operation type as an assertion operation according to the current test operation, and obtain the view type and key information according to the current test operation ;
具体地,从解析结果中获取与第四测试操作对应的第四测试代码并将其作为当前测试代码,若当前测试代码为第三函数,则当前测试操作类型为断言操作,获取第三函数中第五参数和第六参数,将第五参数作为视图类型,将第六参数作为关键信息。Specifically, the fourth test code corresponding to the fourth test operation is obtained from the parsing result and used as the current test code. If the current test code is the third function, the current test operation type is an assertion operation. The fifth parameter and the sixth parameter, the fifth parameter is used as the view type, and the sixth parameter is used as the key information.
例如:从解析结果中获取与第四测试操作对应的第四测试代码并将其作为当前测试代码,获取到当前测试代码为第四函数“Then assert see text"103243""{…..view_class="android.widget.TextViewFor example: Obtain the fourth test code corresponding to the fourth test operation from the analysis result and use it as the current test code, and the obtained current test code is the fourth function "Then assert see text "103243""{.....view_class= "android.widget.TextView
….. …
}}
则当前测试操作类型为断言操作,将第五参数view_class="android.widget.TextView"作为视图类型,将第六参数text"103243"作为关键信息。Then the current test operation type is an assertion operation, the fifth parameter view_class="android.widget.TextView" is used as the view type, and the sixth parameter text "103243" is used as the key information.
步骤228:当当前被测应用跳转到显示动态口令的当前页面时,在被测设备上生成与当前被测应用的当前页面对应的当前活动组件元素集合文件;Step 228: When the current application under test jumps to the current page displaying the dynamic password, generate a current active component element set file corresponding to the current page of the current application under test on the device under test;
具体地,根据被测设备的设备序列号androiddevsn组织第一生成命令<adb-sandroiddevsn shell uiautomator dump>发给被测设备的操作系统,在被测设备上生成与当前被测应用的当前页面对应的当前活动组件元素集合文件。Specifically, according to the device serial number androiddevsn of the device under test, the first generation command <adb-sandroiddevsn shell uiautomator dump> is sent to the operating system of the device under test, and the corresponding to the current page of the current application under test is generated on the device under test. The currently active component element collection file.
更加具体地,根据被测设备的设备序列号androiddevsn组织第一生成命令<adb-sandroiddevsn shell uiautomator dump>发送给被测设备的操作系统,判断是否接收到来自被测设备的操作系统的生成失败应答,如果是,则判断没有在被测设备上生成与当前被测应用的当前页面对应的活动组件元素集合文件,报错结束;否则,判断在被测设备上成功生成与当前被测应用的当前页面对应的活动组件元素集合文件。More specifically, according to the device serial number androiddevsn of the device under test, the first generation command <adb-sandroiddevsn shell uiautomator dump> is sent to the operating system of the device under test, and it is judged whether a generation failure response from the operating system of the device under test is received , if yes, it is judged that the active component element set file corresponding to the current page of the current application under test has not been generated on the device under test, and the error report ends; otherwise, it is judged that the current page of the current application under test is successfully generated on the device under test The corresponding activity component element collection file.
步骤229:将当前活动组件元素集合文件转移到计算机上;Step 229: Transfer the current active component element set file to the computer;
具体地,根据被测设备的设备序列号androiddevsn组织第一转移命令<adb-sandroiddevsn shell pull>发给被测设备的操作系统,将当前活动组件元素集合文件“window_dump4.xml”转移到计算机上。Specifically, according to the device serial number androiddevsn of the device under test, the first transfer command <adb-sandroiddevsn shell pull> is sent to the operating system of the device under test, and the current active component element set file "window_dump4.xml" is transferred to the computer.
更加具体地,根据被测设备的设备序列号androiddevsn组织第一转移命令<adb-sandroiddevsn shell pull>发送给被测设备的操作系统,之后,还包括:判断是否接收到来自被测设备的操作系统的转移失败应答,如果是,则判断出没有将活动组件元素集合文件成功转移到计算机上,报错结束;否则,判断出将活动组件元素集合文件成功转移到计算机上。More specifically, according to the device serial number androiddevsn of the device under test, the first transfer command <adb-sandroiddevsn shell pull> is sent to the operating system of the device under test. If yes, it is determined that the active component element set file has not been successfully transferred to the computer, and an error is reported; otherwise, it is determined that the active component element set file has been successfully transferred to the computer.
本实施例中,当前活动组件元素集合文件“window_dump4.xml”中包含当前页面的多个活动组件元素,每个活动组件元素中包括多个元素属性,元素属性可以具体为:元素索引、元素文本、元素类型和元素坐标等信息;例如: 当前活动组件元素集合文件“window_dump4.xml”为:In this embodiment, the current active component element collection file "window_dump4.xml" contains multiple active component elements of the current page, and each active component element includes multiple element attributes, and the element attributes can be specifically: element index, element text , element type, element coordinates and other information; for example: The element set file "window_dump4.xml" of the current active component is:
其中,<node index="0"text="请输入以下口令进行认证:"resource-id=""class="android.widget.TextView"package="com.ftsafe.otp.activity"content-desc=""checkable="false"checked="false"clickable="false"enabled="true"focusable="false"focused="false"scrollable="false"long-clickable="false"password="false"selected="false"bounds="[60,321][672,389]"/>为一个活动组件元素,node中的class为活动组件元素的元素类型、text为活动组件元素的元素文本、index为活动组件元素的元素索引,bounds为活动组件元素的元素坐标。Among them, <node index="0"text="Please enter the following password for authentication: "resource-id=""class="android.widget.TextView"package="com.ftsafe.otp.activity"content-desc=" ""checkable="false"checked="false"clickable="false"enabled="true"focusable="false"focused="false"scrollable="false"long-clickable="false"password="false"selected ="false" bounds="[60,321][672,389]"/> is an active component element, class in node is the element type of the active component element, text is the element text of the active component element, index is the element of the active component element Index, bounds is the element coordinates of the active component element.
步骤230:根据视图类型和关键信息在活动组件元素集合文件中获取与视图类型和关键信息匹配的活动组件元素;若未获取到,则当前测试失败,报错;若获取到,则测试成功,结束。Step 230: Obtain the active component element matching the view type and key information from the active component element set file according to the view type and key information; if not obtained, the current test fails and an error is reported; if obtained, the test succeeds and ends .
其中,关键信息中包括关键信息标识和关键信息值。Wherein, the key information includes a key information identifier and a key information value.
具体地,根据预设的视图类型“TextView”和关键信息标识“text”和关键信息值在活动组件元素集合文件中查找元素属性中的元素类型与视图类型匹配且元素属性为关键信息标识的元素属性值为关键信息值的活动组件元素,若查找到,判断出在活动组件元素集合文件中查找与视图类型和关键信息匹配的活动组件元素,则测试成功,结束;否则,判断出在活动组件元素集合文件中没有查找与视图类型和关键信息匹配的活动组件元素,当前测试失败,报错。Specifically, according to the preset view type "TextView" and the key information identifier "text" and the key information value, search for elements whose element type in the element attribute matches the view type and whose element attribute is the key information identifier in the active component element collection file If the active component element whose attribute value is the key information value is found, it is judged that the active component element matching the view type and key information is found in the active component element collection file, and the test is successful and the end; otherwise, it is judged that the active component element in the active component An active component element that matches the view type and key information is not found in the element collection file. The current test fails and an error is reported.
例如:根据预设的视图类型“TextView”和第关键信息标识“text”和关键信息值“103243”在活动组件元素集合文件“window_dump3.xml”中查找到元素类型class"=android.widget.TextView"为与视图类型TextView匹配且元素属性为关键信息标识text的元素属性值为“103243”的活动组件元素,<node index="1"text="103423"resource-id="com.ftsafe.otp.activity:id/challenge_tkn"class="android.widget.TextView"package="com.ftsafe.otp.activity"content-desc=""checkable="false"checked="false"clickable="false"enabled="true"focusable="false"focused="false"scrollable="false"long-clickable="false"password="false"selected="false"bounds="[312,419][768,599]"/>,测试成功,结束。For example: according to the preset view type "TextView", the first key information identifier "text" and the key information value "103243", find the element type class"=android.widget.TextView in the active component element collection file "window_dump3.xml" "It is an active component element that matches the view type TextView and whose element attribute is the key information identifier text. The element attribute value of "103243" is <node index="1"text="103423"resource-id="com.ftsafe.otp .activity:id/challenge_tkn"class="android.widget.TextView"package="com.ftsafe.otp.activity"content-desc=""checkable="false"checked="false"clickable="false"enabled="false"enabled=" "true"focusable="false"focused="false"scrollable="false"long-clickable="false"password="false"selected="false"bounds="[312,419][768,599]"/>, the test is successful ,Finish.
步骤230报错或结束之前,还包括:根据解析结果判断当前测试操作是否为测试器中的最后一个测试操作,如果是最后一个测试操作,则若未查找到与视图类型和关键信息匹配的活动组件元素,则当前测试失败,报错;若查找到与视图类型和关键信息匹配的活动组件元素,则当前测试成功,结束;如果不是最后一个测试操作,将测试器中的当前测试操作的下一个测试操作作为当前测试操作,继续测试。Before step 230 reports an error or ends, it also includes: judging whether the current test operation is the last test operation in the tester according to the parsing result, if it is the last test operation, if no active component matching the view type and key information is found element, the current test fails and an error is reported; if an active component element matching the view type and key information is found, the current test succeeds and ends; if it is not the last test operation, the next test of the current test operation in the tester Action Continue testing as the current test action.
步骤230中根据视图类型和关键信息在活动组件元素集合文件中获取与视图类型和关键信息匹配的活动组件元素之后,还可以包括:保存获取结果;相应地:After obtaining the active component elements matching the view type and key information in the active component element set file according to the view type and key information in step 230, it may also include: saving the obtained result; correspondingly:
若步骤230中若未获取到与视图类型和关键信息匹配的活动组件元素,还包括:根据已保存的所有获取结果得到测试报告。If no active component element matching the view type and key information is obtained in step 230, the method further includes: obtaining a test report according to all the obtained obtained results.
若步骤230中若获取到与视图类型和关键信息匹配的活动组件元素,还包括:根据已保存的所有获取结果得到测试报告。If in step 230, if an active component element matching the view type and key information is obtained, the method further includes: obtaining a test report according to all the obtained obtained results.
例如,若步骤230中若未获取到与视图类型和关键信息匹配的活动组件元素,则根据已保存的所有获取结果得到测试报告,可以为:根据步骤208中已保存的获取到元素类型class"=android.widget.TextView"为与视图类型TextView匹配且元素属性为关键信息标识text的元素属性值为“挑战应答型”的活动组件元素;和步骤215中已保存的获取到元素类型class"=android.widget.EditText"为与视图类型EditText匹配且元素属性为关键信息标识index的元素属性值为“0”的活动组件元素以及步骤223中已保存的获取到元素类型class"=android.widget.Button"为与视图类型Button匹配且元素属性为关键信息标识index的元素属性值为“1”的活动组件元素还有的步骤230中已获取到元素类型class"=android.widget.TextView"为与视图类型TextView匹配且元素属性为关键信息标识text的元素属性值为“103243”的活动组件元素的信息,组织测试报告。For example, if no active component element matching the view type and key information is obtained in step 230, then the test report is obtained according to all the obtained results that have been saved, which may be: according to the saved obtained element type "class" in step 208 =android.widget.TextView" is an active component element that matches the view type TextView and whose element attribute is the key information identifier text whose element attribute value is "challenge-response type"; and the obtained element type class saved in step 215"= android.widget.EditText" is an active component element that matches the view type EditText and the element attribute is the key information identifier index, the element attribute value is "0", and the element type class "=android.widget that has been saved and obtained in step 223. Button" is an active component element that matches the view type Button and has an element attribute value of "1" for the element attribute of the key information identifier index. In addition, the element type class "=android.widget.TextView" that has been obtained in step 230 is the same as The information of the active component element whose view type TextView matches and whose element attribute is key information identifies the element attribute value of text as "103243", and organizes the test report.
若步骤230中获取到与视图类型和关键信息匹配的活动组件元素,则根据已保存的所有获取结果得到测试报告,可以为:根据步骤208中已保存的获取到元素类型class"=android.widget.TextView"为与视图类型TextView匹配且元素属性为关键信息标识text的元素属性值为“挑战应答型”的活动组件元素;和步骤215中已保存的获取到元素类型class"=android.widget.EditText"为与视图类型EditText匹配且元素属性为关键信息标识index的元素属性值为“0”的活动组件元素以及步骤223中已保存的获取到元素类型class"=android.widget.Button"为与视图类型Button匹配且元素属性为关键信息标识index的元素属性值为“1”的活动组件元素还有的步骤230中没有获取到元素类型class"=android.widget.TextView"为与视图类型TextView匹配且元素属性为关键信息标识text的元素属性值为“103243”的活动组件元素的信息,组织测试报告。If the active component element matching the view type and key information is obtained in step 230, then a test report is obtained according to all the obtained results that have been saved, which can be: according to the obtained obtained element type class"=android.widget that has been saved in step 208 .TextView" is an active component element that matches the view type TextView and whose element attribute is the key information identifier text whose element attribute value is "challenge-response type"; and the obtained element type class"=android.widget that has been saved in step 215. EditText" is an active component element that matches the view type EditText and has an element attribute value of "0" and the element type class "=android.widget.Button" that is saved in step 223 is the key information identifier index The view type Button matches and the element attribute is an active component element whose element attribute value is "1" and the element attribute is the key information identification index. In step 230, the element type class "=android.widget.TextView" is not obtained to match the view type TextView And the element attribute is the information of the active component element whose element attribute value of the key information identifier text is "103243", and organizes the test report.
实施例3Example 3
本实施例中提供的自动化测试方法,还可以测试移动设备上的当前被测应用的显示页面的不同进行不同的测试,例如:当前页面为登录页面时,可以执行包括输入用户名和密码的输入操作和点击登录按钮的点击操作;具体操作流程如图7-1和图7-2所所示的操作。The automated testing method provided in this embodiment can also test the different display pages of the current application under test on the mobile device and perform different tests, for example: when the current page is a login page, input operations including inputting user names and passwords can be performed and the click operation of clicking the login button; the specific operation process is as shown in Figure 7-1 and Figure 7-2.
步骤301:解析测试器得到解析结果,从解析结果中获取计算机的数据配置文件,从计算机的数据配置文件中获取目标设备序列号,并枚举出连接到计算机的所有设备的设备序列号;Step 301: the analysis tester obtains the analysis result, obtains the data configuration file of the computer from the analysis result, obtains the serial number of the target device from the data configuration file of the computer, and enumerates the device serial numbers of all devices connected to the computer;
本实施例中,测试器安装在计算机上。In this embodiment, the tester is installed on a computer.
步骤302:判断获取到的目标设备序列号是否为空,如果是,则将枚举到的第一个设备的设备序列号对应的设备作为当前被测设备,执行步骤305;否则,执行步骤303;Step 302: Determine whether the acquired target device serial number is empty, if yes, take the device corresponding to the device serial number of the first enumerated device as the current device under test, and execute step 305; otherwise, execute step 303 ;
步骤303:判断枚举到的所有设备的设备序列号中是否存在和目标设备序列号对应的设备序列号,如果是,则执行步骤304;否则,报错;Step 303: Determine whether there is a device serial number corresponding to the target device serial number among the device serial numbers of all the enumerated devices, if yes, perform step 304; otherwise, report an error;
步骤304:将目标设备序列号对应的设备作为当前被测设备,执行步骤305;Step 304: take the device corresponding to the serial number of the target device as the current device under test, and execute step 305;
步骤305:从解析结果中获取测试器中的第一测试操作,将第一测试操作作为当前测试操作,根据当前测试操作获取当前测试操作类型为输入操作,根据当前测试操作获取视图类型、关键信息和文本内容;Step 305: Obtain the first test operation in the tester from the analysis result, use the first test operation as the current test operation, obtain the current test operation type as the input operation according to the current test operation, and obtain the view type and key information according to the current test operation and text content;
具体地,从解析结果中获取测试器中的与第一测试操作对应的第一测试代码并将其作为当前测试代码,若当前测试代码为第二函数,则当前测试操作类型为输入操作,获取第二函数中第三参数、第四参数和第九参数,将第三参数作为视图类型,将第四参数作为关键信息、将第九参数作为文本内容;Specifically, obtain the first test code corresponding to the first test operation in the tester from the parsing result and use it as the current test code, if the current test code is the second function, the current test operation type is an input operation, and obtain In the third parameter, the fourth parameter and the ninth parameter in the second function, the third parameter is used as the view type, the fourth parameter is used as the key information, and the ninth parameter is used as the text content;
例如:从解析结果中获取测试器中的与第一测试操作对应的第一测试代码并将其作为当前测试代码,获取到当前测试代码为第二函数“Then enter"张三"into editextwith index 0For example: Obtain the first test code corresponding to the first test operation in the tester from the analysis result and use it as the current test code, and the current test code obtained is the second function "Then enter" Zhang San" into editextwith index 0
"{…..view_class="android.widget.EditText"….."{…..view_class="android.widget.EditText"…..
}则当前测试操作类型为输入操作,将第三参数view_class="android.widget.EditText"作为视图类型,将第四参数“index 0”作为关键信息,将第九参数"张三"作为文本内容。} Then the current test operation type is an input operation, the third parameter view_class="android.widget.EditText" is used as the view type, the fourth parameter "index 0" is used as the key information, and the ninth parameter "Zhang San" is used as the text content .
步骤306:在被测设备上生成与当前被测应用的当前页面对应的当前活动组件元素集合文件;Step 306: Generate a current active component element set file corresponding to the current page of the current application under test on the device under test;
本步骤中,当前页面为当前被测应用的等待输入用户名和密码的登录页面,可以但不限于如图8所示。In this step, the current page is the login page of the currently tested application waiting for input of user name and password, which may be, but not limited to, as shown in FIG. 8 .
具体地,根据被测设备的设备序列号androiddevsn组织第一生成命令<adb-sandroiddevsn shell uiautomator dump>发给被测设备的操作系统,在被测设备上生成与当前被测应用的当前页面对应的当前活动组件元素集合文件。Specifically, according to the device serial number androiddevsn of the device under test, the first generation command <adb-sandroiddevsn shell uiautomator dump> is sent to the operating system of the device under test, and the corresponding to the current page of the current application under test is generated on the device under test. The currently active component element collection file.
步骤307:将当前活动组件元素集合文件转移到计算机上;Step 307: Transfer the current active component element set file to the computer;
具体地,根据被测设备的设备序列号androiddevsn组织第一转移命令<adb-sandroiddevsn shell pull>发给被测设备的操作系统,将当前活动组件元素集合文件“window_dump5.xml”转移到计算机上。Specifically, according to the device serial number androiddevsn of the device under test, the first transfer command <adb-sandroiddevsn shell pull> is sent to the operating system of the device under test, and the current active component element set file "window_dump5.xml" is transferred to the computer.
本实施例中,当前活动组件元素集合文件“window_dump6.xml”中包含当前页面的多个活动组件元素,每个活动组件元素中包括多个元素属性,元素属性可以具体为:元素索引、元素文本、元素类型和元素坐标等信息;例如:当前活动组件元素集合文件“window_dump5.xml”为:In this embodiment, the current active component element collection file "window_dump6.xml" contains multiple active component elements of the current page, and each active component element includes multiple element attributes, and the element attributes can be specifically: element index, element text , element type, element coordinates and other information; for example: the current active component element collection file "window_dump5.xml" is:
步骤308:根据视图类型和关键信息在活动组件元素集合文件中获取与视图类型和关键信息匹配的活动组件元素;若未获取到,则当前测试失败,报错;若获取到,则执行步骤309。Step 308: Obtain the active component element matching the view type and key information from the active component element set file according to the view type and key information; if not obtained, the current test fails and an error is reported; if obtained, execute step 309.
其中,关键信息中包括关键信息标识和关键信息值。Wherein, the key information includes a key information identifier and a key information value.
本实施例中,本实施例中,视图类型可以是预设的,也可以是外部传入的。关键信息可以是预设的,也可以是外部传入的。In this embodiment, in this embodiment, the view type can be preset or imported from outside. Key information can be preset or imported from the outside.
具体地,根据预设的视图类型和关键信息标识和关键信息值在活动组件元素集合文件中查找元素属性中的元素类型与视图类型匹配且元素属性为关键信息标识的元素属性值为关键信息值的活动组件元素,若查找到,判断出在活动组件元素集合文件中查找与视图类型和关键信息匹配的活动组件元素,则执行步骤309;否则,判断出在活动组件元素集合文件中没有查找与视图类型和关键信息匹配的活动组件元素,当前测试失败,报错。Specifically, according to the preset view type, key information identification and key information value, search the element set file of the active component, the element type in the element attribute matches the view type, and the element attribute value is the key information identification element attribute value If the active component element is found, it is judged that the active component element matching the view type and key information is found in the active component element set file, and then step 309 is executed; otherwise, it is judged that there is no active component element matching with The active component element whose view type and key information match, the current test fails and an error is reported.
例如:根据预设的视图类型“EditText”和关键信息标识“index”和关键信息值“0”在活动组件元素集合文件“window_dump6.xml”中查找到元素类型class"=android.widget.EditText"为与视图类型EditText匹配且元素属性为关键信息标识index的元素属性值为“0”的活动组件元素,则执行步骤309。For example: according to the preset view type "EditText", the key information identifier "index" and the key information value "0", the element type class "=android.widget.EditText" is found in the active component element collection file "window_dump6.xml" If it is an active component element that matches the view type EditText and has an element attribute value of "0" whose element attribute is the key information identifier index, step 309 is executed.
步骤309:获取与视图类型和关键信息匹配的活动组件元素的元素坐标信息;Step 309: Obtain the element coordinate information of the active component element matching the view type and key information;
例如:获取与视图类型“EditText”和关键信息“挑战应答型”匹配的活动组件元素<node index="0"text="输入用户名"resource-id=""class="android.widget.EditText"package=""content-desc=""checkable="false"checked="false"clickable="true"enabled="true"focusable="true"focused="true"scrollable="false"long-clickable="true"password="false"selected="false"bounds="[60,321][1020,427]"/>的元素坐标信息:bounds="[60,321][1020,427]"。For example: get the active component element matching the view type "EditText" and the key information "challenge-response type"<node index="0"text="enter user name"resource-id=""class="android.widget.EditText "package=""content-desc=""checkable="false"checked="false"clickable="true"enabled="true"focusable="true"focused="true"scrollable="false"long-clickable="false"long-clickable=" "true"password="false"selected="false"bounds="[60,321][1020,427]"/> element coordinate information: bounds="[60,321][1020,427]".
步骤310:根据与视图类型和关键信息匹配的活动组件元素的元素坐标信息计算第五焦点位置;Step 310: Calculate the fifth focus position according to the element coordinate information of the active component element matching the view type and key information;
具体地,根据第五算法对与视图类型和关键信息匹配的活动组件元素的元素坐标信息进行计算得到第五焦点位置。Specifically, the element coordinate information of the active component element matching the view type and key information is calculated according to the fifth algorithm to obtain the fifth focus position.
例如,根据第五算法对与视图类型和关键信息匹配的活动组件元素的元素坐标信息进行计算得到元素坐标信息的中心点坐标位置,并将元素坐标信息的中心点坐标位置作为第五焦点位置。For example, calculate the element coordinate information of the active component element matching the view type and key information according to the fifth algorithm to obtain the coordinate position of the center point of the element coordinate information, and use the coordinate position of the center point of the element coordinate information as the fifth focus position.
步骤311:判断与视图类型和关键信息匹配的活动组件元素的元素文本值是否为空,如果是,则执行步骤312;否则,清空与视图类型和关键信息匹配的活动组件元素的元素文本值,执行步骤312;Step 311: Determine whether the element text value of the active component element matching the view type and key information is empty, if yes, perform step 312; otherwise, clear the element text value of the active component element matching the view type and key information, Execute step 312;
步骤312:根据第五焦点位置将文本内容输入到当前页面的文本输入区域;Step 312: Input text content into the text input area of the current page according to the fifth focus position;
步骤312具体包括:Step 312 specifically includes:
步骤312-1:根据焦点位置组织第四点击命令,将第四点击命令发送给被测设备点击当前页面上的文本输入区域;Step 312-1: Organize the fourth click command according to the focus position, and send the fourth click command to the device under test to click the text input area on the current page;
具体地,根据第五焦点位置的坐标positionX positionY组织点击命令<adb-sandroiddevsn shell input tap positionX positionY>,将点击命令发送给被测设备的操作系统,被测设备的操作系统接收到第四点击命令后,根据第四点击命令中的第五焦点位置点击当前页面上的待点击区域。Specifically, organize the click command <adb-sandroiddevsn shell input tap positionX positionY> according to the coordinate positionX positionY of the fifth focus position, and send the click command to the operating system of the device under test, and the operating system of the device under test receives the fourth click command After that, click the area to be clicked on the current page according to the fifth focus position in the fourth click command.
步骤312-2:组织包括文本内容的第二文本输入命令,将第二文本输入命令发送给被测设备将文本内容输入到当前页面上的文本输入区域中。Step 312-2: Organize a second text input command including text content, and send the second text input command to the device under test to input the text content into the text input area on the current page.
具体地,组织包括文本内容content的第二文本输入命令<adb-s androiddevsnshell input text content>,将第二文本输入命令发送给被测设备的操作系统,被测设备的操作系统接收到第二文本输入命令后,将第二文本输入命令中的文本内容本输入到当前页面上的文本输入区域中。Specifically, organize the second text input command <adb-s androiddevsnshell input text content> including text content, send the second text input command to the operating system of the device under test, and the operating system of the device under test receives the second text After the command is input, the text content in the second text input command is input into the text input area on the current page.
例如:根据第五焦点位置将文本内容“张三”输入到当前页面的文本输入区域。For example: input the text content "Zhang San" into the text input area of the current page according to the fifth focus position.
本实施例中,文本内容可以是预设的,还可以是从已注册数据库中获取到的,也可以是接收外部传入的。In this embodiment, the text content may be preset, obtained from a registered database, or received from an external source.
本实施例中,输入文本内容“张三”的登录当前页面可以但不限于如图9所示。In this embodiment, the current login page for inputting the text content "Zhang San" may be, but not limited to, as shown in FIG. 9 .
步骤313:从解析结果中获取测试器中的第二测试操作,将第二测试操作作为当前测试操作,根据当前测试操作获取当前测试操作类型为输入操作,根据当前测试操作获取视图类型、关键信息和当前文本信息;Step 313: Obtain the second test operation in the tester from the analysis result, use the second test operation as the current test operation, obtain the current test operation type as the input operation according to the current test operation, and obtain the view type and key information according to the current test operation and current text information;
例如:从解析结果中获取测试器中的与第二测试操作对应的第二测试代码并将其作为当前测试代码,获取到当前测试代码为第二函数“Then enter"123456"into editextwith index 1For example: Obtain the second test code corresponding to the second test operation in the tester from the analysis result and use it as the current test code, and the current test code obtained is the second function "Then enter"123456"into editextwith index 1
"{…..view_class="android.widget.EditText"….."{…..view_class="android.widget.EditText"…..
}则当前测试操作类型为输入操作,将第三参数view_class="android.widget.EditText"作为视图类型,将第四参数“index 1”作为关键信息,将第九参数"123456"作为文本内容。} Then the current test operation type is an input operation, the third parameter view_class="android.widget.EditText" is used as the view type, the fourth parameter "index 1" is used as the key information, and the ninth parameter "123456" is used as the text content.
步骤314:在被测设备上生成与当前被测应用的当前页面对应的当前活动组件元素集合文件;Step 314: Generate a current active component element set file corresponding to the current page of the current application under test on the device under test;
具体地,根据被测设备的设备序列号androiddevsn组织第一生成命令<adb-sandroiddevsn shell uiautomator dump>发给被测设备的操作系统,在被测设备上生成与当前被测应用的当前页面对应的当前活动组件元素集合文件。Specifically, according to the device serial number androiddevsn of the device under test, the first generation command <adb-sandroiddevsn shell uiautomator dump> is sent to the operating system of the device under test, and the corresponding to the current page of the current application under test is generated on the device under test. The currently active component element collection file.
步骤315:将当前活动组件元素集合文件转移到计算机上;Step 315: Transfer the current active component element set file to the computer;
具体地,根据被测设备的设备序列号androiddevsn组织第一转移命令<adb -sandroiddevsn shell pull>发给被测设备的操作系统,将当前活动组件元素集合文件“window_dump6.xml”转移到计算机上。Specifically, according to the device serial number androiddevsn of the device under test, the first transfer command <adb -sandroiddevsn shell pull> is sent to the operating system of the device under test, and the current active component element set file "window_dump6.xml" is transferred to the computer.
本实施例中,当前活动组件元素集合文件“window_dump1.xml”中包含当前页面的多个活动组件元素,每个活动组件元素中包括多个元素属性,元素属性可以具体为:元素索引、元素文本、元素类型和元素坐标等信息;例如: 当前活动组件元素集合文件“window_dump6.xml”为:In this embodiment, the current active component element collection file "window_dump1.xml" contains multiple active component elements of the current page, and each active component element includes multiple element attributes, and the element attributes can be specifically: element index, element text , element type, element coordinates and other information; for example: The current active component element collection file "window_dump6.xml" is:
步骤316:根据视图类型和关键信息在活动组件元素集合文件中获取与视图类型和关键信息匹配的活动组件元素;若未获取到,则当前测试失败,报错;若获取到,则执行步骤317。Step 316: Obtain the active component element matching the view type and key information from the active component element set file according to the view type and key information; if not obtained, the current test fails and an error is reported; if obtained, execute step 317.
其中,关键信息中包括关键信息标识和关键信息值。Wherein, the key information includes a key information identifier and a key information value.
本实施例中,本实施例中,视图类型可以是预设的,也可以是外部传入的。关键信息可以是预设的,也可以是外部传入的。In this embodiment, in this embodiment, the view type can be preset or imported from outside. Key information can be preset or imported from the outside.
具体地,根据预设的视图类型和关键信息标识和关键信息值在活动组件元素集合文件中查找元素属性中的元素类型与视图类型匹配且元素属性为关键信息标识的元素属性值为关键信息值的活动组件元素,若查找到,判断出在活动组件元素集合文件中查找与视图类型和关键信息匹配的活动组件元素,则执行步骤308;否则,判断出在活动组件元素集合文件中没有查找与视图类型和关键信息匹配的活动组件元素,当前测试失败,报错。Specifically, according to the preset view type, key information identification and key information value, search the element set file of the active component, the element type in the element attribute matches the view type, and the element attribute value is the key information identification element attribute value If the active component element is found, it is determined that the active component element matching the view type and key information is found in the active component element collection file, and then step 308 is performed; The active component element whose view type and key information match, the current test fails and an error is reported.
例如:根据预设的视图类型“EditText”和关键信息标识“index”和关键信息值“1”在活动组件元素集合文件“window_dump6.xml”中查找到元素类型class"=android.widget. EditText "为与视图类型EditText匹配且元素属性为关键信息标识index的元素属性值为“1”的活动组件元素<node index="1" text="输入密码"resource-id=" " class="android.widget.EditText"package=" " content-desc="" checkable="false" checked="false" clickable="true"enabled="true"focusable="true" focused="true" scrollable="false"long-clickable="true"password="false" selected="false"bounds="[80,321][1020,427]" /> ,则执行步骤308。For example: according to the preset view type "EditText", the key information identifier "index" and the key information value "1", the element type class "=android.widget.EditText" is found in the active component element collection file "window_dump6.xml" It is an active component element that matches the view type EditText and the element attribute is the key information identifier index. The element attribute value is "1". <node index="1" text="Enter password" resource-id=" " class="android. widget.EditText "package=" " content-desc="" checkable="false" checked="false" clickable="true" enabled="true" focusable="true" focused="true" scrollable="false"long -clickable="true" password="false" selected="false" bounds="[80,321][1020,427]" />, then step 308 is executed.
本实施例中,步骤314还可以具体包括:In this embodiment, step 314 may also specifically include:
步骤c1:创建与将活动组件元素集合文件的中活动组件元素一一对应的标识信息,并将标识信息和活动组件元素对应保存;Step c1: Create identification information corresponding to the active component elements in the active component element collection file one by one, and store the identification information and the active component elements correspondingly;
步骤c2:根据外部传入的目标标识信息获取与目标标识信息对应的活动组件元素;判断获取到的活动组件元素是否与关键信息和视图类型匹配,如果是,执行步骤315;否则,测试失败,报错。Step c2: Obtain the active component element corresponding to the target identification information according to the target identification information passed in from the outside; judge whether the acquired active component element matches the key information and view type, if yes, execute step 315; otherwise, the test fails, error.
本实施例中,步骤314又可以具体包括:In this embodiment, step 314 may specifically include:
步骤d1:在活动组件元素集合文件中获取与视图类型对应的活动组件元素,并创建与获取到的活动组件元素一一对应的标识信息,并将标识信息和活动组件元素对应保存;Step d1: Obtain the active component element corresponding to the view type in the active component element collection file, create identification information corresponding to the acquired active component element one by one, and store the identification information and the active component element correspondingly;
步骤d2:根据外部传入的目标标识信息获取与目标标识信息对应的活动组件元素,判断活动组件元素是否与关键信息匹配,如果是,则将其作为与视图类型和关键信息匹配的活动组件元素;执行步骤315;否则,测试失败,报错。Step d2: Obtain the active component element corresponding to the target identification information according to the target identification information passed in from the outside, judge whether the active component element matches the key information, and if so, use it as the active component element matching the view type and key information ; Execute step 315; otherwise, the test fails and an error is reported.
步骤317:获取与视图类型和关键信息匹配的活动组件元素的元素坐标信息;Step 317: Obtain the element coordinate information of the active component element matching the view type and key information;
例如:获取与视图类型“EditText”和关键信息“挑战应答型”匹配的活动组件元素<node index="1"text="输入密码"resource-id=""For example: get the active component element matching the view type "EditText" and the key information "challenge-response type"<node index="1"text="enter password"resource-id=""
class="android.widget.EditText"class="android.widget.EditText"
package=""content-desc=""checkable="false"checked="false"clickable="true"enabled="true"focusable="true"focused="true"scrollable="false"long-clickable="true"password="false"selected="false"bounds="[60,321][1020,427]"/>的元素坐标信息:bounds="[80,321][1020,427]"。package=""content-desc=""checkable="false"checked="false"clickable="true"enabled="true"focusable="true"focused="true"scrollable="false"long-clickable=" true"password="false"selected="false"bounds="[60,321][1020,427]"/> element coordinate information: bounds="[80,321][1020,427]".
步骤318:根据与视图类型和关键信息匹配的活动组件元素的元素坐标信息计算第六焦点位置;Step 318: Calculate the sixth focus position according to the element coordinate information of the active component element matching the view type and key information;
具体地,根据第六算法对与视图类型和关键信息匹配的活动组件元素的元素坐标信息进行计算得到第六焦点位置。Specifically, the element coordinate information of the active component element matching the view type and key information is calculated according to the sixth algorithm to obtain the sixth focus position.
例如,根据第六算法对与视图类型和关键信息匹配的活动组件元素的元素坐标信息进行计算得到元素坐标信息的中心点坐标位置,并将元素坐标信息的中心点坐标位置作为第六焦点位置。For example, calculate the element coordinate information of the active component element matching the view type and key information according to the sixth algorithm to obtain the coordinate position of the center point of the element coordinate information, and use the coordinate position of the center point of the element coordinate information as the sixth focus position.
步骤319:判断与视图类型和关键信息匹配的活动组件元素的元素文本值是否为空,如果是,则执行步骤320;否则,清空与视图类型和关键信息匹配的活动组件元素的元素文本值,执行步骤320;Step 319: Determine whether the element text value of the active component element matching the view type and key information is empty, if yes, perform step 320; otherwise, clear the element text value of the active component element matching the view type and key information, Execute step 320;
步骤320:根据第六焦点位置将文本内容输入到当前页面的文本输入区域;Step 320: Input text content into the text input area of the current page according to the sixth focus position;
步骤320具体包括:Step 320 specifically includes:
步骤320-1:根据焦点位置组织第五点击命令,将第五点击命令发送给被测设备点击当前页面上的文本输入区域;Step 320-1: Organize the fifth click command according to the focus position, and send the fifth click command to the device under test to click the text input area on the current page;
具体地,根据第六焦点位置的坐标positionX positionY组织点击命令<adb-sandroiddevsn shell input tap positionX positionY>,将点击命令发送给被测设备的操作系统,被测设备的操作系统接收到第五点击命令后,根据第五点击命令中的第六焦点位置点击当前页面上的待点击区域。Specifically, organize the click command <adb-sandroiddevsn shell input tap positionX positionY> according to the coordinate positionX positionY of the sixth focus position, and send the click command to the operating system of the device under test, and the operating system of the device under test receives the fifth click command After that, click the area to be clicked on the current page according to the sixth focus position in the fifth click command.
步骤320-2:组织包括文本内容的第三文本输入命令,将第三文本输入命令发送给被测设备将文本内容输入到当前页面上的文本输入区域中。Step 320-2: Organize a third text input command including text content, and send the third text input command to the device under test to input the text content into the text input area on the current page.
具体地,组织包括文本内容content的第三文本输入命令<adb-s androiddevsnshell input text content>,将第三文本输入命令发送给被测设备的操作系统,被测设备的操作系统接收到第三文本输入命令后,将第三文本输入命令中的文本内容本输入到当前页面上的文本输入区域中。Specifically, organize the third text input command <adb-s androiddevsnshell input text content> including the text content, send the third text input command to the operating system of the device under test, and the operating system of the device under test receives the third text After the command is input, the text content in the third text input command is input into the text input area on the current page.
例如:根据第六焦点位置将文本内容“123456”输入到当前页面的文本输入区域。For example: input the text content "123456" into the text input area of the current page according to the sixth focus position.
本实施例中,文本内容可以是预设的,还可以是从已注册数据库中获取到的,也可以是接收外部传入的。In this embodiment, the text content may be preset, obtained from a registered database, or received from an external source.
本实施例中,输入文本内容“123456”的登录当前页面可以但不限于如图10所示。In this embodiment, the current login page for inputting the text content "123456" may be, but not limited to, as shown in FIG. 10 .
步骤321:从解析结果中获取测试器中的第三测试操作,将第三测试操作作为当前测试操作,根据当前测试操作获取当前测试操作类型为按钮点击操作,根据当前测试操作获取视图类型和关键信息;Step 321: Obtain the third test operation in the tester from the parsing result, use the third test operation as the current test operation, obtain the current test operation type as button click operation according to the current test operation, and obtain the view type and key according to the current test operation information;
具体地,从解析结果中获取测试器中的与第三测试操作对应的第三测试代码并将其作为当前测试代码,若当前测试代码为第四函数,则当前测试操作类型为按钮点击操作,获取第四函数中第七参数和第八参数,将第七参数作为视图类型,将第八参数作为关键信息。Specifically, obtain the third test code corresponding to the third test operation in the tester from the analysis result and use it as the current test code, if the current test code is the fourth function, then the current test operation type is a button click operation, Obtain the seventh parameter and the eighth parameter in the fourth function, use the seventh parameter as the view type, and use the eighth parameter as key information.
例如:从解析结果中获取测试器中的与第三测试操作对应的第三测试代码并将其作为当前测试代码,获取到当前测试代码为第四函数“Then press button with index 1"For example: obtain the third test code corresponding to the third test operation in the tester from the analysis result and use it as the current test code, and obtain the current test code as the fourth function "Then press button with index 1"
{…..view_class="android.widget.Button"…..{…..view_class="android.widget.Button"…..
},则当前测试操作类型为按键点击操作,将第七参数view_class="android.widget.Button"作为视图类型,将第八参数“index1”作为关键信息。}, the current test operation type is button click operation, the seventh parameter view_class="android.widget.Button" is used as the view type, and the eighth parameter "index1" is used as the key information.
步骤322:在被测设备上生成与当前被测应用的当前页面对应的当前活动组件元素集合文件;Step 322: Generate a current active component element collection file corresponding to the current page of the current application under test on the device under test;
具体地,根据被测设备的设备序列号androiddevsn组织第一生成命令<adb-sandroiddevsn shell uiautomator dump>发给被测设备的操作系统,在被测设备上生成与当前被测应用的当前页面对应的当前活动组件元素集合文件。Specifically, according to the device serial number androiddevsn of the device under test, the first generation command <adb-sandroiddevsn shell uiautomator dump> is sent to the operating system of the device under test, and the corresponding to the current page of the current application under test is generated on the device under test. The currently active component element collection file.
步骤323:将当前活动组件元素集合文件转移到计算机上;Step 323: Transfer the current active component element set file to the computer;
具体地,根据被测设备的设备序列号androiddevsn组织第一转移命令<adb-sandroiddevsn shell pull>发给被测设备的操作系统,将当前活动组件元素集合文件“window_dump7.xml”转移到计算机上。Specifically, according to the device serial number androiddevsn of the device under test, the first transfer command <adb-sandroiddevsn shell pull> is sent to the operating system of the device under test, and the current active component element set file "window_dump7.xml" is transferred to the computer.
本实施例中,当前活动组件元素集合文件“window_dump7.xml”中包含当前页面的多个活动组件元素,每个活动组件元素中包括多个元素属性,元素属性可以具体为:元素索引、元素文本、元素类型和元素坐标等信息;例如:当前活动组件元素集合文件“window_dump7.xml”为:In this embodiment, the current active component element collection file "window_dump7.xml" contains multiple active component elements of the current page, and each active component element includes multiple element attributes, and the element attributes can be specifically: element index, element text , element type, element coordinates and other information; for example: the current active component element collection file "window_dump7.xml" is:
其中,node index="1"text="登录"resource-id=""class="android.widget.Button"package="com.ftsafe.otp.activity"content-desc=""checkable="false"checked="false"clickable="true"enabled="true"focusable="true"focused="false"scrollable="false"long-clickable="false"password="false"selected="false"bounds="[375,472][705,616]"/>为一个活动组件元素,node中的class为活动组件元素的元素类型、text为活动组件元素的元素文本、index为活动组件元素的元素索引,bounds为活动组件元素的元素坐标。Among them, node index="1"text="login"resource-id=""class="android.widget.Button"package="com.ftsafe.otp.activity"content-desc=""checkable="false" checked="false"clickable="true"enabled="true"focusable="true"focused="false"scrollable="false"long-clickable="false"password="false"selected="false"bounds="false"bounds="false" [375,472][705,616]"/> is an active component element, class in node is the element type of the active component element, text is the element text of the active component element, index is the element index of the active component element, bounds is the active component element element coordinates.
步骤324:根据视图类型和关键信息在活动组件元素集合文件中获取与视图类型和关键信息匹配的活动组件元素;若未获取到,则当前测试失败,报错;若获取到,则执行步骤325;Step 324: Obtain the active component element matching the view type and key information from the active component element collection file according to the view type and key information; if not obtained, the current test fails and an error is reported; if obtained, execute step 325;
本实施例中,视图类型可以是预设的,也可以是外部传入的。关键信息可以是预设的,也可以是外部传入的。In this embodiment, the view type can be preset or imported from outside. Key information can be preset or imported from the outside.
其中,关键信息中包括关键信息标识和关键信息值。Wherein, the key information includes a key information identifier and a key information value.
具体地,根据预设的视图类型和关键信息标识和关键信息值在活动组件元素集合文件中查找元素属性中的元素类型与视图类型匹配且元素属性为关键信息标识的元素属性值为关键信息值的活动组件元素,若查找到,判断出在活动组件元素集合文件中查找与视图类型和关键信息匹配的活动组件元素,执行步骤325;否则,判断出在活动组件元素集合文件中没有查找与视图类型和关键信息匹配的活动组件元素,当前测试失败,报错;Specifically, according to the preset view type, key information identification and key information value, search the element set file of the active component, the element type in the element attribute matches the view type, and the element attribute value is the key information identification element attribute value If the active component element is found, it is determined that the active component element matching the view type and key information is found in the active component element collection file, and step 325 is performed; otherwise, it is determined that there is no search and view in the active component element collection file For active component elements whose type and key information match, the current test fails and an error is reported;
例如:根据预设的视图类型“Button”和第关键信息标识“index”和关键信息值“1”在活动组件元素集合文件“window_dump7.xml”中查找到元素类型class"=android.widget.Button"为与视图类型Button匹配且元素属性为关键信息标识index的元素属性值为“1”的活动组件元素<node index="1"text="登录"resource-id=""class="android.widget.Button"package="com.ftsafe.otp.activity"content-desc=""checkable="false"checked="false"clickable="true"enabled="true"focusable="true"focused="false"scrollable="false"long-clickable="false"password="false"selected="false"bounds="[375,472][705,616]"/>,执行步骤325;For example: according to the preset view type "Button", the first key information identifier "index" and the key information value "1", the element type class"=android.widget.Button is found in the active component element collection file "window_dump7.xml" "It is an active component element that matches the view type Button and whose element attribute is the key information identifier index. The element attribute value is "1"<node index="1"text="login"resource-id=""class="android. widget.Button"package="com.ftsafe.otp.activity"content-desc=""checkable="false"checked="false"clickable="true"enabled="true"focusable="true"focused="false "scrollable="false" long-clickable="false" password="false" selected="false" bounds="[375,472][705,616]"/>, execute step 325;
步骤325:获取与视图类型和关键信息匹配的活动组件元素的元素坐标信息;Step 325: Obtain the element coordinate information of the active component element matching the view type and key information;
例如:获取与视图类型“TextView”和关键信息“挑战应答型”匹配的活动组件元素<node index="1"text="登录"resource-id=""class="android.widget.Button"package="com.ftsafe.otp.activity"content-desc=""checkable="false"checked="false"clickable="true"enabled="true"focusable="true"focused="false"scrollable="false"long-clickable="false"password="false"selected="false"bounds="[375,472][705,616]"/>的元素坐标信息:bounds="[375,472][705,616]"。For example: get the active component element matching the view type "TextView" and the key information "challenge-response type"<node index="1"text="login"resource-id=""class="android.widget.Button"package ="com.ftsafe.otp.activity"content-desc=""checkable="false"checked="false"clickable="true"enabled="true"focusable="true"focused="false"scrollable="false "long-clickable="false"password="false"selected="false"bounds="[375,472][705,616]"/> element coordinate information: bounds="[375,472][705,616]".
步骤326:根据与视图类型和关键信息匹配的活动组件元素的元素坐标信息计算第七焦点位置;Step 326: Calculate the seventh focus position according to the element coordinate information of the active component element matching the view type and key information;
具体地,根据第七算法对与视图类型和关键信息匹配的活动组件元素的元素坐标信息进行计算得到第七焦点位置。Specifically, the element coordinate information of the active component element matching the view type and key information is calculated according to the seventh algorithm to obtain the seventh focus position.
例如,根据第七算法对与视图类型和关键信息匹配的活动组件元素的元素坐标信息进行计算得到元素坐标信息的中心点坐标位置,并将元素坐标信息的中心点坐标位置作为第七焦点位置。For example, calculate the element coordinate information of the active component element matching the view type and key information according to the seventh algorithm to obtain the coordinate position of the center point of the element coordinate information, and use the coordinate position of the center point of the element coordinate information as the seventh focus position.
步骤327:根据在第七焦点位置上点击当前页面上的待点击区域。Step 327: According to clicking the area to be clicked on the current page at the seventh focus position.
具体地,根据第七焦点位置组织第六点击命令,将第六点击命令发送给被测设备点击当前页面上的待点击区域。Specifically, the sixth click command is organized according to the seventh focus position, and the sixth click command is sent to the device under test to click the area to be clicked on the current page.
更加具体地,根据第七焦点位置的坐标positionX positionY组织点击命令<adb-s androiddevsn shell input tap positionX positionY>,将第六点击命令发送给被测设备的操作系统,被测设备的操作系统接收到第六点击命令后,根据点击命令中的第七焦点位置点击当前页面上的待点击区域。More specifically, organize the click command <adb-s androiddevsn shell input tap positionX positionY> according to the coordinates positionX positionY of the seventh focus position, and send the sixth click command to the operating system of the device under test, and the operating system of the device under test receives After the sixth click command, click the area to be clicked on the current page according to the seventh focus position in the click command.
当当前被测应用检测到登录按钮被点击后,根据登录结果显示相应登录页面。When the current application under test detects that the login button is clicked, the corresponding login page is displayed according to the login result.
实施例4Example 4
本实施例提供了一种自动化测试装置,如图11所示,包括:第一解析模块01、第一定位模块02、第一获取模块03、第二获取模块04、第一生成模块05、第一转移模块06、第三获取模块07和第一测试模块08;This embodiment provides an automated testing device, as shown in FIG. A transfer module 06, a third acquisition module 07 and a first test module 08;
第一解析模块01,用于解析测试器得到解析结果;The first parsing module 01 is used for parsing the tester to obtain parsing results;
第一定位模块02,用于根据第一解析模块01得到的解析结果从已连接到计算机上的设备中定位被测设备;The first positioning module 02 is used to locate the device under test from the devices connected to the computer according to the analysis result obtained by the first analysis module 01;
本实施例中,计算机上安装有测试器;In this embodiment, a tester is installed on the computer;
第一获取模块03,用于从第一解析模块01得到的解析结果中获取测试器中的当前测试操作;The first obtaining module 03 is used to obtain the current test operation in the tester from the analysis result obtained by the first analysis module 01;
第二获取模块04,用于根据第一获取模块03获取到的当前测试操作得到当前测试操作类型、视图类型和关键信息;The second acquisition module 04 is used to obtain the current test operation type, view type and key information according to the current test operation acquired by the first acquisition module 03;
第一生成模块05,用于在被测设备上生成与被测设备上的当前被测应用的当前页面对应的活动组件元素集合文件;The first generation module 05 is used to generate, on the device under test, an active component element set file corresponding to the current page of the current application under test on the device under test;
第一转移模块06,用于将第一生成模块05生成的活动组件元素集合文件转移到计算机上;The first transfer module 06 is used to transfer the active component element set file generated by the first generation module 05 to the computer;
第三获取模块07,用于根据第二获取模块04获取到的视图类型和关键信息在转移到计算上的活动组件元素集合文件中获取与视图类型和关键信息匹配的活动组件元素;The third obtaining module 07 is used to obtain the active component element matching the view type and key information in the active component element collection file transferred to the calculation according to the view type and key information obtained by the second obtaining module 04;
第一测试模块08,用于根据第三获取模块07获取到的获取结果和第二获取模块04获取到的当前测试操作类型对被测设备进行测试。The first test module 08 is configured to test the device under test according to the acquisition result acquired by the third acquisition module 07 and the current test operation type acquired by the second acquisition module 04 .
本实施例中,测试装置中还可以包括:测试报告模块;In this embodiment, the test device may also include: a test report module;
测试报告模块,用于根据第三获取模块07获取到的获取结果得到测试报告。A test report module, configured to obtain a test report according to the acquisition result acquired by the third acquisition module 07.
进一步地,第一测试模块08,可以具体用于当第二获取模块04获取到的当前测试操作类型为点击操作时,判断第三获取模块07是否获取到与视图类型和关键信息匹配的活动组件元素,如果是,则根据与视图类型和关键信息匹配的活动组件元素的元素坐标信息得到当前页面上的待点击区域的焦点位置,在焦点位置上点击当前页面上的待点击区域;Further, the first test module 08 can be specifically used to determine whether the third acquisition module 07 has acquired an active component that matches the view type and key information when the current test operation type acquired by the second acquisition module 04 is a click operation element, if yes, obtain the focus position of the area to be clicked on the current page according to the element coordinate information of the active component element matched with the view type and key information, and click the area to be clicked on the current page at the focus position;
相应地,测试报告模块,具体用于当第一测试模块08判断出第三获取模块07没有获取到与视图类型和关键信息匹配的活动组件元素时,组织包括匹配失败信息的测试报告;当第一测试模块08判断出第三获取模块07获取到与视图类型和关键信息匹配的活动组件元素时,组织包括匹配成功信息的测试报告。Correspondingly, the test report module is specifically used to organize a test report including matching failure information when the first test module 08 judges that the third acquisition module 07 has not acquired an active component element that matches the view type and key information; When a test module 08 determines that the third acquisition module 07 has acquired an active component element that matches the view type and key information, it organizes a test report including matching success information.
本实施例中,第二获取模块04还用于当获取到的当前测试操作类型为输入操作时,根据当前测试操作获取文本内容;相应地:In this embodiment, the second obtaining module 04 is also used to obtain text content according to the current test operation when the obtained current test operation type is an input operation; correspondingly:
第一测试模块08,还可以具体用于判断第三获取模块07是否获取到与视图类型和关键信息匹配的活动组件元素,如果是,则根据与视图类型和关键信息匹配的活动组件元素中的元素坐标信息得到当前页面上的文本输入区域的焦点位置,在焦点位置点击当前页面上的文本输入区域;将文本内容输入到当前页面上的文本输入区域中;The first test module 08 can also be specifically used to judge whether the third acquisition module 07 has acquired an active component element that matches the view type and key information, and if so, according to the active component element that matches the view type and key information The element coordinate information obtains the focus position of the text input area on the current page, clicks the text input area on the current page at the focus position; enters the text content into the text input area on the current page;
测试报告模块,具体用于当第一测试模块08判断出第三获取模块07没有获取到与视图类型和关键信息匹配的活动组件元素时,组织包括匹配失败信息的测试报告;当第一测试模块08判断出第三获取模块07获取到与视图类型和关键信息匹配的活动组件元素时,组织包括匹配成功信息的测试报告。The test report module is specifically used to organize a test report including matching failure information when the first test module 08 judges that the third acquisition module 07 has not acquired an active component element that matches the view type and key information; when the first test module 08. When it is judged that the third acquisition module 07 has acquired the active component element that matches the view type and key information, organize a test report including matching success information.
本实施例中,第一测试模块08,又可以具体用于当第二获取模块04获取到的当前测试操作类型为断言操作时,判断第三获取模块07是否获取到与视图类型和关键信息匹配的活动组件元素;In this embodiment, the first test module 08 can also be specifically used to determine whether the third acquisition module 07 has acquired a key information that matches the view type and key information when the current test operation type acquired by the second acquisition module 04 is an assertion operation. The active component element of the ;
相应地,测试报告模块,具体用于当第一测试模块08判断出第三获取模块07没有获取到与视图类型和关键信息匹配的活动组件元素时,组织包括匹配失败信息的测试报告;当第一测试模块08判断出第三获取模块07获取到与视图类型和关键信息匹配的活动组件元素时,组织包括匹配成功信息的测试报告。Correspondingly, the test report module is specifically used to organize a test report including matching failure information when the first test module 08 judges that the third acquisition module 07 has not acquired an active component element that matches the view type and key information; When a test module 08 determines that the third acquisition module 07 has acquired an active component element that matches the view type and key information, it organizes a test report including matching success information.
本实施例中,测试装置中还可以包括:第一判断模块;In this embodiment, the test device may further include: a first judging module;
第三获取模块07具体包括:第三获取单元和第一判断单元;The third acquiring module 07 specifically includes: a third acquiring unit and a first judging unit;
第一获取模块,具体用于从第一解析模块01获取到的解析结果中获取测试器中的测试操作,将测试器的第一测试操作作为当前测试操作;The first obtaining module is specifically used to obtain the test operation in the tester from the analysis result obtained by the first analysis module 01, and use the first test operation of the tester as the current test operation;
第二获取模块04,用于根据第一获取模块03获取到的当前测试操作得到当前测试操作类型、视图类型和关键信息;当前测试操作类型包括:点击操作、输入操作和断言操作中的至少一种;The second acquisition module 04 is used to obtain the current test operation type, view type and key information according to the current test operation acquired by the first acquisition module 03; the current test operation type includes: at least one of click operation, input operation and assertion operation kind;
第三获取单元,用于根据第二获取模块04获取到的视图类型和关键信息在活动组件元素集合文件中获取与视图类型和关键信息匹配的活动组件元素;The third obtaining unit is used to obtain the active component element matching the view type and key information in the active component element collection file according to the view type and key information obtained by the second obtaining module 04;
第一判断单元,判断第三获取单元是否获取到与视图类型和关键信息匹配的活动组件元素;The first judging unit judges whether the third acquiring unit has acquired the active component element matching the view type and key information;
第一测试模块08,具体用于当第一判断单元判断为是后:The first test module 08 is specifically used when the first judging unit judges as yes:
若当前测试操作为点击操作,则根据第三获取单元获取到的与视图类型和关键信息匹配的活动组件元素的元素坐标信息得到当前页面上的待点击区域的焦点位置,在焦点位置上点击当前页面上的待点击区域;If the current test operation is a click operation, the focus position of the area to be clicked on the current page is obtained according to the element coordinate information of the active component element matched with the view type and key information obtained by the third acquisition unit, and the current click is clicked on the focus position. The area to be clicked on the page;
若当前测试操作为输入操作,则根据与视图类型和关键信息匹配的活动组件元素的元素坐标信息得到当前页面上的文本输入区域的焦点位置,在焦点位置点击当前页面上的文本输入区域;将文本内容输入到当前页面上的文本输入区域中;If the current test operation is an input operation, the focus position of the text input area on the current page is obtained according to the element coordinate information of the active component element matching the view type and key information, and the text input area on the current page is clicked at the focus position; Text content is entered into the text input area on the current page;
第一判断模块,用于若当前测试操作为点击操作,则在第一测试模块08在焦点位置上点击当前页面上的待点击区域之后,判断当前测试操作是否为测试器中的最后一个测试操作;若当前测试操作为输入操作,则在第一测试模块08在将文本内容输入到当前页面上的文本输入区域中之后,判断当前测试操作是否为测试器中的最后一个测试操作;若当前测试操作为断言操作,则判断当前测试操作是否为测试器中的最后一个测试操作;The first judgment module is used to judge whether the current test operation is the last test operation in the tester after the first test module 08 clicks the area to be clicked on the current page on the focus position if the current test operation is a click operation ; If the current test operation is an input operation, then after the first test module 08 inputs the text content in the text input area on the current page, judge whether the current test operation is the last test operation in the tester; if the current test If the operation is an assertion operation, it is judged whether the current test operation is the last test operation in the tester;
第二获取模块04,还用于当第一判断模块判断为否后,将测试器中的当前测试操作的下一个测试操作作为当前测试操作;根据当前测试操作得到当前测试操作类型,根据当前测试操作获取视图类型和关键信息。The second acquisition module 04 is also used to use the next test operation of the current test operation in the tester as the current test operation when the first judgment module judges as no; The operation gets the view type and key information.
进一步地,还可以包括:测试报告模块;测试报告模块包括第一保存单元和第一报告单元;Further, it may also include: a test report module; the test report module includes a first storage unit and a first report unit;
第一保存单元,用于保存第三获取单元的获取结果;a first storage unit, configured to store the acquisition result of the third acquisition unit;
第一报告单元,用于当第一判断模块判断为是后,根据第一保存单元保存的所有获取结果得到测试报告;以及当第一判断单元判断为否后,根据第一保存单元保存的所有获取结果得到测试报告。The first reporting unit is used to obtain a test report according to all the acquisition results stored by the first storage unit when the first judging module judges yes; Get results Get test reports.
本实施例中,点击操作可以包括文本点击操作和按钮点击操作。In this embodiment, the click operation may include a text click operation and a button click operation.
本实施例中,第一测试模块08可以具体包括:第四获取单元、第一点击单元;In this embodiment, the first test module 08 may specifically include: a fourth acquisition unit, a first click unit;
第四获取单元,用于若当前测试操作为点击操作,则根据第三获取模块07获取到的与视图类型和关键信息匹配的活动组件元素的元素坐标信息得到当前页面上的待点击区域的焦点位置;The fourth acquisition unit is used to obtain the focus of the area to be clicked on the current page according to the element coordinate information of the active component element matched with the view type and key information acquired by the third acquisition module 07 if the current test operation is a click operation Location;
第一点击单元,用于根据第四获取单元获取到的焦点位置组织点击命令,将点击命令发送给被测设备点击当前页面上的待点击区域。The first click unit is configured to organize click commands according to the focus position acquired by the fourth acquisition unit, and send the click commands to the device under test to click the area to be clicked on the current page.
进一步地,第一点击单元,具体用于根据第四获取单元获取到的焦点位置的坐标组织点击命令,将点击命令发送给被测设备的操作系统,被测设备的操作系统接收到点击命令后,根据点击命令中的焦点位置的坐标点击当前页面上的待点击区域。Further, the first click unit is specifically configured to organize the click command according to the coordinates of the focus position acquired by the fourth acquisition unit, and send the click command to the operating system of the device under test, and the operating system of the device under test receives the click command , click the area to be clicked on the current page according to the coordinates of the focus position in the click command.
本实施例中,第一测试模块08还可以具体包括:第五获取单元、第二点击单元和第一输入单元;In this embodiment, the first testing module 08 may also specifically include: a fifth acquiring unit, a second clicking unit, and a first input unit;
第五获取单元,用于若当前测试操作为输入操作,则根据第三获取模块07获取到的与视图类型和关键信息匹配的活动组件元素的元素坐标信息得到当前页面上的文本输入区域的焦点位置,The fifth acquisition unit is used to obtain the focus of the text input area on the current page according to the element coordinate information of the active component element matched with the view type and key information acquired by the third acquisition module 07 if the current test operation is an input operation Location,
第二点击单元,用于根据第五获取单元获取到的焦点位置组织点击命令,将点击命令发送给被测设备点击当前页面上的文本输入区域;The second click unit is configured to organize a click command according to the focus position acquired by the fifth acquisition unit, and send the click command to the device under test to click the text input area on the current page;
第一输入单元,用于组织包括文本内容的文本输入命令,将文本输入命令发送给被测设备将文本内容输入到当前页面上的文本输入区域中。The first input unit is configured to organize text input commands including text content, and send the text input commands to the device under test to input the text content into the text input area on the current page.
进一步地,第二点击单元,具体用于根据第五获取单元获取到的焦点位置的坐标组织点击命令,将点击命令发送给被测设备的操作系统,被测设备的操作系统接收到点击命令后,根据点击命令中的焦点位置的坐标点击当前页面上的文本输入区域;Further, the second click unit is specifically used to organize the click command according to the coordinates of the focus position acquired by the fifth acquisition unit, and send the click command to the operating system of the device under test, and the operating system of the device under test receives the click command , click the text input area on the current page according to the coordinates of the focus position in the click command;
第一输入单元,具体用于组织包括文本内容的文本输入命令,将文本输入命令发送给被测设备的操作系统,被测设备的操作系统接收到文本输入命令后,将文本输入命令中的文本内容输入到当前页面上的文本输入区域中。The first input unit is specifically used to organize text input commands including text content, send the text input commands to the operating system of the device under test, and after the operating system of the device under test receives the text input commands, input the text in the command Content is entered into the text input area on the current page.
本实施例中,第二获取模块04,还用于当当前测试操作为输入操作时,根据当前测试操作获取文本内容。In this embodiment, the second obtaining module 04 is further configured to obtain text content according to the current test operation when the current test operation is an input operation.
本实施例中,第二获取模块04可以包括:第一获取单元和第二获取单元;In this embodiment, the second acquisition module 04 may include: a first acquisition unit and a second acquisition unit;
第一获取单元,用于判断测试器中的当前测试代码类型,若当前测试代码为第一函数或第四函数,则当前测试操作类型为点击操作;若当前测试代码为第二函数,则当前测试操作类型为输入操作;若当前测试代码为第三函数,则当前测试操作类型为断言操作;The first acquisition unit is used to judge the current test code type in the tester. If the current test code is the first function or the fourth function, the current test operation type is a click operation; if the current test code is the second function, the current test code is the second function. The test operation type is an input operation; if the current test code is a third function, the current test operation type is an assertion operation;
第二获取单元,用于根据当前测试操作获取视图类型和关键信息。The second obtaining unit is used to obtain the view type and key information according to the current test operation.
33、根据权利要求32的装置,其特征在于,第二获取单元具体用于:33. The device according to claim 32, wherein the second acquisition unit is specifically used for:
若当前测试代码为第一函数时,获取第一函数中第一参数和第二参数,将第一参数作为视图类型,将第二参数作为关键信息;If the current test code is the first function, obtain the first parameter and the second parameter in the first function, use the first parameter as the view type, and use the second parameter as the key information;
若当前测试代码为第二函数时,获取第二函数中第三参数和第四参数,将第三参数作为视图类型,将第四参数作为关键信息;If the current test code is the second function, obtain the third parameter and the fourth parameter in the second function, use the third parameter as the view type, and use the fourth parameter as the key information;
若当前测试代码为第三函数时,获取第三函数中第五参数和第六参数,将第五参数作为视图类型,将第六参数作为关键信息;If the current test code is the third function, obtain the fifth parameter and the sixth parameter in the third function, use the fifth parameter as the view type, and use the sixth parameter as the key information;
若当前测试代码为第四函数时,获取第四函数中第七参数和第八参数,将第七参数作为视图类型,将第八参数作为关键信息。If the current test code is the fourth function, obtain the seventh parameter and the eighth parameter in the fourth function, use the seventh parameter as the view type, and use the eighth parameter as key information.
本实施例中,第一生成模块05包括:第一组织单元、第一发送单元、第一接收单元、第二判断单元、第一报错单元;In this embodiment, the first generating module 05 includes: a first organizing unit, a first sending unit, a first receiving unit, a second judging unit, and a first error reporting unit;
第一转移模块06包括:第二组织单元、第二发送单元、第二接收单元、第三判断单元和第二报错单元;The first transfer module 06 includes: a second organization unit, a second sending unit, a second receiving unit, a third judging unit and a second error reporting unit;
第一组织单元,用于根据被测设备的设备标识组织第一生成命令;The first organization unit is used to organize the first generation command according to the device identification of the device under test;
第一发送单元,用于将第一组织单元组织的第一生成命令发送给被测设备的操作系统;The first sending unit is configured to send the first generation command organized by the first organization unit to the operating system of the device under test;
第二判断单元,用于判断第一接收单元是否接收到来自被测设备的操作系统的生成失败应答;若为否,则判断在被测设备上成功生成与当前被测应用的当前页面对应的活动组件元素集合文件;The second judging unit is used to judge whether the first receiving unit has received a generation failure response from the operating system of the device under test; Activity component element collection file;
第一报错单元,用于当第二判断单元判断为是后,报错;The first error reporting unit is used to report an error after the second judging unit judges yes;
第二组织单元,用于根据被测设备的设备标识组织第一转移命令;The second organization unit is used to organize the first transfer command according to the device identification of the device under test;
第二发送单元,用于将第二组织单元组织的第一转移命令发送给被测设备的操作系统;The second sending unit is configured to send the first transfer command organized by the second organization unit to the operating system of the device under test;
第三判断单元,用于判断第二接收单元是否接收到来自被测设备的操作系统的转移失败应答;若为否,则判断出将活动组件元素集合文件成功转移到计算机上;The third judging unit is used to judge whether the second receiving unit has received a transfer failure response from the operating system of the device under test; if not, it is judged that the active component element set file is successfully transferred to the computer;
第二报错单元,还用于当第三判断单元判断为是后,报错。The second error reporting unit is also used to report an error after the third judging unit judges yes.
本实施例中,关键信息包括关键信息标识和关键信息值;In this embodiment, the key information includes a key information identifier and a key information value;
第三获取模块07,具体用于根据视图类型和关键信息标识和关键信息值在活动组件元素集合文件中查找元素属性中的元素类型与视图类型匹配且元素属性为关键信息标识,元素属性值为关键信息值的活动组件元素,若查找到,则判断出获取到与视图类型和关键信息匹配的活动组件元素;否则,判断出没有获取到与视图类型和关键信息匹配的活动组件元素。The third acquisition module 07 is specifically used to search the active component element collection file according to the view type, key information identifier and key information value. The element type in the element attribute matches the view type and the element attribute is the key information identifier, and the element attribute value is If the active component element of the key information value is found, it is judged that the active component element matching the view type and key information is obtained; otherwise, it is judged that the active component element matching the view type and key information is not obtained.
本实施例提供了一种自动化测试装置:通过解析测试器,根据测试器中的当前测试操作获取当前测试操作类型、视图类型和关键信息,通过对被测设备的被测应用程序的界面分析获取界面中的与视图类型和关键信息匹配的活动组件元素,根据获取到活动组件元素中的信息和当前测试操作类型完成对被测设备的被测应用程序界面的测试操作,提高了测试的效率。This embodiment provides an automated testing device: by analyzing the tester, the current test operation type, view type and key information are obtained according to the current test operation in the tester, and obtained by analyzing the interface of the application program under test of the device under test. The active component element in the interface that matches the view type and key information completes the test operation of the tested application program interface of the device under test according to the information obtained in the active component element and the current test operation type, thereby improving the test efficiency.
以上所述,仅为本发明较佳的具体实施方式,但本发明的保护范围并不局限于此,任何熟悉本技术领域的技术人员在本发明公开的技术范围内,可轻易想到的变化或替换,都应涵盖在本发明的保护范围之内。因此,本发明的保护范围应该以权利要求的保护范围为准。The above is only a preferred embodiment of the present invention, but the scope of protection of the present invention is not limited thereto, any changes or variations that can be easily conceived by those skilled in the art within the technical scope disclosed in the present invention Replacement should be covered within the protection scope of the present invention. Therefore, the protection scope of the present invention should be determined by the protection scope of the claims.
Claims (34)
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810153211.7A CN108388513B (en) | 2018-02-09 | 2018-02-09 | Automatic testing method and device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810153211.7A CN108388513B (en) | 2018-02-09 | 2018-02-09 | Automatic testing method and device |
Publications (2)
Publication Number | Publication Date |
---|---|
CN108388513A true CN108388513A (en) | 2018-08-10 |
CN108388513B CN108388513B (en) | 2021-06-08 |
Family
ID=63069001
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201810153211.7A Expired - Fee Related CN108388513B (en) | 2018-02-09 | 2018-02-09 | Automatic testing method and device |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN108388513B (en) |
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110139302A (en) * | 2019-05-17 | 2019-08-16 | 广州品唯软件有限公司 | A kind of app type of service localization method and device |
CN112015662A (en) * | 2020-09-09 | 2020-12-01 | 深圳市通久电子有限公司 | Automatic test method, system and equipment for video terminal interface menu function |
CN113568688A (en) * | 2020-04-29 | 2021-10-29 | RealMe重庆移动通信有限公司 | View switching method and device, electronic equipment and storage medium |
Family Cites Families (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN105320595A (en) * | 2014-07-31 | 2016-02-10 | 腾讯科技(深圳)有限公司 | Application test method and device |
CN104717337B (en) * | 2015-04-03 | 2018-03-02 | 杭州昕云信息科技有限公司 | A kind of method of batch testing mobile phone application and its equipment used |
-
2018
- 2018-02-09 CN CN201810153211.7A patent/CN108388513B/en not_active Expired - Fee Related
Cited By (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN110139302A (en) * | 2019-05-17 | 2019-08-16 | 广州品唯软件有限公司 | A kind of app type of service localization method and device |
CN113568688A (en) * | 2020-04-29 | 2021-10-29 | RealMe重庆移动通信有限公司 | View switching method and device, electronic equipment and storage medium |
CN113568688B (en) * | 2020-04-29 | 2023-06-06 | RealMe重庆移动通信有限公司 | View switching method and device, electronic equipment and storage medium |
CN112015662A (en) * | 2020-09-09 | 2020-12-01 | 深圳市通久电子有限公司 | Automatic test method, system and equipment for video terminal interface menu function |
CN112015662B (en) * | 2020-09-09 | 2022-03-15 | 深圳市通久电子有限公司 | Automatic testing method, system and equipment for menu function of video terminal interface |
Also Published As
Publication number | Publication date |
---|---|
CN108388513B (en) | 2021-06-08 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US8701092B1 (en) | System and method for testing applications | |
WO2020119430A1 (en) | Protocol interface test method, device, computer device and storage medium | |
CN108683562B (en) | Anomaly detection and positioning method, device, computer equipment and storage medium | |
CN106844217B (en) | Method and device for embedding point of applied control and readable storage medium | |
WO2020220638A1 (en) | Method and apparatus for associating link system with log system, and storage medium | |
CN106294134B (en) | The collapse localization method and device of code | |
US20140359362A1 (en) | Information interaction test device and method based on automatic generation of associated test cases | |
CN108509339A (en) | Method for generating test case, device based on browser and mind map and equipment | |
CN107679051B (en) | Transaction system error-detecting method and device | |
EP2891041B1 (en) | User interface apparatus in a user terminal and method for supporting the same | |
WO2020082673A1 (en) | Invoice inspection method and apparatus, computing device and storage medium | |
CN111158998B (en) | Buried point data display method and device | |
WO2019223056A1 (en) | Gesture recognition-based teaching and learning method and apparatus | |
CN108388513A (en) | A kind of automated testing method and device | |
CN102707958B (en) | A kind of interface generation method of calibration and equipment based on open platform | |
CN104408050A (en) | Online automatic interpretation system and method of test data | |
US20050228621A1 (en) | Terminal emulation program, storage medium, load test method, load test apparatus, and load test system | |
CN109948107A (en) | Area surface integral calculation method, device, equipment and storage medium | |
CN109359282A (en) | Listings data introduction method, device, computer equipment and storage medium | |
CN108399125A (en) | Automated testing method, device, computer equipment and storage medium | |
US8112411B2 (en) | Method and system for providing search results | |
CN115481025A (en) | Script recording method and device for automatic test, computer equipment and medium | |
WO2020259034A1 (en) | Method, apparatus, and device for identifying offline source code, and storage medium | |
CN110659191A (en) | Buried point data analysis method and device, computer equipment and storage medium | |
CN118503114A (en) | Application program testing method and device, computer equipment and readable storage medium |
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 | ||
GR01 | Patent grant | ||
GR01 | Patent grant | ||
CF01 | Termination of patent right due to non-payment of annual fee |
Granted publication date: 20210608 |
|
CF01 | Termination of patent right due to non-payment of annual fee |