Forum Discussion
I don't know about Python scripting... but here's how I do it in JavaScript... you should be able to translate:
var counter = 0; var maxCount = 60; while ((!Aliases.MyApp.WaitAliasChild('myObject', 500).Exists) && (counter < maxCount)){ counter++; }
This will wait max 30 seconds (500 ms executed 60 times = 30000ms). Convert this to a function where you pass in the parent object, the alias name, and a max wait time and you've got a nice little routine.
- tristaanogre7 years agoEsteemed Contributor
JackSparrow wrote:
In ur routine ur waiting for the child object ?Correct... that's what the WaitAliasChild does... it waits for the immediate Alias child object of the indicated parent (in my example, Aliases.Myapp) with the indicated name. There are other "Wait" methods as well that work similarly where you wait for some child object of the parent.
Another way of doing it, if you aren't looking for the immediate child object, is to use some sort of "Find" method... search for the object with a set of parameters, check to see if the result comes back as the object, pause, repeat... something like...
var objectToFind; var counter; var maxCount = 60; objectToFind = Aliases.MyApp.FindChild('ObjectType|ObjectLabel','Button|OK', 5); while ((!objectToFind.Exists) && (counter < maxCount)){ aqUtils.Delay(500); counter++; objectToFind = Aliases.MyApp.FindChild('ObjectType|ObjectLabel','Button|OK', 5); }
The above has, effectively, the same general effect of waiting 30 seconds for an object to exist. It searchs for the object... if the object is not found and we haven't hit our max loop counter, wait 500 ms, increment the counter, and repeat the search.
- JackSparrow7 years agoFrequent Contributor
thanks for the code but , i want to implement without delay method .
- baxatob7 years agoCommunity Hero
You can't avoid a delay, if you need to wait for something.
tristaanogre has advised a nice and flexible method.
def wait_for_something_exists(something, timeout): counter = 0 while not something.Exists and c < timeout: aqUtils.Delay(1000) # or time.sleep(1) counter += 1
Related Content
- 3 years agoIuliaVascan
- 6 years agosriram_sig
- 2 years agolalit_singh
Recent Discussions
- 2 hours agosimonaferrara
- 11 hours agoSubhraDas
- 2 days agotramuntana