FlaUI
FlaUI copied to clipboard
How to expand a cell of table
Hi, I have a Table with cells, which can be expanded or collapsed. Please see below snapshot for the same.

Below is the snapshot of flaui inspect for the same.

So kindly suggest how can I perform expand and collapse operation on these cells using FLAUI?
It seems that the control does not support the ExpandCollapsePattern. So you probably need to fallback to Keyboard inputs or Mouse clicks at the correct location.
It doesn't support any keyboard input. And using mouse click will result into flaky script.
Have you tried messing with the IsEnabled?
No, I didn't try.
Have you tried using the LegacyIAccessible.Pattern.State? The expanded and collapsed state can be read from there. In my case, I have vertical grids with rows that are expandable in the UI but do not have the ExpandCollapse pattern and the following works for me when passing thru the GridHeader element:
if (element.Patterns.LegacyIAccessible.IsSupported)
{
var currentPattern = element.Patterns.LegacyIAccessible.Pattern;
var currentState = currentPattern.State;
if (targetState == ExpandCollapseState.Collapsed && currentState.Value.HasFlag(AccessibilityState.STATE_SYSTEM_EXPANDED))
{
currentPattern.DoDefaultAction(); //Assuming Activate expands it
}
else if (targetState == ExpandCollapseState.Expanded && currentState.Value.HasFlag(AccessibilityState.STATE_SYSTEM_COLLAPSED))
{
currentPattern.DoDefaultAction(); //Assuming Activate expands it
}
}
@kuskitkd I have tried using this solution but this also didn't worked. In my case the values for currentPattern.State are {STATE_SYSTEM_SELECTED, STATE_SYSTEM_FOCUSED, STATE_SYSTEM_FOCUSABLE, STATE_SYSTEM_SELECTABLE}.
And the value for currentPattern.DefaultAction is {Edit}
Currently I am using BoundingRectangles to click on the expand/collapse icon.
Grid grd = element.AsGrid(); grd.GetRowByIndex(1).Cells[1].Click(); Rectangle rect = grd.GetRowByIndex(1).Cells[1].BoundingRectangle; Point pnt = new Point(); pnt.X = rect.X; pnt.Y = rect.Y; Mouse.Click(pnt);