Display interface testing method, device, electronic equipment and storage medium

By detecting and obtaining the target element after the electronic device loads the display interface, ensuring that it meets the preset display scenario before loading the test case, the problem of verification failure caused by inconsistent page loading in the interface automation test is solved, and the success rate of the test is improved. and stability.

CN114706753BActive Publication Date: 2024-09-24MASHANG CONSUMER FINANCE CO LTD
View PDF 9 Cites 0 Cited by

Patent Information

Application Number
CN202210249372.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-03-14
Publication Date
2024-09-24
Estimated Expiration
2042-03-14

AI Technical Summary

Technical Problem

In interface automation testing, existing technology is difficult to effectively handle the inconsistency between page loading and element loading and rendering times, resulting in unstable test scripts and prone to verification failures, and the existing waiting mechanism cannot be applied to changes in interface elements or button states. Changing scenarios lead to test failure.

Method used

After the electronic device loads the display interface, the target element is detected and acquired to ensure that it meets the preset display scenario before loading the test case to ensure that the test case can successfully test the target display interface.

Benefits of technology

It improves the success rate and stability of test cases, avoids test failures, and ensures that the target display interface can be effectively tested after loading is completed.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114706753B
    Figure CN114706753B
Patent Text Reader

Abstract

The present application discloses a display interface testing method, device, electronic device and storage medium, and relates to the technical field of display interface testing. When the electronic device loads the display interface, the target element loaded on the display interface is detected; when the target element is detected, the target element currently loaded on the display interface is acquired; when the currently loaded target element satisfies a preset display scenario, the display interface is determined as a target display interface; a test case is loaded, and the target display interface is tested according to the test case to ensure that the test case can successfully test the target display interface.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of display interface testing, and more specifically, to a display interface testing method, device, electronic device and storage medium. Background Art

[0002] Due to the rapid development of the Internet, product (mobile and web) business processes are becoming more and more complex, more and more numerous, and the iteration speed is getting faster and faster. The pressure on testers to perform regression tests on interface functions is also increasing, and interface automation testing is becoming more and more important. In daily interface automation testing, it is often encountered that the writing or execution of a single case is successful, but once the test script file is officially tested, the verification fails, which eventually leads to the failure of the display interface test. Summary of the invention

[0003] In view of the above problems, the present application proposes a display interface testing method, device, electronic device and storage medium, which can solve the above problems.

[0004] In a first aspect, an embodiment of the present application provides a display interface testing method, which is applied to an electronic device, and the method includes: when the electronic device loads the display interface, detecting a target element loaded on the display interface; when the target element is detected, obtaining the target element currently loaded on the display interface; when the currently loaded target element satisfies a preset display scenario, determining the display interface as a target display interface; loading a test case, and testing the target display interface according to the test case.

[0005] In a second aspect, an embodiment of the present application provides a display interface testing device, which is applied to an electronic device, and the device includes: a loading module, which is used to detect a target element loaded on the display interface when the electronic device loads the display interface; an acquisition module, which is used to acquire the target element currently loaded on the display interface when the target element is detected; a determination module, which is used to determine the display interface as a target display interface when the currently loaded target element meets a preset display scenario; and a testing module, which is used to load a test case and test the target display interface according to the test case.

[0006] In a third aspect, an embodiment of the present application provides an electronic device, comprising: one or more processors; a memory; and one or more applications, wherein the one or more applications are stored in the memory and configured to be executed by the one or more processors, and the one or more applications are configured to execute the above method.

[0007] In a fourth aspect, an embodiment of the present application provides a computer-readable storage medium, in which a program code is stored, and the program code can be called by a processor to execute the above method.

[0008] In a fifth aspect, an embodiment of the present application provides a computer program product, characterized in that the computer program / instructions are executed by a processor to perform the above method.

[0009] The display interface testing method, device, electronic device and storage medium provided in the present application load the test case after the electronic device loads the target display interface, and tests the target display interface according to the test case, that is, after obtaining the target display interface, the target display interface is tested again, ensuring that the test case can test the target display interface, thereby avoiding test failures to a certain extent.

[0010] These and other aspects of the present application will become more clearly understood in the description of the following embodiments. BRIEF DESCRIPTION OF THE DRAWINGS

[0011] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For those skilled in the art, other drawings can be obtained based on these drawings without creative work.

[0012] Figure 1 A schematic diagram of an application environment of a display interface testing method provided by an embodiment of the present application is shown;

[0013] Figure 2 A schematic diagram of a flow chart of a display interface testing method provided in an embodiment of the present application is shown;

[0014] Figure 3 A schematic diagram showing a flow chart of a display interface testing method provided by another embodiment of the present application is shown;

[0015] Figure 4 This application shows Figure 3 A flow chart of step S250 of the display interface testing method shown;

[0016] Figure 5 A schematic diagram showing a flow chart of a display interface testing method provided by another embodiment of the present application is shown;

[0017] Figure 6 A block diagram of a display interface testing device provided by an embodiment of the present application is shown;

[0018] Figure 7is a block diagram of an electronic device for executing a display interface testing method according to an embodiment of the present application;

[0019] Figure 8 A storage unit for storing or carrying program codes for implementing a display interface testing method according to an embodiment of the present application is shown. DETAILED DESCRIPTION

[0020] 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 those skilled in the art without creative work are within the scope of protection of this application.

[0021] First, the nouns and terms involved are explained. The nouns and terms involved in the embodiments of the present application are subject to the following interpretations:

[0022] (1) Test Case: A test case is a set of test inputs, execution conditions, and expected results compiled for a specific purpose. It is used to test a program path or verify whether a specific requirement is met.

[0023] (2) UI automated testing: It is a process of converting human-driven testing behavior into machine-executed testing. Usually, after designing a test case and passing the review, the tester will perform the test step by step according to the procedures described in the test case to compare the actual results with the expected results. In this process, in order to save manpower, time or hardware resources and improve testing efficiency, the concept of automated testing was introduced.

