Forum Discussion
The WaitProperty method, and it's specified timeout, only applies to the object you specified (ToolbarButton).
If any parent object associated does not exist then the WaitProperty method does not apply.
Ex:
Sys.Process("someprocess").WinFormsObject("someform").WinFormsObject("somecontrol").WaitProperty("Exists", true, 5000);
Will fail if "someform" does not exist.
Waiting for each parent object...
Sys.Process("someprocess").WaitProperty("Exists", true, 5000);
Sys.Process("someprocess").WinFormsObject("someform").WaitProperty("Exists", true, 5000);
Sys.Process("someprocess").WinFormsObject("someform").WinFormsObject("somecontrol").WaitProperty("Exists", true, 5000);
- jmcwhinney10 years agoContributor
Thanks Ryan,
As you can see from my code, my objects have a very long list of parents, and it would not be realistic to write code to traverse the entire tree, waiting for each parent to exist before looking at its children.
Surely there must be some builtin function to do this for me?
Thanks again for the quick response,
Cheers,
- James
- Ryan_Moran10 years agoValued Contributor
"my objects have a very long list of parents"
Indeed. That is why I gave you the link to: Waiting For Web Pages
At the very least you may want to check that the page exists, and that the toolbar on which the button resides exists.
If you want a very simple solution then add a delay.
If you want a more dynamic approach I would suggest searching for the object within a loop with either .Find or .FindChild methods.
- jmcwhinney10 years agoContributor
Thanks Ryan,
I did read the page you suggested.
I tried using the below to ensure that my object parents exist.
if(GBFunc.WFO(Aliases.browser.BrowserWindow,"FrameTab.tabpage.ShellDocObjectView.browser.JavaPluginControlWindow.frame0.panel0.RootPane.null_layeredPane.StartupDialog.RootPane.null_layeredPane.null_contentPane.Panel.Panel.TextField",10000)){ Log.Checkpoint("Java Loaded"); } function WFO(Root,ObjectPathString,TimeOut){ //Set Timeout to default of 5000 if not provided if(TimeOut == 0){ TimeOut = 10000; } //Start Stop Watch to Calculate the time remaining var MyStopWatch = HISUtils.StopWatch; MyStopWatch.Start(); var TimeRemaining = TimeOut; //Iterate through object heirarchy and ensure each object exists before moving on... var TargetObject = Root; var AliasNameArray = ObjectPathString.split('.'); var ObjectFound = true; for (x = 0; x < AliasNameArray.length; x++) { TimeRemaining = TimeOut - MyStopWatch.Split(); if(TimeRemaining > 0){ TargetObject = TargetObject.WaitAliasChild(AliasNameArray[x],TimeRemaining); if(TargetObject.Exists == false){ ObjectFound = false; Log.Error("Unable to find UI object: '" + AliasNameArray[x] + "'"); x = AliasNameArray.length; } } else { ObjectFound = false; Log.Error("Timed out while looking for UI object: '" + AliasNameArray[x] + "'"); x = AliasNameArray.length; } } //Add Checkpoint if(ObjectFound){ Log.Checkpoint("UI Object found: '" + AliasNameArray[AliasNameArray.length-1] + "'"); } return ObjectFound; }
The above function works fine for a number of objects on my TestExecute PC, but then later on in the script it fails with the error "the execution timeout has expired" on the below line:
TargetObject = TargetObject.WaitAliasChild(AliasNameArray[x],TimeRemaining);
I feel that I have ruled out the possibility of a parent object not existing.
I am allowing a total of 10 seconds to traverse the object heriarchy, ensuring each parent exists before moving downwards, but somehow within 1 second of starting its heirarchical search, it fails on the above line.
I am completely confounded by this.
Any ideas?
Thanks again!
- James
Related Content
- 4 years ago
Recent Discussions
- 12 minutes ago