Page 1 of 1

How to do a Validation based on a Local Variable in Code

Posted: Wed May 17, 2017 3:38 pm
by nas
How do I do a validation action based on a variable I created in the UserCode.cs section. For example,

I want to see if my local int variable is greater than 0, and if it is then pass the step. Else, fail it.

if (int myDefinedVar) > 0
Pass
Else
Fail

Re: How to do a Validation based on a Local Variable in Code

Posted: Thu May 18, 2017 8:21 am
by Stub
Use the Validate API for that. You have IsTrue, IsFalse, AreEqual and more to play with. You can have them fail your test. Lots of options. Very useful.

Re: How to do a Validation based on a Local Variable in Code

Posted: Thu May 18, 2017 8:32 am
by odklizec
Hi,

In case you are not sure about exact usage of a certain Ranorex action in code (in this case Validation), examine the code behind a recorded/manually added action. Simply add an action to recording module an then examine its code via context menu >> "View Code" (or Ctrl+Enter shortcut).