[0024] (3) Forced waiting (sleep): Set a waiting time according to the code, and the next operation can be executed only when the set time is reached.

[0025] (4) Explicit waiting (visibility_of_element_located): Set a maximum waiting time according to the code, wait for the specified element on the page to appear within the specified time, and execute the next operation immediately after it appears. If it does not appear within the time limit, a timeout exception is thrown.

[0026] (5) Implicit wait (implicitly_wait): If WebDriver does not find the element in the Document Object Model (DOM), it will continue to wait. After the set time, an exception will be thrown indicating that the element cannot be found. When the element is being searched for or the element does not appear immediately, the implicit wait will wait for a period of time before searching the DOM. The default time is 0. Once the implicit wait is set, it exists throughout the declaration lifecycle of the WebDriver object instance, and it will wait for each element when searching.

[0027] In the related art, in page automation testing, it is often encountered that the writing or execution of a single test case is successful, but once the test case is officially run in the actual testing process, verification failure will occur, and the test case script is very unstable; because in the actual running process, various conditions will be encountered, such as unstable network and different configurations of the running machine, which will cause different page loading and element loading and rendering times during testing, so various problems will arise when the script is running.

[0028] At present, the selenium interface automation framework encapsulates implicit waiting and explicit waiting methods for the situation where the page loading and element loading rendering time are different. Explicit waiting can only solve the problem of judging whether the element appears, and implicit waiting can only solve the scene of whether all the interface elements are loaded. These technical solutions are not applicable to the scene where some interface elements change or the button status changes. In many actual scenes, the target test interface is only after the page is loaded and the elements on the page are loaded. If the interface only appears the page (the elements have not been loaded yet), it is meaningless to continue to execute the next test rule code. The use case checkpoint will fail, resulting in the failure of the final display interface check. In addition, when the selenium interface automation framework encapsulates the forced waiting, if the interface element has been loaded, it is still necessary to continue waiting until the preset time in the forced waiting is over, and then the check will be executed. After the interface element has been loaded (appeared), the continuous waiting will extend the test time and reduce the test efficiency. If the preset waiting time is short, the waiting time may end, but the interface element has not been loaded. At this time, the test will directly fail.

[0029] In some embodiments, the test case is loaded at the same time as the test page, and the currently loaded test page is tested directly after the test case is loaded. However, at this time, it cannot be determined that the page element to be tested has appeared, so it is easy to cause the test to be invalid. Exemplarily, in the scenario where the test case is tested to search for a name from a list, the script edited by the tester inputs the preset name element "Zhang San" for search, locates the name column through the element positioning method, and then tests the elements in the name column. Since the test case is loaded at a fast speed, for example, the loading can be completed in 0.1 seconds, and at the same time in 0.1 seconds, only the name element located before the preset name element in the list can be loaded. For example, at 0.1 seconds, the name element loaded by the display page is "Li Si", and the preset name element "Zhang San" has not yet been successfully loaded. That is to say, when the test case is loaded in 0.1 seconds, the display page with the name element "Li Si" loaded at the same time will be tested. It can be seen that this implementation scheme does not achieve the purpose of the tester testing the preset name element "Zhang San" at all.

[0030] In view of the above technical problems, the inventor has discovered and proposed a display interface testing method, device, electronic device and storage medium after long-term research. After the electronic device loads the target display interface, the test case is loaded, and the target display interface is tested according to the test case, that is, it is ensured that the test case can test the target display interface, thereby avoiding the test failure to a certain extent. Among them, the specific display interface testing method is specifically described in the subsequent embodiments.

[0031] In combination with the above example, in the method provided in the embodiment of the present application, the preset name element "Zhang San" is pre-loaded, and after the preset name element "Zhang San" is successfully loaded, the test case is loaded to ensure that the preset name element has been successfully loaded when the test case is loaded, thereby ensuring the success rate of the preset name element test.

[0032] In order to better understand a display interface testing method, device, electronic device and storage medium provided in the embodiments of the present application, the application environment applicable to the embodiments of the present application is first described below.

[0033] Figure 1 A schematic diagram of an application environment of a display interface testing method provided by an embodiment of the present application is shown. Figure 1 The display interface testing method provided in the embodiment of the present application can be applied to a display interface testing system 100. The display interface testing system 100 includes an electronic device 110, a server 120 and a communication network 130, and the electronic device 110 and the server 120 are connected via the communication network 130.

[0034] Figure 1The electronic device 110 is a test terminal, which is used to display the user interface during the display interface test, and can also be used to display the test results. For example, the test results may include a test pass and a test fail, and the text results of "test pass" or "test fail" can be displayed on the test result display page of the electronic device 110 so that the tester can understand the test results.

[0035] In an embodiment of the present application, the tester can input test operations based on the electronic device 110, the electronic device 110 can load a display interface from the server 120 through the communication network 130, and load test cases from the server 120 through the communication network 130, and the electronic device 110 tests the display interface through the test cases to obtain test results.

[0036] The electronic device 110 may be various types of computer devices, such as portable handheld devices, general-purpose computers (such as personal computers and laptop computers), and wearable devices. The portable handheld devices may include cellular phones, smart phones, tablet computers, personal digital assistants (PDAs), etc.; wearable devices may include head-mounted displays and other devices. The electronic device 110 is capable of executing various different applications, such as various Internet-related applications, communication applications (such as email applications), short message service (SMS) applications, and may use various communication protocols.

[0037] Server 120 can be an independent physical server, or a server cluster or distributed system composed of multiple physical servers. It can also be a cloud server that provides basic cloud computing services such as cloud services, cloud databases, cloud computing, cloud functions, cloud storage, network services, cloud communications, middleware services, domain name services, security services, network acceleration services (Content Delivery Network, CDN), as well as big data and artificial intelligence platforms.

