Software engineering

Run a Playwright smoke test after deployment

Check the page visitors reach after a release. Save the browser check and screenshot as separate actions so your coding agent can reuse them on the next deploy.

  • Playwright
  • Chromium

A deployment can succeed and still send visitors to a sign-in page or a fallback that returns HTTP 200. Run a short Playwright check against the public URL after deployment. Compare the final address and visible heading with the expected page.

In code mode, an agent can write the navigation, assertions, screenshot and browser cleanup each time. Save the page check and evidence capture as two versioned actions. The next agent supplies the route and expected heading. When a check fails, the agent can collect evidence and decide what to investigate.

Install Chromium on the project runner

Enable Playwright (Local) in a project with a linked Linux executor. The runner needs Chromium system libraries and network access to the browser download service. Run this setup action once for the runner. Repeat it after changing to a version that pins a different browser.

install-browser.ts
// Download Chromium once on the computer that runs your browser checks.
return await playwrightLocal.installBrowser({});
Inspect tool types
Download this plugin's pinned Chromium into project runner storage. Run once per project runner before browser automation.
playwrightLocal.installBrowser(args: {
  headless?: boolean;
}): Promise<{ browser: string; playwrightVersion: string; installed: boolean }>

Give the check a route and an expected heading

Define url and expectedHeading as required text inputs. For the GitHub listing, use https://orgsdk.ai/plugins/github and GitHub. A heading shared across releases checks the visitor path. Use a separate build marker when the question is which version shipped.

Save the browser check

The action opens a clean tab, checks the final URL and HTTP status, then reads the visible heading. It closes the tab even when a check fails.

check-page.ts
// Supply the address and main heading you expect visitors to see.
const { url, expectedHeading } = defineParams(
  z.object({
    url: z.string(),
    expectedHeading: z.string(),
  }),
);

// Open a fresh page and check where the address leads.
await playwrightLocal.openPage({ timeoutMs: 10000 });
try {
  const page = await playwrightLocal.navigate({ url });
  if (page.status !== 200 || page.url !== url) {
    throw new Error(
      "Unexpected response: " + page.status + " at " + page.url,
    );
  }

  // A fallback page can load successfully. Check its heading as well.
  await playwrightLocal.waitForSelector({ selector: "h1" });
  const heading = await playwrightLocal.readText({ selector: "h1" });
  if (heading.trim() !== expectedHeading) {
    throw new Error("Unexpected heading: " + heading);
  }
  return { url: page.url, status: page.status, heading: heading.trim() };
} finally {
  // Close the page even if the check failed.
  await playwrightLocal.closePage({});
}
Inspect tool types
Open an isolated blank page or resume a named session at its saved URL. Close with closePage to checkpoint sign-in state.
playwrightLocal.openPage(args: {
  viewport?: { width: number; height: number };
  headless?: boolean;
  session?: string;
  timeoutMs?: number;
  idleTimeoutMs?: number;
}): Promise<null>
Navigate the open page to an HTTP(S) URL.
playwrightLocal.navigate(args: {
  url: string;
}): Promise<{ url: string; status: number | null }>
Wait until the element matching a selector is visible.
playwrightLocal.waitForSelector(args: {
  selector: string;
}): Promise<null>
Read the rendered text of the matching element, up to 1,000 characters.
playwrightLocal.readText(args: {
  selector: string;
}): Promise<string>
Save a named session and close the page. An unnamed session is discarded.
playwrightLocal.closePage(args: {}): Promise<null>

Save a separate screenshot action

Run this on the same approved public URL when you need a screenshot for a failed check or a visual review. The action opens a fresh Chromium page and returns the final URL, HTTP status and a base64 JPEG of the viewport. Use a width of 390 for a phone-sized check or 1280 for desktop.

Save the check and capture as separate action versions. Give the caller access to run those versions and read their results. It can run each one on its own or ask for a screenshot only when the check fails.

