Forum Discussion
6 Replies
- tristaanogreEsteemed Contributor
aqUtils.Delay (https://support.smartbear.com/testcomplete/docs/reference/program-objects/aqutils/delay.html)
is what you're looking for, I believe.
However... it depends upon why you're waiting as to whether or not I'd suggest using it. As a rule of thumb, I don't like hardcoded "sleep" commands because, depending upon environment, server load, etc, execution times and wait times may vary.
If you can tell us WHY you need to introduce these sleeps, perhaps we can suggest a better way that will help with execution and robustness of your automation.- prabhjot88singhContributor
My application has 2 buttons:
1. Validate
2. Post
Step 1 : .Initially user clicks on Validate button, and it takes around 2-5 seconds for this operation to complete.
This is why I need to put some Implicit wait after clicking on Validate button , similar to selenium.
2. Later once this validation is completed, my Post button is enabled immediately.
Note : Page is not refreshed anywhere in this entire process, It is just like after first button is validated, second button gets enabled.
Please share the implicit wait commands, something like Thread.sleep(time) in Testcomplete script.
- LinoTadrosCommunity Hero
When you validate by clicking the first button, does the UI show at least a label somewhere that says "...validating" or anything at all on the UI so that it doe snot leave you hanging for 2 to 5 seconds?
If the answer is "No" then you have a bug report to file against R&D, as it is not acceptable nowadays to hang the system for 2 to 5 seconds without telling the user UI wise that you in the process of validating.
If there is a label somewhere on the UI stating that the validating is in progress then your the WaitProperty() command in JScript on the second button object to wait for the label text to no be available anymore to continue with the clicking of the second button
This way you don't have to sleep or delay for a number of seconds but wait for an indication from the label to disapear to move on with life.
Hope that helps
-Lino
- Krishna_KumarContributor
Hi prabhjot88singh ,
you will be able to achieve that by using dynamic wait for the object.
the below is the code snippet which you can refer.
function waitForObject(propName, propValue, maxTime) { var object; var counter=0; if(maxTime== undefined) maxTime= 20000; do { aqUtils.Delay(100); counter+= 100; if(counter>maxTime) { Log.Warning("Time Exceeded"); return; } object= sys.browser("Chrome").page("*").Find(propName, propValue, 30, true); }while (! object.Exists) object.Click(); }
the above function takes two mandateory parameter ("property", "value") of the object for which you are waiting for. And the third parameter is "maxTime" which is not mandatory if you dont give the third parameter, it will wait untill the some time (20000 milisec).
it enters into a loop which will try finding the object untill object is identified or untill the maxTime is reached
please try this and let me know
Kind Regards,
Sathish Kumar K
Hi,
There are many ways to wait for an object during the test execution. WaitNNN methods are the best here. All recommended approaches are listed in the following article - please review it: https://support.smartbear.com/testcomplete/docs/app-objects/common-tasks/waiting-process-or-window-activation.html