[0038] The communication network 130 may be any type of network that can support data communications using any of a variety of available protocols, including but not limited to TCP / IP, SNA, IPX, etc. By way of example only, the one or more communication networks 130 may be a local area network (LAN), an Ethernet-based network, a token ring, a wide area network (WAN), the Internet, a virtual network, a virtual private network (VPN), an intranet, an extranet, a public switched telephone network (PSTN), an infrared network, a wireless network (e.g., Bluetooth, WIFI), and / or any combination of these and / or other networks.

[0039] It should be noted that Figure 1The application environment diagram shown is only an example. The display interface test scenario described in the embodiment of the present application is to more clearly illustrate the technical solution of the present application and does not constitute a limitation on the technical solution provided by the present application. A person of ordinary skill in the art will know that with the evolution of display pages and test cases and the emergence of new business scenarios, the technical solution provided by the present application is also applicable to similar technical problems. The display interface test method, device, electronic device and storage medium provided in the embodiment of the present application will be described in detail below through specific embodiments.

[0040] Figure 2 A flow chart showing a display interface testing method provided by an embodiment of the present application is shown. Figure 2 The present application embodiment provides a display interface testing method, which can be applied to Figure 1 The display interface testing system 100 shown in FIG. 1 is shown in FIG. 100. The following is an example of a display interface testing method applied to an electronic device 110. Figure 2 The process shown is described in detail, and the display interface testing method may specifically include the following steps:

[0041] Step S110: When the electronic device loads a display interface, detecting a target element loaded on the display interface.

[0042] The electronic device may load a display interface locally or from a server, wherein the display interface may be a display interface of a web page, a display interface of an application program, a desktop, etc.

[0043] When the electronic device loads the above-mentioned display interface, the loaded display interface is detected to detect the target element appearing on the display interface, wherein the target element can be an element at a preset position or a pre-set element, and the target element is used to determine whether the display interface displaying the target element is the target display interface.

[0044] It should be noted that element, also known as data element, is a term in computer science and is the basic unit of data.

[0045] In some embodiments, the electronic device receives an input operation from a user, wherein the input operation may be performed based on the touch screen, keyboard, mouse, remote control, etc. of the electronic device, for example, it may be a loading control on a touch-sensitive screen, or it may be clicking a link displayed on the touch screen; the electronic device loads the display interface in response to the user's input operation.

[0046] In other embodiments, a loading event is pre-set, and the electronic device responds to the loading event and automatically loads the display interface from the server. As a method, a timer (setTimeout) function is pre-set, and when a predetermined time is reached, the display page is automatically loaded.

[0047] When detecting the target element of the display interface, the target element is waited for to appear on the display interface by pre-packaging the waiting method. The target element may include elements such as pictures, titles, interface keywords, authors, etc.

[0048] In some implementations, the waiting method (expected_conditions.visibility_of_element_locate) may be pre-packaged and saved in a public configuration file. When it is necessary to detect a target element on a display interface, the execution script of the pre-packaged waiting method is run from the public configuration file to detect the display interface to wait for the target element to appear.

[0049] In other embodiments, a loop method (WebDriverWait.until) can be pre-packaged and saved in a public configuration file. In combination with the pre-packaged waiting method, an execution script of the pre-packaged waiting method is run from the public configuration file. The appearance of an element on the display interface is detected by the waiting method. When it is detected that the element is not the target element, the execution script of the pre-packaged loop method is obtained from the public configuration file, and the pre-packaged loop method is used to loop and wait until the target element is waited for.

[0050] In other embodiments, in combination with explicit waiting, the waiting time is preset and saved in a public configuration file, which is convenient for candidate calling and management. When it is necessary to detect the target element on the display interface, the preset waiting time is called from the public configuration file, and the target element is waited for to be loaded on the display interface within the preset waiting time. When the target element is waited for within the preset waiting time, the waiting ends, or, when the target element is not waited for within the preset waiting time, the waiting also ends.

[0051] It should be noted that the pre-packaged waiting method, the pre-packaged loop method and the pre-set waiting time are all stored in the public configuration file, which is convenient for direct calling when detecting and displaying the target element, and is also convenient for unified management and modification. In addition, the above content is stored in advance, which can be used for subsequent detection of target elements in addition to the detection of the target element this time, thereby improving the reuse rate of the code.

[0052] Step S120: when the target element is detected, obtaining the target element currently loaded on the display interface.

[0053] After detecting that a target element exists on the display interface, the target element currently loaded on the display interface is obtained.

[0054] In some embodiments, after the target element is detected, the target element currently loaded on the display interface is obtained through a pre-packaged public method. For example, when the target element is a title, the title on the display interface is selected by running the execution script of the pre-packaged title detection method (element.title()), such as the obtained title title is "How to Make Fish Balls"; for another example, when the target element is an element value, the value of the element loaded on the display interface is obtained by running the execution script of the pre-packaged value detection method (element.text()) of the assertion expression, wherein the value of the element standard displays the specific meaning of the element represented, such as the target element is an element at a preset position (e.g., the lower right corner of the display interface), and the element value is "Confirm"; for another example, when the target element is a picture, a screenshot tool (e.g., Casperjs) is used to capture the picture of the target position on the display interface.

[0055] Step S130: when the currently loaded target element satisfies a preset display scenario, the display interface is determined as a target display interface.

[0056] The preset display scene is the scene that the tester expects to be presented on the display interface.

[0057] Determine whether the currently loaded target element meets the preset display scenario. If the loaded target element meets the preset display scenario, it means that the display interface loaded with the target element has met the preset display scenario, and the display interface is determined as the target display interface. The target display interface is the test interface expected by the tester, and the target display interface is also the interface used for testing.

[0058] In some embodiments, a preset element is set in advance, wherein the preset element is an element expected by the tester, the preset element is obtained, and it is determined whether the currently loaded target element is consistent with the preset element. When the currently loaded target element is consistent with the preset element, it means that an element that meets the test expectations has been loaded on the display interface, that is, the target element meets the preset display scenario, and the display interface loaded with the target element is determined as the target display interface.

