Use cases · Codex

QA testing with Codex and Playwright

Codex can write and fix Playwright tests in your repository and, with the Playwright MCP server, check your app in a real browser. For scripted runs, codex exec reads test output from stdin, so a failing suite can go straight to Codex for a summary and a fix. This page covers the setup, the rules and the commands.

What Codex does for QA testing

  • Writes end-to-end tests for the flows that matter: sign-up, checkout, the main screens.
  • Runs the suite, reads the failures and fixes the test or the code, saying which.
  • Drives a real browser to check a change by hand, and files bugs with steps and screenshots.
  • Finds flaky tests and quarantines them with an issue, instead of retrying until they pass.

Codex features for QA testing

FeatureWhat it doesHow to start
Playwright MCP serverDrives a real browser to check a changecodex mcp add playwright npx "@playwright/mcp@latest"
Stdin to codex execTest output piped in becomes context for the promptnpm test 2>&1 | codex exec "..."
--output-schemaReturns the result as JSON that matches your schema, for CIcodex exec --output-schema schema.json
/reviewReviews the test changes before you commitType /review in the CLI

How to set up Codex for QA testing

  1. Connect the tools

    Add the Playwright MCP server with one command, or the same table in config.toml. If the tests need to reach a staging site, turn on network access for the sandbox.

    # A real browser for exploratory checks
    codex mcp add playwright npx "@playwright/mcp@latest"
    
    # Or in ~/.codex/config.toml
    [mcp_servers.playwright]
    command = "npx"
    args = ["@playwright/mcp@latest"]
  2. Write the rules in AGENTS.md

    Codex reads AGENTS.md before any work: ~/.codex/AGENTS.md, then the files from the repository root down to the folder it's working in. Put the job's rules there, or in a skill under .agents/skills/ if they're long. See the AGENTS.md guide.

    ## QA rules
    - Test against the local or staging app, never production.
    - Use the test accounts in .env.example, never real ones.
    - A failing test is a finding: say whether the test or the code
      is wrong before you change either.
    - Every bug report: steps, expected, actual, a screenshot and
      the commit you tested.
    - Don't delete or skip a test to make the suite pass.
  3. Run it without the interactive interface

    codex exec runs one task and exits. Progress goes to stderr and the final message to stdout; -o also writes it to a file and --json streams events. The sandbox is read-only unless you pass --sandbox workspace-write.

    # Hand the failing test output to Codex
    npm test 2>&1 | codex exec "summarize the failing tests and propose the smallest likely fix"
  4. Put it on a schedule

    Create a scheduled task in the ChatGPT desktop app or on the web (the CLI doesn't manage them), or run codex exec from cron. See how to make Codex proactive.

Source: Codex documentation

Limits and safety

  • It tests what it can reach: a local or staging app with test data, not production.
  • A passing suite covers only the flows someone wrote tests for. Ask it to list what isn't covered.
  • Browser runs are slow and use more of your plan. Run the full suite on a schedule and a smoke test on each change.
  • Codex sandboxes commands by default: writes stay in the workspace and the network is off. Keep danger-full-access for an isolated runner or container.

Claude Code or Codex for QA testing?

The rules carry over. Write them once in AGENTS.md and put @AGENTS.md in CLAUDE.md, and both agents read the same file.

Step by step for the other agent: QA testing with Claude Code.

Claude CodeCodex
Rules fileCLAUDE.mdAGENTS.md
Connect toolsclaude mcp addcodex mcp add or config.toml
Run without youclaude -pcodex exec
Schedule/schedule, desktop scheduled tasks, /loopScheduled tasks in the ChatGPT app, cron
Built in for QA testingPlaywright MCP, subagentsPlaywright MCP, stdin to codex exec
With Crewmark

Make QA testing someone's job

Commands run when someone remembers to run them. Crewmark turns your own Codex into an AI employee with a role, a goal in numbers, working hours and a heartbeat, so the work happens on schedule and shows up on a board.

  1. Start from the role

    The AI software engineer, with these rules in its brief.

  2. Put the work on its board

    Add the job as a recurring issue. The employee wakes on its heartbeat, does it and reports in a comment.

  3. Related

    GitHub issues covers what happens to the bugs it files.

FAQ

Can Codex use Playwright?

Yes. Add the Playwright MCP server with codex mcp add playwright npx "@playwright/mcp@latest" or in config.toml and Codex can drive a browser; it can also write and run Playwright tests.

How do I use Codex in CI for failing tests?

Pipe the test output into codex exec with a prompt, and use -o or --output-schema to get a result your pipeline can read. For GitHub Actions, OpenAI recommends openai/codex-action.

Why can't Codex's tests reach my staging site?

The default workspace-write sandbox has network access off. Set network_access = true under [sandbox_workspace_write] in config.toml.

Checked against Claude Code's and OpenAI's Codex documentation on November 13, 2026.

Hand QA testing to an AI employee on Codex.

Crewmark turns Claude Code and Codex sessions into AI employees with roles, goals, working hours and a heartbeat.