Now inviting automation leaders: publish your playbook as a skill, under your own name. Publish yours →
Automation Skills
All skills/Uipath core/Xaml-ui-automation
Reference · Uipath core

Xaml-ui-automation

Part of Uipath core. Install the skill and your agent reads this page when it needs the depth.

UI Automation & Selectors

NApplicationCard (browser + desktop), NClick, NTypeInto, NSelectItem, NGetText, NExtractDataGeneric, NGoToUrl, NGetUrl, NCheckState, TargetAnchorable patterns, selector syntax, dynamic selectors, wildcards, fuzzy/regex search, anchor-based targeting, desktop selector frameworks.

Contents

Requires xmlns:uix="http://schemas.uipath.com/workflow/activities/uix" on root Activity.

These are the Modern Design Experience activities (Studio 24.10+, required minimum). They replace classic activities like AttachBrowser, OpenBrowser, Click, TypeInto. Real templates in assets/samples/common-workflows/ and assets/simple-sequence/FormFilling_Main.xaml.

Required namespace imports (in TextExpression.NamespacesForImplementation):

UiPath.UIAutomationNext.Enums
UiPath.UIAutomationCore.Contracts
UiPath.UIAutomation.Models
UiPath.UIAutomation.Activities
UiPath.Shared.Activities

⚠️ The NuGet package is UiPath.UIAutomation.Activities but the CLR enum namespace is UiPath.UIAutomationNext.Enums. The package was renamed, but the enum types kept the old namespace. All fully-qualified enum values in expressions use UIAutomationNext: [UiPath.UIAutomationNext.Enums.NAppOpenMode.Always], [UiPath.UIAutomationNext.Enums.NClickMode.None], etc. Do NOT "fix" this to UIAutomation.Enums — that namespace does not exist and will cause a compile error. For Extract Table Data, also add: UiPath.UIAutomation.Models.ExtractData

Required assembly references:

UiPath.UIAutomation.Activities
UiPath.UIAutomationCore

Use Application/Browser (NApplicationCard)

The container for all modern UI interactions. Wraps any browser or desktop app actions.

CRITICAL — Browser vs Desktop App:

Browser example (Chrome/Edge)

→ Use gen_napplicationcard_open() / gen_napplicationcard_attach() / gen_napplicationcard_desktop_open() — generates correct XAML deterministically.

Desktop app example — traditional .exe (WinForms/WPF)

→ Use gen_napplicationcard_open() / gen_napplicationcard_attach() / gen_napplicationcard_desktop_open() — generates correct XAML deterministically.

Desktop app example — UWP / Microsoft Store app

UWP apps use the package AppId as FilePath and applicationframehost.exe in the selector. → Use gen_napplicationcard_open() / gen_napplicationcard_attach() / gen_napplicationcard_desktop_open() — generates correct XAML deterministically.

Desktop apps: No BrowserType, no Url. Selector uses <wnd> root (not <html>). No InUiElement/OutUiElement chaining.

Traditional .exe vs UWP:

TargetApp child elements:

Studio-generated metadata (optional, added by Studio during recording):

Key attributes:

Activity Recommended Also valid ❌ Crash
NApplicationCard V2 V1 V3, V4
TargetApp V2
NClick, NTypeInto, NGetText, NCheckState V5 V1
NGoToUrl V3
NSelectItem V1
NExtractDataGeneric V5
TargetAnchorable V6

⚠️ Do NOT use the same Version value across all activities. Each has its own enum. V4 on NApplicationCard causes: V4 is not a valid value for NApplicationCardVersion → Studio crash.

.OCREngine — NEVER include this child element. Studio exports an empty OCREngine ActivityFunc delegate on some templates, but it serves no purpose in generated XAML:

The empty delegate adds complexity (requires System.Drawing namespace declarations that conflict with System.Data prefixes) and zero functionality. Always omit it.