[0059] For example, there is a preset control in the preset display scene, and the preset element on the preset control is "OK". When the preset control is loaded on the display interface, the element displayed on the preset control is the target element. When the target element is "OK", the target element is consistent with the preset element, the display interface satisfies the preset scene, and the display interface is determined as the target display interface.

[0060] Optionally, the preset elements of this embodiment can be obtained in the following manner, as follows, obtaining the display position of the currently loaded target element on the display interface. According to the first preset mapping relationship, the preset element corresponding to the display position is obtained, wherein the first preset mapping relationship includes a correspondence between multiple display positions and multiple preset elements, and the multiple display positions and the multiple preset elements correspond one to one, and one of the display positions corresponds to one preset element. It can be understood that each display position corresponds to a preset element in the first preset mapping relationship. For example, the first preset relationship includes display position A corresponding to the preset element "confirm", display position B corresponding to the preset element "cancel", and display position C corresponding to the preset element "return". If the display position where the target element is located in this embodiment is C, based on the above first preset relationship, the display position C where the target element is located corresponds to the preset element "return". If the target element matches the preset element, it is determined that the currently loaded target element meets the preset display scene. Continuing to explain in conjunction with the above example, if the target element is "return", the preset element "return" matches the target element "return", indicating that the target element loaded from the display interface is consistent with the preset element expected to appear, and the test result is that the currently loaded target element meets the preset display scene. If there is no match, the currently loaded target element does not meet the preset display scenario. Continuing with the above example, if the target element is "Confirm", the preset element "Return" and the target element "Confirm" do not match, indicating that the target element appearing on the display interface is not the expected preset element. The test result is that the currently loaded target element does not meet the preset display scenario. The backend personnel modify the software program used to display the above interface based on the test result to make the actual loaded elements consistent with the expected elements.

[0061] Step S140: loading a test case, and testing the target display interface according to the test case.

[0062] After determining to load the target display interface, the electronic device then loads a test case corresponding to the target display interface, wherein the test case includes test rules written in a program or code, and tests the target display interface according to the test rules included in the test case.

[0063] Optionally, after loading the target display interface, a smaller time interval is preset, such as 0.2 seconds. The electronic device loads the test case corresponding to the target display interface 0.2 seconds after loading the target display interface. The above time interval is set to ensure that the test case is loaded only after the target display interface is successfully loaded, so as to improve the test success rate.

[0064] The electronic device loads the test case from the storage location. In some embodiments, the test case can be pre-stored locally in the electronic device, and when the electronic device needs to use the test case, the test case can be quickly loaded from the local electronic device. In addition, since the test case is stored locally in the electronic device, it can effectively avoid the impact of network factors that reduce the speed of loading the test case, and ensure that the test of the display interface is carried out quickly.

[0065] In other embodiments, the test cases can be pre-stored in a server that is communicatively connected to the electronic device. When the electronic device needs to load the test cases, the test requirements can be sent to the server. The server responds to the test requirements and feeds back the test cases. The electronic device then loads the test cases from the server. Since the test cases are stored on the server, the test cases can reduce the occupancy of the local storage space of the electronic device, thereby reducing the impact on the normal operation of the electronic device.

[0066] The target display interface is tested according to the test rules included in the test case to obtain the test result, wherein the test result may include a test pass TRUE, or a test failure FALSE and the corresponding reason. The obtained test result may be fed back to the background, or directly displayed on the electronic device to inform the tester of the test result.

[0067] In the display interface testing method provided in the present embodiment, when the electronic device loads the display interface, the target element loaded on the display interface is detected, and when the target element is detected, the target element currently loaded on the display interface is obtained, and when the currently loaded target element satisfies the preset display scenario, the display interface loaded with the target element is determined as the target display interface, and after ensuring that the target display interface is successfully loaded, the test case is loaded, and the target display interface is tested according to the test case. By loading the display interface and then the test case, it is guaranteed to a certain extent that the test case can successfully test the target display interface, thereby improving the success rate of the test case test and the stability of the test.

[0068] Optionally, in the previous embodiment, when judging whether the currently loaded target element satisfies the preset display scene, the judgment result obtained, in addition to determining the display interface as the target display interface when the currently loaded target element satisfies the preset display scene in the above embodiment, may also include in this embodiment: if the target element does not satisfy the preset display scene, indicating that an abnormal pop-up window may appear on the display window where the target element is loaded, then continue to execute the above step S110, that is, continue to execute the step of detecting the target element loaded on the display interface.

[0069] In some embodiments, preset elements are set in advance, wherein the preset elements are elements expected by the tester. When the currently loaded target element is inconsistent with the preset element, it means that the elements that meet the test expectations have not been loaded on the display interface yet, and the target element does not meet the preset display scenario and needs to continue waiting.

[0070] For example, the preset element in the preset display scene is pre-set as "name". When the target element loaded on the display interface is "ID number", the target element "ID number" is inconsistent with the preset element "name". The display interface has not been fully loaded, or the display page expected by the tester has not been loaded, and it is necessary to continue waiting.

[0071] In the case that the currently loaded target element does not satisfy the preset display scenario, the step of detecting the target element loaded on the display interface (i.e., step S120) is continued to be executed. When the step of detecting the target element loaded on the display interface is re-executed, the actual acquisition times are incremented once until the target element re-acquired within the preset acquisition times matches the preset element, and it is determined that the re-acquired target element satisfies the preset display scenario, and the display interface is determined as the target display interface for subsequent testing. In other words, the actual acquisition times are at most the preset acquisition times. As one of the ways, a preset acquisition times is pre-configured in the public configuration file. The preset acquisition times are the times of returning to execute the step of detecting the target element loaded on the display interface. The preset acquisition times are used to limit the number of times the target element is repeatedly acquired. For example, the preset acquisition times can be 3 times, 6 times, etc.

