Skip to main content
Version: 1.x

Function: extendUI5Handler()

extendUI5Handler<T>(name, factory): void

Registers a custom sub-namespace extension on the ui5 handler.

Type Parameters

T

T extends ExtensionMethods

The shape of the methods object returned by the factory.

Parameters

name

string

Unique namespace name. Must be non-empty and not conflict with built-in namespaces or UI5Handler method names.

factory

ExtensionFactory<T>

Function that receives an ExtensionContext and returns an object of async methods.

Returns

void

Remarks

Extensions are applied during fixture creation. Each extension becomes a sub-namespace on ui5 (e.g., ui5.approval.approve()), following the same pattern as built-in sub-namespaces like ui5.table and ui5.dialog.

All extension methods are automatically wrapped with the UI5 stability guard and appear as named steps in the Playwright trace viewer.

Call this at module scope (outside tests), similar to Cypress.Commands.add().

For TypeScript type safety, use module augmentation:

declare module 'playwright-praman' {
interface ExtendedUI5Handler {
readonly approval: {
approve(id: string): Promise<void>;
};
}
}

Throws

PluginError if the name is empty, reserved, or already registered, or if the factory is not a function.

Example

import { extendUI5Handler } from 'playwright-praman';

extendUI5Handler('approval', (ctx) => ({
async approveWorkflow(workflowId: string): Promise<void> {
const btn = await ctx.handler.control({ id: workflowId });
await btn.press();
await ctx.handler.waitForUI5();
},
async getApprovalStatus(controlId: string): Promise<string> {
return ctx.handler.getText({ id: controlId });
},
}));