Skip to content

PatternNotSupportedException when trying to access Tree UI element #250

Description

@agagalski

When trying to access (Get, Click, Expand, Select Collapse ...) Tree UI item (QTreeWidget, Qt 5.x) with any Tree-type keyword library throws exception (#10005, #10010, ...) for example when trying Get All Visible Treeitems Names:

PatternNotSupportedException: The requested pattern 'ExpandCollapse [#10005]' is not supported ---> System.InvalidOperationException: Native pattern is null
   w FlaUI.Core.FrameworkAutomationElementBase.GetNativePattern[T](PatternId pattern)
   --- Koniec śladu stosu wyjątków wewnętrznych ---
   w FlaUI.Core.FrameworkAutomationElementBase.GetNativePattern[T](PatternId pattern)
   w FlaUI.Core.AutomationPattern`2.get_Pattern()
   w FlaUI.Core.AutomationElements.PatternElements.ExpandCollapseAutomationElement.get_ExpandCollapseState()

No issue with other Qt UI elements like buttons, lists, textbox... just this Tree.

Also togling treeitems is not possible, similar exception is thrown.
Tried to fix issue on library level with AI gave partial success for fixing ExpandCollapse

RobotFramework-FlaUI/FlaUI is calling ExpandCollapseState on an element that does not support ExpandCollapse, and the TreeItem implementation does not guard against that case
I've added such guarding which prevented raising exception and afterwards retrival of treeitem names was possible. Could you please add such "guarding" in case Tree element does not support:

  • ExpandCollapsePattern
  • SelectionItemPattern
  • TogglePattern
    so that at least partial support is achieved (Get TreeItem Name, Select, Toogle )
    (below complete list of supported patterns)

Keywords tried:

.venv description

pip list
Package                      Version
---------------------------- -------
cffi                         2.0.0
clr_loader                   0.2.10
pip                          26.0.1
pycparser                    3.0
pythonnet                    3.0.5
robotframework               7.4.2
robotframework-flaui         4.1.0
robotframework-pythonlibcore 4.5.0
robotframework-remoterunner  2.0.0
six                          1.17.0
typing_extensions            4.15.0

python --version
Python 3.13.12

Details of QTreeWidget from FlaUIInspectStable v1.4.1

Identification
AutomationId: ---------------------------------------------------------
Name:
ClassName: QTreeWidget
ControlType: Tree
LocalizedControlType: drzewo
FrameworkType: Qt
FrameworkId: Qt
ProcessId: 22700

Details
IsEnabled: True
IsOffscreen: False
BoundingRectangle: X=-859, Y=386, Width=586, Height=163
HelpText:
IsPassword: False
NativeWindowHandle: Not Supported

Pattern Support
AnnotationPattern: No
DockPattern: No
DragPattern: No
DropTargetPattern: No
ExpandCollapsePattern: No
GridItemPattern: No
GridPattern: Yes
InvokePattern: No
ItemContainerPattern: No
LegacyIAccessiblePattern: Yes
MultipleViewPattern: No
ObjectModelPattern: No
RangeValuePattern: No
ScrollItemPattern: No
ScrollPattern: No
SelectionItemPattern: No
SelectionPattern: No
SpreadsheetItemPattern: No
SpreadsheetPattern: No
StylesPattern: No
SynchronizedInputPattern: No
TableItemPattern: No
TablePattern: Yes
TextChildPattern: No
TextEditPattern: No
Text2Pattern: No
TextPattern: No
TogglePattern: No
Transform2Pattern: No
TransformPattern: No
ValuePattern: Yes
VirtualizedItemPattern: No
WindowPattern: No
Grid Pattern
ColumnCount: 3
RowCount: 13
LegacyIAccessible Pattern
Name:
State:
Role: konspekt

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions