Skip to main content

Selector Reference

Selectors are the primary way to find UI5 controls on a page. Praman uses UI5Selector objects that query the UI5 runtime's control registry — not the DOM.

UI5Selector Fields​

FieldTypeDescription
controlTypestringFully qualified UI5 type (e.g., 'sap.m.Button')
idstring | RegExpControl ID or pattern
viewNamestringOwning view name for scoped discovery
viewIdstringOwning view ID for scoped discovery
propertiesRecord<string, unknown>Property matchers (key-value pairs)
bindingPathRecord<string, string>OData binding path matchers
i18NTextRecord<string, string>i18n text matchers (translated values)
ancestorUI5SelectorParent control must match this selector
descendantUI5SelectorChild control must match this selector
interactionUI5InteractionSub-control targeting (idSuffix, domChildWith)
searchOpenDialogsbooleanAlso search controls inside open dialogs

All fields are optional. At least one must be provided.

Examples​

By ID​

const button = await ui5.control({ id: 'saveBtn' });

By ID with RegExp​

const button = await ui5.control({ id: /submit/i });

By Control Type​

const buttons = await ui5.controls({ controlType: 'sap.m.Button' });

By Type + Properties​

const input = await ui5.control({
controlType: 'sap.m.Input',
properties: { placeholder: 'Enter vendor' },
});

Scoped to View​

const field = await ui5.control({
controlType: 'sap.m.Input',
viewName: 'myApp.view.Detail',
properties: { value: '' },
});

By Binding Path​

const field = await ui5.control({
controlType: 'sap.m.Input',
bindingPath: { value: '/PurchaseOrder/Vendor' },
});

With Ancestor​

const cellInput = await ui5.control({
controlType: 'sap.m.Input',
ancestor: {
controlType: 'sap.m.Table',
id: 'poTable',
},
});

With Descendant​

const form = await ui5.control({
controlType: 'sap.ui.layout.form.SimpleForm',
descendant: {
controlType: 'sap.m.Input',
properties: { placeholder: 'Vendor' },
},
});

Interaction Sub-Targeting​

// Target the arrow button inside a ComboBox
const combo = await ui5.control({
controlType: 'sap.m.ComboBox',
id: 'countrySelect',
interaction: { idSuffix: 'arrow' },
});

Search Inside Dialogs​

const dialogButton = await ui5.control({
controlType: 'sap.m.Button',
properties: { text: 'OK' },
searchOpenDialogs: true,
});

Selector String Format​

Praman registers a ui5= custom selector engine with Playwright, enabling usage in page.locator():

const locator = page.locator('ui5={"controlType":"sap.m.Button","properties":{"text":"Save"}}');
await locator.click();

Control Type Cheat Sheet​

ControlcontrolTypeCommon Properties
Buttonsap.m.Buttontext, icon, type, enabled
Inputsap.m.Inputvalue, placeholder, enabled, editable
Textsap.m.Texttext
Labelsap.m.Labeltext, required
Selectsap.m.SelectselectedKey
ComboBoxsap.m.ComboBoxvalue, selectedKey
CheckBoxsap.m.CheckBoxselected, text
DatePickersap.m.DatePickervalue, dateValue
TextAreasap.m.TextAreavalue, rows
Linksap.m.Linktext, href
GenericTilesap.m.GenericTileheader, subheader
Tablesap.m.TableheaderText
SmartFieldsap.ui.comp.smartfield.SmartFieldvalue, editable
SmartTablesap.ui.comp.smarttable.SmartTableentitySet, useTablePersonalisation
SmartFilterBarsap.ui.comp.smartfilterbar.SmartFilterBarentitySet
SmartField Inner Controls

SmartField wraps inner controls (Input, ComboBox, etc.). getControlType() returns sap.ui.comp.smartfield.SmartField, not the inner control type. Use properties matching to target by value rather than relying on the inner control type.

Discovery Strategies​

Praman uses a multi-strategy chain for control discovery:

  1. LRU Cache (200 entries, 5s TTL) — instant for repeat lookups
  2. Direct ID — sap.ui.getCore().byId(id) for exact ID matches
  3. RecordReplay — SAP's RecordReplay API (requires UI5 >= 1.94)
  4. Registry Scan — full ElementRegistry scan as fallback

Configure the strategy chain:

import { defineConfig } from 'playwright-praman';

export default defineConfig({
discoveryStrategies: ['direct-id', 'recordreplay'],
});