CN113791974A - User interface UI element explicit waiting method and device - Google Patents

User interface UI element explicit waiting method and device Download PDF

Info

Publication number
CN113791974A
CN113791974A CN202110979322.5A CN202110979322A CN113791974A CN 113791974 A CN113791974 A CN 113791974A CN 202110979322 A CN202110979322 A CN 202110979322A CN 113791974 A CN113791974 A CN 113791974A
Authority
CN
China
Prior art keywords
specified
state
specific operation
waiting
condition
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Granted
Application number
CN202110979322.5A
Other languages
Chinese (zh)
Other versions
CN113791974B (en
Inventor
刘丹丹
梁海燕
梁田
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Weimeng Chuangke Network Technology China Co Ltd
Original Assignee
Weimeng Chuangke Network Technology China Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Weimeng Chuangke Network Technology China Co Ltd filed Critical Weimeng Chuangke Network Technology China Co Ltd
Priority to CN202110979322.5A priority Critical patent/CN113791974B/en
Publication of CN113791974A publication Critical patent/CN113791974A/en
Application granted granted Critical
Publication of CN113791974B publication Critical patent/CN113791974B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management
    • G06F11/3684Test management for test design, e.g. generating new test cases
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F11/00Error detection; Error correction; Monitoring
    • G06F11/36Preventing errors by testing or debugging software
    • G06F11/3668Software testing
    • G06F11/3672Test management

Landscapes

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

Abstract

The embodiment of the invention provides a method and a device for explicitly waiting a user interface UI element, which are used for acquiring positioning information of a first element on a user interface; and circularly executing specific operation and detecting the state of the first element according to the positioning information of the first element until the state of the first element is updated to a specified target state or the total execution time of the circulation is more than or equal to the specified total timeout time, and exiting the circulation.

Description

User interface UI element explicit waiting method and device
Technical Field
The invention relates to the field of User Interface (UI) automatic testing, in particular to a method and a device for explicitly waiting UI elements of a user interface.
Background
The WebDriverWait class of the Selenium and the expected _ conditions module are combined to use the explicit waiting which can realize the static element judgment, wherein the WebDriverWait module realizes the explicit waiting, and the expected _ conditions realizes a series of static element judgment. The static element judgment used in the existing implementation manner is to only circularly wait for a period of time to judge whether the page element meets the judgment method, and if an event triggering the page element to meet the judgment condition is not executed or is not executed successfully due to some reason (for example, a network drop exception), the explicit waiting fails, and a timeout exception is thrown.
In the process of implementing the invention, the applicant finds that at least the following problems exist in the prior art:
in the testing process, the static element judgment is easy to have timeout failure due to testing environment interference and the problem of repeated coding aiming at explicit waiting in each test.
Disclosure of Invention
The embodiment of the invention provides a method and a device for explicitly waiting UI elements of a user interface, which solve the problems that in the test process, the judgment of static elements is easy to cause overtime failure due to the interference of test environment and the explicit waiting repeated coding in each test is easy to realize.
To achieve the above object, in one aspect, an embodiment of the present invention provides a method for explicitly waiting for a UI element of a user interface, including:
acquiring positioning information of a first element on a user interface;
circularly executing specific operation and detecting the state of the first element according to the positioning information of the first element until the state of the first element is updated to a specified target state or the total execution time of the circulation is more than or equal to the specified total timeout time, and exiting the circulation;
wherein the specific operation is to make a specified condition hold; the specified condition is a condition for updating the state of the first element to the specified target state.
Further, the loop executes a specific operation and detects the state of the first element according to the positioning information of the first element, and exits the loop until the state of the first element is updated to a specified target state or the total execution time of the loop is greater than or equal to a specified total timeout time, including:
according to the specified total timeout time and the specified time interval, circularly executing the following steps:
judging whether the total execution time of the circulation is more than or equal to the specified total timeout time, if so, returning to failure and exiting the circulation; if not, then,
judging whether the state of the first element is updated to the specified target state or not according to the positioning information of the first element, if so, returning to be successful and exiting from the cycle;
executing the specific operation and waiting for the delay of the specified time interval;
returning to the step of judging whether the total execution time of the circulation is more than or equal to the specified total timeout time or not, and starting the next circulation;
wherein the specified time interval is less than the specified total timeout time.
Further, while the positioning information of the first element on the user interface is obtained, the positioning information of the second element on the user interface is also obtained;
wherein the specific operation is to operate the second element according to the positioning information of the second element to make the specified condition.
Further, before the performing the specific operation and waiting for the delay of the specified time interval, the method further includes:
determining whether an execution condition for executing the specific operation for the second element is satisfied;
if the execution condition is met, continuing to execute the specific operation and waiting for the delay of the specified time interval;
if the execution condition is not satisfied, returning to the step of executing whether the total execution time of the judgment loop is more than or equal to the specified total timeout time or not, and starting the next loop
Further, the determining whether the execution condition for executing the specific operation on the second element is satisfied specifically includes:
and judging whether the second element exists and whether the second element can be executed with the specific operation, wherein if the second element exists and the second element can be executed with the specific operation, the execution condition is met, and if not, the execution condition is not met.
On the other hand, an embodiment of the present invention provides an explicit waiting apparatus for UI elements, including:
the element acquisition unit is used for acquiring positioning information of a first element on the user interface;
the explicit waiting unit is used for circularly executing specific operation and detecting the state of the first element according to the positioning information of the first element, and the loop exits until the state of the first element is updated to a specified target state or the total execution time of the loop is more than or equal to the specified total timeout time;
wherein the specific operation is to make a specified condition hold; the specified condition is a condition for updating the state of the first element to the specified target state.
Further, the explicit waiting unit includes:
the overtime detection module is used for judging whether the total execution time of the circulation is greater than or equal to the specified total overtime time or not, and if so, returning to failure and exiting the circulation; otherwise, triggering the state detection module or the operation execution module;
the state detection module is used for judging whether the state of the first element is updated to the specified target state according to the positioning information of the first element under the triggering of the overtime detection module, if so, returning to be successful and exiting from circulation, and if not, triggering the operation execution module; or, under the trigger of the operation execution module, judging whether the state of the first element is updated to the specified target state according to the positioning information of the first element, if so, returning to success and exiting from circulation, and if not, triggering the circulation control module;
the operation execution module is used for executing the specific operation and waiting for the time delay of the specified time interval under the triggering of the state detection module, and then triggering the cycle control module; or, under the trigger of the overtime detection module, executing the specific operation and waiting for the delay of the specified time interval, and then triggering the state detection module;
the cycle control module is used for returning to the overtime detection module and starting the next cycle;
wherein the specified time interval is less than the specified total timeout time.
Further, the element obtaining unit is further configured to obtain positioning information of a second element on the user interface;
wherein the specific operation is to operate the second element according to the positioning information of the second element to make the specified condition.
Further, before the operation execution module, the method further includes:
a condition judgment module configured to judge whether an execution condition for executing the specific operation with respect to the second element is satisfied or not, and notify the operation execution module if the execution condition is satisfied, under the trigger of the element acquisition unit; and if the execution condition is not met, triggering the circulation control module.
Further, the condition determining module is configured to:
and judging whether the second element exists and whether the second element can be executed with the specific operation, wherein if the second element exists and the second element can be executed with the specific operation, the execution condition is met, and if not, the execution condition is not met.
The technical scheme has the following beneficial effects: the test method realized by the technical scheme of the invention realizes that the same test method can be repeatedly reused in a plurality of test cases by inputting different first elements without repeatedly encoding each test case, thereby improving the test efficiency and reducing the error rate of test operation; in the loop of the explicit waiting, a condition causing the state of the first element to be updated to a specified target state is prompted to appear by executing a specific operation in each loop, so that the problem that the state of the first element is only statically waited to be updated in the explicit waiting and is easily interfered by a test environment is avoided, and the test passing rate is obviously improved; the technical scheme of the invention is applied to the automatic test verification statistics of the UI of the web end, and the test passing rate is improved by 50 percent compared with the prior art. Furthermore, a universal UI test method which is determined by specific operation of a second element according to state change of a first element is provided, and only the first element and the second element need to be input into the method in each test case, so that the aim of code multiplexing is achieved, repeated coding is reduced, and the efficiency of test case preparation is improved. Further, by judging whether the condition for executing the specific operation on the second element is met or not, the success rate of testing the first element is further improved, and the error reason can be accurately and quickly determined when the first element fails.
Drawings
In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present invention, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
FIG. 1 is a flow chart of a method for explicit waiting of UI elements of a user interface according to one embodiment of the present invention;
FIG. 2 is an exemplary diagram of a user interface UI display page of one embodiment of the invention;
FIG. 3 is an exemplary diagram of an updated user interface UI display page of one embodiment of the invention;
FIG. 4 is another flow diagram of a method for explicit waiting of UI elements of a user interface according to an embodiment of the invention;
fig. 5 is a structural diagram of an explicit waiting device for UI elements according to an embodiment of the present invention.
Detailed Description
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Before describing embodiments of the present invention, the following terms are explained:
UI (user interface): namely User Interface, refers to the overall design of man-machine interaction, operation logic and beautiful Interface of software. This is particularly the user interface of the software system.
UI automated testing: and replacing the manual operation user interface with codes, thereby discovering the bugs and problems of the system program and completing the test of the user interface.
selenium: the automatic UI testing tool is a tool for automatic UI testing of Web application programs, directly runs in a Web browser, and simulates a human operation user interface to realize automatic UI testing.
Element positioning: in the UI automation test, a user interface consists of a plurality of element objects, the process of searching elements by using attributes of the element objects such as name, label, value, xpath and the like as positioning information is element positioning, and subsequent automation test operations such as inputting, clicking and the like can be carried out on the elements after the elements are positioned.
Explicitly waiting: and executing element judgment at intervals (for example, the element is generally defaulted to 0.5 second and can also be defined by a user), for example, judging whether the element exists or not, clicking or not, executing the next step if the judgment condition is met, otherwise, continuing to wait until the set maximum waiting time is exceeded, and throwing the exception of the TimeOutException. The WebDriverWait module of selenium implements explicit waiting.
Judging static elements: the element judgment method does not perform any operation on the page elements, and only judges whether the elements meet the judgment conditions. The sequenced _ conditions module of the Selenium implements a series of static element judgment methods.
The following is a detailed description of embodiments of the invention:
in one aspect, as shown in fig. 1, an embodiment of the present invention provides an explicit waiting method for a UI element of a user interface, including:
step S100, acquiring positioning information of a first element on a user interface;
step S101, circularly executing specific operation and detecting the state of the first element according to the positioning information of the first element, and quitting the circulation until the state of the first element is updated to a specified target state or the total execution time of the circulation is more than or equal to a specified total timeout time;
wherein the specific operation is to make a specified condition hold; the specified condition is a condition for updating the state of the first element to the specified target state.
In some embodiments, the input location information of the first element is obtained, and the corresponding element may be located in the user interface through the location information, and specifically, the attribute of the first element may be specified to include, but is not limited to, attributes such as name, label, value, XPath, XML path, and the like as the location information. Specific operations may include, but are not limited to, mouse clicks, refreshing pages, text modifications, property settings for other elements, and the like; for example, a mouse click may be a click on a specified element, such as a click on a first element, or a click on other elements on the page. The specified target state is a state that a certain attribute of the first element should become when the specified condition is satisfied; the specified condition is a result of successful execution of a specific operation, for example, element X (corresponding to the first element) is displayed on the user interface on the premise that the page is refreshed; the specific operation is a refresh page operation, the specified condition is that the page has been refreshed, the specified target state is that the visibility of element X is updated to be visible, and is displayed on the user interface. An explicit wait is performed, and in each loop of the explicit wait, the state of the first element, i.e., one or more of the various attributes the first element has, including, but not limited to, the state of visibility, whether selected, whether input occurred, etc., is detected. And particularly, specific operation is executed in each cycle to ensure that the specified condition which causes the first element state to be updated to the specified target state is established, so that the probability of displaying the test case waiting for successfully completing the test is obviously improved, and the anti-interference capability of the test case for accidental interference factors is improved. For example, in each cycle, an operation of refreshing the page (corresponding to a specific operation) is performed, and whether a specified presentation text (corresponding to the first element) appears (whether the state of the first element is updated to a specified target state) is checked, and then a specified condition is satisfied when the page is refreshed as a result of the specific operation. The particular operation may be an operation implemented by code to simulate, including but not limited to, a mouse click, text entry, page refresh, and/or state setting for an element; by inputting the positioning information of different first elements into the overall process formed by steps S100 to S101, the same overall process can be used to test for different first elements. For example, the method steps in the technical solution of the present invention may be packaged as a function, and a first element externally input is received in a function parameter, so as to parameterize the first element, so as to apply a process to a plurality of test cases. Besides the first element, other input elements, specific operations and other parameters involved in the technical solution of the present invention may also be input externally in a parameterized form.
The embodiment of the invention has the following technical effects: by inputting different first elements into the overall process formed by the steps S100 to S101, the same overall process can be used for testing different first elements, so that the same testing method can be repeatedly reused in a plurality of test cases without repeatedly encoding each test case, the testing efficiency is improved, and the error rate of testing operation is reduced; further, in the loop of the explicit waiting, by executing a specific operation in each loop, a condition causing the state of the first element to be updated to a specified target state is prompted to occur, so that the problem that only the state of the first element is statically waited to be updated in the loop of the explicit waiting and is easily interfered by a test environment is avoided, and the test passing rate is obviously improved; the technical scheme of the invention is applied to the automatic test verification statistics of the UI of the web end, and the test passing rate is improved by 50 percent compared with the prior art.
Further, the loop executes a specific operation and detects the state of the first element according to the positioning information of the first element, and exits the loop until the state of the first element is updated to a specified target state or the total execution time of the loop is greater than or equal to a specified total timeout time, including:
according to the specified total timeout time and the specified time interval, circularly executing the following steps:
judging whether the total execution time of the circulation is more than or equal to the specified total timeout time, if so, returning to failure and exiting the circulation; if not, then,
judging whether the state of the first element is updated to the specified target state or not according to the positioning information of the first element, if so, returning to be successful and exiting from the cycle;
executing the specific operation and waiting for the delay of the specified time interval;
returning to the step of judging whether the total execution time of the circulation is more than or equal to the specified total timeout time or not, and starting the next circulation;
wherein the specified time interval is less than the specified total timeout time.
In some embodiments, a total timeout time is specified for controlling the explicit wait total execution time; and the specified time interval is used for controlling the frequency of the loop, periodically detecting whether the state of the first element is updated to a specified target state, if the state is updated to the specified state, exiting the loop to continuously execute other test cases, and if the state is not updated to the specified state, continuously waiting in the loop. Particularly, in the embodiment of the present invention, a step of executing a specific operation is added in a loop, so that a specified condition can be triggered again in each loop, and a condition for updating the state of the first element to a specified target state is satisfied, thereby promoting a probability of successfully completing a test for a test case of the first element. In each cycle, if the state of the first element is not updated to the specified target state, a specific operation is performed and the state of the first element is re-detected in the next cycle after a specified time interval. In some embodiments, the relative order between the 2 nd step in the loop (i.e., determining whether the state of the first element is updated to the specified target state based on the positioning information of the first element, and if so, returning to success and exiting the loop) and the 3 rd step in the loop (i.e., performing the specified operation and waiting for a delay of the specified time interval) may be exchanged, for example, the 2 nd step may be performed first and then the 3 rd step may be performed, or the 3 rd step may be performed first and then the 2 nd step may be performed.
Further, in some embodiments, before step S101, a specific operation may also be performed in advance, so that after entering the loop, the state of the first element may be detected once first.
The embodiment of the invention has the following technical effects: in the loop of the explicit waiting, a condition causing the state of the first element to be updated to a specified target state is prompted to occur by executing a specific operation in each loop, so that the problem that only the state of the first element is statically waited to be updated in the explicit waiting and is easily interfered by a test environment is avoided, and the test passing rate is remarkably improved. Furthermore, after the specific operation is executed, the state of the first element is detected after a specified time interval is delayed, and a certain time is reserved for updating the state of the first element after the specific operation, so that the probability of successfully completing the test of the test case is further improved.
Further, while the positioning information of the first element on the user interface is obtained, the positioning information of the second element on the user interface is also obtained;
wherein the specific operation is to operate the second element according to the positioning information of the second element to make the specified condition.
In some embodiments, the whole process from step S100 to step S101 may input the positioning information of the first element and also input the positioning information of the second element, and the condition that the second element is acted on by a specific operation to cause the state of the first element to change is satisfied. For example, in one embodiment, as shown in fig. 2 and 3, the interest keyword selection button is used as the second element, the search keyword input box in fig. 3 is used as the first element, and the specific operation is to select the interest keyword button by clicking the interest keyword selection button; when the page is in the display state of fig. 2 and a click on the interest keyword button occurs to cause the interest keyword to be selected, the page is updated to the case shown in fig. 3, and the search keyword input box as the first element is displayed in the page. XPath values of the first element and the second element may be input in step S100, and the first element and the second element may be located by the XPath values, and if the first element or the second element is not located, it indicates that the first element or the second element is not displayed on the page. Judging whether the first element is displayed in each cycle of explicit waiting, if so, exiting the explicit waiting successfully, if not, executing specific operation to enable the display condition of the first element to be met, after waiting for a specified time interval, entering the next cycle, and detecting whether the first element is displayed again; the loop continues multiple times until the first element shows or fails to exit until the explicitly waiting execution time reaches a specified total timeout time.
The embodiment of the invention has the following technical effects: the UI general test method is determined by specific operation of the second element according to the state change of the first element, only the first element and the second element need to be input into the method in each test case, the purpose of code multiplexing is achieved, repeated coding is reduced, and the efficiency of preparing the test cases is improved. Meanwhile, in the loop of the explicit waiting, a condition causing the state of the first element to be updated to a specified target state is prompted to appear by executing a specific operation in each loop, so that the problem that the state of the first element is only statically waiting to be updated in the explicit waiting and is easily interfered by a test environment is avoided, and the test passing rate is obviously improved.
Further, before the performing the specific operation and waiting for the delay of the specified time interval, the method further includes:
determining whether an execution condition for executing the specific operation for the second element is satisfied;
if the execution condition is met, continuing to execute the specific operation and waiting for the delay of the specified time interval;
if the execution condition is not satisfied, returning to the step of executing whether the total execution time of the judgment loop is more than or equal to the specified total timeout time, and starting the next loop.
In some embodiments, when a specific operation is performed on a second element, it is first determined whether the second element meets a condition for performing the specific operation, so as to avoid a failure that a test returns an unknown reason due to the second element not being prepared.
The embodiment of the invention has the following technical effects: by judging whether the condition of executing the specific operation on the second element is met or not, the success rate of testing the first element is further improved, and the error reason can be accurately and quickly determined when the first element fails.
Further, the determining whether the execution condition for executing the specific operation on the second element is satisfied specifically includes:
and judging whether the second element exists and whether the second element can be executed with the specific operation, wherein if the second element exists and the second element can be executed with the specific operation, the execution condition is met, and if not, the execution condition is not met.
In some embodiments, preferably, the condition that the second element performs the specific operation includes, but is not limited to, that the second element exists and the second element can be performed the specific operation, for example, in fig. 2, the second element is an interest keyword selection button, and the condition that the second element performs the specific operation is that the interest keyword selection button has been correctly displayed on the page, i.e., can be positioned to the interest keyword selection button by an XPath value of the interest keyword selection button, and the interest keyword selection button is clickable, such as the interest keyword selection button cannot be in an invalid state, e.g., gray, which means that the button does not currently receive a click operation.
In one embodiment, as shown in fig. 2 and 3, the interest keyword selection button is used as the second element, the search keyword input box in fig. 3 is used as the first element, and the specific operation is to select the interest keyword button by clicking the interest keyword selection button; when the page is in the display state of fig. 2, and a click on the interest keyword button occurs to cause the interest keyword to be selected, the page is updated to the display state of fig. 3, and the search keyword input box as the first element is displayed in the page, that is, the designated target state of the search keyword input box as the first element is displayed in the page.
A flowchart shown in fig. 4 illustrates a test procedure implemented in the present embodiment for searching a UI element for a keyword input box. Element a represents the "interest keyword" radio button in fig. 2 and 3, i.e., the second element, and element b represents the "search keyword" input box in fig. 3, i.e., the first element;
example scenario description: clicking on element a in the UI page shown in fig. 2 triggers the UI page to reveal element b as in fig. 3, which can continue to be operated on (e.g., enter keywords) by explicitly waiting to determine that element b is indeed already being presented on the page.
The method comprises the following specific steps:
step S400, running a UI automation program to a UI interface displayed in the figure 2, and clicking an element a; the automation program enters an explicit wait, which introduces two parameters: timeout time timeout (i.e., specified total timeout time) and interval frequency (i.e., specified interval).
Step S401, the program judges whether to enter explicit waiting, judges whether the total consumed time is larger than timeout (namely, the total timeout time is appointed), if yes, throws out the TimeOutException exception, and exits after the explicit waiting fails; otherwise, entering the next step of dynamic judgment; the automation program enters dynamic judgment, and 2 parameters are introduced: XPath _ a (element a, i.e., XPath path of the second element, i.e., location information of the second element) and XPath _ b (element b, i.e., XPath path of the first element, i.e., location information of the first element).
Step S402, element b is positioned through xpath _ b, if the element b is positioned to be dynamically judged to return to True, the element b explicitly waits for the successful exit; otherwise, executing the next step.
Step S403, positioning the element a by using xpath _ a, and if the element a is successfully positioned, executing the next step; otherwise, the dynamic judgment returns false, and the next explicit waiting loop is entered.
Step S404, judging whether the element a is in a clickable state, if not, executing step S407 to dynamically judge and return to false; otherwise, step S405 is performed.
Step S405, if element a is clickable, click element a (i.e., perform a specific operation), and perform step 406;
step S406, waiting for a frequency time period (i.e. waiting for a specified time interval), executing step S407, and dynamically determining to return to false;
in step S407, the dynamic determination returns to false, and then the next explicit wait loop is entered (step S401).
The embodiment of the invention has the following technical effects: by judging whether the condition of executing the specific operation on the second element is met or not, the success rate of testing the first element is further improved, and the error reason can be accurately and quickly determined when the first element fails.
On the other hand, as shown in fig. 5, an embodiment of the present invention provides an apparatus for explicitly waiting for a UI element of a user interface, including:
an element obtaining unit 500, configured to obtain positioning information of a first element on a user interface;
an explicit waiting unit 501, configured to execute a specific operation in a loop and detect a state of the first element according to the positioning information of the first element, and exit the loop until the state of the first element is updated to a specified target state or a total execution time of the loop is greater than or equal to a specified total timeout time;
wherein the specific operation is to make a specified condition hold; the specified condition is a condition for updating the state of the first element to the specified target state.
Further, the explicit waiting unit 501 includes:
the overtime detection module is used for judging whether the total execution time of the circulation is greater than or equal to the specified total overtime time or not, and if so, returning to failure and exiting the circulation; otherwise, triggering the state detection module or the operation execution module;
the state detection module is used for judging whether the state of the first element is updated to the specified target state according to the positioning information of the first element under the triggering of the overtime detection module, if so, returning to be successful and exiting from circulation, and if not, triggering the operation execution module; or, under the trigger of the operation execution module, judging whether the state of the first element is updated to the specified target state according to the positioning information of the first element, if so, returning to success and exiting from circulation, and if not, triggering the circulation control module;
the operation execution module is used for executing the specific operation and waiting for the time delay of the specified time interval under the triggering of the state detection module, and then triggering the cycle control module; or, under the trigger of the overtime detection module, executing the specific operation and waiting for the delay of the specified time interval, and then triggering the state detection module;
the cycle control module is used for returning to the overtime detection module and starting the next cycle;
wherein the specified time interval is less than the specified total timeout time.
Further, the element obtaining unit 500 is further configured to obtain positioning information of a second element on the user interface;
wherein the specific operation is to operate the second element according to the positioning information of the second element to make the specified condition.
Further, still include:
a condition determining module, configured to determine whether an execution condition for executing the specific operation on the second element is satisfied under the trigger of the element obtaining unit 500, and if the execution condition is satisfied, notify the operation executing module; and if the execution condition is not met, triggering the circulation control module.
Further, the condition judging module is configured to:
and judging whether the second element exists and whether the second element can be executed with the specific operation, wherein if the second element exists and the second element can be executed with the specific operation, the execution condition is met, and if not, the execution condition is not met.
The user interface UI element explicit waiting apparatus provided in the embodiments of the present invention is a one-to-one correspondence apparatus to the foregoing user interface UI element explicit waiting method, and those skilled in the art can explain an understanding that no objection is made according to the foregoing embodiment of the user interface UI element explicit waiting method.
It should be understood that the specific order or hierarchy of steps in the processes disclosed is an example of exemplary approaches. Based upon design preferences, it is understood that the specific order or hierarchy of steps in the processes may be rearranged without departing from the scope of the present disclosure. The accompanying method claims present elements of the various steps in a sample order, and are not intended to be limited to the specific order or hierarchy presented.
In the foregoing detailed description, various features are grouped together in a single embodiment for the purpose of streamlining the disclosure. This method of disclosure is not to be interpreted as reflecting an intention that the claimed embodiments of the subject matter require more features than are expressly recited in each claim. Rather, as the following claims reflect, invention lies in less than all features of a single disclosed embodiment. Thus, the following claims are hereby expressly incorporated into the detailed description, with each claim standing on its own as a separate preferred embodiment of the invention.
The previous description of the disclosed embodiments is provided to enable any person skilled in the art to make or use the present invention. To those skilled in the art; various modifications to these embodiments will be readily apparent, and the generic principles defined herein may be applied to other embodiments without departing from the spirit or scope of the disclosure. Thus, the present disclosure is not intended to be limited to the embodiments shown herein but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
What has been described above includes examples of one or more embodiments. It is, of course, not possible to describe every conceivable combination of components or methodologies for purposes of describing the aforementioned embodiments, but one of ordinary skill in the art may recognize that many further combinations and permutations of various embodiments are possible. Accordingly, the embodiments described herein are intended to embrace all such alterations, modifications and variations that fall within the scope of the appended claims. Furthermore, to the extent that the term "includes" is used in either the detailed description or the claims, such term is intended to be inclusive in a manner similar to the term "comprising" as "comprising: as interpreted by the use of "in the claims as a conjunction. Furthermore, any use of the term "or" in the specification of the claims is intended to mean a "non-exclusive or".
Those of skill in the art will further appreciate that the various illustrative logical blocks, units, and steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, computer software, or combinations of both. To clearly illustrate the interchangeability of hardware and software, various illustrative components, elements, and steps have been described above generally in terms of their functionality. Whether such functionality is implemented as hardware or software depends upon the particular application and design requirements of the overall system. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present embodiments.
The various illustrative logical blocks, or elements, described in connection with the embodiments disclosed herein may be implemented or performed with a general purpose processor, a digital signal processor, an Application Specific Integrated Circuit (ASIC), a field programmable gate array or other programmable logic device, discrete gate or transistor logic, discrete hardware components, or any combination thereof designed to perform the functions described herein. A general-purpose processor may be a microprocessor, but in the alternative, the processor may be any conventional processor, controller, microcontroller, or state machine. A processor may also be implemented as a combination of computing devices, e.g., a digital signal processor and a microprocessor, a plurality of microprocessors, one or more microprocessors in conjunction with a digital signal processor core, or any other similar configuration.
The steps of a method or algorithm described in connection with the embodiments disclosed herein may be embodied directly in hardware, in a software module executed by a processor, or in a combination of the two. A software module may be stored in RAM memory, flash memory, ROM memory, EPROM memory, EEPROM memory, registers, hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art. For example, a storage medium may be coupled to the processor such the processor can read information from, and write information to, the storage medium. In the alternative, the storage medium may be integral to the processor. The processor and the storage medium may reside in an ASIC, which may be located in a user terminal. In the alternative, the processor and the storage medium may reside in different components in a user terminal.
In one or more exemplary designs, the functions described above in connection with the embodiments of the invention may be implemented in hardware, software, firmware, or any combination of the three. If implemented in software, the functions may be stored on or transmitted over as one or more instructions or code on a computer-readable medium. Computer-readable media includes both computer storage media and communication media that facilitate transfer of a computer program from one place to another. Storage media may be any available media that can be accessed by a general purpose or special purpose computer. For example, such computer-readable media can include, but is not limited to, RAM, ROM, EEPROM, CD-ROM or other optical disk storage, magnetic disk storage or other magnetic storage devices, or any other medium which can be used to carry or store program code in the form of instructions or data structures and which can be read by a general-purpose or special-purpose computer, or a general-purpose or special-purpose processor. Additionally, any connection is properly termed a computer-readable medium, and, thus, is included if the software is transmitted from a website, server, or other remote source via a coaxial cable, fiber optic cable, twisted pair, Digital Subscriber Line (DSL), or wirelessly, e.g., infrared, radio, and microwave. Such discs (disk) and disks (disc) include compact disks, laser disks, optical disks, DVDs, floppy disks and blu-ray disks where disks usually reproduce data magnetically, while disks usually reproduce data optically with lasers. Combinations of the above may also be included in the computer-readable medium.
The above-mentioned embodiments are intended to illustrate the objects, technical solutions and advantages of the present invention in further detail, and it should be understood that the above-mentioned embodiments are merely exemplary embodiments of the present invention, and are not intended to limit the scope of the present invention, and any modifications, equivalent substitutions, improvements and the like made within the spirit and principle of the present invention should be included in the scope of the present invention.

Claims (10)

1. A User Interface (UI) element explicit waiting method is characterized by comprising the following steps:
acquiring positioning information of a first element on a user interface;
circularly executing specific operation and detecting the state of the first element according to the positioning information of the first element until the state of the first element is updated to a specified target state or the total execution time of the circulation is more than or equal to the specified total timeout time, and exiting the circulation;
wherein the specific operation is to make a specified condition hold; the specified condition is a condition for updating the state of the first element to the specified target state.
2. The method for explicitly waiting for a UI element of a user interface according to claim 1, wherein the loop executes a specific operation and detects the state of the first element according to the positioning information of the first element, and exits the loop until the state of the first element is updated to a specified target state or the total execution time of the loop is greater than or equal to a specified total timeout time, comprising:
according to the specified total timeout time and the specified time interval, circularly executing the following steps:
judging whether the total execution time of the circulation is more than or equal to the specified total timeout time, if so, returning to failure and exiting the circulation; if not, then,
judging whether the state of the first element is updated to the specified target state or not according to the positioning information of the first element, if so, returning to be successful and exiting from the cycle;
executing the specific operation and waiting for the delay of the specified time interval;
returning to the step of judging whether the total execution time of the circulation is more than or equal to the specified total timeout time or not, and starting the next circulation;
wherein the specified time interval is less than the specified total timeout time.
3. The explicit waiting method for UI element of claim 2 wherein the location information of the first element on the UI is obtained simultaneously with the location information of the second element on the UI;
wherein the specific operation is to operate the second element according to the positioning information of the second element to make the specified condition.
4. The user interface UI element explicit wait method of claim 3 further comprising, before the performing the particular operation and waiting for the specified time interval's delay:
determining whether an execution condition for executing the specific operation for the second element is satisfied;
if the execution condition is met, continuing to execute the specific operation and waiting for the delay of the specified time interval;
if the execution condition is not satisfied, returning to the step of executing whether the total execution time of the judgment loop is more than or equal to the specified total timeout time, and starting the next loop.
5. The method for explicitly waiting for the UI element of the user interface according to claim 4, wherein the determining whether the execution condition for executing the specific operation on the second element is satisfied specifically comprises:
and judging whether the second element exists and whether the second element can be executed with the specific operation, wherein if the second element exists and the second element can be executed with the specific operation, the execution condition is met, and if not, the execution condition is not met.
6. A user interface, UI, element explicit wait apparatus, comprising:
the element acquisition unit is used for acquiring positioning information of a first element on the user interface;
the explicit waiting unit is used for circularly executing specific operation and detecting the state of the first element according to the positioning information of the first element, and the loop exits until the state of the first element is updated to a specified target state or the total execution time of the loop is more than or equal to the specified total timeout time;
wherein the specific operation is to make a specified condition hold; the specified condition is a condition for updating the state of the first element to the specified target state.
7. The user interface UI element explicit waiting device of claim 6 wherein the explicit waiting unit comprises:
the overtime detection module is used for judging whether the total execution time of the circulation is greater than or equal to the specified total overtime time or not, and if so, returning to failure and exiting the circulation; otherwise, triggering the state detection module or the operation execution module;
the state detection module is used for judging whether the state of the first element is updated to the specified target state according to the positioning information of the first element under the triggering of the overtime detection module, if so, returning to be successful and exiting from circulation, and if not, triggering the operation execution module; or, under the trigger of the operation execution module, judging whether the state of the first element is updated to the specified target state according to the positioning information of the first element, if so, returning to success and exiting from circulation, and if not, triggering the circulation control module;
the operation execution module is used for executing the specific operation and waiting for the time delay of the specified time interval under the triggering of the state detection module, and then triggering the cycle control module; or, under the trigger of the overtime detection module, executing the specific operation and waiting for the delay of the specified time interval, and then triggering the state detection module;
the cycle control module is used for returning to the overtime detection module and starting the next cycle;
wherein the specified time interval is less than the specified total timeout time.
8. The user interface UI element explicit waiting device of claim 7, wherein the element obtaining unit is further configured to obtain positioning information of a second element on the user interface;
wherein the specific operation is to operate the second element according to the positioning information of the second element to make the specified condition.
9. The user interface UI element explicit wait means of claim 8 further comprising:
a condition judgment module configured to judge whether an execution condition for executing the specific operation with respect to the second element is satisfied or not, and notify the operation execution module if the execution condition is satisfied, under the trigger of the element acquisition unit; and if the execution condition is not met, triggering the circulation control module.
10. The user interface UI element explicit waiting device of claim 9, wherein the condition determining module is configured to:
and judging whether the second element exists and whether the second element can be executed with the specific operation, wherein if the second element exists and the second element can be executed with the specific operation, the execution condition is met, and if not, the execution condition is not met.
CN202110979322.5A 2021-08-25 2021-08-25 Explicit waiting method and device for user interface UI element Active CN113791974B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202110979322.5A CN113791974B (en) 2021-08-25 2021-08-25 Explicit waiting method and device for user interface UI element

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202110979322.5A CN113791974B (en) 2021-08-25 2021-08-25 Explicit waiting method and device for user interface UI element

Publications (2)

Publication Number Publication Date
CN113791974A true CN113791974A (en) 2021-12-14
CN113791974B CN113791974B (en) 2024-05-17

Family

ID=79182072

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202110979322.5A Active CN113791974B (en) 2021-08-25 2021-08-25 Explicit waiting method and device for user interface UI element

Country Status (1)

Country Link
CN (1) CN113791974B (en)

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115687146A (en) * 2022-11-15 2023-02-03 中科可控信息产业有限公司 BIOS (basic input output System) test method and device, computer equipment and storage medium

Citations (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2012040178A1 (en) * 2010-09-24 2012-03-29 Waters Technologies Corporation Techniques for automated software testing
CN104461900A (en) * 2014-12-19 2015-03-25 北京奇虎科技有限公司 User interface testing method, center control server, test terminal and system
CN106951369A (en) * 2017-03-15 2017-07-14 微梦创科网络科技(中国)有限公司 The management method and device of a kind of joint debugging test
CN107577607A (en) * 2017-09-07 2018-01-12 携程旅游信息技术(上海)有限公司 User interface automated testing method, device, electronic equipment, storage medium
CN107678952A (en) * 2017-09-22 2018-02-09 郑州云海信息技术有限公司 A kind of method and system of Webpage element operation
US20190303269A1 (en) * 2018-03-28 2019-10-03 Layout.io Ltd Methods and systems for testing visual aspects of a web page
CN110413279A (en) * 2019-07-05 2019-11-05 中国平安财产保险股份有限公司 Data load method and device
CN110737585A (en) * 2019-08-31 2020-01-31 苏州浪潮智能科技有限公司 UI (user interface) automatic test case and system and page element loading waiting method and system
CN110851356A (en) * 2019-10-30 2020-02-28 河海大学 Selenium-based Web application automatic test framework and construction method and system thereof
CN110990264A (en) * 2019-11-11 2020-04-10 中国建设银行股份有限公司 Element identification method, device and equipment for UI automation test and storage medium
CN112214397A (en) * 2020-09-09 2021-01-12 腾讯科技(深圳)有限公司 User interface testing method and device, computer equipment and storage medium
CN113448845A (en) * 2021-06-22 2021-09-28 重庆长安汽车股份有限公司 UI automation test method and system

Patent Citations (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2012040178A1 (en) * 2010-09-24 2012-03-29 Waters Technologies Corporation Techniques for automated software testing
CN104461900A (en) * 2014-12-19 2015-03-25 北京奇虎科技有限公司 User interface testing method, center control server, test terminal and system
CN106951369A (en) * 2017-03-15 2017-07-14 微梦创科网络科技(中国)有限公司 The management method and device of a kind of joint debugging test
CN107577607A (en) * 2017-09-07 2018-01-12 携程旅游信息技术(上海)有限公司 User interface automated testing method, device, electronic equipment, storage medium
CN107678952A (en) * 2017-09-22 2018-02-09 郑州云海信息技术有限公司 A kind of method and system of Webpage element operation
US20190303269A1 (en) * 2018-03-28 2019-10-03 Layout.io Ltd Methods and systems for testing visual aspects of a web page
CN110413279A (en) * 2019-07-05 2019-11-05 中国平安财产保险股份有限公司 Data load method and device
CN110737585A (en) * 2019-08-31 2020-01-31 苏州浪潮智能科技有限公司 UI (user interface) automatic test case and system and page element loading waiting method and system
CN110851356A (en) * 2019-10-30 2020-02-28 河海大学 Selenium-based Web application automatic test framework and construction method and system thereof
CN110990264A (en) * 2019-11-11 2020-04-10 中国建设银行股份有限公司 Element identification method, device and equipment for UI automation test and storage medium
CN112214397A (en) * 2020-09-09 2021-01-12 腾讯科技(深圳)有限公司 User interface testing method and device, computer equipment and storage medium
CN113448845A (en) * 2021-06-22 2021-09-28 重庆长安汽车股份有限公司 UI automation test method and system

Non-Patent Citations (2)

* Cited by examiner, † Cited by third party
Title
KE MA等: "Prediction and Validation of Wear-Out Reliability Metrics for Power Semiconductor Devices With Mission Profiles in Motor Drive Application", 《 IEEE TRANSACTIONS ON POWER ELECTRONICS 》, 26 January 2018 (2018-01-26), pages 9843 *
张添: "基于Selenium的Web自动化测试", 《CNKI优秀硕士学位论文全文库 信息科技辑》, no. 03, 15 March 2015 (2015-03-15), pages 138 - 806 *

Cited By (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN115687146A (en) * 2022-11-15 2023-02-03 中科可控信息产业有限公司 BIOS (basic input output System) test method and device, computer equipment and storage medium

Also Published As

Publication number Publication date
CN113791974B (en) 2024-05-17

Similar Documents

Publication Publication Date Title
CN109189665B (en) Method and device for recording, replaying and automatically testing data
US7072800B1 (en) Application response monitor
US8676966B2 (en) Detecting and monitoring server side states during web application scanning
US20040103394A1 (en) Mechanism for testing execution of applets with plug-ins and applications
CN110457211B (en) Script performance test method, device and equipment and computer storage medium
CN105426310B (en) A kind of method and apparatus for the performance for detecting target process
CN105335283A (en) Application testing method and device in terminal equipment
US20080127067A1 (en) Method and system for timing code execution in a korn shell script
WO2020019490A1 (en) Interface testing method, electronic device and storage medium
CN106294094A (en) The method of testing of game server, client, server and system
CN111008154B (en) Android application automatic test method and system based on reinforcement learning
US12079298B2 (en) Methods and systems for browser extension used to generate relative XPath, absolute XPath and/or CSS selectors
CN103631706B (en) A kind of browser testing method and apparatus
CN106713011B (en) Method and system for obtaining test data
CN108549652B (en) Hotel dynamic data acquisition method and device, electronic equipment and readable storage medium
CN113791974A (en) User interface UI element explicit waiting method and device
US20040054944A1 (en) Debug thread termination control points
CN111639002A (en) Method and system for testing sleep power consumption, computer equipment and storage medium
CN109271315A (en) Scripted code detection method, device, computer equipment and storage medium
US10846206B2 (en) Adaptive software testing
US8397114B2 (en) Automated regression testing intermediary
CN107656849B (en) Method and device for positioning performance problem of software system
CN113778878A (en) Interface testing method and device, electronic equipment and storage medium
CN111026947B (en) Crawler method and embedded crawler implementation method based on browser
CN112084108A (en) Test script generation method and device and related components

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant