Page 1 of 1

Handling objects

Posted: Sun Oct 31, 2010 3:17 pm
by kris123pra
Hi

I have a workflow, where we expect that as per the input given there might be a error message displayed or the workflow might just go on.

Say, if there is a image open functionality which takes image string as input. If the image is valid, then it shall be opened and some operations are performed. But if it is a invalid image, there would be a error dialog displayed.

In my case, I had used RxPath in the code. It works fine if the object is found, but throws an error if not found, which is known. But I would like to know if we can handle this dynamically and no error is thrown.

Here is the code snippet:

Code: Select all

try{
Ranorex Form formError = "/form[@title='Error'];
if (formError.Visible)
  <click on ok>
   <return>
else
  <open image>
  <do some operations on image>
   <return>
}
catch(Exception e)
{
report.error(e.ToString());
}
This throws a error if a valid image is passed, since the formError is not found. Can anyone please suggest what can be done here? :roll:

Thanks
Kris

Re: Handling objects

Posted: Mon Nov 01, 2010 9:01 am
by artur_gadomski
Try:
formErrorInfo.Exists()
or
formError.SelfInfo.Exists()
they should not throw exception when form is not found. Drawback is that your automation will be put on hold for however long it will look for that form (default is 10 sec). You might want to read:
http://www.ranorex.com/blog/handling-di ... up-windows
to detect this form in a separate thread.

Re: Handling objects

Posted: Mon Nov 01, 2010 3:33 pm
by Support Team
Hi,

An additional option would be to use the TryFindSingle() Method which returns you a boolean value. With this value you can handle you decision and actions by code. But I would suggest you the same as artur_gadomski to read the following blog http://www.ranorex.com/blog/handling-di ... up-windows

Regards,
Peter
Ranorex Team

Re: Handling objects

Posted: Wed Nov 10, 2010 11:21 am
by kris123pra
Hi
Since I am working on i18n, I use my own repository. I dont know how to use the selfInfo.exists() method.

I tried using the TryFindSingle and it worked. Thanks !
Though this works for now, since I have lots of such different pop ups (errors, warnings), I would like to know if I can use the .Exists method too :|

Thanks :)
Kris

Re: Handling objects

Posted: Wed Nov 10, 2010 3:27 pm
by Support Team
Hi,

Normally there shouldn't be a problem to use the Exists() method. Take a look to following post http://www.ranorex.com/forum/selecting- ... html#p6282
I also used the Exists() method to check if an item is available. Would it be possible to send us an example application with your automation code, where we can reproduce this issue. Maybe it's just a wrong code.

Thanks in advance.

Regards,
Peter
Ranorex Team

Re: Handling objects

Posted: Mon Nov 29, 2010 4:44 am
by kris123pra
Hi
I used the code given in
http://www.ranorex.com/forum/how-to-val ... t1047.html
This seems to be neater and works fine for my code.

I would have been happy to put my code here, but I am not supposed to do that as per company policies. So here is a explanation of how my code works :)

As I said before, I do not use the repository generated by Ranorex, but have a code which dynamically generates the RXpath as per the language selected. So I have no freedom of using <something>Info.Exists() method.

Anyways, now that I have something working .. thanks a lot for all the support :D Regards
Kris