CN109766275B - Automated testing method, system, storage medium and device for mobile application - Google Patents

Automated testing method, system, storage medium and device for mobile application Download PDF

Info

Publication number
CN109766275B
CN109766275B CN201811633770.4A CN201811633770A CN109766275B CN 109766275 B CN109766275 B CN 109766275B CN 201811633770 A CN201811633770 A CN 201811633770A CN 109766275 B CN109766275 B CN 109766275B
Authority
CN
China
Prior art keywords
test
script
key
characteristic point
automatic
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.)
Active
Application number
CN201811633770.4A
Other languages
Chinese (zh)
Other versions
CN109766275A (en
Inventor
陈列奋
马朔
徐振涛
黄劲谦
彭颖辉
唐铭舜
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Flamingo Network Guangzhou Co ltd
Original Assignee
Flamingo Network Guangzhou Co ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Flamingo Network Guangzhou Co ltd filed Critical Flamingo Network Guangzhou Co ltd
Priority to CN201811633770.4A priority Critical patent/CN109766275B/en
Publication of CN109766275A publication Critical patent/CN109766275A/en
Application granted granted Critical
Publication of CN109766275B publication Critical patent/CN109766275B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Abstract

The invention relates to an automatic testing method, a system, a storage medium and equipment for mobile application, wherein the method comprises the following steps: initializing the running environment of the automatic testing tool, running the script engine with shell identity authority, and establishing communication connection between the script engine and the automatic testing tool; receiving an automatic test instruction, and acquiring a Lua test script and an application to be tested according to the automatic test instruction; and installing and running the mobile application to be tested, and informing the script engine to execute the Lua test script by the automatic test tool according to the automatic test instruction. The automated testing instruction is received through the automated testing tool, the script engine is informed through the automated testing tool, and the script engine executes the Lua testing script in the shell identity authority, so that a testing program does not need to be embedded in the development process, the workload of developers is reduced, the cross-application automated testing is supported, and the automated testing can be more suitable for the actual use environment of a user.

Description

Automated testing method, system, storage medium and device for mobile application
Technical Field
The present invention relates to the field of testing of mobile applications, and in particular, to an automated testing method, system, storage medium, and device for mobile applications.
Background
With the rapid development of mobile communication technology, the mobile internet becomes an indispensable component in the life of people, and mobile applications are widely used. With the increasing abundance and complexity of functions of mobile applications and the increasing acceleration of iteration speed of products, higher requirements are put forward on the quality of the mobile applications.
The automatic test is a test method which can quickly complete related functions, regression and stability, effectively improve the test efficiency and improve the test coverage rate, and is widely applied. Some of the automated testing methods adopt an embedded intrusive testing scheme, that is, some testing programs are written in the development process of the mobile application, and the testing framework is called by the testing programs to realize the testing of the mobile application.
In the process of implementing the invention, the inventor finds that the scheme of writing some test programs in the development process of the mobile application increases the workload of developers and does not fit the actual use environment of the mobile application.
Disclosure of Invention
Therefore, the invention aims to provide an automatic testing method for mobile application, which has the advantages of reducing the workload of developers and enabling the automatic testing to be more suitable for the actual use environment of users.
An automated testing method for mobile applications comprises the following steps:
initializing the running environment of an automatic testing tool, running the automatic testing tool, running a script engine with shell identity authority, and establishing communication connection between the script engine and the automatic testing tool;
receiving an automatic test instruction, and acquiring a Lua test script and an application to be tested according to the automatic test instruction;
installing and running a mobile application to be tested, and informing the script engine to execute the Lua test script by the automatic test tool according to the automatic test instruction;
the test script stores data information of a characteristic point set of the key region; the characteristic point set is a plurality of pixel points selected in the key area; the data information comprises RGB values of all the characteristic points, comparison ranges of the RGB values of all the characteristic points, absolute coordinate values of all the characteristic points, coordinate offset difference values of other characteristic points except the first characteristic point relative to the first characteristic point and a determination mode of a key region; the step of informing the script engine to execute the Lua test script by the automated test tool according to the automated test instruction comprises the following steps: and positioning the position of the key area according to the data information of the characteristic point set of the key area stored in the test script, simulating the key of the user and acquiring the key operation.
According to the invention, the automatic test instruction is received by the automatic test tool, and the script engine is informed by the automatic test tool, so that the script engine executes the Lua test script in the shell identity authority, a test program is not required to be embedded in the development process, the workload of developers is reduced, various automatic tests can be performed at high authority, and the cross-application automatic test is supported, so that the automatic test is more suitable for the actual use environment of a user. Furthermore, the expansion of the test can be conveniently carried out through the Lua test script, so that the test performance is expanded, and the test compatibility and stability are improved.
In one embodiment, the test script stores data information of a feature point set of a key region; the characteristic point set is a plurality of pixel points selected in the key area; the data information comprises RGB values of all the characteristic points, comparison ranges of the RGB values of all the characteristic points, absolute coordinate values of all the characteristic points, coordinate offset difference values of other characteristic points except the first characteristic point relative to the first characteristic point and a determination mode of a key region; the step of informing the script engine to execute the Lua test script by the automated test tool according to the automated test instruction comprises the following steps: and positioning the position of the key area according to the data information of the characteristic point set of the key area stored in the test script, simulating the key of the user and acquiring the key operation.
In an embodiment, the step of locating the position of the key region according to the data information of the feature point set of the key region stored in the test script includes:
the screen capturing method includes the steps that screen capturing is conducted on the screen state of a current mobile application to be tested, and a screen capturing picture is obtained;
determining a search path according to a set retrieval direction;
sequentially traversing screen capture pictures according to the search path, and determining pixel points in the comparison range of the RGB values of the first characteristic point in the characteristic point set of the key region;
establishing an X-Y coordinate system by taking the upper left corner of the screenshot picture as an original point, acquiring absolute coordinate values of the pixel points, and determining the pixel points which correspond to and are consistent with the absolute value coordinates of other feature points according to coordinate offset differences of other feature points in the test script; and comparing whether the RGB value of each pixel point is in the RGB value comparison range of the corresponding characteristic point, if so, obtaining the position of the key region according to a preset key region determining mode, and otherwise, feeding back a test result of positioning failure.
The keys are positioned in a screen capture mode, so that the recognition efficiency is improved, and the non-native interface test can be supported.
In an embodiment, the step of obtaining the position of the key region according to a preset determination manner of the key region includes:
determining and obtaining a rectangular area by taking the absolute value coordinate of a pixel point corresponding to the first feature point as a center according to a preset length and width value, and taking the rectangular area as the position of the key area; or;
and taking the pixel points corresponding to the characteristic points as edge points to determine an area as the position of the key area.
In an embodiment, the test script further stores text information of a key region, and after obtaining a position of the key region according to a preset key region determination manner, the method further includes the following steps:
and acquiring the text information of the key area, comparing the text information with the text information of the key area stored in the test script, judging whether the text information is consistent with the stored text information, if so, feeding back the position of the key area, and otherwise, feeding back a test result of positioning failure.
By comparing the character information in the key area, the position of the key information can be more accurately obtained.
In one embodiment, the method for determining the comparison range of RGB values of each feature point in the test script includes the following steps:
acquiring RGB values of the characteristic points and a set deflection value;
and determining the comparison range of the RGB values of each characteristic point by taking the difference value between the RGB value of the characteristic point and the set color cast value as the minimum value in the comparison range of the RGB values of the characteristic point and taking the value obtained by adding the RGB value of the characteristic point and the set color cast value as the maximum value in the comparison range of the RGB values of the characteristic point.
In one embodiment, the step of the automated testing tool informing the script engine to execute the Lua test script according to the automated test instruction comprises: simulating a user to input a Chinese text, and displaying the input Chinese text information; wherein, the step of simulating the user to input Chinese text and displaying the input Chinese text information comprises the following steps:
the method comprises the steps that a simulation user clicks an input edit box of an application to be tested, an input focus is obtained in the input edit box, and an input method switching instruction is triggered;
according to the input method switching instruction, recording the currently adopted input method, switching to a Chinese input method realized by a test script, and storing Chinese text information to be input;
when the Chinese input method starts the initialization callback, the stored Chinese text information is taken out, and the Chinese text information is output and displayed to the input edit box;
and switching the current Chinese input method back to the recorded input method.
The invention also provides an automatic test system for mobile application, which comprises:
the initialization module is used for initializing the running environment of the automatic testing tool, running a script engine with shell identity authority and establishing communication connection between the script engine and the automatic testing tool;
the test instruction acquisition module is used for receiving an automatic test instruction and acquiring a Lua test script and an application to be tested according to the automatic test instruction;
the Lua test script execution module is used for installing and running a mobile application to be tested, and the automated test tool informs the script engine to execute the Lua test script according to the automated test instruction;
the test script stores data information of a characteristic point set of the key region; the characteristic point set is a plurality of pixel points selected in the key area; the data information comprises RGB values of all the characteristic points, comparison ranges of the RGB values of all the characteristic points, absolute coordinate values of all the characteristic points, coordinate offset difference values of other characteristic points except the first characteristic point relative to the first characteristic point and a determination mode of a key region; the Lua test script execution module is specifically configured to: and positioning the position of the key area according to the data information of the characteristic point set of the key area stored in the test script, simulating the key of the user and acquiring the key operation.
According to the invention, the automatic test instruction is received by the automatic test tool, and the script engine is informed by the automatic test tool, so that the script engine executes the Lua test script in the shell identity authority, a test program is not required to be embedded in the development process, the workload of developers is reduced, various automatic tests can be performed at high authority, and the cross-application automatic test is supported, so that the automatic test is more suitable for the actual use environment of a user. Furthermore, the expansion of the test can be conveniently carried out through the Lua test script, so that the test performance is expanded, and the test compatibility and stability are improved.
The invention also provides a computer-readable storage medium, on which a computer program is stored, which computer program, when being executed by a processor, carries out the steps of the method for automated testing of mobile applications as defined in any of the above.
The invention also provides a computer device, which comprises a storage, a processor and a computer program stored in the storage and executable by the processor, wherein the processor executes the computer program to realize the steps of the automatic testing method of the mobile application.
For a better understanding and practice, the invention is described in detail below with reference to the accompanying drawings.
Drawings
FIG. 1 is a flow chart of a method for automated testing of mobile applications in an embodiment of the present invention;
FIG. 2 is a flow chart of positioning a key in an embodiment of the present invention;
FIG. 3 is a flow chart of simulating a user inputting Chinese text in an embodiment of the present invention;
FIG. 4 is a functional block diagram of an automated testing system for mobile applications in an embodiment of the present invention;
FIG. 5 is a schematic block diagram of a Lua test script execution module for positioning a key in an embodiment of the present invention;
FIG. 6 is a flowchart of a Lua test script execution module for simulating a user inputting Chinese text according to an embodiment of the present invention.
Detailed Description
Referring to fig. 1, the automated testing method for mobile applications of the present invention includes the following steps:
step S1: initializing the running environment of the automatic testing tool, running a script engine with shell identity authority, and establishing communication connection between the script engine and the automatic testing tool.
The Shell is also called a Shell, and refers to software for providing a user interface, and its essence is a command parser, which receives a user command and then calls a corresponding application program. The shell identity authority is a higher authority which can be obtained without destroying the system environment so as to execute high-authority operation used in an automatic test, such as a script engine executing high-authority operation such as simulating user touch click, simulating user input events, screenshot of a mobile phone, cross-application simulation user operation and the like.
The automatic testing tool runs in a foreground Service mode and runs in the running environment of the abstract class of Android Context to provide calling for Android system functions. The script engine process and the automatic test tool are connected and communicated through a socket, a lightweight remote procedure call protocol (JSON-RPC) protocol is used for transmitting relevant data, and the script engine process and the automatic test tool are matched with each other to completely provide functions required by running of the test script.
The steps of initializing the running environment of the automatic testing tool, running or executing a script engine with shell identity authority, and establishing the communication connection between the script engine and the automatic testing tool comprise:
step S11: opening a developer USB debugging mode through a test mobile phone, and connecting to a PC end through a USB line;
step S12: uploading the operating environment deployment script to the test mobile phone through an adb push command;
step S13: after entering a shell through an adb shell command, executing a running environment deployment script to initialize the running environment of the automatic test tool;
step S14: the automatic test tool runs in a foreground Service mode;
step S15: running an environment deployment script to execute a system nohup command, and starting a script engine in a shell process identity background through app _ process/app _ process 32;
step S16: the automated testing tool and the script engine use a JSON-RPC protocol and establish data transmission communication based on the socket.
Step S2: and receiving an automatic test instruction, and acquiring a test script and an application to be tested according to the automatic test instruction.
Step S3: and installing and running the mobile application to be tested, and informing the script engine to execute the Lua test script by the automatic test tool according to the automatic test instruction.
The Lua test script uses a standard module management library, which comprises a built-in function module composed of a basic function module and an optional function module, wherein the basic function module forms a core function of a script engine, the script engine is loaded in advance when started, the optional function module is an extension module, such as an ocr auxiliary function module and a socket auxiliary function module, and the function module can be loaded as required by adopting a require () function. In addition, a testing function interface suitable for the operation of the Android system can be expanded by utilizing an Android system bottom layer command and architecture (framework) layer open/hidden Application Programming interface (API for short), and an expansion module corresponding to the bottom layer can be automatically called by calling the testing function interface. In addition, according to the test requirements, a Lua extension interface and a loading-on-demand mechanism are utilized, the C/C + + extension function module is based on, and then loading is carried out when the script is executed, so that the plugins of the test function are realized, the test script provides better system compatibility and stability and better customizability, expansibility and plugins, specifically required test function plugins can be issued according to different test tasks, and the problems that half of test frames are poor in extension capability, or do not support extension, or can be simply packaged only based on the test frames are solved
According to the invention, the automatic test instruction is received by the automatic test tool, and the script engine is informed by the automatic test tool, so that the script engine executes the Lua test script in the shell identity authority, a test program is not required to be embedded in the development process, the workload of developers is reduced, various automatic tests can be performed at high authority, and the cross-application automatic test is supported, so that the automatic test is more suitable for the actual use environment of a user. Furthermore, the expansion of the test can be conveniently carried out through the Lua test script, so that the test performance is expanded, and the test compatibility and stability are improved.
In one embodiment, the test script stores data information of a feature point set of a key region; the characteristic point set is a plurality of pixel points selected in the key area; the data information comprises RGB values of all the characteristic points, comparison ranges of the RGB values of all the characteristic points, absolute coordinate values of all the characteristic points, coordinate offset difference values of other characteristic points except the first characteristic point relative to the first characteristic point and a determination mode of a key region. In one embodiment, the method for determining the comparison range of RGB values of each feature point in the test script includes the following steps: acquiring RGB values of the characteristic points and a set deflection value; and determining the comparison range of the RGB values of each characteristic point by taking the difference value between the RGB value of the characteristic point and the set color cast value as the minimum value in the comparison range of the RGB values of the characteristic point and taking the value obtained by adding the RGB value of the characteristic point and the set color cast value as the maximum value in the comparison range of the RGB values of the characteristic point. For example, if the RGB value of one of the feature points is { r, g, b }, and the set bias value is { diffr, diffg, diffb }, the comparison range value of the RGB values of the feature point is: { r-diffr, g-diffg, b-diffb } - { r + diffr, g + diffg, b + diffb }. In one embodiment, the step of determining the coordinate offset difference of other feature points except the first feature point from the first feature point in the test script includes: the screen capturing method comprises the steps of capturing a screen state of an application to be tested to obtain a screen capturing picture; selecting a key area in the screen capture picture, and selecting a plurality of pixel points in the key area as a feature point set; establishing an X-Y coordinate system by taking the upper left corner of the selected screenshot picture as an origin, and determining absolute value coordinate values of all feature points in the feature point set; and taking the difference value of other feature points except the first feature point in the feature point set and the first feature point as the coordinate offset difference value of the corresponding feature point. For example, if the absolute value coordinates of each feature point in the feature point set are { x1, y1 }; { x2, y2 }; { x3, y3 }; wherein { x1, y1} is an absolute value coordinate of the first feature point, and coordinate offset differences of other feature points except the first feature point relative to the first feature point are { x2-x1, y2-y1 }; { x3-x1, y3-y1 }. In one embodiment, the text information is text in a TXT format.
Referring to fig. 2, the step of informing the script engine to execute the Lua test script according to the automated test instruction by the automated test tool includes: and positioning the position of the key area according to the data information of the characteristic point set of the key area stored in the test script, simulating the key of the user and acquiring the key operation. In order to solve the problems that in an automated test, only a control can identify a positioning key, which results in low identification efficiency and does not support a non-native interface test, in an embodiment, the step of positioning the key position includes:
step S311: and capturing the screen of the screen state of the current mobile application to be tested to obtain a screen capture picture.
Step S312: and determining a search path according to the set search direction.
In one embodiment, the retrieval direction is a retrieval direction determined by three dimensions, i.e., horizontal direction first and then vertical direction or vertical direction first and then horizontal direction, left to right or right to left, and top to bottom or bottom to top.
Step S313: and traversing the screen shot pictures in sequence according to the search path, and determining pixel points in the comparison range of the RGB values of the first characteristic point in the characteristic point set of the key area.
Step S314: establishing an X-Y coordinate system by taking the upper left corner of the screenshot picture as an original point, acquiring absolute coordinate values of the pixel points, and determining the pixel points which correspond to and are consistent with the absolute value coordinates of other feature points according to coordinate offset differences of other feature points in the test script; and comparing whether the RGB value of each pixel point is in the RGB value comparison range of the corresponding characteristic point, if so, obtaining the position of the key region according to a preset key region determining mode, and otherwise, feeding back a test result of positioning failure.
The keys are positioned in a screen capture mode, so that the recognition efficiency is improved, and the non-native interface test can be supported.
In an embodiment, the step of obtaining the position of the key region according to a preset determination manner of the key region includes:
determining and obtaining a rectangular area by taking the absolute value coordinate of a pixel point corresponding to the first feature point as a center according to a preset length and width value, and taking the rectangular area as the position of the key area; or;
and taking the pixel points corresponding to the characteristic points as edge points to determine an area as the position of the key area.
In order to determine the position of the key region more accurately, in an embodiment, the test script further stores text information of the key region, and after obtaining the position of the key region according to a preset determination manner of the key region, the method further includes the following steps:
and acquiring the text information of the key area, comparing the text information with the text information of the key area stored in the test script, judging whether the text information is consistent with the stored text information, if so, feeding back the position of the key area, and otherwise, feeding back a test result of positioning failure.
In one embodiment, the manner of acquiring the text information of the feature region is to perform recognition by an OCR text recognition technology. In one embodiment, a screencap command is called to intercept the current screen, and the data stream of the intercepted picture is directly acquired through a command line pipeline, so that the file io operation is avoided, and the screenshot efficiency is improved.
Referring to fig. 3, in order to solve the problem that in an automated test, when a system-based command of an input text is executed to implement cross-application text input, chinese input is not supported, in an embodiment, the step of notifying the script engine to execute the Lua test script by the automated test tool according to the automated test instruction includes: simulating a user to input a Chinese text, and displaying the input Chinese text information; wherein, the step of simulating the user to input Chinese text and displaying the input Chinese text information comprises the following steps:
step S321: and the simulation user clicks an input edit box of the application to be tested, acquires an input focus in the input edit box and triggers an input method switching instruction.
Step S322: and recording the currently adopted input method according to the input method switching instruction, switching to a Chinese input method realized by the test script, and storing the Chinese text information to be input.
Step S323: and when the Chinese input method starts the initialization callback, the stored Chinese text information is taken out, and the Chinese text information is output and displayed to the input edit box.
Step S324: and switching the current Chinese input method back to the recorded input method.
Referring to fig. 4, the present invention further provides an automated testing system 1 for mobile applications, comprising:
the initialization module 11 is configured to initialize an operating environment of the automatic test tool, run the script engine with the shell identity authority, and establish a communication connection between the script engine and the automatic test tool.
And the test instruction acquisition module 12 is configured to receive an automatic test instruction, and acquire a Lua test script and an application to be tested according to the automatic test instruction.
And the Lua test script execution module 13 is configured to install and run a mobile application to be tested, and the automated test tool notifies the script engine to execute the Lua test script according to the automated test instruction.
According to the invention, the automatic test instruction is received by the automatic test tool, and the script engine is informed by the automatic test tool, so that the script engine executes the Lua test script in the shell identity authority, a test program is not required to be embedded in the development process, the workload of developers is reduced, various automatic tests can be performed at high authority, and the cross-application automatic test is supported, so that the automatic test is more suitable for the actual use environment of a user. Furthermore, the expansion of the test can be conveniently carried out through the Lua test script, so that the test performance is expanded, and the test compatibility and stability are improved.
In one embodiment, the test script stores data information of a feature point set of a key region; the characteristic point set is a plurality of pixel points selected in the key area; the data information comprises RGB values of all the characteristic points, comparison ranges of the RGB values of all the characteristic points, absolute coordinate values of all the characteristic points, coordinate offset difference values of other characteristic points except the first characteristic point relative to the first characteristic point and a determination mode of a key region. In one embodiment, the method for determining the comparison range of RGB values of each feature point in the test script includes the following steps: acquiring RGB values of the characteristic points and a set deflection value; and determining the comparison range of the RGB values of each characteristic point by taking the difference value between the RGB value of the characteristic point and the set color cast value as the minimum value in the comparison range of the RGB values of the characteristic point and taking the value obtained by adding the RGB value of the characteristic point and the set color cast value as the maximum value in the comparison range of the RGB values of the characteristic point. For example, if the RGB value of one of the feature points is { r, g, b }, and the set bias value is { diffr, diffg, diffb }, the comparison range value of the RGB values of the feature point is: { r-diffr, g-diffg, b-diffb } - { r + diffr, g + diffg, b + diffb }. In one embodiment, the step of determining the coordinate offset difference of other feature points except the first feature point from the first feature point in the test script includes: the screen capturing method comprises the steps of capturing a screen state of an application to be tested to obtain a screen capturing picture; selecting a key area in the screen capture picture, and selecting a plurality of pixel points in the key area as a feature point set; establishing an X-Y coordinate system by taking the upper left corner of the selected screenshot picture as an origin, and determining absolute value coordinate values of all feature points in the feature point set; and taking the difference value of other feature points except the first feature point in the feature point set and the first feature point as the coordinate offset difference value of the corresponding feature point. For example, if the absolute value coordinates of each feature point in the feature point set are { x1, y1 }; { x2, y2 }; { x3, y3 }; wherein { x1, y1} is an absolute value coordinate of the first feature point, and coordinate offset differences of other feature points except the first feature point relative to the first feature point are { x2-x1, y2-y1 }; { x3-x1, y3-y1 }. In one embodiment, the text information is text in a TXT format.
Referring to fig. 5, the Lua test script execution module 3 is specifically configured to: and positioning the position of the key area according to the data information of the characteristic point set of the key area stored in the test script, simulating the key of the user and acquiring the key operation. In order to solve the problems that in an automated test, only the control can identify the positioning key, which results in low identification efficiency, and the non-native interface test is not supported, in an embodiment, when the Lua test script execution module 13 is used for positioning the position of the positioning key in the key region, the method further includes:
the screen capture module 1311 is configured to capture a screen of a screen state of the mobile application to be tested currently, so as to obtain a screen capture picture.
A search path determining module 1312, configured to determine a search path according to the set search direction.
In one embodiment, the retrieval direction is a retrieval direction determined by three dimensions, i.e., horizontal direction first and then vertical direction or vertical direction first and then horizontal direction, left to right or right to left, and top to bottom or bottom to top.
A pixel point obtaining module 1313, configured to sequentially traverse the screenshot picture according to the search path, and determine a pixel point within a comparison range of RGB values of a first feature point in the feature point set of the key region.
A key region determining module 1314, configured to establish an X-Y coordinate system with the upper left corner of the screenshot as an origin, obtain absolute coordinate values of the pixel points, and determine pixel points respectively corresponding to the absolute value coordinates of other feature points according to coordinate offset differences of other feature points in the test script; and comparing whether the RGB value of each pixel point is in the RGB value comparison range of the corresponding characteristic point, if so, obtaining the position of the key region according to a preset key region determining mode, and otherwise, feeding back a test result of positioning failure.
In an embodiment, the key region determining module is configured to, when obtaining the position of the key region according to a preset key region determining manner, specifically:
determining and obtaining a rectangular area by taking the absolute value coordinate of a pixel point corresponding to the first feature point as a center according to a preset length and width value, and taking the rectangular area as the position of the key area; or;
and taking the pixel points corresponding to the characteristic points as edge points to determine an area as the position of the key area.
In order to determine the position of the key region more accurately, in an embodiment, the test script further stores text information of the key region, and the Lua test script execution module 3 is configured to, after obtaining the position of the key region according to a preset key region determining manner, further include:
and the character information comparison module is used for acquiring the character information of the key area, comparing the character information with the character information of the key area stored in the test script, judging whether the character information is consistent with the stored character information, if so, feeding back the position of the key area, and otherwise, feeding back a test result of positioning failure.
Referring to fig. 6, in order to solve the problem that in the automated testing, when the input text is executed by the system bottom level command, the input text is not supported by chinese input, in an embodiment, the Lua test script execution module 3 is further specifically configured to: simulating a user to input a Chinese text, and displaying the input Chinese text information; the Lua test script execution module 3 is used for simulating a user to input a Chinese text, and includes:
the input method switching instruction triggering module 1321 is configured to simulate a user to click an input edit box of an application to be tested, acquire an input focus in the input edit box, and trigger an input method switching instruction.
And the storage module 1322 is used for recording the currently adopted input method according to the input method switching instruction, switching to the Chinese input method realized by the test script, and storing the Chinese text information to be input.
And the display module 1323 is configured to, when the chinese input method starts the initialization callback, take out the stored chinese text information, and output and display the chinese text information to the input edit box.
And a switching module 1324, configured to switch the current chinese input method back to the recorded input method.
The invention also provides a computer-readable storage medium, on which a computer program is stored, which computer program, when being executed by a processor, carries out the steps of the method for automated testing of mobile applications as defined in any of the above.
The present invention may take the form of a computer program product embodied on one or more storage media including, but not limited to, disk storage, CD-ROM, optical storage, and the like, having program code embodied therein. Computer readable storage media, which include both non-transitory and non-transitory, removable and non-removable media, may implement any method or technology for storage of information. The information may be computer readable instructions, data structures, modules of a program, or other data. Examples of the storage medium of the computer include, but are not limited to: phase change memory (PRAM), Static Random Access Memory (SRAM), Dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), Read Only Memory (ROM), Electrically Erasable Programmable Read Only Memory (EEPROM), flash memory or other memory technologies, compact disc read only memory (CD-ROM), Digital Versatile Discs (DVD) or other optical storage, magnetic tape storage or other magnetic storage devices, or any other non-transmission medium, may be used to store information that may be accessed by a computing device.
The invention also provides a computer device, which comprises a storage, a processor and a computer program stored in the storage and executable by the processor, wherein the processor executes the computer program to realize the steps of the automatic testing method of the mobile application.
The above-mentioned embodiments only express several embodiments of the present invention, and the description thereof is more specific and detailed, but not construed as limiting the scope of the invention. It should be noted that, for a person skilled in the art, several variations and modifications can be made without departing from the inventive concept, which falls within the scope of the present invention.

