Recording a transaction

A "transaction" is a standard Playwright test — no PandoraFMS import required. Three native constructs map to plugin behavior:

You write Becomes
test.step('name', ...) a monitored phase (status + time)
test.info().annotations.push({ type: 'pandora.metric', description: 'name=value' }) a custom metric module
a failing assertion the test fails; a screenshot is captured automatically

1. Record the flow with Playwright's recorder (codegen)

Playwright ships its own recorder, codegen: it opens a real browser, and every click, fill, and navigation you perform is turned into Playwright code in real time, plus a Pick Locator / Explore mode to test selectors against the live page. Official documentation: playwright.dev/docs/codegen-intro. General authoring reference: playwright.dev/docs/writing-tests.

On any machine with Node and Playwright installed (this does not need to be the plugin's Docker image):

npm init playwright@latest    # first time only, if the project isn't set up yet
npx playwright codegen https://your-app.example.com

Two windows open: the browser you interact with, and the Playwright Inspector, which shows the generated code live and lets you pick/copy a locator for any element on the page. Useful flags:

codegen output is flat, ungrouped code — clicks and assertions one after another, with no test.step(...) and no metric annotations. It is a starting point, not the final transaction: copy it into your .ts file and go to step 2.

2. Turn it into phases

Wrap each meaningful part of the recorded flow in test.step('name', async () => { ... }). Every top-level test.step call — one written directly inside the test(...) callback — becomes one phase, with its own Phase <name> status and Phase <name> time module (see Agent and modules generated by the plugin). Official reference: test.step() API.

await test.step('open home', async () => {
  await page.goto('https://your-app.example.com');
  await expect(page).toHaveTitle(/Shop/);
});

Things to know:

3. Add custom metrics

Push a pandora.metric annotation with test.info() — from anywhere in the test body, including inside a test.step:

const count = await page.locator('.cart-count').innerText();
test.info().annotations.push({ type: 'pandora.metric', description: `cart_items=${count}` });

Official reference for annotations: test.info().annotations.

Parsing rules (exact, from the runner):

Full example

import { test, expect } from '@playwright/test';

test('checkout flow', async ({ page }) => {
  await test.step('open home', async () => {
    await page.goto('https://your-app.example.com');
    await expect(page).toHaveTitle(/Shop/);
  });

  await test.step('login', async () => {
    await page.fill('#user', 'demo');
    await page.fill('#password', 'demo');
    await page.click('#submit');
    await expect(page.locator('.dashboard')).toBeVisible();
  });

  await test.step('add to cart', async () => {
    await page.click('text=Add to cart');
    const count = await page.locator('.cart-count').innerText();
    test.info().annotations.push({ type: 'pandora.metric', description: `cart_items=${count}` });
  });
});

Notes


Revision #1
Created 2 August 2026 09:36:05 by Rafael Ameijeiras
Updated 2 August 2026 09:37:18 by Rafael Ameijeiras