Waiting for a form to be visible

Ask general questions here.
slither
Posts: 11
Joined: Thu Jun 18, 2009 3:27 pm

Waiting for a form to be visible

Post by slither » Thu Jun 18, 2009 4:07 pm

In the application we are testing, sometimes it takes a little while for a form to be visible.

Lets say I click the MenuBar to load FormA. I then do a FindSingle<Ranorex.Form>("myRxPath"); to find the form. It does find the form almost right away (i'm guessing it's in memory, but not visible yet).

The problem here is if I want to click buttons on the form, currently it will perform the click() actions even if the form is not visible.

I tried using something like:

form.EnsureVisible();
form.button.EnsureVisible();
form.button.click();

but the same thing happens (looks like .EnsureVisible() is not actually checking Element.Visible to see if it's true)

Now I have somewhat of a workaround for this, which works good (obviously would need to add some limits to the time we are waiting...):

while(!form.Visible)
{
Ranorex.Core.Delay.Milliseconds(100);
}
form.button.click();


Is there any functionality for this built into Ranorex? I've seen "RxElementIgnoreInvisible(TRUE);" mentioned in the forum (old post from 2007), but can't find it in the documentation.

User avatar
Ciege
Ranorex Guru
Posts: 1335
Joined: Thu Oct 16, 2008 6:46 pm
Location: Arizona, USA

Re: Waiting for a form to be visible

Post by Ciege » Thu Jun 18, 2009 4:13 pm

What you do with the While loop is exactly what I do. However, I would suggest creating your own method that its job is to find and wait for a window to appear and be visible. That way you still only have to make a single call when you are waiting for a window to appear. Similarly you can create another method called WaitForWindowToClose to wait for a window to go away after submitting it or closing it in some form or fashion.

The EnsureVisible has been problematic for me at times on different controls so I tend to stay away from it or at least supplement it with my own check of form.visible or element.visible.
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: Waiting for a form to be visible

Post by Support Team » Mon Jun 22, 2009 2:00 pm

Currently, there is no functionality to wait for an element to become visible. The EnsureVisible method just tries to make an element visible and returns whether that was successful. So, as Ciege recommended, you could write your own helper method that waits until an element is visible.

The RxElementIgnoreInvisible is a setting that is specific to Ranorex 1.X versions.

Regards,
Alex
Ranorex Support Team
.
Image