XPath Navigator
Wraps the C# AutomationElementXPathNavigator for manual XPath-based navigation of the UI
Automation tree. For most use cases prefer
find_first_by_x_path / find_all_by_x_path; obtain a navigator with
element.get_x_path_navigator().
flaui.core.xpath_navigator.AutomationElementXPathNavigator
Bases: BaseModel
Wraps the C# AutomationElementXPathNavigator for XPath-based tree navigation.
current_element
property
Return the element at the navigator's current position.
Returns:
| Type | Description |
|---|---|
'AutomationElement'
|
The current :class: |
has_attributes
property
Return whether the current node has attributes (True on element nodes).
Returns:
| Type | Description |
|---|---|
bool
|
|
is_empty_element
property
Return whether the current node is an empty element (always False for UIA elements).
Returns:
| Type | Description |
|---|---|
bool
|
The C# |
local_name
property
Return the local name of the current node; equal to :attr:name since the tree has no namespaces.
Returns:
| Type | Description |
|---|---|
str
|
The node's local name. |
name
property
Return the name of the current node (its control type, or attribute name).
Returns:
| Type | Description |
|---|---|
str
|
The node name. |
node_type
property
Return the XPath node type of the current node (e.g. Root, Element).
Returns:
| Type | Description |
|---|---|
str
|
The node type as a string. |
underlying_object
property
Return the element at the current position (C# UnderlyingObject; same as :attr:current_element).
Returns:
| Type | Description |
|---|---|
'AutomationElement'
|
The current :class: |
value
property
Return the string value of the current node.
Returns:
| Type | Description |
|---|---|
str
|
The node value. |
clone()
Return an independent copy of this navigator at the same position.
Returns:
| Type | Description |
|---|---|
'AutomationElementXPathNavigator'
|
A cloned navigator. |
Source code in flaui/core/xpath_navigator.py
from_element(element)
classmethod
Create a navigator rooted at the given element.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
element
|
'AutomationElement'
|
The element to use as the navigation root. |
required |
Returns:
| Type | Description |
|---|---|
'AutomationElementXPathNavigator'
|
A new :class: |
Source code in flaui/core/xpath_navigator.py
get_attribute(name)
Return the value of a named attribute on the current element.
Supported attribute names mirror the C# navigator: AutomationId, Name, ClassName,
HelpText, IsPassword, FullDescription, ItemType, AcceleratorKey,
AccessKey, IsEnabled, IsOffscreen, ProcessId.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The attribute name. |
required |
Returns:
| Type | Description |
|---|---|
Optional[str]
|
The attribute value, or an empty string when unset. |
Source code in flaui/core/xpath_navigator.py
is_same_position(other)
Return whether this navigator is at the same position as another.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
other
|
'AutomationElementXPathNavigator'
|
The navigator to compare against. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
|
Source code in flaui/core/xpath_navigator.py
move_to(other)
Move to the same position as another navigator over the same tree.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
other
|
'AutomationElementXPathNavigator'
|
The navigator whose position to copy. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
|
Source code in flaui/core/xpath_navigator.py
move_to_attribute(local_name, namespace_uri='')
Move to the named attribute of the current element.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
local_name
|
str
|
The attribute name (see :meth: |
required |
namespace_uri
|
str
|
The attribute namespace; the UIA tree uses none, so keep the default. |
''
|
Returns:
| Type | Description |
|---|---|
bool
|
|
Source code in flaui/core/xpath_navigator.py
move_to_first_attribute()
Move to the first attribute of the current element.
While on an attribute, :attr:name is the attribute name and :attr:value its value; call
:meth:move_to_parent to return to the element.
Returns:
| Type | Description |
|---|---|
bool
|
|
Source code in flaui/core/xpath_navigator.py
move_to_first_child()
Move to the first child of the current element.
Returns:
| Type | Description |
|---|---|
bool
|
|
move_to_next()
Move to the next sibling of the current element.
Returns:
| Type | Description |
|---|---|
bool
|
|
move_to_next_attribute()
Move to the next attribute of the current element.
Returns:
| Type | Description |
|---|---|
bool
|
|
Source code in flaui/core/xpath_navigator.py
move_to_parent()
Move to the parent of the current element.
Returns:
| Type | Description |
|---|---|
bool
|
|
move_to_previous()
Move to the previous sibling of the current element.
Returns:
| Type | Description |
|---|---|
bool
|
|