Get result of Validate.Exists()

Ask general questions here.
alearava
Posts: 3
Joined: Sat Oct 20, 2012 12:04 am

Get result of Validate.Exists()

Post by alearava » Wed Oct 24, 2012 12:32 am

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

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

Re: Get result of Validate.Exists()

Post by Support Team » Wed Oct 24, 2012 9:45 am

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