Page 1 of 1

Trying to validate without recording a failure...

Posted: Wed Sep 26, 2012 8:46 am
by ajw
Hi,

I am using the following method from the Validate class, to carry out some validation.

public static bool Attribute(
RepoItemInfo itemInfo,
string name,
Object value,
string message,
bool exceptionOnFail
)

I am passing exceptionOnFail = false, to ensure no exception is thrown if the validation fails. However if validation does fail, a Failure is still recorded in the report, so the module itself fails: "The module has failed because one or more actions have failed."

Is there a way to ensure the module still records a success, despite the failure on this validation?

Essentially I am trying to validate an element against several options - if it doesn't match the first option then validate against the second option; failure should only occur if it doesn't match either option. Is there a better way to do this?

Re: Trying to validate without recording a failure...

Posted: Wed Sep 26, 2012 12:36 pm
by Support Team
Hi,

Yes this is possible, you just have to change the ReportLevel of that Validation action, the following code should work for you:
Validate.Options option = new Validate.Options(ReportLevel.Info); // you can of course set it to a different ReportLevel
option.ExceptionOnFail = false;
        	
Report.Log(ReportLevel.Info, "Validation", "Validating AttributeEqual (ControlId='134') on item 'Calculator.Button134'.", repo.Calculator.Button134Info);
Validate.Attribute(repo.Calculator.Button134Info, "ControlId", "34", "Anything", option);
, at the moment it is unfortunately just possible to Validate one attribute of an element per Validation, a "multi validation" is not yet possible.

Regards,
Markus
Ranorex Support Team

Re: Trying to validate without recording a failure...

Posted: Wed Sep 26, 2012 4:06 pm
by ajw
Cheers, that has done what I want :)

Re: Trying to validate without recording a failure...

Posted: Mon Jan 14, 2013 9:16 pm
by Swapnil_d13
Hi,
I am facing same issue and try your solution but it still fails test at the end giving error "The module has failed because one or more actions have failed."

Problem : I recorded test for result message at status bar '<record_name> already exist.' In this scenario if I input record which is not available in database. Then it shows '<record-name> saved successfully in our application' but how can I achieve these two scenario in one run.In user code I check Validate.Exists(RecordExistInfoObj, String, Boolean) then it returns false(here message is of 'saved successfully') because it cant find 'record already exist' in its recording and it takes around 30-45 sec to search this item.In else part I wrote Report.Success("Success Message") . At end it fails. Help!!!

Re: Trying to validate without recording a failure...

Posted: Tue Jan 15, 2013 3:32 pm
by Support Team
Hi,

Could you post or send us the used code and the generated report?
This will help us to analyze the issue faster.
If I got it correctly the problem is that the status bar shows different strings, and you want to validate if one of the mentioned strings are shown, is this right?
Have you already tried to save the text (attribute) to a variable and check if the value of the variable is either the first or the second string?

Regards,
Markus