[0072] Optionally, the preset number of acquisitions pre-configured in the public configuration file can be a fixed value, for example, it can be 5 times. After the preset number of acquisitions is configured, the step of re-executing the detection of the target elements loaded on the display interface is at most the fixed preset number of acquisitions. In order to adapt to different test scenarios, the tester can adjust the fixed preset number of acquisitions, for example, it can be adjusted to a fixed number of 6 times.

[0073] Optionally, the preset acquisition times preconfigured in the public configuration file may be variable, and the variable preset acquisition times may be more suitable for different preset display scenarios. For example, the preset acquisition times may follow Figure 1 The display interface test system 100, the electronic device 110, the server 120 and the communication network 130 in the display interface test system 100, the electronic device 110, the server 120 and the communication network 130 change. As an implementation mode, the current state of the electronic device is obtained, wherein the current state at least includes the current network state, and the current network state includes the network speed at the electronic device, for example, the network speed is 8kb / s, 0.6kb / s, and then the preset acquisition times are determined based on the current network state.

[0074] As one of the ways, a preset network state is pre-set, for example, the preset network state is 7kb / s, and the network state is compared with the preset network state; when the current network state is better than the preset network state, for example, the preset network state is 7kb / s and the current network state is 8kb / s, then the current network state 8kb / s is better than the preset network state 7kb / s, indicating that the current network condition of the electronic device is better, and the first acquisition number can be configured; or, when the preset network state is better than the current network state, for example, the preset network state is 7kb / s and the current network state is 0.6kb / s, then the preset network state 7kb / s is better than the current network state 0.6kb / s, indicating that the current network condition of the electronic device is worse, and the second acquisition number can be configured, wherein the first acquisition number is greater than the second acquisition number. That is to say, the preset acquisition number determined when the current network state is better than the preset network state is greater than the preset acquisition number determined when the preset network state is better than the current network state.

[0075] As another method, a correspondence relationship between a plurality of network states and acquisition times is pre-established, and when the network state of the electronic device is detected, the acquisition times corresponding to the network state are acquired based on the correspondence relationship.

[0076] As another implementation, the network status may also include processor remaining resources, such as remaining space of a random access memory, obtaining the processor remaining resources of the electronic device, determining the number of acquisitions based on the processor remaining resources, and using the number of acquisitions as the preset number of acquisitions. When the processor remaining resources are greater than the preset remaining resources, a third number of acquisitions is obtained, and when the processor remaining resources are less than or equal to the preset remaining resources, a fourth number of acquisitions is obtained, wherein the third number of acquisitions is greater than the fourth number of acquisitions.

[0077] The present embodiment provides a method for testing a display page. When an electronic device loads a display interface, a target element loaded on the display interface is detected and acquired; it is determined whether the currently loaded target element satisfies a preset display scenario; when it is determined that the currently loaded target element has satisfied the preset display scenario, the display page loaded with the target element can be tested; when the currently loaded target element does not satisfy the preset display scenario, it indicates that a loop waiting needs to be continued until the target element reacquired within a preset number of acquisitions matches the preset element, and the display interface loaded with the reacquired target element is tested. When a target element satisfying the preset display scenario is loaded, the display page is tested. Compared with forced waiting, the loop waiting of the present embodiment can avoid the situation where a shorter waiting time is not enough to wait for the target element satisfying the preset display scenario, and can also avoid the situation where a longer waiting time is set and a longer waiting time is required after the target element satisfying the preset display scenario is found.

[0078] Optionally, based on the above embodiment, this embodiment provides a display interface testing method, Figure 3 A flow chart showing a display interface testing method provided by another embodiment of the present application is shown. Figure 3 The display interface testing method may specifically include the following steps:

[0079] Step S210: When the electronic device loads the display interface, detecting the target element loaded on the display interface within a preset waiting time.

[0080] When an electronic device loads a display interface, an explicit waiting method is used to pre-set a preset waiting time, and the preset waiting time is stored in a public configuration file. When it is necessary to detect a target element, the preset waiting time is obtained from the public configuration file, and the target element loaded on the display interface is detected within the preset waiting time. If the target element is still not loaded on the display interface after the waiting time exceeds the preset waiting time, it means that the target display page has failed to load, and the detection of the target element is ended. Since the target element is not detected, the loading of the target display interface fails, and the test of the target display interface also fails. Prompts such as "Failed to load the target display interface" or "Loading failed" can be displayed on the electronic device to prompt the tester to investigate the cause of the loading failure, such as poor network instructions.

[0081] Step S220: Acquire the target element currently loaded on the display interface.

[0082] Step S230: when the currently loaded target element satisfies a preset display scenario, the display interface is determined as a target display interface.

[0083] In this embodiment, the specific description of step S220 to step S230 can refer to step S120 to step S130 in the above embodiment, which will not be repeated here.

[0084] Step S240: determining a plurality of function points on the target display interface.

[0085] Among them, the function point can be understood as the position on the target display interface whose function needs to be tested, and there are multiple function points distributed on the display interface. Optionally, the tester can select multiple function points in advance, or select multiple function points in places where problems are likely to occur based on historical verification data.

[0086] Step S250: Load the test case, and test the multiple function points according to the test case.

[0087] Load the test case and test multiple functional points according to the test rules carried in the test case to implement the test of the target display interface.

[0088] In some implementations, a test case is loaded, and the test order of the multiple function points is set according to the test rules in the test case, and the multiple function points are tested one by one until the last function point of the multiple function points is tested, and it is determined that the entire target display interface test is completed. Alternatively, a test case is loaded, and the position order of the multiple test cases is obtained. The test case tests the multiple function points one by one according to the position order, until each function point is tested, and it is determined that the entire target display interface test is completed.

