State.expanded and State.Collapsed

Ask general questions here.
din2dino
Posts: 12
Joined: Wed Nov 05, 2008 6:50 pm

State.expanded and State.Collapsed

Post by din2dino » Wed Nov 05, 2008 8:23 pm

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?

din2dino
Posts: 12
Joined: Wed Nov 05, 2008 6:50 pm

Post by din2dino » Thu Nov 06, 2008 1:42 am

Any solution?

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

Post by Support Team » Thu Nov 06, 2008 11:39 am

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

din2dino
Posts: 12
Joined: Wed Nov 05, 2008 6:50 pm

Post by din2dino » Thu Nov 06, 2008 7:40 pm

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?

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

Post by Support Team » Fri Nov 07, 2008 3:59 pm

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