Validate.HasState method question

Class library usage, coding and language questions.
Posts: 1
Joined: Tue Dec 30, 2008 11:05 am

Validate.HasState method question

Post by Mykhailo_Dyrda » Tue Dec 30, 2008 11:17 am

I am newbie to Ranorex and I have some questions regarding Validate.HasState method.
It is possible to validate that element has required state using Validate.HasState method. But I need to validate element that it does not have the state. For example,
in one case button should has state State.Unavailable
in other case it should not have this state. How is it possible to validate. The button doesn't have state State.Normal or State.Default.

One more question: my controls has set of state, e.g. State.Focusable, State.Selectable e.t.c. Is it possible to validate a set of states?

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

Post by Support Team » Mon Jan 05, 2009 3:11 pm

The state of an element is a bitwise combination of values of the State enumeration. The Validate.HasState method can only validate whether the state of an element includes a specific flag. You can, however, use other Validate methods to achieve your validation tasks:

Code: Select all

// validate the exact state of the element
Validate.AreEqual(element.State, State.Focusable | State.Selectable, "Validate exact state.");

// validate that the element does not have the Unavailable flag set
Validate.IsTrue((element.State & State.Unavailable) == 0, "Element does not have Unavailable flag set.");
Ranorex Support Team