Page 1 of 1

Get result of Validate.Exists()

Posted: Wed Oct 24, 2012 12:32 am
by alearava
Hi,
I am validating that several components must be present in the application using the following method Validate.Exists ()

public void ValidateComponentsLobby()
{
List<string> ComponentsList = new List<string>();
ComponentsList.Add ("Slots");
ComponentsList.Add ("Table Games ");
ComponentsList.Add ("Video Poker");
ComponentsList.Add ("Specialty ");

foreach(string item in ComponentsList){
Validate_Components(item);
}

}

In Validate_Components() I am validating if the object exists. However if a component is not present in the application the test case needs to continue validating the other components, the current behavior is that if the component is not present in the app the test case immediately fails without to check the others components

Re: Get result of Validate.Exists()

Posted: Wed Oct 24, 2012 9:45 am
by Support Team
Hi,

That's because an exception will be thrown when the element cannot be found.
There are several overloads of the Exists method. It is also possible to use one where you can specify that the exception shouldn't be thrown in case when an element couldn't be found.
It is also possible to catch this "ValidationException" in a try- catch block.
For detailed information about the methods please take a look at the following link: Validate Class.

Regards,
Markus
Ranorex Support Team