[0089] In other implementations, some function points may be selected from multiple function points as target function points, and the target function points may be tested to improve the display interface test rate. Figure 4 This application shows Figure 3 A flow chart of step S250 of the display interface testing method shown in FIG. Figure 4 , step S250 includes the following sub-steps:

[0090] Sub-step S251: Obtain a first duration, wherein the first duration is the duration for the display interface to currently load the target element.

[0091] The duration of loading the target element on the display interface is obtained as the first duration, where the first duration refers to the duration from the start of loading to the successful loading of the target element. For example, the first duration is 2 seconds.

[0092] It should be noted that if the currently loaded target element does not satisfy the preset display scene, it is necessary to repeat step S210, that is, when the electronic device loads the display interface, detect the target element loaded on the display interface within the preset waiting time, and acquire the target element in a loop until the target element that satisfies the preset display scene is acquired within the preset waiting time. In the case of cyclically acquiring the target element, the first time duration is the time duration from the start of loading to the successful loading of the target element that satisfies the preset display scene.

[0093] Sub-step S252: obtaining a second duration according to a difference between a preset waiting duration and the first duration, wherein the preset waiting duration is a test duration for the target display interface.

[0094] For the scenario of testing the automatically switched display interface (such as a slide display interface, a video playback page, etc.), the time for testing each target display interface is limited, and the test duration for each target display interface can be a preset waiting duration. According to the difference between the preset waiting duration and the first duration, a second duration is obtained, wherein the second duration can represent the duration of the test target function point, and can also represent the duration of the test target display interface. It can be understood that when the speed of loading the target display interface is faster, the corresponding first duration is shorter, and the second duration left for the display interface test is longer. Conversely, when the speed of loading the target display interface is slower, the corresponding first duration is longer, and the second duration left for the display interface test is shorter.

[0095] Sub-step S253: determining a target function point from the plurality of function points according to the second duration.

[0096] The second time length is the time length used to test the function points. The longer the second time length is, the more time the electronic device has to test the function points, so more function points can be selected as target function points. Conversely, the shorter the second time length is, the less time the electronic device has to test the function points, so fewer function points can be selected as target function points.

[0097] As a method, a second preset mapping relationship is pre-established, wherein the second preset mapping relationship includes a correspondence between multiple second durations and multiple quantities, wherein the multiple second durations and the multiple quantities correspond one to one, and one second duration corresponds to one quantity. It is understandable that each of the multiple second durations corresponds to a quantity. For example, the second preset mapping relationship includes 0.2 seconds corresponding to 5 function points and 0.8 seconds corresponding to 9 function points. It is understandable that when the value of the second duration is inconsistent with the second duration in the second preset mapping relationship, the value can be rounded off and then the corresponding number of function points can be found. Based on the second preset mapping relationship, the target number corresponding to the second duration is obtained, wherein the target number is less than or equal to the total number of multiple function points, that is, the selected target number does not exceed the total number of function points on the display interface. The target function point needs to be verified by a test case, and the number of test cases is at least one.

[0098] Sub-step S254: Load the test case, and test the target function point according to the test case.

[0099] A test case is loaded, wherein the test case carries a test rule, and a target function point is tested according to the test rule to implement a test on a target display page loaded with the target function point.

[0100] In this embodiment, when the electronic device loads a display interface, the target element loaded on the display interface is detected and the currently loaded target element is obtained. When the currently loaded target element meets the preset display scenario, the display interface loaded with the target element is determined as the target display interface, and multiple function points are determined on the target display interface. Some function points are selected from the multiple function points as target function points, and then the test case is loaded, and the target function point is tested according to the test case, so as to realize the testing of the target display interface and only test some target function points, thereby improving the test rate.

[0101] Based on the above embodiment, this embodiment provides a display interface testing method. Figure 5 A flow chart showing a display interface testing method provided by another embodiment of the present application is shown. Figure 5 The display interface testing method may specifically include the following steps:

[0102] Step S301: Detect target elements.

[0103] When the electronic device loads the display page, the target element is detected through pre-packaged public methods such as (expected_conditions.visibility_of_element_locate) and (WebDriverWait.until).

[0104] Step S302: Determine whether the target element appears.

[0105] When the target element does not appear, that is, the target element is not loaded on the display page, step S303 is executed. On the contrary, when the target element appears, that is, the target element is loaded on the display page, step S304 is executed.

[0106] Step S303: Determine whether it is within the preset waiting time.

[0107] When the waiting time is within the time limit, the process returns to step S301 to continue detecting the target element. When the waiting time is not within the time limit, the process executes step S310.

[0108] Step S304: Obtain interface element values.

[0109] Among them, the interface element value refers to the specific meaning represented by the target element. For example, if the target element is an element at a preset position (for example, the lower right corner of the display interface), the element value is "confirm".

[0110] Step S305: Determine whether the element value meets expectations.

[0111] When the element value does not meet expectations, the process proceeds to step S306 , otherwise, when the element value meets expectations, the process proceeds to step S307 .

[0112] Step S306: Determine whether the number of cycles is greater than the set number.

[0113] When the number of cycles is less than the set number, the process returns to step S304. Conversely, when the number of cycles is greater than the set number, the process enters step S310.

[0114] Step S307: Check the target display page, that is, check whether the target page is TURE.

[0115] When the verification result is TRUE, the process proceeds to step S308, otherwise when the verification result is FALSE, the process proceeds to step S309.

[0116] Step S308: If the first verification result is obtained, the test passes.

[0117] The first verification result is displayed on the display screen of the electronic device in the form of text "Verification passed" or in the form of voice broadcast "Verification passed". The first verification result can also be fed back to the backend server.

[0118] Step S309: If a second verification result is obtained, the test fails.

[0119] The second verification result is displayed on the electronic device, for example, in the form of "verification failed" and the corresponding failure reason is displayed for easy modification. The second verification result can also be fed back to the backend server.

[0120] Step S310: Verification is completed.

[0121] In this embodiment, the specific description of steps S301 to S310 can refer to the steps in the above embodiments, which will not be repeated here.

