Page 1 of 1

EnsureVisible does not working

Posted: Tue Mar 15, 2011 6:41 pm
by John Silver, Esq.
Hello,

I use the following code to wait for appearing of the titlebar of the tested app:

Code: Select all

            	bool isShown=false;
            	for (int i=0;i<100;i++)
            		try
            		{
	            		if (repo.FormApp.TitleBarApp.EnsureVisible())
		            	{
		            		isShown=true;
		            		break;
		            	}
            		}
            		catch (ElementNotFoundException)
            		{
            			Delay.Milliseconds(1000);
            		}
            		catch(Exception e)
            		{
        				Report.Log(ReportLevel.Info, "myapp", "Error: "+e.Message, new RecordItemIndex(2));
						break;
            		}
The problem is that the repo.FormApp.TitleBarApp.EnsureVisible() always raises the ElementNotFoundException, even the titlebar is already shown.
When I set breakpoint on this line (at this moment I'm sure that titlebar IS visible), I call "HighlightRepositoryItem" from the context menu, and the titlebar becomes highlight. But the repo.FormApp.TitleBarApp.EnsureVisible() still raises the mentioned exception.

OS: Win7 x64, Ranorex Studio v. 3.0.0.11639, repo.FormApp.UseCache is false.

What I'm doing wrong?

Thank You in advance.

Re: EnsureVisible does not working

Posted: Wed Mar 16, 2011 5:38 pm
by Support Team
Hi,

Instead of using your code to wait for an element, use the Ranorex methods to wait for an element. We have a nice feature called timeout which handle this for you. :wink: The following documentation explaines how to wait for an element
http://www.ranorex.com/support/user-gui ... eouts.html

Regards,
Peter
Ranorex Team