ComboBox
WinForms combo boxes don't work through UI Automation
On WinForms, with both UIA2 and UIA3, items comes back empty, select(index) raises
IndexOutOfRangeException, and expand() leaves the box collapsed. The bug is in Windows/.NET,
not in FlaUI or this wrapper, and upstream FlaUI skips its WinForms combo box tests for the same
reason (#75). WPF combo boxes work normally.
Usage notes
- Bring the window to the front first. A WPF drop-down closes as soon as its window loses
focus, for example when another window overlaps it. Call
set_foreground()on the window beforeexpand(). - Wait for the state, not a fixed sleep. The drop-down animates open. Poll
expand_collapse_statewithRetry.Whileuntil it reportsExpandCollapseState.Expanded. - Editable combo boxes take text through
editable_text; setting it selects the matching item.
flaui.core.automation_elements.ComboBox
Bases: AutomationElement
Class to interact with a combobox element
animation_duration
property
writable
Timespan to wait until the animation for opening/closing is finished.
Returns:
| Type | Description |
|---|---|
Any
|
C# TimeSpan object from System namespace |
editable_text
property
writable
The text of the editable element inside the combobox. Only works if the combobox is editable.
Returns:
| Type | Description |
|---|---|
str
|
Editable text of the element |
expand_collapse_state
property
Gets the ExpandCollapseStateof the element
Returns:
| Type | Description |
|---|---|
ExpandCollapseState
|
Expand/Collapse state |
is_editable
property
Flag which indicates, if the combobox is editable or not
Returns:
| Type | Description |
|---|---|
bool
|
True If element editable, else False |
is_read_only
property
Flag which indicates, if the combobox is read-only or not
Returns:
| Type | Description |
|---|---|
bool
|
True If element read-only, else False |
items
property
Gets all available items from the ComboBox element
Returns:
| Type | Description |
|---|---|
List[ComboBoxItem]
|
Item |
selected_item
property
selected_items
property
Gets all selected items
Returns:
| Type | Description |
|---|---|
List[str]
|
Selected items |
value
property
Selected value of the Combobox element
Returns:
| Type | Description |
|---|---|
str
|
Element selected value |
collapse()
expand()
select(value)
Select an item by index/the first item which matches the given text..
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
Union[int, str]
|
Index value/The text to search for |
required |
Returns:
| Type | Description |
|---|---|
ComboBoxItem
|
The first found item or null if no item matches. |