[0122] To implement the above method embodiments, this embodiment provides a display interface testing device. Figure 6 A block diagram of a display interface testing device provided by an embodiment of the present application is shown. Figure 6 The display interface testing device 200 includes: a loading module 210 , an acquisition module 220 , a determination module 230 and a testing module 240 .

[0123] A loading module 210, configured to detect a target element loaded on the display interface when the electronic device loads the display interface;

[0124] An acquisition module 220 is used to acquire the target element currently loaded on the display interface when the target element is detected;

[0125] A determination module 230, configured to determine the display interface as a target display interface if the currently loaded target element satisfies a preset display scenario;

[0126] The testing module 240 is used to load a test case and test the target display interface according to the test case.

[0127] Optionally, the display interface testing device 200 further includes: a circulation module.

[0128] A loop module is used to continue to execute the step of detecting the target element loaded on the display interface when the currently loaded target element does not satisfy the preset display scenario, until the target element re-acquired within a preset number of acquisitions matches the preset element, determine that the re-acquired target element satisfies the preset display scenario, and determine the display interface as the target display interface, and the preset number of acquisitions is the number of times the step of detecting the target element loaded on the display interface is returned.

[0129] Optionally, the display interface testing device 200 further includes: a state acquisition module and a number determination module.

[0130] A status acquisition module, used to acquire the current network status of the electronic device;

[0131] The number determination module is used to determine the preset number of acquisitions based on the current network state, wherein the preset number of acquisitions determined when the current network state is better than the preset network state is greater than the preset number of acquisitions determined when the preset network state is better than the current network state.

[0132] Optionally, the determination module 230 includes: a display position determination submodule, a mapping submodule and a preset element determination submodule.

[0133] A display position determination submodule, used to obtain the display position of the currently loaded target element on the display interface;

[0134] a mapping submodule, configured to obtain a preset element corresponding to the display position according to a first preset mapping relationship, wherein the first preset mapping relationship includes a correspondence relationship between a plurality of display positions and a plurality of preset elements, and the plurality of display positions and the plurality of preset elements correspond one to one;

[0135] The preset element determination submodule is used to determine whether the currently loaded target element satisfies a preset display scenario when the target element matches the preset element.

[0136] Optionally, the loading module 210 includes: a waiting submodule.

[0137] The waiting submodule is used to detect the target element loaded on the display interface within a preset waiting time when the electronic device loads the display interface.

[0138] Optionally, the test module 240 includes: a function point driving submodule and a test submodule.

[0139] A function point driving submodule, used for determining a plurality of function points on the target display interface;

[0140] The test submodule is used to load the test case and test the multiple function points according to the test case.

[0141] Optionally, the testing submodule includes: a first duration acquisition submodule, a second duration acquisition submodule, a target function point determination submodule and a target function point testing submodule.

[0142] A first duration acquisition submodule, used to acquire a first duration, wherein the first duration is the duration of the target element currently loaded on the display interface;

[0143] A second duration acquisition submodule, configured to obtain a second duration according to a difference between a preset waiting duration and the first duration, wherein the preset waiting duration is a test duration for the target display interface;

[0144] a target function point determination submodule, configured to determine a target function point from the plurality of function points according to the second duration;

[0145] The target function point test submodule is used to load the test case and test the target function point according to the test case.

[0146] Optionally, the target function point determination submodule includes: a target quantity determination submodule and a target function point.

[0147] a target quantity determination submodule, configured to obtain, based on a second preset mapping relationship, a quantity corresponding to the second duration as a target quantity, wherein the second preset mapping relationship includes a correspondence relationship between a plurality of second durations and a plurality of quantities, and the plurality of second durations and the plurality of quantities correspond one to one;

[0148] The target function point determination submodule is used to select the target number of function points from the multiple function points as the target function points.

[0149] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the above-described devices and modules can refer to the corresponding processes in the aforementioned method embodiments, and will not be repeated here.

[0150] In several embodiments provided in the present application, the coupling between modules may be electrical, mechanical or other forms of coupling.

[0151] In addition, each functional module in each embodiment of the present application can be integrated into a processing module, or each module can exist physically separately, or two or more modules can be integrated into one module. The above integrated modules can be implemented in the form of hardware or software functional modules.

[0152] Figure 7 is a block diagram of an electronic device for executing a display interface testing method according to an embodiment of the present application, please refer to Figure 7 , which shows a structural block diagram of an electronic device 110 provided in an embodiment of the present application. The electronic device 110 may be an electronic device capable of running applications, such as a smart phone, a tablet computer, an e-book, etc. The electronic device 110 in the present application may include one or more of the following components: a processor 111, a memory 112, and one or more applications, wherein the one or more applications may be stored in the memory 112 and configured to be executed by one or more processors 111, and the one or more programs are configured to execute the method described in the aforementioned method embodiment.

[0153] Among them, the processor 111 may include one or more processing cores. The processor 111 uses various interfaces and lines to connect various parts of the entire electronic device 110, and executes various functions and processes data of the electronic device 110 by running or executing instructions, programs, code sets or instruction sets stored in the memory 112, and calling data stored in the memory 112. Optionally, the processor 111 can be implemented in at least one hardware form of digital signal processing (Digital Signal Processing, DSP), field programmable gate array (Field-Programmable Gate Array, FPGA), and programmable logic array (Programmable Logic Array, PLA). The processor 111 can integrate one or a combination of a central processing unit (Central Processing Unit, CPU), a graphics processing unit (Graphics Processing Unit, GPU) and a modem. Among them, the CPU mainly processes the operating system, user interface and application programs; the GPU is responsible for rendering and drawing components to be displayed; and the modem is used to process wireless communications. It can be understood that the above-mentioned modem may not be integrated into the processor 111, and it can be implemented separately through a communication chip.