Claims (9)

1. An automated testing method for mobile applications is characterized by comprising the following steps:
initializing the running environment of an automatic testing tool, running the automatic testing tool, running a script engine with shell identity authority, and establishing communication connection between the script engine and the automatic testing tool;
receiving an automatic test instruction, and acquiring a Lua test script and an application to be tested according to the automatic test instruction;
installing and running a mobile application to be tested, and informing the script engine to execute the Lua test script by the automatic test tool according to the automatic test instruction;
the test script stores data information of a characteristic point set of the key region; the characteristic point set is a plurality of pixel points selected in the key area; the data information comprises RGB values of all the characteristic points, comparison ranges of the RGB values of all the characteristic points, absolute coordinate values of all the characteristic points, coordinate offset difference values of other characteristic points except the first characteristic point relative to the first characteristic point and a determination mode of a key region; the step of informing the script engine to execute the Lua test script by the automated test tool according to the automated test instruction comprises the following steps: and positioning the position of the key area according to the data information of the characteristic point set of the key area stored in the test script, simulating the key of the user and acquiring the key operation.
2. The method according to claim 1, wherein the step of locating the position of the key region according to the data information of the feature point set of the key region stored in the test script comprises:
the screen capturing method includes the steps that screen capturing is conducted on the screen state of a current mobile application to be tested, and a screen capturing picture is obtained;
determining a search path according to a set retrieval direction;
sequentially traversing screen capture pictures according to the search path, and determining pixel points in the comparison range of the RGB values of the first characteristic point in the characteristic point set of the key region;
establishing an X-Y coordinate system by taking the upper left corner of the screenshot picture as an original point, acquiring absolute coordinate values of the pixel points, and determining the pixel points which correspond to and are consistent with the absolute value coordinates of other feature points according to coordinate offset differences of other feature points in the test script; and comparing whether the RGB value of each pixel point is in the RGB value comparison range of the corresponding characteristic point, if so, obtaining the position of the key region according to a preset key region determining mode, and otherwise, feeding back a test result of positioning failure.
3. The automated testing method for mobile applications according to claim 2, wherein the step of obtaining the position of the key region according to the predetermined key region determination manner comprises:
determining and obtaining a rectangular area by taking the absolute value coordinate of a pixel point corresponding to the first feature point as a center according to a preset length and width value, and taking the rectangular area as the position of the key area; or;
and taking the pixel points corresponding to the characteristic points as edge points to determine an area as the position of the key area.
4. The automated testing method for mobile applications according to claim 3, wherein the testing script further stores text information of a key region, and after obtaining the position of the key region according to a predetermined key region determination manner, the method further comprises the following steps:
and acquiring the text information of the key area, comparing the text information with the text information of the key area stored in the test script, judging whether the text information is consistent with the stored text information, if so, feeding back the position of the key area, and otherwise, feeding back a test result of positioning failure.
5. The method according to claim 1, wherein the determination of the RGB values of each feature point in the test script comprises the following steps:
acquiring RGB values of the characteristic points and a set deflection value;
and determining the comparison range of the RGB values of each characteristic point by taking the difference value between the RGB value of the characteristic point and the set color cast value as the minimum value in the comparison range of the RGB values of the characteristic point and taking the value obtained by adding the RGB value of the characteristic point and the set color cast value as the maximum value in the comparison range of the RGB values of the characteristic point.
6. The automated testing method for mobile applications according to claim 1, wherein the step of the automated testing tool informing the script engine to execute the Lua test script according to the automated testing instruction comprises: simulating a user to input a Chinese text, and displaying the input Chinese text information; wherein, the step of simulating the user to input Chinese text and displaying the input Chinese text information comprises the following steps:
the method comprises the steps that a simulation user clicks an input edit box of an application to be tested, an input focus is obtained in the input edit box, and an input method switching instruction is triggered;
according to the input method switching instruction, recording the currently adopted input method, switching to a Chinese input method realized by a test script, and storing Chinese text information to be input;
when the Chinese input method starts the initialization callback, the stored Chinese text information is taken out, and the Chinese text information is output and displayed to the input edit box;
and switching the current Chinese input method back to the recorded input method.
7. An automated test system for mobile applications, comprising:
the initialization module is used for initializing the running environment of the automatic testing tool, running a script engine with shell identity authority and establishing communication connection between the script engine and the automatic testing tool;
the test instruction acquisition module is used for receiving an automatic test instruction and acquiring a Lua test script and an application to be tested according to the automatic test instruction;
the Lua test script execution module is used for installing and running a mobile application to be tested, and the automated test tool informs the script engine to execute the Lua test script according to the automated test instruction;
the test script stores data information of a characteristic point set of the key region; the characteristic point set is a plurality of pixel points selected in the key area; the data information comprises RGB values of all the characteristic points, comparison ranges of the RGB values of all the characteristic points, absolute coordinate values of all the characteristic points, coordinate offset difference values of other characteristic points except the first characteristic point relative to the first characteristic point and a determination mode of a key region; the Lua test script execution module is specifically configured to: and positioning the position of the key area according to the data information of the characteristic point set of the key area stored in the test script, simulating the key of the user and acquiring the key operation.
8. A computer-readable storage medium, on which a computer program is stored which, when being executed by a processor, carries out the steps of the method for automated testing of a mobile application according to any one of claims 1 to 6.
9. A computer device comprising a memory, a processor and a computer program stored in the memory and executable by the processor, the processor implementing the steps of the method for automated testing of a mobile application according to any one of claims 1 to 6 when executing the computer program.
CN201811633770.4A 2018-12-29 2018-12-29 Automated testing method, system, storage medium and device for mobile application Active CN109766275B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811633770.4A CN109766275B (en) 2018-12-29 2018-12-29 Automated testing method, system, storage medium and device for mobile application

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811633770.4A CN109766275B (en) 2018-12-29 2018-12-29 Automated testing method, system, storage medium and device for mobile application

