Validation exception

Ask general questions here.
SanMan
Posts: 151
Joined: Tue Apr 13, 2010 9:59 am

Validation exception

Post by SanMan » Mon May 28, 2018 6:58 am

bool this_one = Validate.Exists(repo.MyItemInfo, Validate.DefaultMessage, false);

If this item is not found, there should not be validation exception?

(ValidationException: If the validation fails and options.ExceptionOnFail is true. )

User avatar
odklizec
Ranorex Guru
Ranorex Guru
Posts: 3932
Joined: Mon Aug 13, 2012 9:54 am
Location: Zilina, Slovakia

Re: Validation exception

Post by odklizec » Mon May 28, 2018 7:49 am

Hi,

Yes, in this particular case, there should be no validation exception thrown. Are you sure the exception is not issued by another action (before/after validation)?

Anyway, if you are still getting the exception on Validate.Exists (which you should not), you can avoid it by using Try...Catch, as described here:
https://www.ranorex.com/forum/if-statem ... tml#p43758

Or by using RepoInfo.Exists() instead of Validation.Exists(), as described here:
https://www.ranorex.com/forum/if-statem ... tml#p43759
Pavel Kudrys
Ranorex explorer at Descartes Systems

Please add these details to your questions:
  • Ranorex Snapshot. Learn how to create one >here<
  • Ranorex xPath of problematic element(s)
  • Ranorex version
  • OS version
  • HW configuration

SanMan
Posts: 151
Joined: Tue Apr 13, 2010 9:59 am

Re: Validation exception

Post by SanMan » Mon May 28, 2018 8:12 am

Thank you!

This one worked fine:

if (repo.MyForm.MyButtonInfo.Exists()) { //notice MyButtonInfo instead of MyButton
//do stuff
}