Hi!
sundarpn wrote:On FindSingle & TryfindSingle method, If one deoes not specifiy the 'Duration', does it mean no waiting?
Or does take into account the global duration?
If you define no Duration, the tree is searched only once in descending order. If you pass a duration, e.g. 5 seconds, Ranorex is searching the item for 5 seconds. The method immediately returns when an element is found. The search will be aborted after 5 seconds - even if the element is in the tree, but not found because searching the tree took longer than the timeout.
sundarpn wrote:FindSingle throws and exception while TryFindSingle returns a bool. So I suppose I use tryfindsingle in cases where I want to conditionally test for a widgets presence and branch?
You are right, but for Ranorex repositories, you can also use the RepoItemInfo.Exists() method of the info object corresponding to your repository items:
bool buttonExists = myRepo.MyForm.MyButtonInfo.Exists<Button>();
That way, the timeout values and the path set to the repository item will be used. You can even get the item using the out parameter of the Exists method:
Button myButton;
bool buttonExists = myRepo.MyForm.MyButtonInfo.Exists<Button>(out myButton);
sundarpn wrote:But in cases where I want to defensively check that a widget exists before say clicking on it.... (if not throw an exception) I use FindSingle. Is my interpretation correct?
Before Ranorex can click on an element, it has to find it first. If you want an exception to be raised when the element is not found, then use FindSingle. There's still the chance that Ranorex could find the element, but the element immediately disappears afterwards and therefore the click won't be performed (no exception will be thrown). To be sure that a click went through, use validation to check the outcome of the click!
Regards,
Peter
Ranorex Support Team