Search Timeout

Class library usage, coding and language questions.
bsing
Posts: 81
Joined: Tue Feb 07, 2012 5:25 am

Search Timeout

Post by bsing » Fri Nov 09, 2012 3:06 am

Hi there,

I have a user code module that waits until a dialog is visible before going to the next step. See below

Code: Select all

        public void WaitForPromptDialog()
        {
        	Ranorex.Form frmPrompt = "/form[@controlname='Prompt']";
        	
        	while (frmPrompt.Visible.Equals(false))
        	{
        		Delay.Milliseconds(500);
        	}
        }
However the Ranorex script fails due to Ranorex not finding the form (Search Timeouts at 10 seconds).

The actual form in the repository has a timeout of 30 seconds though. Why would it be timing out at 10 seconds? Is there a way I can set the 10 second timeout to say 1 minute?

Brad.

User avatar
artur_gadomski
Posts: 207
Joined: Mon Jul 19, 2010 6:55 am
Location: Copenhagen, Denmark
Contact:

Re: Search Timeout

Post by artur_gadomski » Fri Nov 09, 2012 7:43 am

The timeout is different because you don't use repository item but create a new one from RxPath. Either use repository item or use this code:
public void WaitForPromptDialog()
{
    Ranorex.Form frmPrompt;
    bool found = Host.Local.TryFindSingle("/form[@controlname='Prompt']", new TimeSpan(0,1,0), out frmPrompt);
    if (!found) {
        Report.Screenshot();
        Report.Snapshot(Host.Local);
        Report.Failure("Could not find Prompt.");
        // leave either by throwing exception or returning
        throw new Exception();
    }
    while (frmPrompt.Visible.Equals(false))
    {
        Delay.Milliseconds(500);
    }
}
EDIT: if you're using repository it is recommended that you keep using repository. Otherwise you need to maintain RxPaths in 2 places.

bsing
Posts: 81
Joined: Tue Feb 07, 2012 5:25 am

Re: Search Timeout

Post by bsing » Mon Nov 12, 2012 5:16 am

Hi thanks for the example,

I have tried using the following code

Code: Select all

Validate.Exists("/form[@controlname='Prompt']", new Duration(60000));
which seems to do the same thing. Is there any differece in your code and the one above?

User avatar
artur_gadomski
Posts: 207
Joined: Mon Jul 19, 2010 6:55 am
Location: Copenhagen, Denmark
Contact:

Re: Search Timeout

Post by artur_gadomski » Mon Nov 12, 2012 7:32 am

I think Validate posts a success message to report also, but I'm not sure. We don't use validate a lot here.