A method, device and storage medium for automatic testing of pages
By identifying and filtering interface elements, generating and executing test reports, the problems of high maintenance costs and low coverage of traditional UI automation testing when changes in APP interface are solved, and full coverage and efficient testing of APP interface are achieved.
Patent Information
- Application Number
- CN202010998381.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-09-21
- Publication Date
- 2024-11-26
- Estimated Expiration
- 2040-09-21
AI Technical Summary
The traditional UI automation test mode needs to be fully modified when the APP interface changes, resulting in high maintenance costs and difficulty in achieving full coverage of the APP interface.
By loading the page to be tested, traversing and reading the package name attributes of the visible operation elements, filtering elements that do not belong to the page, generating a queue to be operated, performing operations and generating test reports, identifying the interface element structure to achieve automated traversal, reducing maintenance costs and improving maintenance costs Page coverage.
It achieves full coverage of the APP interface, reduces maintenance costs, improves testing efficiency and coverage, and reduces the difficulty of adapting interface changes.
Smart Images

Figure CN112131111B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of Internet technology, and in particular to a method, device and storage medium for automatically testing a page. Background Art
[0002] User Interface (UI) automated testing is a very important auxiliary means of testing applications. Using automated testing technology instead of manual testing plays a great role in improving test efficiency and reducing regression testing costs. However, while providing convenience, traditional UI automation implementation solutions also generate high maintenance costs. Generally, in traditional UI automated testing models, each step must have clear operating elements declared in advance, and each test case consists of a series of fixed operating steps. This means that when there are major changes in the APP interface, the test case must be fully modified to match the latest interface, and the maintenance cost is huge. As a result, the scale of automated test cases is limited, and it is difficult to achieve full coverage of the APP interface. Summary of the invention
[0003] The embodiment of the present application provides a method for automatically testing a page, which overcomes the problem that test samples need to be re-declared when performing page testing.
[0004] The method includes:
[0005] Load the page to be tested;
[0006] Traversing the page to be tested, reading visible operation elements on the page to be tested, and obtaining package name attributes of the visible operation elements, and filtering the visible operation elements that do not belong to the page to be tested based on the package name attributes;
[0007] Traversing the visible operation elements contained in the generated queue to be operated, and comparing them with the current visible operation elements, and when the current visible operation element does not exist in the queue to be operated, putting the visible operation element into the queue to be operated;
[0008] Execute corresponding operations on the visible operation elements in the queue to be operated, and put the visible operation elements that have completed the operation into the queue of executed operations;
[0009] When the queue for operations is empty, a test report corresponding to the page to be tested is generated based on the visible operation elements in the queue for executed operations.
[0010] Optionally, performing corresponding operations on the visible operation elements in the queue to be operated;
[0011] Acquire a first activity class name of the page to be tested where the visible operation element is located, and a second activity class name of the display page after the visible operation element performs an operation;
[0012] When the first activity class name and the second activity class name are inconsistent, it is determined whether the page to be tested has been traversed to completion, and the operable element corresponding to the displayed page that has been traversed to completion is placed in an executed operation queue.
[0013] Optionally, after the corresponding operation is performed on the visible operation element, the queue for operations is searched to see whether there is a visible operation element belonging to the same first activity class name as the visible operation element that has performed the operation, and if not, it is determined that the current page to be tested has been traversed.
[0014] Optionally, in the process of performing the corresponding operation on the visible operation element, the number of the operations performed on the page to be tested and the screenshots of the operation contents corresponding to each of the operations are obtained;
[0015] Recording abnormal information on the page to be tested;
[0016] The operation content screenshot and the exception information of at least one visible operation element in at least one of the pages to be tested, as well as the version number information and the test time period of the application program in which the page to be tested is located, are associated to generate a test report corresponding to the page to be tested.
[0017] Optionally, based on the first activity category name of the page to be tested, when the first activity category name carries a blacklist page identifier, the page to be tested is filtered.
[0018] Optionally, based on the package name attribute of the visible operation element, when the package name attribute carries a blacklist element identifier, the visible operation element is filtered.
[0019] In another embodiment of the present invention, a device for performing automatic testing on a page is provided, the device comprising:
[0020] Loading module, used to load the page to be tested;
[0021] A first traversal module is used to traverse the page to be tested, read the visible operation elements on the page to be tested, and obtain the package name attribute of the visible operation elements, and filter the visible operation elements that do not belong to the page to be tested based on the package name attribute;
[0022] A second traversal module is used to traverse the visible operation elements contained in the generated queue to be operated, and compare them with the current visible operation elements, and put the visible operation elements into the queue to be operated when the current visible operation element does not exist in the queue to be operated;
[0023] An execution module, configured to execute corresponding operations on the visible operation elements in the queue to be operated, and put the visible operation elements for which the operations have been completed into a queue of executed operations;
[0024] A generating module is used to generate a test report corresponding to the page to be tested based on the visible operation elements in the executed operation queue when the queue to be operated is empty.
[0025] Optionally, the execution module includes:
[0026] An execution unit, configured to execute corresponding operations on the visible operation elements in the queue to be operated;
[0027] A first acquisition unit, configured to acquire a first activity class name of the page to be tested where the visible operation element is located, and a second activity class name of the display page after the visible operation element performs an operation;
[0028] The judging unit is used to judge whether the page to be tested has been traversed to completion when the first activity class name and the second activity class name are inconsistent, and put the operable element corresponding to the displayed page that has been traversed to the executed operation queue.
[0029] Optionally, the judging unit is further configured to:
[0030] After the corresponding operation is performed on the visible operation element, the queue for operations is searched to see whether there is a visible operation element belonging to the same first activity class name as the visible operation element that has completed the operation, and if not, it is determined that the current page to be tested has been traversed.
[0031] Optionally, the generating module includes:
[0032] A second acquisition unit is used to acquire the number of operations performed on the page to be tested and operation content screenshots corresponding to each operation in the process of performing the corresponding operation on the visible operation element;
[0033] A recording unit, used for recording abnormal information on the page to be tested;
[0034] A generating unit is used to associate the operation content screenshot and the exception information of at least one visible operation element in at least one of the pages to be tested, as well as the version number information and the test time period of the application program in which the page to be tested is located, to generate a test report corresponding to the page to be tested.
[0035] Optionally, the device further comprises:
[0036] The first filtering module is used to filter the page to be tested based on the first activity category name of the page to be tested, when the first activity category name carries a blacklist page identifier.
[0037] Optionally, the device further comprises:
[0038] The second filtering module is used to filter the visible operation element based on the package name attribute of the visible operation element when the package name attribute carries a blacklist element identifier.
[0039] In another embodiment of the present invention, a non-transitory computer-readable storage medium is provided, wherein the non-transitory computer-readable storage medium stores instructions, which, when executed by a processor, cause the processor to perform each step in the above-mentioned method for automatically testing a page.
[0040] In another embodiment of the present invention, a terminal device is provided, including a processor, wherein the processor is used to execute each step of the above-mentioned method for automatically testing a page.
[0041] Based on the above embodiment, first load the page to be tested, then traverse the page to be tested, read the visible operation elements on the page to be tested, and obtain the package name attribute of the visible operation elements, based on the package name attribute, filter the visible operation elements that do not belong to the page to be tested, further, traverse the visible operation elements contained in the queue to be operated that has been generated, and compare them with the current visible operation elements, when the current visible operation elements do not exist in the queue to be operated, put the visible operation elements into the queue to be operated, then, perform the corresponding operation on the visible operation elements in the queue to be operated, and put the visible operation elements that have completed the operation into the queue of executed operations, and finally, when the queue to be operated is empty, generate a test report corresponding to the page to be tested based on the visible operation elements in the queue of executed operations. The embodiment of the present application automatically traverses the page to be tested by identifying the element structure on the current interface during operation, thereby achieving full coverage of the page to be tested in the application, reducing maintenance costs and improving page coverage. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the embodiments will be briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present application and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.
[0043] Figure 1 A schematic diagram of a flow chart of a method for automatically testing a page provided by embodiment 100 of the present application is shown;
[0044] Figure 2 A schematic diagram showing a specific process of a method for performing automated testing on a page provided by embodiment 200 of the present application;
[0045] Figure 3 A schematic diagram showing that the embodiment 300 of the present application also provides an apparatus for performing automatic testing on a page;
[0046] Figure 4 A schematic diagram of a terminal device provided in embodiment 400 of the present application is shown. DETAILED DESCRIPTION
[0047] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0048] The terms "first", "second", "third", "fourth", etc. (if any) in the specification and claims of the present invention and the above-mentioned drawings are used to distinguish similar objects, and are not necessarily used to describe a specific order or sequence. It should be understood that the data used in this way can be interchangeable where appropriate, so that the implementation of the present invention described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions. For example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units that are clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0049] Based on the problems in the prior art, an embodiment of the present application provides a method for automated testing of pages, which is mainly applicable to the field of Internet technology. Based on the simple configuration of the traversal program, automated traversal testing of the pages to be tested contained in the application is implemented, which greatly reduces the traversal testing cost and achieves a high coverage of the testing of the pages to be tested in the application. The technical scheme of the present invention is described in detail with specific embodiments below to implement a method for automated testing of pages. The following specific embodiments may be combined with each other, and the same or similar concepts or processes may not be repeated in some embodiments. Figure 1 FIG. 1 is a flow chart of a method for automatically testing a page provided by Embodiment 100 of the present application. The detailed steps are as follows:
[0050] S11, load the page to be tested.
[0051] In this step, the Android Robotium framework is used to drive the application to be tested. Furthermore, the dumpWindowHierarchy method provided by the UiDevice module of the UIAutomator tool is used to load the page to be tested.
[0052] S12, traversing the page to be tested, reading the visible operation elements on the page to be tested, and obtaining the package name attributes of the visible operation elements, and filtering the visible operation elements that do not belong to the page to be tested based on the package name attributes.
[0053] In this step, traverse each page to be tested, and use the UiDevice.getInstance().dumpWindowHierarchy() method provided by the UIAutomator tool to obtain the visible operation elements on the current page to be tested. Furthermore, based on the package name attribute of the visible operation element, when the package name attribute carries the blacklist element identifier, filter the visible operation element. Specifically, according to the package name attribute packageName to which the element belongs, determine whether it carries the blacklist element identifier, and filter the visible operation elements carrying the blacklist element identifier.
[0054] S13, traversing the visible operation elements contained in the generated queue to be operated, and comparing them with the current visible operation elements, and when the current visible operation element does not exist in the queue to be operated, putting the visible operation element into the queue to be operated.
[0055] In this step, a queue to be operated is created, and the read visible operation elements are sequentially placed in the queue to be operated in the order in which they are read. Further, the visible operation elements of the page to be tested that do not belong to the current application are filtered according to the package name attribute packageName to which the elements belong, such as filtering the content of the status bar.
[0056] S14, executing corresponding operations on the visible operation elements in the queue to be operated, and placing the visible operation elements for which the operations have been completed into the queue of executed operations.
[0057] In this step, based on the type of each operable element read in the queue to be operated, such as when the operable element read is an operable element such as ImageView, TextView, and EditView, the corresponding input and click operations are performed. Furthermore, an executed operation queue is created, and the operable elements that have completed the corresponding operations are sequentially placed in the executed operation queue.
[0058] S15, when the queue for operations is empty, generating a test report corresponding to the page to be tested based on the visible operation elements in the queue for executed operations.
[0059] In this step, after the traversal of the pages to be tested is completed, the operations performed on each visible operation element during the test are automatically captured, and the test running status of the application is monitored. After the execution is completed, a test report in Hyper Text Markup Language (html) format is automatically generated. Among them, the test report of the pages to be tested generally includes the version information of the application, the test time period, the test results, and the list of pages to be tested covered by this test, as well as the number of clicks and input events performed on each page to be tested and the screenshots of the content corresponding to the operations, etc.
[0060] As described above, based on the above embodiment, specifically, first load the page to be tested, then traverse the page to be tested, read the visible operation elements on the page to be tested, and obtain the package name attribute of the visible operation elements, based on the package name attribute, filter the visible operation elements that do not belong to the page to be tested, further, traverse the visible operation elements contained in the queue to be operated that has been generated, and compare them with the current visible operation elements, when the current visible operation elements do not exist in the queue to be operated, put the visible operation elements into the queue to be operated, then, perform the corresponding operation on the visible operation elements in the queue to be operated, and put the visible operation elements that have completed the operation into the queue of executed operations, and finally, when the queue to be operated is empty, based on the visible operation elements in the queue of executed operations, generate a test report corresponding to the page to be tested. The embodiment of the present application automatically traverses the page to be tested by identifying the element structure on the current interface during operation, thereby achieving full coverage of the page to be tested in the application, reducing maintenance costs and improving page coverage.
[0061] like Figure 2As shown, it is a schematic diagram of a specific process of a method for performing automatic testing on a page provided by the embodiment 200 of the present application. The detailed process of the specific process is as follows:
[0062] S201, perform pre-test configuration.
[0063] In this step, a configuration file is set for the application to be tested. Wherein, the configuration file adopts an Extensible Markup Language (XML) structure. Specifically, the blacklist page identifier of the page to be tested that does not need to be traversed, and the blacklist element identifier of the visible operation element that does not need to perform the operation are stored in the configuration file. For the visible operation element that can be input on the page to be tested, the input content can be configured. When the corresponding visible operation element is encountered during the traversal test process, the specified text will be automatically input, which is often used to enter the account password on the login page. Further, the operation sequence of the visible operation element can be configured, that is, the operation sequence of multiple visible operation elements on the page to be tested can be configured. When the corresponding page to be tested is encountered, the relevant visible operation elements will be operated in sequence. For example, on the login page, you need to enter the user name first, then enter the password, and then click the login button to complete the entire login process. In addition, by default, only one operation will be performed on the visible operation element on the page to be tested. If multiple operations need to be performed on a certain visible operation element, the number of operations of this visible operation element can be declared in the configuration file.
[0064] S202, loading the page to be tested.
[0065] Here, the Android Robotium framework is used to drive the application under test and load the page to be tested in the application. In addition, after loading the page to be tested, the Android DocumentBuilderFactory class is used to parse the XML configuration file.
[0066] S203, traverse the pages to be tested.
[0067] S204, filtering the pages to be tested that are included in the blacklist.
[0068] Here, based on the first activity class name of the page to be tested, when the first activity class name carries the blacklist page identifier, the page to be tested is filtered. Specifically, the embodiment of the present application obtains the ActivityName of the page to be tested of the application as the unique identifier of the page to be tested. Different pages are distinguished based on the activity class name of the page to be tested, that is, the Activity name, for example<page name="ProcessCompatibilityActivity"> , indicating that the current configuration is only effective on the ProcessCompatibilityActivity page. Furthermore, when the activity class name carries the blacklist page identifier action="blackPage", it means that the current page to be tested is a blacklist page, and the blacklist page is filtered.
[0069] S205: Read visible operating elements on the page to be tested.
[0070] Here, in the embodiment of the present application, the UiDevice.getInstance().dumpWindowHierarchy() method provided by the UIAutomator tool is used to output the visible operational elements of the page to be tested to the memory in a tree structure. In addition, the operational elements are distinguished by resource-id.<resource-id action="input"content="19100001002"> etMobile indicates that for the operable element with resource ID etMobile, the input text is "19100001002".
[0071] S206: Filter the visible operation elements that are included in the blacklist.
[0072] Here, based on the package name attribute of the visible operation element, when the package name attribute carries the blacklist element identifier, the visible operation element is filtered. Specifically, according to the package name attribute packageName to which the element belongs, it is determined whether it carries the blacklist element identifier, and the visible operation element carrying the blacklist element identifier is filtered.
[0073] S207, filtering visible operation elements that do not belong to the page to be tested.
[0074] In this step, the package name attribute of the visible operation element is obtained, and based on the package name attribute, the visible operation elements that do not belong to the page to be tested are filtered. Specifically, the visible operation elements of the page to be tested that do not belong to the current application are filtered according to the package name attribute packageName to which the element belongs, such as filtering the content of the status bar.
[0075] S208: Put the visible operation element into a queue to be operated.
[0076] Here, the visible operation elements contained in the waiting operation queue are traversed and compared with the current visible operation element. When the current visible operation element does not exist in the waiting operation queue, the current visible operation element is put into the waiting operation queue waitingClickViewList.
[0077] S209: Execute corresponding operations on visible operation elements in the queue to be operated.
[0078] In this step, a visible operation element is taken from the end of the waitingClickViewList queue each time to determine whether the visible operation element is currently visible. If it is not visible, the operation is skipped; if it is visible, different operations are performed according to the type of the visible operation element. If the visible operation element is an EditText input control, the input operation is performed; if the visible operation element is a TextView text control, the click operation is performed.
[0079] S210, determining whether the visible operation element that has completed the operation can be added to the executed operation queue.
[0080] In this step, first determine whether the visible operation element after the operation is performed is a visible operation element on the newly opened page to be tested. Specifically, obtain the first activity class name of the page to be tested where the visible operation element is located, and the second activity class name of the display page after the visible operation element is performed; when the first activity class name and the second activity class name are inconsistent, determine whether the page to be tested has been traversed to completion, and put the operable elements corresponding to the display page after the traversal is completed into the executed operation queue clickedViewList. Among them, by determining whether the first activity class name activity name to which the visible operation element of the current operation belongs is consistent with the activity name of the display page after the operation is performed, if they are inconsistent, it means that a new page to be tested is opened after this click event.
[0081] Furthermore, after the corresponding operation is performed on the visible operation element, the queue to be operated is searched to see whether there is a visible operation element belonging to the same first activity class name as the visible operation element that has completed the operation, and if not, it is determined that the current page to be tested has been traversed to the end. If the page to be tested to which the visible operation element that has completed the operation belongs does not have a visible operation element of the same page to be tested in the queue to be operated waitingClickViewList, it means that the page to be tested has been completely traversed and can be recorded in the queue of executed operations clickedPageList.
[0082] In addition, if all visible operation elements of the current page to be tested have been operated, it will return to the previous page. If after a certain operation, a page to be tested that has been traversed is opened, it will automatically return to the previous page. If after a certain operation, another application is jumped to, it will return to the application to be tested.
[0083] S211, putting the visible operation elements that have completed the operation into the executed operation queue.
[0084] S212, determining whether the queue to be operated is empty.
[0085] Here, when the queue to be operated is not empty, the contents from step S203 to this step are continued to be executed.
[0086] S213: Generate a test report corresponding to the page to be tested based on the visible operation elements in the executed operation queue.
[0087] In this step, in the process of performing corresponding operations on visible operation elements, obtain the number of operations performed on the page to be tested and the screenshots of the operation content corresponding to each operation; record the exception information on the page to be tested; associate the screenshot of the operation content and the exception information of at least one visible operation element in at least one page to be tested, as well as the version number information and the test time period of the application where the page to be tested is located, and generate a test report corresponding to the page to be tested. Specifically, the test report displays the application version information and the test time period. The main body of the report displays the test results and test details, including a list of pages to be tested covered by this test, as well as the number of clicks and input events performed on each page to be tested and screenshots of the operation content. Furthermore, when the traversal test runs and encounters a Crash, the log is automatically saved. By calling the Android system's exception handling class CrashHandler, the system UncaughtExceptionHandler is implemented. When a crash occurs, the exception information can be captured and the crash content can be added to the test report.
[0088] In addition, the version number information of the application is obtained through the PackageManager class to obtain the versionName of the APP. The start time and end time of the test in the test period are set in the setUp() and tearDown() methods in the test class respectively. The report body uses the HTML format to dynamically assemble the data generated during the test into the HTML format, and then write it into the report template and associate it with the screenshot of the operation content. After the traversal test is completed, the report is automatically saved in the client storage space. Among them, the screenshot is divided into two steps. First, capture an original image and then add a border. The specific steps are: use UIAutomator or Robotium's screenshot API to obtain an original image and save it in the client memory card; read the original image and convert it into a Bitmap object; create a canvas Canvas on the bitmap object; add Paint to the canvas and set the border thickness and color for the Paint; draw with the coordinate points in the bounds attribute of the visible operation element, such as "[200,906][880,960]", and add it to the Canvas; finally, output the bitmap object as a portable network graphics (PNG) file.
[0089] This application implements the above-mentioned method of automated testing of pages based on the above steps. The application under test is driven by the Robotium framework of Android. When starting the test, first load the content of the xml configuration file, then use the dumpWindowHierarchy method provided by the UiDevice module of the UIAutomator tool to obtain the visible operation elements on the page to be tested, and add these visible operation elements to the queue to be operated, and then take out the visible operation elements from the queue in sequence, and execute click or input events one by one. During the test process, each step of the operation will be automatically screenshoted, and the test operation of the application will be monitored. After the execution is completed, a test report in HTML format will be automatically generated. Among them, the test report includes screenshots before and after each click and input operation, and the visible operation elements of the operation are marked on the screenshot; the pages to be tested covered by this traversal test are counted, as well as the number of clicks and input events on each page to be tested; support automatic acquisition of basic information of the client system and application, such as system Android version, APP version information, etc.; support automatic acquisition of CRASH logs generated during the traversal test, and add CRASH stack information to the test report; automatic summary of HTML format test reports, convenient for viewing test results, and save them on the client.
[0090] Based on the same inventive concept, the embodiment 300 of the present application also provides a device for automatically testing a page, wherein: Figure 3 As shown, the device comprises:
[0091] A loading module 31 is used to load a page to be tested;
[0092] The first traversal module 32 is used to traverse the page to be tested, read the visible operation elements on the page to be tested, and obtain the package name attributes of the visible operation elements, and filter the visible operation elements that do not belong to the page to be tested based on the package name attributes;
[0093] The second traversal module 33 is used to traverse the visible operation elements contained in the generated queue to be operated, and compare them with the current visible operation elements. If the current visible operation element does not exist in the queue to be operated, the visible operation element is put into the queue to be operated;
[0094] An execution module 34 is used to execute corresponding operations on the visible operation elements in the queue to be operated, and put the visible operation elements that have completed the operation into the queue of executed operations;
[0095] The generating module 35 is used to generate a test report corresponding to the page to be tested based on the visible operation elements in the executed operation queue when the queue to be operated is empty.
[0096] In this embodiment, the specific functions and interaction modes of the loading module 31, the first traversal module 32, the second traversal module 33, the execution module 34 and the generation module 35 can be found in Figure 1 The description of the corresponding embodiments will not be repeated here.
[0097] Optionally, the execution module 34 includes:
[0098] An execution unit, used to execute corresponding operations on visible operation elements in the waiting operation queue;
[0099] A second acquisition unit is used to acquire a first activity class name of the page to be tested where the visible operation element is located, and a second activity class name of the display page after the visible operation element performs the operation;
[0100] The judging unit is used to judge whether the page to be tested has been traversed to completion when the first activity class name and the second activity class name are inconsistent, and put the operable elements corresponding to the displayed page that has been traversed to the executed operation queue.
[0101] Optionally, the judging unit is further configured to:
[0102] After the corresponding operation is completed on the visible operation element, the queue for operations is searched to see whether there is a visible operation element with the same first activity class name as the visible operation element on which the operation has been completed. If not, it is determined that the current page to be tested has been traversed.
[0103] Optionally, the generating module 35 includes:
[0104] A second acquisition unit is used to acquire the number of operations performed on the page to be tested and a screenshot of the operation content corresponding to each operation in the process of performing the corresponding operation on the visible operation element;
[0105] A recording unit, used to record abnormal information on the page to be tested;
[0106] The generating unit is used to associate the operation content screenshot and abnormal information of at least one visible operation element in at least one page to be tested, as well as the version number information and test time period of the application program in which the page to be tested is located, to generate a test report corresponding to the page to be tested.
[0107] Optionally, the device further comprises:
[0108] The first filtering module 36 is configured to filter the page to be tested based on the first activity class name of the page to be tested, when the first activity class name carries a blacklist page identifier.
[0109] Optionally, the device further comprises:
[0110] The second filtering module 37 is used to filter the visible operation elements based on the package name attribute of the visible operation elements when the package name attribute carries a blacklist element identifier.
[0111] like Figure 4 As shown, another embodiment 400 of the present application further provides a terminal device, including a processor 401, wherein the processor 401 is used to execute the steps of the above-mentioned method for automatically testing a page. Figure 4 It can also be seen that the terminal device provided in the above embodiment also includes a non-transient computer-readable storage medium 402, on which a computer program is stored, and when the computer program is run by the processor 401, the steps of the above method for automatically testing a page are executed. In practical applications, the terminal device can be one or more computers, as long as it includes the above computer-readable medium and processor.
[0112] Specifically, the storage medium can be a general storage medium, such as a mobile disk, a hard disk, and FLASH, etc. When the computer program on the storage medium is run, each step in the above-mentioned method for automatically testing a page can be executed. In practical applications, the computer-readable medium can be included in the device / apparatus / system described in the above embodiments, or it can exist independently without being assembled into the device / apparatus / system. The above-mentioned computer-readable storage medium carries one or more programs, and when the above-mentioned one or more programs are executed, each step in the above-mentioned method for automatically testing a page can be executed.
[0113] According to the embodiments disclosed in the present application, the computer-readable storage medium may be a non-volatile computer-readable storage medium, for example, it may include but is not limited to: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof, but it is not used to limit the scope of protection of the present application. In the embodiments disclosed in the present application, the computer-readable storage medium may be any tangible medium containing or storing a program, which may be used by or in combination with an instruction execution system, apparatus, or device.
[0114] The flow chart and block diagram in the accompanying drawings of the present application show the possible architecture, function and operation of the system, method and computer program product according to the various embodiments disclosed in the present application. In this regard, each box in the flow chart or block diagram can represent a module, a program segment or a part of a code, and the above-mentioned module, program segment or a part of a code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some implementations as replacements, the functions marked in the box can also occur in the order marked in different drawings. For example, the boxes represented by two connections can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram or flow chart, and the combination of the boxes in the block diagram or flow chart can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0115] Those skilled in the art will appreciate that the features described in the various embodiments and / or claims of the present disclosure may be combined and / or combined in a variety of ways, even if such combinations or combinations are not explicitly described in the present application. In particular, without departing from the spirit and teachings of the present application, the features described in the various embodiments and / or claims of the present application may be combined and / or combined in a variety of ways, and all of these combinations and / or combinations fall within the scope disclosed in the present application.
[0116] Finally, it should be noted that the above-described embodiments are only specific implementation methods of the present application, which are used to illustrate the technical solutions of the present application, rather than to limit them. The protection scope of the present application is not limited thereto. Although the present application is described in detail with reference to the above-described embodiments, ordinary technicians in the field should understand that any technician familiar with the technical field can still change the technical solutions recorded in the above-described embodiments within the technical scope disclosed in the present application, or can easily think of changes, or make equivalent replacements for some of the technical features therein; and these changes, modifications or replacements do not make the essence of the corresponding technical solutions deviate from the spirit and scope of the technical solutions of the embodiments of the present application, and should be included in the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the protection scope of the claims.
Claims
1. A method for automated testing of a page, characterized in that: include: Load the page to be tested; Traversing the page to be tested, reading visible operation elements on the page to be tested, and obtaining package name attributes of the visible operation elements, and filtering the visible operation elements that do not belong to the page to be tested based on the package name attributes; Traversing the visible operation elements contained in the generated queue to be operated, and comparing them with the current visible operation elements, and when the current visible operation element does not exist in the queue to be operated, putting the visible operation element into the queue to be operated; Execute corresponding operations on the visible operation elements in the queue to be operated, and put the visible operation elements that have completed the operation into the queue of executed operations; When the queue for operations is empty, generating a test report corresponding to the page to be tested based on the visible operation elements in the queue for executed operations; The performing of corresponding operations on the visible operation elements in the queue to be operated, and placing the visible operation elements that have completed the operation into the queue of executed operations, comprises: Execute corresponding operations on the visible operation elements in the queue to be operated; Acquire a first activity class name of the page to be tested where the visible operation element is located, and a second activity class name of the display page after the visible operation element performs an operation; When the first activity class name and the second activity class name are inconsistent, it is determined whether the page to be tested has been traversed to completion, and the visible operation element corresponding to the displayed page that has been traversed to completion is placed in the executed operation queue.
2. The method according to claim 1, characterized in that The step of determining whether the page to be tested has been traversed to completion comprises: After the corresponding operation is performed on the visible operation element, the queue for operations is searched to see whether there is a visible operation element belonging to the same first activity class name as the visible operation element that has completed the operation, and if not, it is determined that the current page to be tested has been traversed.
3. The method according to claim 1, characterized in that The step of generating a test report corresponding to the page to be tested includes: In the process of performing corresponding operations on the visible operation elements, obtaining the number of the operations performed on the page to be tested and screenshots of operation contents corresponding to each of the operations; Recording abnormal information on the page to be tested; The operation content screenshot and the abnormal information of at least one visible operation element in at least one of the pages to be tested, as well as the version number information and the test time period of the application program in which the page to be tested is located, are associated to generate a test report corresponding to the page to be tested.
4. The method according to claim 1, characterized in that: Between the step of traversing the page to be tested and the step of reading the visible operation elements on the page to be tested, the method further comprises: Based on the first activity class name of the page to be tested, when the first activity class name carries a blacklist page identifier, the page to be tested is filtered.
5. The method according to claim 1, characterized in that The step of reading the visible operation elements on the page to be tested further comprises: Based on the package name attribute of the visible operation element, when the package name attribute carries a blacklist element identifier, the visible operation element is filtered.
6. A device for automatically testing a page, characterized in that: The device comprises: Loading module, used to load the page to be tested; A first traversal module is used to traverse the page to be tested, read the visible operation elements on the page to be tested, and obtain the package name attribute of the visible operation elements, and filter the visible operation elements that do not belong to the page to be tested based on the package name attribute; A second traversal module is used to traverse the visible operation elements contained in the generated queue to be operated, and compare them with the current visible operation elements, and put the visible operation elements into the queue to be operated when the current visible operation element does not exist in the queue to be operated; An execution module, configured to execute corresponding operations on the visible operation elements in the queue to be operated, and put the visible operation elements for which the operations have been completed into a queue of executed operations; A generating module, configured to generate a test report corresponding to the page to be tested based on the visible operation elements in the executed operation queue when the queue to be operated is empty; The execution module includes: An execution unit, configured to execute corresponding operations on the visible operation elements in the queue to be operated; An acquisition unit, used to acquire a first activity class name of the page to be tested where the visible operation element is located, and a second activity class name of the display page after the visible operation element performs an operation; The judging unit is used to judge whether the page to be tested has been traversed to completion when the first activity class name and the second activity class name are inconsistent, and put the visible operation element corresponding to the displayed page that has been traversed to the executed operation queue.
7. A non-transitory computer-readable storage medium, characterized in that The non-transitory computer-readable storage medium stores instructions, which, when executed by a processor, enable the processor to perform each step in the method for automatically testing a page as claimed in any one of claims 1 to 5.
8. A terminal device, characterized in that: The method comprises a processor, wherein the processor is used to execute each step in the method for automatically testing a page as claimed in any one of claims 1 to 5.
