Teach you how to wait for the testcomplete _ object

Source: Internet
Author: User
Tags builtin testcomplete

 

 

For various reasons, the playback of the script won't be so smooth, the test environment may be slower, and the script will immediately become stuttering, or a very clever program, suddenly, my mind was short-circuited and there was no movement for half a day. In a word, we often walk by the river and occasionally step on shit. Therefore, it is difficult to solve the problem of waiting for objects.

First, wait. Who will wait? After careful consideration, it should be the corresponding object waiting for the next action. For example, after you finish the previous step, you need to click a button in the next form. This form will not come out for a long time, the form is not displayed on the surface, and the form is actually displayed. Do you dare say that the button can be clicked? So don't wait for the form. You have to find the correct main button. Once you find the primary node, you can select a method as needed.

You can play with it. It's just an endless loop. If you don't get out of it, I will show it to you:
While (not obj1.obj1. obj1.obj1. exists)
Builtin. Delay 3000, "Wait For obj1... "
Wend

Check whether exists has any problems. If the object is already in the memory, but it is not displayed on the interface, it will be a problem. Will it be better to change it to visible, if it is in the memory and it is not displayed, it will be white. Then you can write a log saying that the object is in memory, but it is okay if it is not displayed.

In other cases, will the object come out? exists and visible are both true, but the screen is in the white state. You may still not be able to do the click operation. Will it be so annoying? Really, this is a more abnormal situation. What should we do? capture images and compare them. This method is certainly okay. You can see it and you cannot operate it.

While (not regions. Compare ("obj1bmp", obj1.obj1. obj1.obj1. obj1bmp, false, false, true, 0 ))
Builtin. Delay 3000, "Wait For obj1bmp... "
Wend

How is this done? Select the checkpoint of the image during recording, and then paste the code.

This practice is relatively shanzhai. Once the form is merged, the entire code will not run.

What? Shanzhai? There are also more shanzhai! You do not need to write any code. Set it directly:
Menu: Tools-default project-Properties
Tree directory on the left: playback
Auto-Wait timeout, Ms: 10000
Oh, the default wait time is 10 seconds.
If you understand the plug-in, you just need to wait for an hour. I don't believe you don't come out. If you don't come out, you will die, and you will not need to be moved.

These practices are too tough. Looking at the standard practice, testcomplete provides a series of wait functions.

For example:
Testobj. waitvbobject (name, timeout)

Testobj a variable, parameter or expression that specifies a reference to one of the objects listed in the applies to section

Name [in] required string
Timeout [in] required integer
Result object

Explanation:
Generally, the parent object waits for the sub-object. testobj is the parent object, and name is the sub-Object Name. Timeout is the natural time to wait. When it is out of date, the Code determines where to go. Result returns the reference of the sub-object.

We can see that the name is more clear and accurate, who will wait, how long will it take, and what wait functions will be used, and the code details will not be processed.

 

Summary:

Different situations adopt different methods. If you only need to complete a simple system automation without much control and require the lowest maintenance cost, you can directly configure a Failover hour, if your system requires refined control, use the wait function for precise control. As for the method of endless loops, you don't want to change the configuration, and you don't want to figure out what wait functions are. You just need to copy them.

Enough. Choose your own.

 

 

 

 

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.