What's going on?
Some playwright-cli commands report a semantic tool failure but still exit with status code 0.
For example, invoking an action with an invalid or stale element reference produces an error response:
playwright-cli open https://example.com
playwright-cli click e999999
echo $?
The command reports:
### Error
Error: Ref e999999 not found in the current page snapshot.
However, the reported exit status is:
The same behavior occurs in JSON mode:
playwright-cli --json click e999999
echo $?
The JSON response contains:
but the process still exits with status code 0.
Impact
This makes shell-based automation interpret the command as successful unless it separately parses the text or JSON output.
For example, coding-agent shell tools and CI scripts commonly use the process exit status to determine whether an invocation succeeded. In this case, they may record the failed browser action as successful.
Expected behavior
I am not sure whether the current behavior is intentional.
Should a CLI command whose final tool response contains isError: true exit with a non-zero status in both text and JSON output modes?
If exit status 0 is intentional because the request to the daemon completed successfully, it would be helpful to document that contract so callers know that they must inspect isError.
Reproduction
-
Install @playwright/cli.
-
Open a page:
playwright-cli open https://example.com
-
Invoke an action using an invalid or stale element reference:
playwright-cli click e999999
-
Immediately inspect the exit status:
-
Repeat using JSON output:
playwright-cli --json click e999999
echo $?
Versions tested
@playwright/cli: 0.1.17
- OS: macOS 26.5.2
- Node.js: v24.14.0
Additional context
A related but broader discussion about Playwright exit codes exists in #14109.
If non-zero exit status is considered the desired behavior, I would be interested in contributing a regression test and a fix.
Version
0.1.17
What's going on?
Some
playwright-clicommands report a semantic tool failure but still exit with status code 0.For example, invoking an action with an invalid or stale element reference produces an error response:
The command reports:
However, the reported exit status is:
The same behavior occurs in JSON mode:
The JSON response contains:
{ "isError": true }but the process still exits with status code 0.
Impact
This makes shell-based automation interpret the command as successful unless it separately parses the text or JSON output.
For example, coding-agent shell tools and CI scripts commonly use the process exit status to determine whether an invocation succeeded. In this case, they may record the failed browser action as successful.
Expected behavior
I am not sure whether the current behavior is intentional.
Should a CLI command whose final tool response contains
isError: trueexit with a non-zero status in both text and JSON output modes?If exit status 0 is intentional because the request to the daemon completed successfully, it would be helpful to document that contract so callers know that they must inspect
isError.Reproduction
Install
@playwright/cli.Open a page:
Invoke an action using an invalid or stale element reference:
Immediately inspect the exit status:
Repeat using JSON output:
Versions tested
@playwright/cli: 0.1.17Additional context
A related but broader discussion about Playwright exit codes exists in #14109.
If non-zero exit status is considered the desired behavior, I would be interested in contributing a regression test and a fix.
Version
0.1.17