Child order in XAML: .Body → .TargetApp (no .OCREngine)

Desktop Selector Frameworks

Different Windows UI frameworks produce different selector patterns. Use scripts/inspect-ui-tree.ps1 to detect the framework and generate appropriate selectors.

UWP / WPF / Win32 — <wnd> + <uia> selectors

Standard apps with proper UIA support. The inspection script generates ready-to-use selectors:

ScopeSelectorArgument:  <wnd app='applicationframehost.exe' appid='...' />
FullSelectorArgument:   <uia automationid='num7Button' cls='Button' />

Key selector attributes: automationid (most stable), cls, name/aaname, role.

WinForms — <ctrl name='...' /> selectors (primary) or <wnd ctrlname='...' /> (with UI Explorer)

WinForms apps expose all elements as ControlType=Pane via standard UIA. UiPath uses a proprietary .NET bridge to read Control.Name and exposes it as both ctrlname and automationid.

Primary approach — <ctrl> selectors: The inspect-ui-tree.ps1 script generates <ctrl name='...' role='...' /> selectors using UIA Name and inferred control role:

ScopeSelectorArgument:  <wnd app='desktopapp.exe' />
FullSelectorArgument:   <ctrl name='First' role='editable text' />

Alternative — <wnd ctrlname> selectors: When UiPath UI Explorer is available, ctrlname selectors are more stable:

ScopeSelectorArgument:  <wnd app='desktopapp.exe' />
FullSelectorArgument:   <wnd ctrlname='txtFirstName' />

Role mapping for WinForms controls in <ctrl> selectors:

WinForms Control <ctrl> role
TextBox (Edit) editable text
Button push button
CheckBox check box
RadioButton radio button
ComboBox combo box
TabItem tab item
Label text (read-only)

If multiple windows of the same app exist, add title (with wildcard) to scope — but never cls:

ScopeSelectorArgument:  <wnd app='desktopapp.exe' title='Desktop App*' />

⚠️ CRITICAL — WinForms cls values are DYNAMIC. WinForms class names contain a session hash that changes between app launches (e.g., WindowsForms10.Window.8.app.0.378734a). Never use cls in selectors for WinForms apps.

WinForms ClassName patterns (for reference only — do NOT use in selectors):

See references/ui-inspection-reference.md for complete framework detection table and property mapping.

Click (NClick)

→ Use gen_nclick() — generates correct XAML deterministically.

With verify (wait for element after click): → Use gen_nclick() — generates correct XAML deterministically.

Key attributes:

Type Into (NTypeInto)

→ Use gen_ntypeinto() — generates correct XAML deterministically.

With dynamic selector (use expression in selector):

  FullSelectorArgument="[string.Format(&quot;&lt;webctrl aaname='Answer {0}' tag='INPUT' /&gt;&quot;, intIndex + 1)]"

Key attributes:

Select Item (NSelectItem)

Selects a value from a dropdown. Item is the value to select (variable or literal). Items is the optional static list of valid options.

→ Use gen_nselectitem() — generates correct XAML deterministically.

Properties:

Get Text (NGetText)

Extracts text content from a UI element. Output stored via TextString property.

→ Use gen_ngettext() — generates correct XAML deterministically.

Properties:

Extract Table Data (NExtractDataGeneric)

Scrapes structured tabular data from web pages. Handles pagination automatically via .NextLink. Output is a DataTable. This is the most complex modern UI activity — the ExtractDataSettings and ExtractMetadata attributes contain embedded XML that defines the table schema and extraction selectors.

→ Use gen_nextractdata() — generates correct XAML deterministically.

Properties:

ExtractDataSettings — XML-encoded table schema defining columns. The XML must be entity-encoded as an attribute value. Decoded structure:

<Table Type='Structured' AddCvHeader='true' IsScrollEnabled='false'>
  <Column xsi:type='DataColumn' ReferenceName='Column0' Name='ColumnDisplayName'>
    <IsValidName>true</IsValidName>
    <ValidationErrorMessage />
    <IsExtra>false</IsExtra>
    <CanExtractSimilar>true</CanExtractSimilar>
    <Format xsi:type='TextColumnFormat' />
  </Column>
  <!-- More columns... -->
  <Column xsi:type='DataNextLink' />  <!-- Pagination marker -->
</Table>

Column types: DataColumn (text data), DataNextLink (pagination — always last, no Name/ReferenceName)

ExtractMetadata — XML-encoded selector rules for row detection and per-column data extraction. Decoded:

<extract>
  <row exact='1'>
    <webctrl tag='li' />
    <webctrl tag='article' idx='1' />
  </row>
  <column exact='1' name='Column0' attr='href'>
    <webctrl tag='li' />
    <webctrl tag='article' idx='1' />
    <webctrl tag='h3' idx='1' />
    <webctrl tag='a' idx='1' />
  </column>
  <column exact='1' name='Column1' attr='fulltext'>
    <webctrl tag='li' />
    <webctrl tag='article' idx='1' />
    <webctrl tag='div' idx='2' />
    <webctrl tag='p' idx='1' />
  </column>
</extract>

Child elements (order matters):

  1. .NextLink — TargetAnchorable pointing to the "Next" page button/link. Omit for single-page extraction. SearchSteps="Selector, Image" — uses image fallback since next buttons change across pages
  2. .Target — TargetAnchorable pointing to the table/list container element

TargetAnchorable visual anchoring attributes (seen in Extract Data targets):

Go To URL (NGoToUrl)

Best practice — URL-first navigation: Always prefer NGoToUrl over clicking links/menus. Faster, more reliable, no selector dependency. See skill-guide.md Rule 3 for the click-then-fetch discovery technique.

⚠️ Never hardcode URLs — all URLs must come from Config.xlsx. See SKILL.md → Production Rules for details. Config keys: WebApp_Url, API_BaseUrl. Dynamic: Config("WebApp_BaseUrl").ToString + "/work-item/" + strWIID.

→ Use gen_ngotourl() — generates correct XAML deterministically.

Get URL (NGetUrl)

→ Use gen_ngeturl() — generates correct XAML deterministically.

Check App State (NCheckState)

Waits for an element to appear or not, then branches. Acts like a UI-aware If/Else.

→ Use gen_ncheckstate() — generates correct XAML deterministically.

Properties:

Target Element Patterns

All modern activities use uix:TargetAnchorable for targeting elements. The generators (gen_nclick(), gen_ntypeinto(), etc.) build this internally via _selector_xml() — pass the raw selector string and the generator handles all TargetAnchorable attributes, escaping, and GUID generation.

TargetAnchorable key attributes (for understanding only — generators produce these):

Core attributes:

Visual/design-time attributes (optional, Studio-generated):

Selector Reference

Selector Syntax and Structure

A selector is an XML fragment that identifies a UI element through its attributes and position in the UI hierarchy:

<node_1 attr='value' /><node_2 attr='value' />...<target_node attr='value' />

Full vs Partial Selectors

Full selector — contains all nodes from root to target. Used by activities OUTSIDE a Use Application/Browser scope:

<wnd app='notepad.exe' />
<wnd cls='Edit' />

Partial selector — omits the root node. Used by activities INSIDE a Use Application/Browser scope (the scope provides the root):

<webctrl aaname='Submit' tag='BUTTON' />

In modern design, activities inside NApplicationCard use partial selectors. The ScopeSelectorArgument on the TargetAnchorable provides the root scope.

Tag Types and Key Attributes

WND (Windows desktop applications)
<wnd app='notepad.exe' />
<wnd cls='Edit' />

Key attributes: app (process name — usually sufficient alone for root node), cls (window class — useful for child elements), title (window title — add only to disambiguate multiple windows), aaname (accessible name), idx (index among siblings), ctrlname/ctrlid (WinForms)

