Page 1 of 1

Avoiding Delays

Posted: Thu Sep 18, 2014 10:24 am
by zshadow
Hi,

What I am trying to do is wait for the footer to appear, and then check that the innertext contains a specific string, are there anyways of not adding delays as I have done and have something more robust, I appreciate your help. Also I am getting the error:
"Failed to instrument Java process", as shown below did you find a workaround for this problem ?

TdTag footerInfo = "/dom[1]//td[#'footerInfo']";
Delay.Milliseconds(200);
Validate.Exists(footerInfo);
Delay.Milliseconds(500);

if(footerInfo.InnerText.Contains("SRDS"))
{
Report.Info(footerInfo.InnerText);
}



===================
Ranorex 5.1
Windows 7 (VM)
Java 1.6.0_26

Intermittent Ranorex warnings on new Java windows/forms:
"Failed to instrument Java process. Please make sure you have enough privileges to access the process.
(This message is only shown once per report.)"

Re: Avoiding Delays

Posted: Thu Sep 18, 2014 8:10 pm
by odklizec
Hi,

I would suggest to use WaitForExists(timeout) instead of delays. It waits for existence of the associated repo item. Check this page for more details...
http://www.ranorex.com/Documentation/Ra ... Exists.htm

Re: Avoiding Delays

Posted: Fri Sep 19, 2014 11:19 am
by zshadow
Hi,

I tried the below but I get an error shown below :

repo.SymptomDrivenDiagnostics.FooterInfo.WaitForExists(10000);


Error :
'Ranorex.TdTag' does not contain a definition for 'WaitForExists' and no extension method 'WaitForExists' accepting a first argument of type 'Ranorex.TdTag' could be found (are you missing a using directive or an assembly reference?) (CS1061)

Re: Avoiding Delays

Posted: Tue Sep 23, 2014 2:37 pm
by Support Team
Hello zshadow,

It seems like you are using an old version of Ranorex. Please note that the "WaitForExists" method was introduced with Ranorex version 5.0.0.

Regards,
Robert

Re: Avoiding Delays

Posted: Wed Sep 24, 2014 9:51 pm
by zshadow
Hi Robert,
I am using Ranorex version 5.1.1

Regards

zshadow

Re: Avoiding Delays

Posted: Thu Sep 25, 2014 10:42 pm
by Support Team
To use the WaitForExists method you need a RepoItemInfo instance to call that method on. You have to use the Ranorex repository to create such an instance.

In your code, you search directly for an element with that line using the Adapter.DefaultSearchTimeout which is 10 seconds by default:
TdTag footerInfo = "/dom[1]//td[#'footerInfo']";
If the item is not found within that timeout, an exception will be thrown and the next code line will never be reached; i.e. footerInfo will not have a value then.

Either use the Ranorex repository where you can easily set a timeout within the element needs to appear or use a Host.Local.FindSingle call and specify the timeout there.

I recommend going through the first few chapters of the Ranorex User Guide :D

Regards,
Alex
Ranorex Team