Page 1 of 1

How to get informed, the component was loaded

Posted: Tue Oct 17, 2017 2:22 pm
by SomeProgrammer
I have an application, where I have several components and I have their ID's (strings, with which i can identify them).
I have a button, that creates a complicated component (which ID I also have). So rendering the component takes some time. Now I write code like this:
while (component == null){
..
Thread.Sleep([for some time])
}
And instead, I want to use an event or whatever.
I wonder, whether Ranorex library provides some way to inform, when the component with a specific ID appears on the screen.

Re: How to get informed, the component was loaded

Posted: Tue Oct 17, 2017 6:01 pm
by Support Team
Hi SomeProgrammer,

With Ranorex, you do not need to use a custom Wait-For type method since Ranorex will not perform an action on an element until it exists. Each element in a repository has a specific timeout that sets the maximum time Ranorex will wait for the element to exists. As soon as the item exists, the action is performed. It is recommended to increase this timeout instead of using a custom Wait-For method.

If you still feel a Wait-For method is needed, Ranorex does have a WaitForExist method in its API you can utilize on a repository item's info object (add Info to end of repository object reference).

Code: Select all

repo.MyForm.MyElementInfo.WaitForExists(5000);
I hope this helps!

Cheers,
Ned