HTML (Browser top-level — root node)
<html app='msedge.exe' title='Dashboard' url='https://app.example.com/dashboard' />

Key attributes: app (browser process), title (page title), url (page URL)

WEBCTRL (Web elements — most common for web automation)
<webctrl aaname='Submit' tag='BUTTON' type='submit' />
<webctrl id='email-input' tag='INPUT' />
<webctrl css-selector='div.modal > form input[name=username]' />
<webctrl tag='TR' tableRow='3' />
<webctrl tag='TD' tableRow='2' tableCol='1' colName='Status' />

Key attributes:

CTRL (Windows desktop controls — legacy)
<ctrl role='push button' name='OK' automationid='btnOK' />

Key attributes: role, name, automationid, labeledby, text, idx

UIA (UI Automation — modern desktop)
<uia automationid='txtSearch' role='edit' name='Search' />

Key attributes: automationid (most stable), role, name, cls, idx, tableRow/tableCol

JAVA (Java applications)
<java role='push button' name='OK' cls='javax.swing.JButton' />

Key attributes: role, name, virtualname, javastate, cls, accessibleClass, idx

RDP (Remote Desktop)

Same attributes as <wnd> tag. Used for remote automation via RDP sessions.

Selector Tag-Attribute Reference

Complete list of valid attributes per selector tag. Using an attribute on the wrong tag causes silent selector failures.

WND (Windows desktop): app, cls, title, aaname, ctrlname (WinForms), ctrlid (WinForms), idx, tid, pid, aastate

HTML (Browser window): url, htmlwindowname, title, class, app, idx, pid, tid

WEBCTRL (Web element): tag, idx, aaname, name, id, parentid, class, css-selector, innertext, visibleinnertext, isleaf, parentclass, parentname, src, href, tableCol, tableRow, colName, rowName, aria-label, aria-labelledby

CTRL (Windows desktop controls): role, name, automationid, labeledby, aastate, virtualname, text, rowName, idx

UIA (UI Automation — modern desktop): automationid, cls, name, role, enabled, helpText, itemstatus, itemtype, tableRow, tableCol, rowName, colName, idx

JAVA (Java applications): role, name, virtualname, javastate, cls, accessibleClass, tableRow, tableCol, rowName, colName, idx

RDP (Remote Desktop): Same attributes as <wnd>. Used for remote automation.

Attribute-Tag Mismatch Rules

⚠️ Using the wrong attribute on the wrong tag causes silent selector failures:

Attribute Valid Tags ⛔ Invalid Tags
aaname <wnd>, <webctrl> <ctrl>, <uia>, <java>
name <ctrl>, <uia>, <java>, <webctrl> <wnd> (use aaname)
automationid <ctrl>, <uia> <wnd> (use ctrlname), <webctrl>, <java>
ctrlname <wnd> (WinForms only) all others
cls <wnd>, <uia>, <java> <ctrl>, <webctrl> (use class)
class <webctrl>, <html> <wnd> (use cls), <ctrl>, <uia>
id <webctrl> <wnd>, <ctrl>, <uia>

Dynamic Selectors (Variables in Selectors)

Use double curly braces {{variableName}} to inject variable values into selectors at runtime:

<wnd app='notepad.exe' title='{{strFileName}} - Notepad' />
<webctrl aaname='{{strButtonName}}' tag='BUTTON' />
<webctrl tag='TR' tableRow='{{intRowIndex}}' />

In XAML, the full selector string with variables would look like:

FullSelectorArgument="&lt;webctrl aaname='{{strMenuOption}}' tag='A' /&gt;"

Wildcards

Replace zero or more characters to handle dynamic attribute values:

<wnd app='notepad.exe' title='* - Notepad' />           ← any filename
<html title='Dashboard - *' />                            ← any suffix
<webctrl aaname='Order_????' tag='A' />                   ← 4-char order ID
<wnd title='Invoice_2025*' />                             ← any 2025 invoice

