Skip to main content
Version: 1.x

Function: discoverPage()

discoverPage(page, options?): Promise<AiResponse<PageContext>>

Defined in: src/ai/bulk-discovery.ts:488

Discovers all UI5 controls on the current Playwright page.

Parameters

page

DiscoveryPage

Playwright Page instance (or any structural equivalent).

options?

DiscoverPageOptions = {}

Optional filtering and timeout options.

Returns

Promise<AiResponse<PageContext>>

AiResponse<PageContext>'success' with a full snapshot or 'error' with a recoverable error payload.

Remarks

Calls sap.ui.core.ElementRegistry.all() (UI5 ≥ 1.106) in the browser, falling back to sap.ui.getCore().mElements for older runtimes. Each discovered control is classified by interactivity, container membership, and object category. The result is partitioned into buttons, formFields, tables, and navigationElements for convenient AI consumption.

The browser-side script is serialized via fn.toString() — module-level imports are not available in the browser callback.

Intent

Enumerate all UI5 controls for AI-driven selector generation.

Capability

ui5-bulk-discovery

Sap Module

All

Example

import { discoverPage } from '#ai/bulk-discovery.js';

// Basic usage
const response = await discoverPage(page, { interactiveOnly: true });
if (response.status === 'success') {
logger.info(`${response.data.controls.length} controls found`);
}

// With pagination
const paged = await discoverPage(page, { limit: 20, offset: 40 });