Praman — Agent-First SAP UI5 Test Automation Plugin - v1.2.0
    Preparing search index...

    Function extendUI5Handler

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

      Type Parameters

      • 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

      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>;
      };
      }
      }

      On success, the extension is registered and available as ui5.<name>.method() in fixtures.

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

      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 });
      },
      }));