WO2019019628A1 - 移动应用的测试方法、装置、测试设备及介质 - Google Patents

移动应用的测试方法、装置、测试设备及介质 Download PDF

Info

Publication number
WO2019019628A1
WO2019019628A1 PCT/CN2018/077224 CN2018077224W WO2019019628A1 WO 2019019628 A1 WO2019019628 A1 WO 2019019628A1 CN 2018077224 W CN2018077224 W CN 2018077224W WO 2019019628 A1 WO2019019628 A1 WO 2019019628A1
Authority
WO
WIPO (PCT)
Prior art keywords
test
text box
jump
page
text
Prior art date
Application number
PCT/CN2018/077224
Other languages
English (en)
French (fr)
Inventor
张二雷
Original Assignee
平安科技(深圳)有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 平安科技(深圳)有限公司 filed Critical 平安科技(深圳)有限公司
Publication of WO2019019628A1 publication Critical patent/WO2019019628A1/zh

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/362Software debugging
    • G06F11/3644Software debugging by instrumenting at runtime

Definitions

  • the present application belongs to the technical field of testing, and in particular, to a test method, device, test device and medium for a mobile application.
  • Functional testing is the most basic part of the testing process. It involves testing each control in the application to determine if the control can execute normally. However, for the control of the text box, multiple text boxes may appear in one page of the mobile application. To test whether each text box can be executed one by one, the tester needs to input a specific one in each text box. After the character, click the corresponding confirmation button, and then observe whether the jump page is normal. After that, return to the initial page and re-do the above. Therefore, the test steps in the prior art are cumbersome, resulting in a relatively low test efficiency of the mobile application.
  • the embodiments of the present application provide a test method, an apparatus, a test device, and a medium for a mobile application, so as to solve the problem that the test procedure is cumbersome and the test efficiency is low in the prior art.
  • a first aspect of the embodiments of the present application provides a testing method for a mobile application, including:
  • test text corresponding to the text box, where the test text includes at least one test character
  • a second aspect of an embodiment of the present application provides a testing apparatus for a mobile application, the testing apparatus comprising means for performing the testing method of the mobile application of the first aspect described above.
  • a third aspect of an embodiment of the present application provides a test device for a mobile application, comprising a memory and a processor, wherein the memory stores computer readable instructions executable on the processor, the processor executing the The steps of the test method of the mobile application as described in the first aspect are implemented when the computer readable instructions are described.
  • a fourth aspect of the embodiments of the present application provides a computer readable storage medium storing computer readable instructions, the computer readable instructions being executed by a processor to implement the first aspect as described in the first aspect The steps of the mobile application's test method.
  • the embodiment of the present application can determine, according to the key coordinates of each test character in the test text, each virtual button that needs to perform an analog click from the pre-activated virtual keyboard; and perform analog clicks and jumps in each virtual button in turn.
  • the page image is intelligently recognized, and the automatic input of test characters is realized, and the functional test of the text box is quickly completed. Because testers no longer need to manually perform control clicks and return operations, the operational complexity and cumbersomeness of mobile application testing are reduced, and the testing efficiency of mobile applications is improved.
  • FIG. 1 is a flowchart of an implementation of a test method for a mobile application according to Embodiment 1 of the present application;
  • FIG. 2 is a schematic diagram of screen focus positioning of a test method for a mobile application according to Embodiment 1 of the present application;
  • FIG. 3 is a specific implementation flowchart of a testing method S105 of a mobile application according to Embodiment 1 of the present application;
  • FIG. 5 is a flowchart of an implementation of a test method for a mobile application provided in Embodiment 4 of the present application;
  • FIG. 6 is a flowchart of implementing a testing method of a mobile application provided in Embodiment 5 of the present application;
  • FIG. 7 is a structural block diagram of a testing apparatus for a mobile application according to Embodiment 6 of the present application.
  • FIG. 8 is a schematic diagram of a test device for a mobile application provided in Embodiment 7 of the present application.
  • FIG. 1 shows an implementation flow of a test method for a mobile application provided by an embodiment of the present application, where the method flow includes steps S101 to S105.
  • the specific implementation principles of each step are as follows:
  • the test page is a page displayed in the application running on the mobile terminal, which contains multiple controls.
  • the above controls include, but are not limited to, user interface controls, image processing controls, and document processing controls.
  • the user interface controls may be, for example, buttons, text boxes, charts, and drop-down menus.
  • the text box in the test page is located according to the central coordinates of each text box pre-stored.
  • the step of activating the text box in the test page includes: moving any focus to a page position corresponding to the center coordinate of the text box; performing a selection instruction to complete the pair The activation of this text box.
  • the test page in the application is an HTML page.
  • the way to locate the text box in the test page includes, but is not limited to, tagName, Xpath, and cssSelector. For example, if the label name of each element in the test page can be detected and the element whose label name is "input" is determined, the element is the text box in the test page.
  • test text corresponding to the text box, where the test text includes at least one test character.
  • test text corresponding to each text box in the mobile application can be generated in real time or written by the tester in advance. If the test text is generated in real time, after determining the currently activated text box, the test text matching the input rule is generated according to the input rule of the text box. And, for each test text generated, it is stored in the specified directory, so that when the text box of the same input rule is activated again, the test text can be directly retrieved and used.
  • the test text contains one or more test characters arranged in sequence, and the test characters include characters such as Chinese, English, numbers, and punctuation.
  • Each test text is used to perform a test operation of the text box, that is, after inputting each test character in the test text into the text box, a jump operation will be performed.
  • S103 Determine, according to the button coordinates corresponding to each of the test characters, a virtual button that matches each of the button coordinates in the pre-activated virtual keyboard.
  • the virtual keyboard represents a keyboard that is simulated by software, and the keyboard is displayed on the display interface of the mobile terminal.
  • the virtual keyboard is a soft keyboard that comes with the Android system.
  • the virtual keyboard contains virtual keys of various characters, and each virtual key corresponds to a preset key coordinate.
  • each test character in the test text is read, and according to the correspondence between the preset character and the key coordinate, the key coordinates of each test character are obtained, and based on the obtained key coordinates, the virtual keyboard is determined.
  • the virtual button corresponding to the button coordinates.
  • the tester in order to visually verify the test process, it is convenient for the tester to observe the positioning process of the virtual button.
  • the terminal device running the mobile application is the terminal device of the Android system
  • the Android system is started. After the coordinate positioning function, the position coordinates corresponding to the current focus of the screen will be displayed at the top of the display interface of the mobile terminal.
  • the position of the screen focus is indeed the position where the virtual button is located, indicating that the virtual button is positioned accurately.
  • S104 Perform an analog click on the virtual button corresponding to each test character in sequence according to the appearance order of the test characters in the test text, to input the test character in the text box.
  • Each test character in the test text is sequentially read, and after each test character is read and the virtual key corresponding to the test character is determined, the virtual button is pressed by the preset DOWN_AND_UP method by calling the preset monkeyrunner software. After the simulated action of the bounce, the simulated click on the virtual button is completed.
  • each virtual key in the virtual keyboard When it is detected that each virtual key in the virtual keyboard is clicked, the character corresponding to the virtual key is input to the text box activated at the current time.
  • the virtual keys corresponding to each test character are simulated. After the click is completed, the test characters in the test text will be displayed in the input box.
  • S105 Acquire a jump event corresponding to the text box after the test character input is completed, and perform recognition processing on the jump event to obtain a test result based on the text box.
  • each text box in the test page there are controls for jumping to a new page or jumping to other locations on the page, such as determining a button, logging in a button, searching for a button, and the like.
  • the text box is associated with its neighboring controls.
  • the control in the test page is positioned and activated according to the preset coordinates or the control ID of the control associated with the text box, thereby executing the text box Associated control selection operations.
  • the focus shift of the current display interface is completed according to the jump condition corresponding to the control.
  • the jump event is identified by a preset algorithm to determine whether the page test result of the text box is normal.
  • the preset algorithm may be: obtaining a link address of a control associated with the text box; determining whether the page address corresponding to the jump page is the same as the link address; if the page address corresponding to the jump page is related to the link If the address is the same, it is determined that the test result based on the text box is normal; if the page address corresponding to the jump page is different from the link address, it is determined that the page test result based on the text box is a test abnormality.
  • FIG. 3 shows a specific implementation process of the testing method S105 of the mobile application provided in Embodiment 1 of the present application, which is described in detail as follows:
  • S1051 Acquire a jump page corresponding to the text box after the test character input is completed.
  • the jump event is a page jump event.
  • the test characters contained in the text box are encapsulated into the above page request and uploaded to the background server of the mobile application.
  • S1052 Perform a screenshot processing on the jump page to obtain a jump page image.
  • the screenshot of the current time jump page is completed based on the takeSnapshot method provided by the above monkeyrunner software.
  • the image obtained by the screenshot is the jump page image.
  • each text box in the test page a jump page image obtained by the text box in a normal jump state is pre-stored, and the jump page image is a reference jump page image.
  • each text box in the test page corresponds to a control ID.
  • a reference jump page image associated with the control ID is matched from the preset reference jump page image storage directory.
  • the size and resolution of the reference jump page image are the same as the display page size and the resolution size of the mobile terminal.
  • S1054 Calculate an image similarity between the jump page image and the reference jump page image by using a preset image comparison algorithm.
  • Image contrast algorithms include, but are not limited to, Scale Invariant Feature Transform (SIFT), bilinear image similarity matching algorithm based on depth feature analysis, and OpenCV image similarity ORB algorithm.
  • SIFT Scale Invariant Feature Transform
  • bilinear image similarity matching algorithm based on depth feature analysis
  • OpenCV image similarity ORB algorithm OpenCV image similarity ORB algorithm.
  • the image comparison algorithm can be used to identify the obtained jump page image and the reference jump page image, and the image similarity between the two can be obtained.
  • calculating image similarity between the jump page image and the reference jump page image may specifically include: respectively calculating respective pixels in the jump page image and the reference jump page image a gray value of the point; obtaining a first average gray value of the jump page image and a second average gray value of the reference jump page image; calculating a gray value of each pixel in the jump page image and the first average a first difference value of the gray value and a second difference between the gray value of each pixel in the reference jump page image and the second average gray value; based on the obtained first difference and the second The difference value is calculated as a hash value corresponding to the jump page image and the reference jump page image, and the difference between the two hash values is determined as the image similarity.
  • the jump page image and the reference jump page image are the same image, or the jump page image and the reference jump page image may be considered to be the same. image. It can be seen that the jump page returned after the simulation click is completed is the page in the normal response state, so the test result based on the page of the above text box is normal.
  • the image similarity is less than the first threshold, it indicates that the jump page image and the reference jump page image are different images.
  • the jump page returned after the simulation click is completed is the page in the abnormal response state, so the page test result based on the above text box is a test exception, and the exception type is a response error.
  • a jump page image can be obtained, thereby being able to use the image comparison algorithm to calculate the image similarity of the jump page image and the reference jump page image corresponding to the text box. .
  • the image similarity is lower than the first threshold, it can be determined that an abnormality occurs in the return page at the current time, thereby realizing automatic recognition of the page test result.
  • the type of the abnormality of the page test result is further determined. As shown in FIG. 4, after the above S104, the method further includes:
  • the jump page is started to be loaded.
  • the mobile terminal will begin to gradually load the various page elements in the jump page.
  • the current time point is recorded, and the time point is determined as the second time.
  • the difference between the second moment and the first moment includes the webpage request processing time of the remote server and the network transmission time. If the difference is greater than the second threshold, it indicates that the processing time of the webpage request is too long or the network delay is large. Therefore, the test result of the text box based on the text box is determined to be a test exception, and the specific exception type is a response timeout.
  • the difference between the third moment and the first moment is the total time required to jump to the page. If the difference reaches the third threshold, the jump page is still not loaded, indicating that the total time taken to jump the page is too long, and the network interrupt may occur or the page cannot be returned normally. Therefore, the text box-based page test is determined. The result is a test exception, and the specific exception type is also recorded as a response timeout.
  • the function test accuracy of the page can be further determined by determining whether the jump page response process and the required time consumption of the loading process are greater than a preset threshold.
  • the ability to simulate the user's experience when actually using the page can be simulated by calculating the delay.
  • the time consumption is greater than the preset threshold, the specific abnormal type corresponding to the test abnormality can be automatically recognized, thereby achieving a more comprehensive automatic test effect.
  • the processing method when the page test result is abnormal is further defined.
  • the test method of the mobile application further includes:
  • test abnormality includes the response error and the response timeout.
  • test log storage directory corresponding to the text box is generated in the specified storage path, and the test process related to the text box is recorded.
  • the test information obtained in the test includes the test text used in the test process, each time node in the test process, the page test exception type, the jump page image, the reference jump page image, the image similarity, and the cause of the abnormality.
  • the test text and the jump page image obtained by the screenshot processing are stored in the specified test log storage directory by calling the writeToFile method preset in the monkeyrunner software.
  • the tester can quickly find the text box in which the test exception occurs and its corresponding test information based on the test log storage directory, so that the tester can analyze and summarize the test results. and.
  • the tester can manually perform the test character input operation based on the text box again according to the test text, and further determines the accuracy of the automated page test result.
  • the processing method when the page test result is abnormal is further defined.
  • the test method of the mobile application further includes:
  • the input rule indicates the character type of the character that can be entered in the text box and the number of characters.
  • Each text box in the test page has its corresponding input rules.
  • the Xpath and the variable definition of each control in the mobile application test page can be read. If the control in the test page is an input box, its variable definition contains input rules.
  • the Xpath and variable definition for each control in the test page can be obtained from the following file running the mobile terminal: Android-SDK ⁇ tools ⁇ uiautomatorviewer.bat.
  • the input rules are identified and processed to obtain mutually exclusive rules for input rules. For example, if the input rule is an English letter, the obtained mutual exclusion rule is a non-English letter.
  • the mutual exclusion rule is input into a preset random character generation algorithm to generate a random character, and the total number of characters of the random character is also a random number.
  • the key coordinates corresponding to each random character are sequentially acquired, and each key coordinate is determined in the virtual keyboard displayed on the display interface.
  • the virtual button represented. After the virtual button is pressed and the two finger touch simulation actions are triggered by calling the DOWN_AND_UP method, the simulated click of the virtual button corresponding to the random character is completed.
  • the input box value of the control ID can be monitored in real time by means of jquery or the like in the prior art.
  • the value of the input box detected in real time is "null", that is, a null value, it means that the random character generated in the above step S113 that does not match the input rule is not successfully input into the text box, and therefore, the text box can be determined.
  • the input restriction conditions take effect and the input function of the text box is tested normally.
  • the input box value detected in real time includes a specific character, that is, a non-null value, it indicates that the random character generated in the above step S113 that does not match the input rule has been successfully input into the text box, so the text box can be determined.
  • the input constraints are invalid. It can be seen that the user can also input illegal characters into the text box, thereby easily causing data anomalies in the subsequent processing of the mobile application. Therefore, it is determined that the input function of the text box is tested abnormally.
  • the illegal character input operation of the user can be simulated; the input box value in the text box is In the case of a null value, the page test result can be automatically recognized as an input abnormality, which improves the test efficiency of the mobile application.
  • FIG. 7 is a structural block diagram of the test device of the mobile application provided by the embodiment of the present application. For the convenience of description, only the related to the embodiment of the present application is shown. section.
  • the apparatus includes:
  • the positioning unit 701 is configured to locate a text box in the test page and activate any of the text boxes that have been located.
  • the first obtaining unit 702 is configured to obtain test text corresponding to the text box, where the test text includes at least one test character.
  • the first determining unit 703 is configured to determine, according to the button coordinates corresponding to each of the test characters, a virtual button that matches each of the button coordinates in the pre-activated virtual keyboard.
  • the input unit 704 is configured to perform an analog click on the virtual button corresponding to each test character in sequence according to the appearance order of the test characters in the test text, to input the test in the text box. character.
  • the second obtaining unit 705 is configured to obtain a jump page image obtained after the simulated click is completed, and perform recognition processing on the jump page image to obtain a page test result based on the text box.
  • the second obtaining unit 705 includes:
  • the first obtaining sub-unit is configured to obtain a jump page obtained after the simulated click is completed.
  • the screenshot subunit is configured to perform a screenshot processing on the jump page to obtain a jump page image.
  • a second acquiring subunit configured to acquire a reference jump page image corresponding to the text box.
  • the calculating subunit is configured to calculate an image similarity between the jump page image and the reference jump page image by using a preset image comparison algorithm.
  • Determining a subunit configured to determine, when the image similarity is less than the first threshold, a page test result based on the text box as a response error.
  • the device further includes:
  • the third obtaining unit is configured to acquire a first moment corresponding to when the simulated click is completed.
  • a fourth acquiring unit configured to acquire a second time corresponding to when the jump page starts loading.
  • the fifth obtaining unit is configured to acquire a third moment corresponding to when the jump page is loaded.
  • a second determining unit configured to determine, if the difference between the second time and the first time is greater than a second threshold, or the difference between the third time and the first time is greater than a third threshold
  • the result of the page test is the response timeout.
  • the device further includes:
  • a establishing unit configured to establish a test log storage directory if the page test result of the current time is detected as a test abnormality, where the test abnormality includes the response error and the response timeout.
  • a storage unit configured to store the jump page image and the test text to the test log storage directory.
  • the device further includes:
  • a sixth obtaining unit configured to acquire an input rule corresponding to the text box.
  • An uploading unit configured to generate a random character that does not match the input rule.
  • a simulated click unit configured to perform a simulated click on the virtual button corresponding to the random character in the pre-activated virtual keyboard.
  • the detecting unit is configured to detect whether the input box value of the text box is a null value.
  • a third determining unit configured to determine that the page test result is an input abnormality if the input box value is a non-null value.
  • FIG. 8 is a schematic diagram of a test device for a mobile application according to an embodiment of the present application.
  • the test device 8 of the mobile application of this embodiment includes a processor 80, a memory 81, and computer readable instructions 82 stored in the memory 81 and executable on the processor 80, such as Test program for mobile apps.
  • the processor 80 executes the computer readable instructions 82 to implement the steps in the method of testing the various mobile applications described above, such as steps 101 through 105 shown in FIG.
  • the processor 80 when executing the computer readable instructions 82, implements the functions of the various modules/units in the various apparatus embodiments described above, such as the functions of the units 701 through 705 shown in FIG.
  • the computer readable instructions 82 may be partitioned into one or more modules/units that are stored in the memory 81 and executed by the processor 80, To complete this application.
  • the one or more modules/units may be a series of computer readable instruction segments capable of performing a particular function, the instruction segments being used to describe the execution of the computer readable instructions 82 in the test device 8 of the mobile application. .
  • the test device 8 of the mobile application may be a mobile device such as a mobile phone, a notebook, a palmtop computer, and a tablet computer.
  • the test device of the mobile application may include, but is not limited to, a processor 80, a memory 81. It will be understood by those skilled in the art that FIG. 8 is merely an example of the test device 8 of the mobile application, does not constitute a limitation of the test device 8 of the mobile application, may include more or less components than the illustration, or combine some
  • the components, or different components, such as the test device of the mobile application may also include input and output devices, network access devices, buses, and the like.
  • the so-called processor 80 can be a central processing unit (Central Processing Unit, CPU), can also be other general-purpose processors, digital signal processors (DSP), application specific integrated circuits (Application Specific Integrated Circuit (ASIC), Field-Programmable Gate Array (FPGA) or other programmable logic device, discrete gate or transistor logic device, discrete hardware components, etc.
  • the general purpose processor may be a microprocessor or the processor or any conventional processor or the like.
  • the memory 81 may be an internal storage unit of the test device 8 of the mobile application, such as a hard disk or memory of the test device 8 of the mobile application.
  • the memory 81 may also be an external storage device of the test device 8 of the mobile application, such as a plug-in hard disk equipped with a test device 8 of the mobile application, a smart memory card (SMC), and a secure digital device. (Secure Digital, SD) card, flash card (Flash Card) and so on.
  • the memory 81 may also include both an internal storage unit of the test device 8 of the mobile application and an external storage device.
  • the memory 81 is configured to store the computer readable instructions and other programs and data required by the test device of the mobile application.
  • the memory 81 can also be used to temporarily store data that has been output or is about to be output.
  • each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
  • the above integrated unit can be implemented in the form of hardware or in the form of a software functional unit.
  • the integrated unit if implemented in the form of a software functional unit and sold or used as a standalone product, may be stored in a computer readable storage medium.
  • a computer readable storage medium A number of instructions are included to cause a computer device (which may be a personal computer, server, or network device, etc.) to perform all or part of the steps of the methods described in various embodiments of the present application.
  • the foregoing storage medium includes: a U disk, a mobile hard disk, a read-only memory (ROM), and a random access memory (RAM, Random Access).
  • ROM read-only memory
  • RAM Random Access

Landscapes

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

Abstract

本方案提供了一种移动应用的测试方法、装置、测试设备及介质,适用于测试技术领域,该方法包括:对测试页面中的文本框进行定位和激活;获取文本框对应的测试文本,测试文本中包含有至少一个测试字符;根据各个测试字符对应的按键坐标,在预先启动的虚拟键盘中,分别确定与每一按键坐标匹配的虚拟按键;基于测试字符在测试文本中的出现顺序,依次在各个测试字符对应的虚拟按键上进行模拟点击,以在文本框中输入测试字符;获取所述文本框在所述测试字符输入完成后对应的跳转事件,并对所述跳转事件进行识别处理,以得到基于所述文本框的测试结果。本方案实现了测试字符的自动化输入,降低了测试的操作复杂度,提高了移动应用的测试效率。

Description

移动应用的测试方法、装置、测试设备及介质
本申请要求于2017年07月24日提交中国专利局、申请号为201710605533.6、发明名称为“移动应用的测试方法及测试设备”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请属于测试技术领域,尤其涉及一种移动应用的测试方法、装置、测试设备及介质。
背景技术
功能测试是测试过程中最基本的一个环节,其包括对应用程序中的各个控件进行测试,以确定控件是否能够正常执行。然而,对于文本框这一控件来说,移动应用的一个页面中可能会出现多个文本框,若要逐一测试各个文本框是否能够正常执行,则测试人员需要在每一文本框中输入特定的字符后,点击相应的确认按键,再观察跳转页面是否正常。此后,再返回初始页面,重新执行上述操作。因此,现有技术中的测试步骤较为繁琐,导致了移动应用的测试效率较为低下。
技术问题
有鉴于此,本申请实施例提供了一种移动应用的测试方法、装置、测试设备及介质,以解决现有技术中测试步骤繁琐以及测试效率低下的问题。
技术解决方案
本申请实施例的第一方面提供了一种移动应用的测试方法,包括:
对测试页面中的文本框进行定位和激活;
获取所述文本框对应的测试文本,所述测试文本中包含有至少一个测试字符;
根据各个所述测试字符对应的按键坐标,在预先启动的虚拟键盘中,分别确定与每一所述按键坐标匹配的虚拟按键;
基于所述测试字符在所述测试文本中的出现顺序,依次在各个所述测试字符对应的所述虚拟按键上进行模拟点击,以在所述文本框中输入所述测试字符;
获取所述文本框在所述测试字符输入完成后对应的跳转事件,并对所述跳转事件进行识别处理,以得到基于所述文本框的测试结果。
本申请实施例的第二方面提供了一种移动应用的测试装置,该测试装置包括用于执行上述第一方面所述的移动应用的测试方法的单元。
本申请实施例的第三方面提供了一种移动应用的测试设备,包括存储器以及处理器,所述存储器中存储有可在所述处理器上运行的计算机可读指令,所述处理器执行所述计算机可读指令时实现如第一方面所述的移动应用的测试方法的步骤。
本申请实施例的第四方面提供了一种计算机可读存储介质,所述计算机可读存储介质存储有计算机可读指令,所述计算机可读指令被处理器执行时实现如第一方面所述的移动应用的测试方法的步骤。
有益效果
本申请实施例能够根据测试文本中每一测试字符所对应的按键坐标,从预先启动的虚拟键盘中确定出需要进行模拟点击的各个虚拟按键;通过依次在各个虚拟按键中进行模拟点击以及对跳转页面图像进行智能识别,实现了测试字符的自动化输入,快速地完成文本框的功能性测试。由于测试人员不再需要人工重复执行控件点击以及返回操作,因而降低了移动应用测试的操作复杂度以及繁琐程度,提高了移动应用的测试效率。
附图说明
图1是本申请实施例一提供的移动应用的测试方法的实现流程图;
图2是本申请实施例一提供的移动应用的测试方法的屏幕焦点定位示意图;
图3是本申请实施例一提供的移动应用的测试方法S105的具体实现流程图;
图4是本申请实施例三提供的移动应用的测试方法的实现流程图;
图5是本申请实施例四提供的移动应用的测试方法的实现流程图;
图6是本申请实施例五提供的移动应用的测试方法的实现流程图;
图7是本申请实施例六提供的移动应用的测试装置的结构框图;
图8是本申请实施例七提供的移动应用的测试设备的示意图。
本发明的实施方式
为了说明本申请所述的技术方案,下面通过具体实施例来进行说明。
实施例一
图1示出了本申请实施例提供的移动应用的测试方法的实现流程,该方法流程包括步骤S101至S105。各步骤的具体实现原理如下:
S101:对测试页面中的文本框进行定位和激活。
测试页面为显示于移动终端所运行的应用程序中的一个页面,其包含有多个控件。上述控件包括但不限于用户界面控件、图像处理控件、以及文档处理控件等。其中,用户界面控件例如可以是按键、文本框、图表以及下拉式菜单等。
本申请实施例中,根据预存储的每一文本框的中心坐标,对测试页面中的文本框进行定位。上述对测试页面中的文本框进行激活的步骤,具体包括:对于测试页面中定位得到的任意一个文本框,将焦点移动至该文本框的中心坐标对应的页面位置;执行选取指令,以完成对该文本框的激活。
特别地,若移动终端所运行的应用程序为基于HTML(HyperText Markup Language,超文本标记语言)语言编写而成的程序,则该应用程序中的测试页面为HTML页面。此时,对测试页面中的文本框进行定位的方式包括但不限于tagName、Xpath以及cssSelector等方式。例如,可检测出测试页面中各个元素的标签名称,确定出其中标签名称为“input”的元素,则该元素即为测试页面中的文本框。
S102:获取所述文本框对应的测试文本,所述测试文本中包含有至少一个测试字符。
移动应用中每一文本框所对应的测试文本可以实时生成,也可以由测试人员预先写好。若测试文本实时生成,则在确定当前已激活的文本框后,根据文本框的输入规则,生成与该输入规则匹配的测试文本。并且,对于每次生成的测试文本,将其存储至指定目录,以在再次激活相同输入规则的文本框时,可以直接调取并使用该测试文本。
测试文本包含有依序排列的一个或多个测试字符,测试字符包括中文、英文、数字以及标点符号等字符。每一个测试文本用于执行一次文本框的测试操作,即,在将测试文本中的各个测试字符输入于文本框后,将执行一次跳转操作。
S103:根据各个所述测试字符对应的按键坐标,在预先启动的虚拟键盘中,分别确定与每一所述按键坐标匹配的虚拟按键。
虚拟键盘表示用软件来模拟的键盘,该键盘展示于移动终端的显示界面。特别地,该虚拟键盘为安卓系统自带的软键盘。虚拟键盘中包含有各种字符的虚拟按键,每个虚拟按键对应有预设的按键坐标。
本申请实施例中,读取测试文本中的每一测试字符,根据预设的字符与按键坐标的对应关系,获取各个测试字符的按键坐标,并基于得到的按键坐标,在虚拟键盘中确定出该按键坐标对应的虚拟按键。
示例性地,如图2所示,为了对测试过程进行可视化验证,便于测试人员观察虚拟按键的定位过程,若运行移动应用的终端设备为安卓系统的终端设备,则在启动了安卓系统自带的坐标定位功能后,当前时刻屏幕焦点所对应的位置坐标将展示于移动终端的显示界面顶端。当检测到位置坐标与测试字符的按键坐标相同时,屏幕焦点所在的位置确实为虚拟按键所在的位置,则表示虚拟按键定位准确。
S104:基于所述测试字符在所述测试文本中的出现顺序,依次在各个所述测试字符对应的所述虚拟按键上进行模拟点击,以在所述文本框中输入所述测试字符。
依次读取测试文本中的各个测试字符,每读取到一个测试字符以及确定了该测试字符对应的虚拟按键后,通过调用预设的monkeyrunner软件,以其提供的DOWN_AND_UP方法对虚拟按键进行按下以及弹起的模拟动作后,完成对虚拟按键的模拟点击。
当检测到虚拟键盘中的每一虚拟按键被点击时,将虚拟按键所对应的字符输入至当前时刻所激活的文本框中。各个测试字符所对应的虚拟按键均模拟点击完成后,输入框中将展示出测试文本中的各个测试字符。
S105:获取所述文本框在所述测试字符输入完成后对应的跳转事件,并对所述跳转事件进行识别处理,以得到基于所述文本框的测试结果。
测试页面中的每一文本框旁边均存在用于跳转至新页面或者跳转至页面其他位置的控件,如确定按键、登录按键、搜索按键等。文本框与其相邻的控件存在关联关系。
作为本申请的一个实施示例,当各个测试字符输入完成后,对虚拟键盘上的回车按键进行模拟点击。当检测到回车按键被点击时,执行与文本框关联的控件选取操作。
作为本申请的另一个实施示例,当各个测试字符输入完成后,根据与文本框关联的控件的预设坐标或控件ID,对测试页面中的该控件进行定位并激活,由此执行与文本框关联的控件选取操作。
若该控件用于跳转至新页面,则生成页面请求,并将包含于文本框中的测试字符封装至上述页面请求后,上传至移动应用的后台服务器。
若该控件用于跳转至测试页面内的其他位置,则根据控件对应的跳转条件,完成当前显示界面的焦点转移。
通过预设的算法来对跳转事件进行识别处理,以确定文本框的页面测试结果是否正常。
示例性,预设的算法例如可以是:获取与文本框关联的控件的链接地址;判断跳转页面所对应的页面地址是否与该链接地址相同;若跳转页面所对应的页面地址与该链接地址相同,则确定基于该文本框的测试结果为测试正常;若跳转页面所对应的页面地址与该链接地址不同,则确定基于该文本框的页面测试结果为测试异常。
实施例二
作为本申请的一个实施例,图3示出了本申请实施例一提供的移动应用的测试方法S105的具体实现流程,详述如下:
S1051:获取所述文本框在所述测试字符输入完成后对应得到的跳转页面。
若与文本框关联的控件具体用于跳转至新页面,则跳转事件为页面跳转事件。将包含于文本框中的测试字符封装至上述页面请求后,上传至移动应用的后台服务器。
当接收到后台服务器返回的页面响应结果时,开始加载跳转页面。
S1052:对所述跳转页面进行截图处理,得到跳转页面图像。
在检测到跳转页面加载完毕时,基于上述monkeyrunner软件所提供的takeSnapshot方法,完成当前时刻跳转页面的截图。截图所得到的图像即为跳转页面图像。
S1053:获取所述文本框对应的参考跳转页面图像。
本申请实施例中,对于测试页面中的每一文本框,预存储有该文本框在正常跳转状态下所得到的跳转页面图像,该跳转页面图像为参考跳转页面图像。具体地,测试页面中的各个文本框分别对应有一个控件ID。根据该控件ID,从预设的参考跳转页面图像存储目录中匹配到与该控件ID关联的一个参考跳转页面图像。
优选地,参考跳转页面图像的尺寸大小以及分辨率大小均与与移动终端的显示页面大小以及分辨率大小相同。
S1054:通过预设的图像对比算法,计算所述跳转页面图像与所述参考跳转页面图像的图像相似度。
图像对比算法包括但不限于尺度不变特征变换匹配算法(Scale Invariant Feature Transform,SIFT)、基于深度特征分析的双线性图像相似度匹配算法以及OpenCV图像相似度ORB算法等。通过图像对比算法对获取得到的跳转页面图像以及参考跳转页面图像进行识别处理,可得到二者之间的图像相似度。
示例性地,本申请实施例中,计算所述跳转页面图像与所述参考跳转页面图像的图像相似度具体可包括:分别计算出对跳转页面图像以及参考跳转页面图像中各个像素点的灰度值;获取跳转页面图像的第一平均灰度值以及参考跳转页面图像的第二平均灰度值;计算跳转页面图像中每一像素点的灰度值与第一平均灰度值的第一差值以及计算参考跳转页面图像中每一像素点的灰度值与第二平均灰度值的第二差值;基于获取的到的各个第一差值以及第二差值,计算跳转页面图像以及参考跳转页面图像所分别对应的哈希值,并将两个哈希值的差值确定为图像相似度。
S1055:当所述图像相似度小于第一阈值时,确定基于所述文本框的页面测试结果为响应错误。
本申请实施例中,当图像相似度大于或等于第一阈值时,表示跳转页面图像以及参考跳转页面图像为相同的图像,或者跳转页面图像以及参考跳转页面图像可认为是相同的图像。由此可知,模拟点击完成后所返回的跳转页面为正常响应状态下的页面,故基于上述文本框的页面测试结果为测试正常。
当图像相似度小于第一阈值时,表示跳转页面图像以及参考跳转页面图像为不同的图像。模拟点击完成后所返回的跳转页面为非正常响应状态下的页面,故基于上述文本框的页面测试结果为测试异常,且异常类型为响应错误。
本申请实施例中,通过对跳转页面进行截图处理,可得到跳转页面图像,由此能够利用图像对比算法来计算跳转页面图像以及与文本框对应的参考跳转页面图像的图像相似度。在图像相似度低于第一阈值的情况下,可以判断出当前时刻的返回页面出现异常,从而实现了页面测试结果的自动化识别。
实施例三
在上述实施例二的基础上,对页面测试结果的异常类型做进一步地确定。如图4所示,在上述S104之后,还包括:
S106:获取触发页面跳转事件时所对应的第一时刻。
执行与文本框关联的控件选取操作,以生成页面请求。在向后台服务器发出页面请求时,记录当前的时间点,将该时间点确定为第一时刻。
S107:获取所述跳转页面开始加载时所对应的第二时刻。
当接收到后台服务器返回的页面响应结果时,开始加载跳转页面。此时,移动终端将开始逐渐加载跳转页面中的各个页面元素。在检测到任一页面元素出现于显示界面时,记录当前的时间点,将该时间点确定为第二时刻。
S108:获取所述跳转页面加载完成时所对应的第三时刻。
若跳转页面中的各个页面元素均已加载完毕,则会接收到响应结束标记。此时,记录当前的时间点,将该时间点确定为第二时刻。
S109:若所述第二时刻与所述第一时刻的差值大于第二阈值,或者所述第三时刻与所述第一时刻的差值大于第三阈值,则确定基于所述文本框的测试结果为响应超时。
第二时刻与第一时刻的差值包括远程服务器的网页请求处理时间以及网络传输时间。若该差值大于第二阈值,则表示网页请求处理时间过长或者网络时延较大,故确定基于文本框的页面测试结果为测试异常,具体异常类型为响应超时。
第三时刻与第一时刻的差值为跳转页面时所需的总耗时。若该差值达到第三阈值时,跳转页面依然未加载完毕,则表示跳转页面的总耗时过长,可能出现网络中断或者页面无法正常返回的问题,故确定基于文本框的页面测试结果为测试异常,具体异常类型同样记录为响应超时。
本申请实施例中,除了判断跳转页面图像是否正确之外,通过分别判断跳转页面响应过程以及加载过程的所需耗时是否大于预设阈值,能够进一步地确定出页面的功能测试准确性,能够通过计算时延的方式来模拟出用户在实际使用页面时的体验效果。在耗时大于预设阈值的情况下,能够自动识别出测试异常时所对应的具体异常类型,因而达到了更为全面的自动化测试效果。
实施例四
在上述各个实施例的基础上,对页面测试结果出现异常时的处理方式做进一步地限定。如图5所示,所述移动应用的测试方法还包括:
S110:若检测到当前时刻基于所述文本框的测试结果为测试异常,则建立测试日志存储目录,所述测试异常包括所述响应错误以及所述响应超时。
S111:将所述跳转页面图像以及所述测试文本存储至所述测试日志存储目录。
若检测到基于一文本框所得到的跳转页面出现响应错误和/或响应超,则在指定的存储路径生成该文本框对应的测试日志存储目录,用于记录与该文本框相关的测试过程中所得到的测试信息,包括测试过程所用到的测试文本、测试过程中的各个时间节点、页面测试异常类型、跳转页面图像、参考跳转页面图像、图像相似度以及异常原因等。
本申请实施例中,在检测到响应异常时,通过调用monkeyrunner软件中所预设的writeToFile方法,将测试文本以及经过截图处理所得到的跳转页面图像存储至指定的测试日志存储目录。
在测试异常结果出现的情况下,测试人员能够基于测试日志存储目录,快速地找到出现测试异常的文本框及其对应的测试信息,便于测试人员分析并总结测试结果。并且。测试人员能够依照测试文本,再次手动执行基于该文本框的测试字符输入操作,实现了对自动化页面测试结果准确性的进一步地确定。
实施例五
在上述各个实施例的基础上,对页面测试结果出现异常时的处理方式做进一步地限定。如图6所示,所述移动应用的测试方法还包括:
S112:获取所述文本框对应的输入规则。
输入规则表示可允许输入于文本框的字符的字符类型以及字符数目。测试页面中的每一文本框有其对应的输入规则。
本申请实施例中,在移动应用安装后,可读取移动应用测试页面中的每一控件的Xpath以及变量定义。若测试页面中的控件为输入框,则其变量定义包含有输入规则。测试页面中的每一控件的Xpath以及变量定义可通过运行移动终端的以下文件中获取:Android-SDK\tools\uiautomatorviewer.bat。
S113:生成与所述输入规则不匹配的随机字符。
对输入规则进行识别处理,以得到输入规则的互斥规则。例如,若输入规则为英文字母,则得到的互斥规则为非英文字母。
将互斥规则输入预设的随机字符生成算法,以生成随机字符,且随机字符的字符总数也为随机数。
S114:在所述预先启动的虚拟键盘中,对所述随机字符对应的虚拟按键进行模拟点击。
同上述S103以及S104的实现原理相同,根据预设的字符与按键坐标的对应关系,依次获取每一随机字符所对应的按键坐标,并在显示界面所展示的虚拟键盘中确定出每一按键坐标所表示的虚拟按键。通过调用DOWN_AND_UP方法对虚拟按键进行按下以及弹起两个手指触摸模拟动作后,完成对随机字符对应的虚拟按键的模拟点击。
S115:检测所述文本框的输入框值是否为空值。
根据文本框所对应的控件ID,可通过现有技术中的jquery等方式来实时监测该控件ID的输入框值。
S116:若所述输入框值为非空值,则确定基于所述文本框的测试结果为输入异常。
若实时监测到的输入框值为“null”,即空值,则表示上述步骤S113中所生成的与输入规则不匹配的随机字符并未成功输入于文本框中,因此,可确定文本框的输入限制条件生效,该文本框的输入功能测试正常。
若实时监测到的输入框值包含有具体的字符,即非空值,则表示上述步骤S113中所生成的与输入规则不匹配的随机字符已成功输入于文本框中,因此,可确定文本框的输入限制条件失效。由此可知,用户也可将非法字符输入于该文本框,由此将容易造成移动应用在后续的处理过程中出现数据异常。因此,确定该文本框的输入功能测试异常。
本申请实施例中,通过生成与文本框的输入规则不匹配的随机字符,并对随机字符对应的虚拟按键进行模拟点击,能够模拟出用户的非法字符输入操作;在文本框的输入框值为空值的情况下,能够自动识别出页面测试结果为输入异常,提高了移动应用的测试效率。
应理解,上述实施例中各步骤的序号的大小并不意味着执行顺序的先后,各过程的执行顺序应以其功能和内在逻辑确定,而不应对本申请实施例的实施过程构成任何限定。
实施例六
对应于上文实施例所述的移动应用的测试方法,图7示出了本申请实施例提供的移动应用的测试装置的结构框图,为了便于说明,仅示出了与本申请实施例相关的部分。
参照图7,该装置包括:
定位单元701,用于对测试页面中的文本框进行定位,并激活已定位的任一所述文本框。
第一获取单元702,用于获取所述文本框对应的测试文本,所述测试文本中包含有至少一个测试字符。
第一确定单元703,用于根据各个所述测试字符对应的按键坐标,在预先启动的虚拟键盘中,分别确定与每一所述按键坐标匹配的虚拟按键。
输入单元704,用于基于所述测试字符在所述测试文本中的出现顺序,依次在各个所述测试字符对应的所述虚拟按键上进行模拟点击,以在所述文本框中输入所述测试字符。
第二获取单元705,用于获取模拟点击完成后所得到的跳转页面图像,并对所述跳转页面图像进行识别处理,以得到基于所述文本框的页面测试结果。
可选地,所述第二获取单元705包括:
第一获取子单元,用于获取模拟点击完成后所得到的跳转页面。
截图子单元,用于对所述跳转页面进行截图处理,得到跳转页面图像。
第二获取子单元,用于获取所述文本框对应的参考跳转页面图像。
计算子单元,用于通过预设的图像对比算法,计算所述跳转页面图像与所述参考跳转页面图像的图像相似度。
确定子单元,用于当所述图像相似度小于第一阈值时,确定基于所述文本框的页面测试结果为响应错误。
可选地,该装置还包括:
第三获取单元,用于获取模拟点击完成时所对应的第一时刻。
第四获取单元,用于获取所述跳转页面开始加载时所对应的第二时刻。
第五获取单元,用于获取所述跳转页面加载完成时所对应的第三时刻。
第二确定单元,用于若所述第二时刻与所述第一时刻的差值大于第二阈值,或者所述第三时刻与所述第一时刻的差值大于第三阈值,则确定所述页面测试结果为响应超时。
可选地,该装置还包括:
建立单元,用于若检测到当前时刻的所述页面测试结果为测试异常,则建立测试日志存储目录,所述测试异常包括所述响应错误以及所述响应超时。
存储单元,用于将所述跳转页面图像以及所述测试文本存储至所述测试日志存储目录。
可选地,该装置还包括:
第六获取单元,用于获取所述文本框对应的输入规则。
上传单元,用于生成与所述输入规则不匹配的随机字符。
模拟点击单元,用于在所述预先启动的虚拟键盘中,对所述随机字符对应的虚拟按键进行模拟点击。
检测单元,用于检测所述文本框的输入框值是否为空值。
第三确定单元,用于若所述输入框值为非空值,则确定所述页面测试结果为输入异常。
实施例七
图8是本申请实施例提供的移动应用的测试设备的示意图。如图8所示,该实施例的移动应用的测试设备8包括:处理器80、存储器81以及存储在所述存储器81中并可在所述处理器80上运行的计算机可读指令82,例如移动应用的测试程序。所述处理器80执行所述计算机可读指令82时实现上述各个移动应用的测试方法实施例中的步骤,例如图1所示的步骤101至105。或者,所述处理器80执行所述计算机可读指令82时实现上述各装置实施例中各模块/单元的功能,例如图7所示单元701至705的功能。
示例性的,所述计算机可读指令82可以被分割成一个或多个模块/单元,所述一个或者多个模块/单元被存储在所述存储器81中,并由所述处理器80执行,以完成本申请。所述一个或多个模块/单元可以是能够完成特定功能的一系列计算机可读指令段,该指令段用于描述所述计算机可读指令82在所述移动应用的测试设备8中的执行过程。
所述移动应用的测试设备8可以是手机、笔记本、掌上电脑及平板电脑等移动端设备。所述移动应用的测试设备可包括,但不仅限于,处理器80、存储器81。本领域技术人员可以理解,图8仅仅是移动应用的测试设备8的示例,并不构成对移动应用的测试设备8的限定,可以包括比图示更多或更少的部件,或者组合某些部件,或者不同的部件,例如所述移动应用的测试设备还可以包括输入输出设备、网络接入设备、总线等。
所称处理器80可以是中央处理单元(Central Processing Unit,CPU),还可以是其他通用处理器、数字信号处理器 (Digital Signal Processor,DSP)、专用集成电路 (Application Specific Integrated Circuit,ASIC)、现成可编程门阵列 (Field-Programmable Gate Array,FPGA) 或者其他可编程逻辑器件、分立门或者晶体管逻辑器件、分立硬件组件等。通用处理器可以是微处理器或者该处理器也可以是任何常规的处理器等。
所述存储器81可以是所述移动应用的测试设备8的内部存储单元,例如移动应用的测试设备8的硬盘或内存。所述存储器81也可以是所述移动应用的测试设备8的外部存储设备,例如所述移动应用的测试设备8上配备的插接式硬盘,智能存储卡(Smart Media Card, SMC),安全数字(Secure Digital, SD)卡,闪存卡(Flash Card)等。进一步地,所述存储器81还可以既包括所述移动应用的测试设备8的内部存储单元也包括外部存储设备。所述存储器81用于存储所述计算机可读指令以及所述移动应用的测试设备所需的其他程序和数据。所述存储器81还可以用于暂时地存储已经输出或者将要输出的数据。
另外,在本申请各个实施例中的各功能单元可以集成在一个处理单元中,也可以是各个单元单独物理存在,也可以两个或两个以上单元集成在一个单元中。上述集成的单元既可以采用硬件的形式实现,也可以采用软件功能单元的形式实现。
所述集成的单元如果以软件功能单元的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。基于这样的理解,本申请的技术方案本质上或者说对现有技术做出贡献的部分或者该技术方案的全部或部分可以以软件产品的形式体现出来,该计算机软件产品存储在一个存储介质中,包括若干指令用以使得一台计算机设备(可以是个人计算机,服务器,或者网络设备等)执行本申请各个实施例所述方法的全部或部分步骤。而前述的存储介质包括:U盘、移动硬盘、只读存储器(ROM,Read-Only Memory)、随机存取存储器(RAM,Random Access Memory)、磁碟或者光盘等各种可以存储程序代码的介质。
以上所述,以上实施例仅用以说明本申请的技术方案,而非对其限制;尽管参照前述实施例对本申请进行了详细的说明,本领域的普通技术人员应当理解:其依然可以对前述各实施例所记载的技术方案进行修改,或者对其中部分技术特征进行等同替换;而这些修改或者替换,并不使相应技术方案的本质脱离本申请各实施例技术方案的精神和范围。

Claims (20)

  1. 一种移动应用的测试方法,其特征在于,包括:
    对测试页面中的文本框进行定位和激活;
    获取所述文本框对应的测试文本,所述测试文本中包含有至少一个测试字符;
    根据各个所述测试字符对应的按键坐标,在预先启动的虚拟键盘中,分别确定与每一所述按键坐标匹配的虚拟按键;
    基于所述测试字符在所述测试文本中的出现顺序,依次在各个所述测试字符对应的所述虚拟按键上进行模拟点击,以在所述文本框中输入所述测试字符;
    获取所述文本框在所述测试字符输入完成后对应的跳转事件,并对所述跳转事件进行识别处理,以得到基于所述文本框的测试结果。
  2. 如权利要求1所述的测试方法,其特征在于,所述跳转事件为页面跳转事件,所述获取所述文本框在所述测试字符输入完成后对应的跳转事件,并对所述跳转事件进行识别处理,以得到基于所述文本框的测试结果,包括:
    获取所述文本框在所述测试字符输入完成后对应得到的跳转页面;
    对所述跳转页面进行截图处理,得到跳转页面图像;
    获取所述文本框对应的参考跳转页面图像;
    通过预设的图像对比算法,计算所述跳转页面图像与所述参考跳转页面图像的图像相似度;
    当所述图像相似度小于第一阈值时,确定基于所述文本框的测试结果为响应错误。
  3. 如权利要求2所述的测试方法,其特征在于,还包括:
    获取触发页面跳转事件时所对应的第一时刻;
    获取所述跳转页面开始加载时所对应的第二时刻;
    获取所述跳转页面加载完成时所对应的第三时刻;
    若所述第二时刻与所述第一时刻的差值大于第二阈值,或者所述第三时刻与所述第一时刻的差值大于第三阈值,则确定基于所述文本框的测试结果为响应超时。
  4. 如权利要求2或3所述的测试方法,其特征在于,还包括:
    若检测到当前时刻基于所述文本框的测试结果为测试异常,则建立测试日志存储目录,所述测试异常包括所述响应错误以及所述响应超时;
    将所述跳转页面图像以及所述测试文本存储至所述测试日志存储目录。
  5. 如权利要求1所述的测试方法,其特征在于,在所述对测试页面中的文本框进行定位和激活之后,还包括:
    获取所述文本框对应的输入规则;
    生成与所述输入规则不匹配的随机字符;
    在所述预先启动的虚拟键盘中,对所述随机字符对应的虚拟按键进行模拟点击;
    检测所述文本框的输入框值是否为空值;
    若所述输入框值为非空值,则确定基于所述文本框的测试结果为输入异常。
  6. 一种移动应用的测试装置,其特征在于,包括:
    定位单元,用于对测试页面中的文本框进行定位,并激活已定位的任一所述文本框;
    第一获取单元,用于获取所述文本框对应的测试文本,所述测试文本中包含有至少一个测试字符;
    第一确定单元,用于根据各个所述测试字符对应的按键坐标,在预先启动的虚拟键盘中,分别确定与每一所述按键坐标匹配的虚拟按键;
    输入单元,用于基于所述测试字符在所述测试文本中的出现顺序,依次在各个所述测试字符对应的所述虚拟按键上进行模拟点击,以在所述文本框中输入所述测试字符;
    第二获取单元,用于获取模拟点击完成后所得到的跳转页面图像,并对所述跳转页面图像进行识别处理,以得到基于所述文本框的页面测试结果。
  7. 根据权利要求6所述的测试装置,其特征在于,所述第二获取单元包括:
    第一获取子单元,用于获取模拟点击完成后所得到的跳转页面;
    截图子单元,用于对所述跳转页面进行截图处理,得到跳转页面图像;
    第二获取子单元,用于获取所述文本框对应的参考跳转页面图像;
    计算子单元,用于通过预设的图像对比算法,计算所述跳转页面图像与所述参考跳转页面图像的图像相似度;
    确定子单元,用于当所述图像相似度小于第一阈值时,确定基于所述文本框的页面测试结果为响应错误。
  8. 根据权利要求7所述的测试装置,其特征在于,还包括:
    第三获取单元,用于获取模拟点击完成时所对应的第一时刻;
    第四获取单元,用于获取所述跳转页面开始加载时所对应的第二时刻;
    第五获取单元,用于获取所述跳转页面加载完成时所对应的第三时刻;
    第二确定单元,用于若所述第二时刻与所述第一时刻的差值大于第二阈值,或者所述第三时刻与所述第一时刻的差值大于第三阈值,则确定所述页面测试结果为响应超时。
  9. 根据权利要求7或8所述的测试装置,其特征在于,还包括:
    建立单元,用于若检测到当前时刻的所述页面测试结果为测试异常,则建立测试日志存储目录,所述测试异常包括所述响应错误以及所述响应超时;
    存储单元,用于将所述跳转页面图像以及所述测试文本存储至所述测试日志存储目录。
  10. 根据权利要求6所述的测试装置,其特征在于,还包括:
    第六获取单元,用于获取所述文本框对应的输入规则;
    上传单元,用于生成与所述输入规则不匹配的随机字符;
    模拟点击单元,用于在所述预先启动的虚拟键盘中,对所述随机字符对应的虚拟按键进行模拟点击;
    检测单元,用于检测所述文本框的输入框值是否为空值;
    第三确定单元,用于若所述输入框值为非空值,则确定所述页面测试结果为输入异常。
  11. 一种移动应用的测试设备,其特征在于,包括存储器以及处理器,所述存储器中存储有可在所述处理器上运行的计算机可读指令,所述处理器执行所述计算机可读指令时实现如下步骤:
    对测试页面中的文本框进行定位和激活;
    获取所述文本框对应的测试文本,所述测试文本中包含有至少一个测试字符;
    根据各个所述测试字符对应的按键坐标,在预先启动的虚拟键盘中,分别确定与每一所述按键坐标匹配的虚拟按键;
    基于所述测试字符在所述测试文本中的出现顺序,依次在各个所述测试字符对应的所述虚拟按键上进行模拟点击,以在所述文本框中输入所述测试字符;
    获取所述文本框在所述测试字符输入完成后对应的跳转事件,并对所述跳转事件进行识别处理,以得到基于所述文本框的测试结果。
  12. 根据权利要求11所述的测试设备,其特征在于,所述跳转事件为页面跳转事件,所述获取所述文本框在所述测试字符输入完成后对应的跳转事件,并对所述跳转事件进行识别处理,以得到基于所述文本框的测试结果,包括:
    获取所述文本框在所述测试字符输入完成后对应得到的跳转页面;
    对所述跳转页面进行截图处理,得到跳转页面图像;
    获取所述文本框对应的参考跳转页面图像;
    通过预设的图像对比算法,计算所述跳转页面图像与所述参考跳转页面图像的图像相似度;
    当所述图像相似度小于第一阈值时,确定基于所述文本框的测试结果为响应错误。
  13. 根据权利要求12所述的测试设备,其特征在于,所述处理器执行所述计算机可读指令时,还实现如下步骤:
    获取触发页面跳转事件时所对应的第一时刻;
    获取所述跳转页面开始加载时所对应的第二时刻;
    获取所述跳转页面加载完成时所对应的第三时刻;
    若所述第二时刻与所述第一时刻的差值大于第二阈值,或者所述第三时刻与所述第一时刻的差值大于第三阈值,则确定基于所述文本框的测试结果为响应超时。
  14. 根据权利要求12或13所述的测试设备,其特征在于,所述处理器执行所述计算机可读指令时,还实现如下步骤:
    若检测到当前时刻基于所述文本框的测试结果为测试异常,则建立测试日志存储目录,所述测试异常包括所述响应错误以及所述响应超时;
    将所述跳转页面图像以及所述测试文本存储至所述测试日志存储目录。
  15. 根据权利要求11所述的测试设备,其特征在于,所述处理器执行所述计算机可读指令时,还实现如下步骤:
    获取所述文本框对应的输入规则;
    生成与所述输入规则不匹配的随机字符;
    在所述预先启动的虚拟键盘中,对所述随机字符对应的虚拟按键进行模拟点击;
    检测所述文本框的输入框值是否为空值;
    若所述输入框值为非空值,则确定基于所述文本框的测试结果为输入异常。
  16. 一种计算机可读存储介质,所述计算机可读存储介质存储有计算机可读指令,其特征在于,所述计算机可读指令被至少一个处理器执行时实现如下步骤:
    对测试页面中的文本框进行定位和激活;
    获取所述文本框对应的测试文本,所述测试文本中包含有至少一个测试字符;
    根据各个所述测试字符对应的按键坐标,在预先启动的虚拟键盘中,分别确定与每一所述按键坐标匹配的虚拟按键;
    基于所述测试字符在所述测试文本中的出现顺序,依次在各个所述测试字符对应的所述虚拟按键上进行模拟点击,以在所述文本框中输入所述测试字符;
    获取所述文本框在所述测试字符输入完成后对应的跳转事件,并对所述跳转事件进行识别处理,以得到基于所述文本框的测试结果。
  17. 根据权利要求16所述的计算机可读存储介质,其特征在于,所述跳转事件为页面跳转事件,所述获取所述文本框在所述测试字符输入完成后对应的跳转事件,并对所述跳转事件进行识别处理,以得到基于所述文本框的测试结果,包括:
    获取所述文本框在所述测试字符输入完成后对应得到的跳转页面;
    对所述跳转页面进行截图处理,得到跳转页面图像;
    获取所述文本框对应的参考跳转页面图像;
    通过预设的图像对比算法,计算所述跳转页面图像与所述参考跳转页面图像的图像相似度;
    当所述图像相似度小于第一阈值时,确定基于所述文本框的测试结果为响应错误。
  18. 根据权利要求17所述的计算机可读存储介质,其特征在于,所述计算机可读指令被至少一个处理器执行时,还实现如下步骤:
    获取触发页面跳转事件时所对应的第一时刻;
    获取所述跳转页面开始加载时所对应的第二时刻;
    获取所述跳转页面加载完成时所对应的第三时刻;
    若所述第二时刻与所述第一时刻的差值大于第二阈值,或者所述第三时刻与所述第一时刻的差值大于第三阈值,则确定基于所述文本框的测试结果为响应超时。
  19. 根据权利要求17或18所述的计算机可读存储介质,其特征在于,所述计算机可读指令被至少一个处理器执行时,还实现如下步骤:
    若检测到当前时刻基于所述文本框的测试结果为测试异常,则建立测试日志存储目录,所述测试异常包括所述响应错误以及所述响应超时;
    将所述跳转页面图像以及所述测试文本存储至所述测试日志存储目录。
  20. 根据权利要求16所述的计算机可读存储介质,其特征在于,所述计算机可读指令被至少一个处理器执行时,还实现如下步骤:
    获取所述文本框对应的输入规则;
    生成与所述输入规则不匹配的随机字符;
    在所述预先启动的虚拟键盘中,对所述随机字符对应的虚拟按键进行模拟点击;
    检测所述文本框的输入框值是否为空值;
    若所述输入框值为非空值,则确定基于所述文本框的测试结果为输入异常。
PCT/CN2018/077224 2017-07-24 2018-02-26 移动应用的测试方法、装置、测试设备及介质 WO2019019628A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201710605533.6 2017-07-24
CN201710605533.6A CN107783898B (zh) 2017-07-24 2017-07-24 移动应用的测试方法及测试设备

Publications (1)

Publication Number Publication Date
WO2019019628A1 true WO2019019628A1 (zh) 2019-01-31

Family

ID=61437480

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2018/077224 WO2019019628A1 (zh) 2017-07-24 2018-02-26 移动应用的测试方法、装置、测试设备及介质

Country Status (2)

Country Link
CN (1) CN107783898B (zh)
WO (1) WO2019019628A1 (zh)

Families Citing this family (13)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109033772B (zh) * 2018-08-09 2020-04-21 北京云测信息技术有限公司 一种验证信息的输入方法及装置
CN109784369A (zh) * 2018-12-14 2019-05-21 深圳壹账通智能科技有限公司 H5页面测试方法与装置、电子设备、存储介质
CN109905390B (zh) * 2019-02-26 2021-09-28 北京智游网安科技有限公司 App劫持检测方法、api包及存储介质
CN111949510B (zh) * 2019-05-17 2024-05-14 百度在线网络技术(北京)有限公司 测试处理方法、装置、电子设备及可读存储介质
CN112702597A (zh) * 2019-10-22 2021-04-23 北京奇艺世纪科技有限公司 一种测试方法、测试装置、电视终端及测试系统
CN111104308A (zh) * 2019-11-12 2020-05-05 贝壳技术有限公司 显示页面的测试方法和装置、存储介质、电子设备
CN110888812B (zh) * 2019-11-26 2023-11-07 国核自仪系统工程有限公司 终端页面的响应时间的测试系统及测试方法
CN111078533A (zh) * 2019-11-26 2020-04-28 智器云南京信息科技有限公司 自动化测试方法及装置、计算机设备和存储介质
CN112000576A (zh) * 2020-08-25 2020-11-27 北京三快在线科技有限公司 代码数据的检测方法、装置、设备及存储介质
CN112363919B (zh) * 2020-11-02 2024-02-13 北京云测信息技术有限公司 用户界面ai自动化测试方法、装置、设备和存储介质
CN112416777B (zh) * 2020-11-23 2022-11-18 珠海格力电器股份有限公司 文本显示测试方法、装置、计算机设备和存储介质
CN112905451B (zh) * 2021-02-02 2023-08-25 北京罗克维尔斯科技有限公司 应用程序的自动化测试方法及装置
CN113360398B (zh) * 2021-06-29 2023-09-01 西安天下帮扶信息科技有限公司 混合应用程序测试方法、装置、设备及介质

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1641592A (zh) * 2004-01-07 2005-07-20 北京北阳电子技术有限公司 一种对带键盘电子产品的功能测试方法及测试系统
CN102567191A (zh) * 2010-12-15 2012-07-11 上海杉达学院 Jsp页面测试方法及测试装置
CN103901307A (zh) * 2014-04-22 2014-07-02 上海扬梓投资管理有限公司 一种用于车载多媒体装置的测试系统及方法

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105653056B (zh) * 2015-12-17 2019-05-28 北京奇虎科技有限公司 输入法的测试方法及装置
CN105740148B (zh) * 2016-01-29 2018-03-06 博雅网信(北京)科技有限公司 一种移动终端自动化测试的脚本引擎系统及测试方法

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1641592A (zh) * 2004-01-07 2005-07-20 北京北阳电子技术有限公司 一种对带键盘电子产品的功能测试方法及测试系统
CN102567191A (zh) * 2010-12-15 2012-07-11 上海杉达学院 Jsp页面测试方法及测试装置
CN103901307A (zh) * 2014-04-22 2014-07-02 上海扬梓投资管理有限公司 一种用于车载多媒体装置的测试系统及方法

Also Published As

Publication number Publication date
CN107783898B (zh) 2020-03-27
CN107783898A (zh) 2018-03-09

Similar Documents

Publication Publication Date Title
WO2019019628A1 (zh) 移动应用的测试方法、装置、测试设备及介质
US8549478B2 (en) Graphical user interface input element identification
US9519401B2 (en) Providing context menu based on predicted commands
KR102047568B1 (ko) 웹페이지 렌더링 시간 측정 기법
US20150378876A1 (en) Visual graphical user interface verification
JP6036100B2 (ja) ウェブ・ブラウザー画面の段階的な視覚的比較
CN108664364B (zh) 一种终端测试方法及装置
CN108228861B (zh) 用于执行机器学习的特征工程的方法及系统
US9881209B2 (en) Methods and systems for detecting tampering in a document image
WO2020029466A1 (zh) 图像处理方法和装置
CN107545181A (zh) 程序运行方法、终端及计算机可读存储介质
WO2020164274A1 (zh) 网络验证数据的发送方法、装置、存储介质和服务器
CN110955590A (zh) 界面检测方法、图像处理方法、装置、电子设备及存储介质
CN111641588A (zh) 网页模拟输入检测方法、装置、计算机设备及存储介质
US20150143342A1 (en) Functional validation of software
CN111324352A (zh) 一种应用页面的代码生成方法及相关设备
CN113609028A (zh) 一种页面测试方法、计算设备及可读存储介质
CN107515821B (zh) 控件测试方法和装置
CN110851349B (zh) 页面异常显示的检测方法、终端设备及存储介质
CN113901996A (zh) 设备屏幕透图检测模型训练方法及设备屏幕透图检测方法
CN113111713B (zh) 一种图像检测方法、装置、电子设备及存储介质
US20190042841A1 (en) Content verification apparatus, method for verifying content, and non-transitory computer-readable storage medium
CN111949510B (zh) 测试处理方法、装置、电子设备及可读存储介质
Chu et al. Automated GUI testing for android news applications
US20210248206A1 (en) Systems and methods for generating data retrieval steps

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 18839074

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 18839074

Country of ref document: EP

Kind code of ref document: A1

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205A DATED 03.08.2020)

122 Ep: pct application non-entry in european phase

Ref document number: 18839074

Country of ref document: EP

Kind code of ref document: A1