Publications (2)

Publication Number Publication Date
CN109766275A CN109766275A (en) 2019-05-17
CN109766275B true CN109766275B (en) 2022-04-26

Family

ID=66452354

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811633770.4A Active CN109766275B (en) 2018-12-29 2018-12-29 Automated testing method, system, storage medium and device for mobile application

Country Status (1)

Country Link
CN (1) CN109766275B (en)

Families Citing this family (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
TWI730384B (en) * 2019-08-22 2021-06-11 新煒科技有限公司 Image testing method, device, computer device and readbale storage medium
CN111309617A (en) * 2020-02-21 2020-06-19 北京字节跳动网络技术有限公司 Application program control method and device, storage medium and electronic equipment
CN112737876B (en) * 2020-12-24 2022-07-08 四川爱联科技股份有限公司 Plug-in type test system and test method based on cloud

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103744787A (en) * 2014-01-21 2014-04-23 上海斐讯数据通信技术有限公司 Cellphone automated testing method
CN105740148A (en) * 2016-01-29 2016-07-06 博雅网信(北京)科技有限公司 Script engine system of mobile terminal automation test and testing method
CN108153672A (en) * 2017-12-25 2018-06-12 苏州蜗牛数字科技股份有限公司 The automatization test system and test method of a kind of mobile application
CN108509343A (en) * 2018-04-04 2018-09-07 浙江小泰科技有限公司 Automated testing method based on image recognition technology and system

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9804956B2 (en) * 2015-08-11 2017-10-31 American Express Travel Related Services Company, Inc. Automated testing of webpages

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103744787A (en) * 2014-01-21 2014-04-23 上海斐讯数据通信技术有限公司 Cellphone automated testing method
CN105740148A (en) * 2016-01-29 2016-07-06 博雅网信(北京)科技有限公司 Script engine system of mobile terminal automation test and testing method
CN108153672A (en) * 2017-12-25 2018-06-12 苏州蜗牛数字科技股份有限公司 The automatization test system and test method of a kind of mobile application
CN108509343A (en) * 2018-04-04 2018-09-07 浙江小泰科技有限公司 Automated testing method based on image recognition technology and system

Also Published As

Publication number Publication date
CN109766275A (en) 2019-05-17

Similar Documents

Publication Publication Date Title
CN109766275B (en) Automated testing method, system, storage medium and device for mobile application
US9317413B2 (en) Testing device and testing method thereof
US10853232B2 (en) Adaptive system for mobile device testing
CN105094783B (en) method and device for testing stability of android application
US20140211021A1 (en) Test system for evaluating mobile device and driving method thereof
GB2513431A (en) Method for creating a label
US20180039559A1 (en) Method and apparatus for creating reference images for an automated test of software with a graphical user interface
CN112947969B (en) Page off-screen rendering method, device, equipment and readable medium
CN107678948B (en) Test case generation method, terminal and storage medium
CN105740144A (en) Automated testing method and system for Android mobile Terminal
CN110837474A (en) Script recording method, device, terminal and storage medium
US20190235881A1 (en) Automatic Import Of Third Party Analytics
CN112732587A (en) Method and device for acquiring automatic test log, electronic equipment and storage medium
CN112732576A (en) Automatic testing method, device and equipment based on user interface
CN110688245B (en) Information acquisition method, device, storage medium and equipment
CN112711536A (en) Automatic dial testing method and system, and computer readable storage medium
CN105339974B (en) Analog sensor
CN111258875A (en) Interface test method and system, electronic device and storage medium
CN115543831A (en) Test script generation method, device, equipment and storage medium
Amirgaliyev et al. Development of applications to mobile devices in Android platform
CN115982018B (en) UI test method, system, computer device and storage medium based on OCR
CN111309613A (en) Application testing method, device, equipment and computer readable storage medium
CN111338961A (en) Application debugging method and device, electronic equipment and storage medium
CN111708704B (en) Cloud real machine testing method, device, terminal and storage medium
CN110162966B (en) Data processing method and device, electronic equipment and 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