Page 1 of 1

State.expanded and State.Collapsed

Posted: Wed Nov 05, 2008 8:23 pm
by din2dino
I have a header which I cna expand and collapse and I want to check if it is collapsed.

After I collapse it, I cant get the element state to State.Collapsed. Its only shown as readonly.

How can I get this thing to work?

Posted: Thu Nov 06, 2008 1:42 am
by din2dino
Any solution?

Posted: Thu Nov 06, 2008 11:39 am
by Support Team
Sorry, I don't quite understand. Do you want to check the state of the element or do you want to change it? The state of an element is readonly, so you can't change by setting a new value to the property. The only way to change the state of an element is by calling Element.DoDefaultAction() or by mouse/keyboard input.

If you just want to test whether an element is collapsed or expanded, you have to check if the Collapsed/Expanded flags are set in the Element.State:

Code: Select all

bool isCollapsed = (myElement.State & State.Collapsed) != 0;
bool isExpanded = (myElement.State & State.Expanded) != 0;
Regards,
Alex
Ranorex Support Team

Posted: Thu Nov 06, 2008 7:40 pm
by din2dino
Thanks for the code. This helped me. however I noticed that element.state & state.collpased is returning the same value when collapsed/expanded.

Am I missing something?

Posted: Fri Nov 07, 2008 3:59 pm
by Support Team
This might be a problem of the MSAA implementation of the control you are automating. What type of control is it?

Regards,
Alex
Ranorex Support Team