Best practice: use wildcards for the changing portion of an attribute, keep the stable portion literal.

Fuzzy Search

Match attributes approximately rather than exactly. Useful when attributes have slight variations across runs:

<html app='firefox.exe' title='WEScho0ls Online Web Tutorials' 
  matching:title='fuzzy' fuzzylevel:title='0.8' />

<webctrl aaname='Colorpicker' parentid='main' tag='IMG' 
  matching:aaname='fuzzy' fuzzylevel:aaname='0.4' />

Syntax for any attribute:

Text content check (verify element contains specific text):

<webctrl tag='DIV' check:text='Options' matching:aaname='fuzzy' fuzzylevel:aaname='0.8' />

In XAML FuzzySelectorArgument:

FuzzySelectorArgument="&lt;webctrl aaname='Submit Order' tag='BUTTON' 
  matching:aaname='fuzzy' fuzzylevel:aaname='0.8' 
  check:innerText='Submit' /&gt;"

RegEx Search

Use regular expressions for complex pattern matching in attribute values:

<webctrl aaname='Order_[0-9]{4,6}' tag='A' matching:aaname='regex' />
<html title='Invoice #\d+ - .*' matching:title='regex' />

Syntax: matching:attrName='regex' — attribute value is interpreted as a regular expression.

Non-Greedy Search (idx='*')

Match any window instance. Useful when multiple windows of the same app are open:

<wnd app='notepad.exe' idx='*' />

Setting idx='*' makes the selector match regardless of the window's position/order. Without this, idx='1' would only match the first instance.

Table Element Selectors

For interacting with specific cells/rows in web tables or data grids:

← Specific cell by row/column index (0-based for web tables)
<webctrl tag='TD' tableRow='2' tableCol='3' />

← Cell by column header name
<webctrl tag='TD' tableRow='1' colName='Status' />

← Entire row
<webctrl tag='TR' tableRow='5' />

← Dynamic row (using variable for iteration)
<webctrl tag='TD' tableRow='{{intCurrentRow}}' colName='Action' />

For SAP tables: <sap tableRow='3' tableCol='2' colName='Material' />

Anchor-Based Targeting

Modern design uses anchors — nearby stable elements that help locate the target:

<uix:TargetAnchorable ...>
  <!-- Anchor: a label next to the input field -->
  <uix:TargetAnchorable.Anchors>
    <uix:AnchorElement 
      SelectorArgument="&lt;webctrl aaname='Email Address' tag='LABEL' /&gt;"
      AnchorType="Left" />
  </uix:TargetAnchorable.Anchors>
</uix:TargetAnchorable>

Anchor types: Left, Right, Top, Bottom — relative position of anchor to target. Anchors make selectors more resilient: even if the target's own attributes are unstable, a stable nearby label can guide matching.

Selector Best Practices

Scope selectors — keep minimal: The <wnd> scope selector (in NApplicationCard's TargetApp or TargetAnchorable's ScopeSelectorArgument) should use the fewest attributes needed. When app uniquely identifies the process, use only app — do not add cls, title, or other properties:

Add title only when multiple windows of the same process exist and you need to disambiguate (use wildcards: title='Desktop App*').

Prefer stable attributes:

  1. automationid / id — most stable (set by developers, rarely changes)
  2. aaname — visible name (stable if UI text doesn't change)
  3. tag + name — reliable combo for web forms
  4. css-selector — powerful but couples to page structure

Avoid unstable attributes:

General rules:

XAML Special Characters

Always escape these in XAML attribute values:

Square brackets [ ] denote VB.NET/C# expressions in UiPath XAML.

Publish your skill

Copy this prompt into Claude Code, Codex or any agent. It walks you through your first skill in about 20 minutes, with you as the author.

Click to copy.