Wait until

Class library usage, coding and language questions.
i.vasilyev
Posts: 30
Joined: Fri Sep 09, 2016 10:14 am

Wait until

Post by i.vasilyev » Tue May 09, 2017 10:09 pm

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?

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 3930
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Wait until

Post by odklizec » Wed May 10, 2017 7:11 am

Hi,

What you are looking for is WaitFor Exists action/method, in which you can define wait timeout. This should solve your problem.
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

i.vasilyev
Posts: 30
Joined: Fri Sep 09, 2016 10:14 am

Re: Wait until

Post by i.vasilyev » Wed May 10, 2017 9:34 am

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.

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 3930
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Wait until

Post by odklizec » Wed May 10, 2017 9:39 am

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.
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

i.vasilyev
Posts: 30
Joined: Fri Sep 09, 2016 10:14 am

Re: Wait until

Post by i.vasilyev » Wed May 10, 2017 10:06 am

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.

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 3930
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Wait until

Post by odklizec » Wed May 10, 2017 11:18 am

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).
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

ngrishakin
Posts: 42
Joined: Fri Oct 04, 2013 9:47 pm

Re: Wait until

Post by ngrishakin » Wed May 17, 2017 7:20 pm

"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");
                } 
            }
        }