Page 1 of 1

How to make test failure to Pass

Posted: Fri May 16, 2014 10:07 am
by cruzez
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

Re: How to make test failure to Pass

Posted: Fri May 16, 2014 12:34 pm
by cruzez
I figured out

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

It worked! :) Thanks

Re: How to make test failure to Pass

Posted: Mon May 19, 2014 3:05 pm
by Support Team
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
Regards,
Markus

Re: How to make test failure to Pass

Posted: Wed May 21, 2014 10:14 am
by cruzez
Thanks Markus, another trick :) This one worked as well.