Qtp Synchronization Methods

Source: Internet
Author: User

When writing a script, you must always consider the interval between two steps. For example, 1. Open www.baidu.com 2. 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. When the qtp identifies an object, there will be a default wait time, which can be set in file --> Settings --> Run --> Object synchronization. The default time is 20 seconds, that is to say, when the page is still not fully opened when step 4 is executed, so that qtp cannot find the object required in step 2, then it will constantly 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. Available as follows: Code Browser ("Browser "). the navigate http://www.baidu.comBrowser ("Browser "). page ("Baidu "). syncbrowser ("Baidu, you will know "). page ("Baidu, you will know "). webedit ("WD "). set "avepoint" 2nd indicates that the following operations will continue only after the Baidu page is fully opened. 3. The 2nd methods can only be used in the web. What if other types of objects need to wait for time? 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, the visible class synchronizes the State attributes and generates the following script browser ("Baidu, you will know "). page ("Baidu, you will know "). webedit ("WD "). waitproperty "visible", true, 100000 means that within 100 seconds, wait for the visible attribute of the webedit object, as long as its visible attribute changes to true, then, execute the following operation. The last 100000 unit is millisecond. if the system does not wait until visible = true after 100000 milliseconds (100 seconds), directly execute the following operation. 4. Use vbs statements. Do until browser ("Baidu, you will know "). page ("Baidu, you will know "). webedit ("WD "). exist (5) Wait (1) loop determines whether the webedite object exists. If not, run wait (1). If yes, 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.

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.