How to make test failure to Pass

Ranorex Spy, Recorder, and Studio.
cruzez
Posts: 24
Joined: Thu Jan 27, 2011 3:03 am
Location: London, UK

How to make test failure to Pass

Post by cruzez » Fri May 16, 2014 10:07 am

Hi I have a scenario:
1. while adding a new user in my app

you enter all the details and register and
System will validate if user already exist or similar name already exist
If similar name exist you have choice either register anyway or modify user details and then register.

I created automation script for this to handle

//Special Case if similar names suggestions appear
if (IsElementVisible(repo.HomeArea.NotListed))
{

//Report.Log(ReportLevel.Info, "Validation", "clicked.", repo.HomeArea.NotListedInfo);
repo.HomeArea.NotListed.PerformClick();
Delay.Seconds(2);

}



// Check condition if User name suggested
public bool IsElementVisible(ButtonTag element)
{
bool condition = Validate.Attribute(element, "Visible", "True", null, false);
return condition;
}


Above code did the trick, but every time I run this test, Report Logs an Error if element is False.

Can somebody suggest me how to handle this situation? I do not want errors to appear if name suggestions doesn't come up. My programming skills are very basic :( so struggling

cruzez
Posts: 24
Joined: Thu Jan 27, 2011 3:03 am
Location: London, UK

Re: How to make test failure to Pass

Post by cruzez » Fri May 16, 2014 12:34 pm

I figured out

instead of validating I passed the value like this
bool condition = element.Visible;

It worked! :) Thanks

User avatar
Support Team
Site Admin
Site Admin
Posts: 11709
Joined: Fri Jul 07, 2006 4:30 pm
Location: Graz, Austria

Re: How to make test failure to Pass

Post by Support Team » Mon May 19, 2014 3:05 pm

Hi,

You can also specify what should happen by passing the Validate.Options to the Validate.Attribute method as shown below:
public void ValidationExample()
        {
        	
        	var calculator = repo.Calculator.Self;
			
        	//exceptionOnFail, reportLevelOnFailure, reportLevelOnSuccess, createScreenshot 
        	Validate.Options options = new Validate.Options(false, ReportLevel.Info, ReportLevel.Success, Validate.CreateScreenshot.OnFail);      	
        	
        	bool condition = Validate.Attribute(calculator, "Visible", "True", "Your message", options);

        	Report.Info("Validation Result: "+condition);
        }
Result when the element is not visible:
ValidateExample.png
ValidateExample.png (14.17 KiB) Viewed 759 times
Regards,
Markus
.
Image

cruzez
Posts: 24
Joined: Thu Jan 27, 2011 3:03 am
Location: London, UK

Re: How to make test failure to Pass

Post by cruzez » Wed May 21, 2014 10:14 am

Thanks Markus, another trick :) This one worked as well.