Trying to validate without recording a failure...

Ask general questions here.
ajw
Posts: 12
Joined: Wed Sep 26, 2012 8:28 am

Trying to validate without recording a failure...

Post by ajw » Wed Sep 26, 2012 8:46 am

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?

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

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

Post by Support Team » Wed Sep 26, 2012 12:36 pm

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

ajw
Posts: 12
Joined: Wed Sep 26, 2012 8:28 am

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

Post by ajw » Wed Sep 26, 2012 4:06 pm

Cheers, that has done what I want :)

Swapnil_d13
Posts: 11
Joined: Mon Jan 14, 2013 8:50 pm

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

Post by Swapnil_d13 » Mon Jan 14, 2013 9:16 pm

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!!!

User avatar
Support Team
Site Admin
Site Admin
Posts: 12145
Joined: Fri Jul 07, 2006 4:30 pm
Location: Houston, Texas, USA
Contact:

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

Post by Support Team » Tue Jan 15, 2013 3:32 pm

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