[0154] The memory 112 may include a random access memory (RAM) or a read-only memory (ROM). The memory 112 may be used to store instructions, programs, codes, code sets or instruction sets. The memory 112 may include a program storage area and a data storage area, wherein the program storage area may store instructions for implementing an operating system, instructions for implementing at least one function (such as a touch function, a sound playback function, an image playback function, etc.), instructions for implementing the following various method embodiments, etc. The data storage area may also store data (such as a historical configuration file) created by the electronic device 110 during use.

[0155] Figure 8 The storage unit of the embodiment of the present application is used to store or carry the program code for implementing the display interface testing method according to the embodiment of the present application, see Figure 8 , which shows a structural block diagram of a computer-readable storage medium provided in an embodiment of the present application. The computer-readable medium 300 stores program codes, which can be called by a processor to execute the method described in the above method embodiment.

[0156] The computer readable storage medium 300 may be an electronic memory such as a flash memory, an EEPROM (electrically erasable programmable read-only memory), an EPROM, a hard disk, or a ROM. Optionally, the computer readable storage medium 300 includes a non-transitory computer-readable storage medium. The computer readable storage medium 300 has storage space for program code 310 that performs any method steps in the above method. These program codes can be read from or written to one or more computer program products. The program code 310 can be compressed, for example, in an appropriate form.

[0157] Optionally, an embodiment of the present application further provides a computer program product, the computer program product comprising a computer program / instructions, which implement the above method when executed by a processor.

[0158] In summary, the present application provides a display interface testing method, device, electronic device and storage medium. When the electronic device loads the display interface, the target element loaded on the display interface is detected, and the target element currently loaded on the display interface is obtained. When the currently loaded target element meets the preset display scene, the display interface loaded with the target element is determined as the target display interface. After ensuring that the target display interface is successfully loaded, the test case is loaded, and the target display interface is tested according to the test case to ensure that the test case can successfully test the target display interface.

[0159] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present application, rather than to limit it. Although the present application has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present application.

Claims

1. A display interface testing method, It is characterized in that Applied to electronic equipment, the method comprises: When the electronic device loads a display interface, detecting a target element loaded on the display interface; When the target element is detected, obtaining the target element currently loaded on the display interface; In a case where the currently loaded target element satisfies a preset display scenario, determining the display interface as a target display interface; Load a test case, and test the target function point of the target display interface according to the test case, wherein the target function point is determined from multiple function points according to a second duration, and the second duration is obtained according to the difference between a preset waiting duration and a first duration for the display interface to currently load the target element; the longer the second duration is, the more target function points are determined, and the preset waiting duration is the test duration for the target display interface.

2. The method according to claim 1, It is characterized in that The method further comprises: In the case that the currently loaded target element does not satisfy the preset display scenario, return to execute the step of detecting the target element loaded on the display interface, until the target element re-acquired within a preset number of acquisitions matches the preset element, determine that the re-acquired target element satisfies the preset display scenario, and determine the display interface as the target display interface, and the preset number of acquisitions is the number of times the step of detecting the target element loaded on the display interface is returned to execute.

3. The method according to claim 2, It is characterized in that The method further comprises: Acquiring the current network status of the electronic device; The preset acquisition number is determined based on the current network state, wherein the preset acquisition number determined when the current network state is better than the preset network state is greater than the preset acquisition number determined when the preset network state is better than the current network state.

4. The method according to claim 2, It is characterized in that The step of determining the display interface as a target display interface when the currently loaded target element satisfies a preset display scenario includes: Obtaining a display position of the currently loaded target element on the display interface; According to a first preset mapping relationship, obtaining a preset element corresponding to the display position, wherein the first preset mapping relationship includes a correspondence between a plurality of display positions and a plurality of preset elements, wherein one display position corresponds to one preset element; In the case where the target element matches the preset element, it is determined that the currently loaded target element satisfies the preset display scenario.

5. The method according to claim 1, It is characterized in that The method further comprises: A plurality of function points are determined on the target display interface.

6. The method according to claim 5, It is characterized in that The method further comprises: Get the first duration.

7. The method according to claim 6, It is characterized in that The method further comprises: Based on a second preset mapping relationship, obtaining a target quantity corresponding to the second duration, wherein the second preset mapping relationship includes a correspondence relationship between multiple second durations and multiple quantities, wherein one second duration corresponds to one quantity; The target number of function points is selected from the plurality of function points and determined as target function points.

8. A display interface testing device, It is characterized in that Applied to electronic equipment, the device comprises: A loading module, configured to detect a target element loaded on the display interface when the electronic device loads the display interface; An acquisition module, configured to acquire the target element currently loaded on the display interface when the target element is detected; A determination module, configured to determine the display interface as a target display interface if the currently loaded target element satisfies a preset display scenario; A test module is used to load test cases and test target function points of the target display interface according to the test cases, wherein the target function points are determined from multiple function points according to a second duration, and the second duration is obtained according to the difference between a preset waiting duration and a first duration for the display interface to currently load the target element; the longer the second duration, the more target function points are determined, and the preset waiting duration is the test duration for the target display interface.

9. An electronic device, It is characterized in that include: one or more processors; Memory; One or more applications, wherein the one or more applications are stored in the memory and configured to be executed by the one or more processors, and the one or more applications are configured to execute the method according to any one of claims 1-7.

10. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores program codes, which can be called by a processor to execute the method according to any one of claims 1 to 7.

11. A computer program product comprising a computer program / instructions, It is characterized in that When the computer program / instructions are executed by a processor, the method according to any one of claims 1 to 7 is implemented.

Citation Information

Patent Citations

  • UI (user interface) automated testing method, device, electronic equipment and storage medium

    CN107577607A

  • Test code generation method and apparatus

    CN108073511A

  • Automatic test method and device, computer equipment and storage medium

    CN109783365A

  • UI automatic test case and system and page element loading waiting method and system

    CN110737585A

  • Application testing method and device, electronic equipment and storage medium

    CN112948259A