Page 1 of 1

Handling ElementNotFound exception when validating

Posted: Wed Oct 12, 2016 1:04 am
by johnzer
I'm a little confused about something.

When using Validate.Exists(), we can pass in an Element and a bool specifying whether to throw an exception if the validation fails.

What I don't get is why we can choose to throw an exception or not for this particular case. If it does not find the Element, it will still throw an ElementNotFound exception.

Is there any way to disable or handle the ElementNotfound exception? We have many, many elements to validate and the default message for the Element validation, which explicitly uses the items name, is much better and more informative than the default message for the RepoItemInfo validation, which is 'Self' for all of them.

Thanks.

Re: Handling ElementNotFound exception when validating

Posted: Wed Oct 12, 2016 7:56 am
by odklizec
Hi,

I believe your problem could be easily solved by using RepoItemInfo.Exists() with some additional handling what to do in case the element exists/does not exists. See for example this post:
http://www.ranorex.com/forum/validate-e ... tml#p33834