Qtp synchronization wait Methods

Source: Internet
Author: User
When writing a script, you often have to consider the interval between two steps, for example, 1. Open http://www.baidu. com2/. Enter avepoint. Due to the different network speeds, there will be a certain delay after opening Baidu web pages, so there must be a short wait between steps 1 and 2, which can be achieved through the following methods:

  1. Default wait time of the object.

  QtpWhen an object is identified, a default wait time can be set in file --> Settings --> Run --> Object synchronization. The default time is 20 seconds, that is, when the object is executed in step 1, the web page has not been fully opened. In this case, qtp cannot find the object required in step 1, so it will continuously try to find the object within 20 seconds, if the Baidu web page is fully opened within 20 seconds, this method is feasible (if all the web pages are opened, the objects required in step 1 will be found ), if not, refer to the following methods:

  2. Use the. Sync method.

Open Baidu and enter avepoint. The following code can be used for implementation:

Browser ("Browser"). navigatehttp: // www.baidu.com

Browser ("Browser"). Page ("Baidu"). sync

Browser ("Baidu, you will know"). Page ("Baidu, you will know"). webedit ("WD"). Set "avepoint"

The third sentence means that the following operations are continued only after the Baidu page is fully opened.

  3. qtp system's built-in synchronization point function

The 2nd methods can only be used in the Web, ifOthersWhat if you need to wait for time for an object of the type? You can use the synchronization point function provided by the qtp system.

In the above example, In the recording status, Select Insert --> synchronization point, select the object to be synchronized, and set the attribute to be synchronized. We can enable the object, execute synchronization points for the properties that indicate the status in visible and generate the following script:

Browser ("Baidu, you will know"). Page ("Baidu, you will know"). webedit ("WD"). waitproperty "visible", true, 100000

This statement means that, within 100 seconds, wait for the visible attribute of the webedit object, as long as its visible attribute changes to true, the following operation will be performed, the final unit of 100000 is millisecond. if the system does not wait until visible = true after 100000 milliseconds (100 seconds), perform the following operations directly.

  4. Use vbs statements.

Do until browser ("Baidu, you will know"). Page ("Baidu, you will know"). webedit ("WD"). exist (5)

Wait (1)

Loop

Determine whether the webedite object exists. If it does not appear, run wait (1). If it appears, it jumps out of the loop.

  5. Death and other methods.

It is to use the wait () statement to set the wait time and wait for death. For example, wait (10) means that the script stops for 10 seconds, no operation is performed, and the operation continues after 10 seconds.

From: http://www.51testing.com/html/91/n-131691.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.