Page 1 of 1
How to run further steps, based on previous image validation
Posted: Fri May 19, 2017 10:26 am
by jpinto
Hello everyone,
I'm quite new to Ranorex.
Within a test case I would like to run further steps, but depending on previous image validation.
Being more specific: if the validation fails or passes the further step will be different.
Something like this:
(pseudo-code)
Code: Select all
if (validation = success) then
Do step 2
else
Ignore step 2
I suspect that's only possible using User Code modules. But how can I evaluate the result of a previous Validation?
Could some share some small examples?
It would be appreciated.
Thanks.
Re: How to run further steps, based on previous image validation
Posted: Mon May 22, 2017 5:22 am
by zivshapirawork
Hi jpinto
You can populate a variable of the recording (e.g. true, false), according to the validation, and then use its value in consecutive steps, to asses whether to perform them or not.
Re: How to run further steps, based on previous image validation
Posted: Mon May 22, 2017 8:02 am
by jpinto
zivshapirawork wrote:Hi jpinto
You can populate a variable of the recording (e.g. true, false), according to the validation, and then use its value in consecutive steps, to asses whether to perform them or not.
Hi zivshapirawork,
first thank you for your answer.
Could you be a bit more specific?
Small example would be of great help...
Thanks again!
Re: How to run further steps, based on previous image validation
Posted: Fri May 26, 2017 1:21 pm
by Support Team
Hello jpinto,
Here is a simple example how to use the validation feature in user code. I would recommend taking a look at our
online API documentation to get a collection of all public API calls.
var doesContain = Validate.ContainsImage(buttonInfo, RanorexStudio_Screenshot1, RanorexStudio_Screenshot1_Options, "Your message", false);
if(doesContain)
{
Report.Info("The image is available");
}
else
{
Report.Info("The image is not available");
}
I hope this information helps.
Sincerely,
Bernhard
Re: How to run further steps, based on previous image validation
Posted: Tue May 30, 2017 6:17 am
by zivshapirawork
hi jpinto
in the validation recording, add a variable (variables button) and populate it in the step of the validation (populate it wit the result: true or false). example
Code: Select all
try
{
Ranorex.Validate(...) [or similar]
myRecording.var_result=Boolean.TrueString
}
catch (exception e)
{
myRecording.var_result=Boolean.FalseString
}
In the next user code steps, check the value of the variable and act accordingly
Code: Select all
If (myRecording.var_result.eqauls(Boolean.FalseString))
{
//do something
}
Re: How to run further steps, based on previous image validation
Posted: Thu Jun 01, 2017 8:17 am
by jpinto
Thank you both for your answers.
@zivshapirawork:
But that means that after the step with a variable for validation, we can only use User Code steps, right? Otherwise they will always be executed, no matter if our variable is true or false... Am I seeing this correctly?
Re: How to run further steps, based on previous image validation
Posted: Thu Jun 01, 2017 12:11 pm
by Vaughan.Douglas
jpinto wrote:Thank you both for your answers.
@zivshapirawork:
But that means that after the step with a variable for validation, we can only use User Code steps, right? Otherwise they will always be executed, no matter if our variable is true or false... Am I seeing this correctly?
Based on this approach you are correct. You can get a bit more fancy and either check or uncheck subsequent Test Cases/Smart folders based on your
result.
Note: the code in those examples may not be compatible with Ranorex 7.x, you will probably have to make adjustments.