capture-page.ts
// Choose the page and a screen width between 320 and 1280 pixels.
const { url, viewportWidth } = defineParams(
  z.object({
    url: z.string().url(),
    viewportWidth: z.number().int().min(320).max(1280),
  }),
);

// Open a page at that width for a new screenshot.
await playwrightLocal.openPage({
  viewport: { width: viewportWidth, height: 844 },
  timeoutMs: 10000,
});
try {
  const page = await playwrightLocal.navigate({ url });

  // Keep the picture with the address and status you actually reached.
  const image = await playwrightLocal.screenshot({
    format: "jpeg",
    quality: 45,
  });
  return {
    url: page.url,
    status: page.status,
    viewportWidth,
    jpegBase64: image,
  };
} finally {
  // Close the page even if the screenshot failed.
  await playwrightLocal.closePage({});
}
Inspect tool types
Open an isolated blank page or resume a named session at its saved URL. Close with closePage to checkpoint sign-in state.
playwrightLocal.openPage(args: {
  viewport?: { width: number; height: number };
  headless?: boolean;
  session?: string;
  timeoutMs?: number;
  idleTimeoutMs?: number;
}): Promise<null>
Navigate the open page to an HTTP(S) URL.
playwrightLocal.navigate(args: {
  url: string;
}): Promise<{ url: string; status: number | null }>
Capture the viewport or full scrollable page as a base64 image. Defaults to a viewport PNG. Use JPEG for larger pages.
playwrightLocal.screenshot(args: {
  fullPage?: boolean;
  format?: "png" | "jpeg";
  quality?: number;
}): Promise<string>
Save a named session and close the page. An unnamed session is discarded.
playwrightLocal.closePage(args: {}): Promise<null>

Hand the failure to a coding agent

Once the release is live, give your agent the exact GitHub commit, the public URL and the expected heading. Ask it to run the saved check and read the result. The heading verifies the visitor path. Use the separate release-tag check to establish which commit deployed.

If the check fails, ask Codex or Claude Code to investigate with the failed run result and a fresh screenshot of the same public route. A separate reviewer can work from the same evidence. Record both observations if the page changes between the check and the capture.

If a fallback passes the heading check, reproduce it and add a fixture with the missing page marker to the check’s tests. Save the improved check as a new version. The screenshot action can keep its existing version.

One release check, three visitor outcomes

In this illustrative release, the target is a public product catalogue with the expected heading GitHub.

Example inputs, observations and decisions
HTTP resultRendered pageVerdict
200, expected URLGitHubPass the visitor-path check.
200, sign-in URLSign inRecord the redirect and capture what an anonymous visitor sees.
200, expected URLPage not foundCapture the fallback and send it with the failed run and release commit to the coding agent.

Run the same check again after the fix to compare the outcome. The capture action also works on its own during a visual review.

Test it before the next run

Start with one public route that accepts anonymous visitors.

  1. Run the saved check against a healthy public route with the correct heading.
  2. Repeat with a wrong expected heading. Run the saved capture action for the same URL and confirm it returns a readable JPEG, final URL and status.
  3. Restore the expected heading and rerun the same version. For a stronger pilot, add a deliberately broken fixture with an HTTP 200 fallback.

Check the result

  • Does the same saved check distinguish the healthy page from a redirect or fallback?
  • Can a second agent use the run result, screenshot and commit to reproduce the reported page?

Common questions

Does this need a remote browser service?

Playwright Local launches Chromium on the project’s executor. The URL must be reachable from that machine.

Why does localhost work on my laptop but fail on the executor?

Loopback addresses refer to the machine or container running Chromium. Use the production hostname or a preview URL reachable from that runner.

How should the agent revise the check?

If a real incident passes this check, capture what distinguished the broken page. Add that assertion, test the broken and healthy pages, then save a new version for the next release.

Sources and service documentation

Provider documentation supports the service behaviour described here. The proposed workflow and illustrative examples are OrgSDK designs.