Page 1 of 1

Wait until

Posted: Tue May 09, 2017 10:09 pm
by i.vasilyev
Hello.

Does anybody know the best way to handle window appearance?

Ranorex - latest
OS- WIN10
app - desktop

Example:
After clicking on some button new window should be displayed, but it may takes more than 30 sec. I want to find out the best way to wait until window is present. Has ranorex some implemented things for that in box or should I implement some custom logic for that? Can somebody give me an example?

Re: Wait until

Posted: Wed May 10, 2017 7:11 am
by odklizec
Hi,

What you are looking for is WaitFor Exists action/method, in which you can define wait timeout. This should solve your problem.

Re: Wait until

Posted: Wed May 10, 2017 9:34 am
by i.vasilyev
Hello.
Are you talking about Validate.Exists
https://www.ranorex.com/Documentation/R ... Exists.htm?

Looks like I found what are you talking about:
https://www.ranorex.com/Documentation/R ... Exists.htm
Am I correct?
odklizec wrote:Hi,

What you are looking for is WaitFor Exists action/method, in which you can define wait timeout. This should solve your problem.

Re: Wait until

Posted: Wed May 10, 2017 9:39 am
by odklizec
Nope. I mean WaitFor action/method...
https://www.ranorex.com/support/user-gu ... html#c3083

PS: Yes, WaitForExists method is what you are looking for in case of coded approach.

Re: Wait until

Posted: Wed May 10, 2017 10:06 am
by i.vasilyev
Can you provide an example of How to use WaitFor?
NOTE:
I'm not using recordings and ranorex studio. I have an rxPath of element and want to wait until that element exists
odklizec wrote:Nope. I mean WaitFor action/method...
https://www.ranorex.com/support/user-gu ... html#c3083

PS: Yes, WaitForExists method is what you are looking for in case of coded approach.

Re: Wait until

Posted: Wed May 10, 2017 11:18 am
by odklizec
I can be wrong, but I think this method is for repo (info) items only? Is there any reason why you are not using Ranorex Studio? You don't have to use recordings if you think you can code things better. But with Ranorex Studio, you will have access to many things, which are not available in Visual Studio. You see, there are things, which are available only in Ranorex Studio (e.g. repo).

Re: Wait until

Posted: Wed May 17, 2017 7:20 pm
by ngrishakin
"Wait For" is for Repo items. If you are not using repository and Ranorex IDE you need to use another functions for this.
When I click on the button and expect some element to show up on another page.
What about this:

Code: Select all

       public void WaitForElementToBeDisplayed(RxPath rxPath, Duration timeInterval)
        {
            Duration waitTime = 3000;
            Duration totalTimeout = 0;
            Element webElement = null;
            while (!
            (Host.Local.TryFindSingle
            (rxPath, waitTime, out webElement)))
            {
                System.Threading.Thread.Sleep(waitTime.Milliseconds);
                totalTimeout = totalTimeout + waitTime;
                if (totalTimeout.Milliseconds > timeInterval.Milliseconds)
                {
                    throw new ElementNotFoundException("Elemet not found");
                } 
            }
        }