Skip to content

playwright-cli fill command fails when input value is numeric — throws "expected string, received number" error #235

@hqzxzb

Description

@hqzxzb

When using playwright-cli to fill a textbox with a numeric username, the command fails with the error:
error: 'text' argument: expected string, received number.

The target input is identified as a textbox type in the snapshot, and the value to fill is a numeric string (e.g., "10000001"). Despite passing the value as a quoted string in the command, the CLI appears to interpret it as a number, causing the operation to fail.

Environment:

OS: Windows Server (64-bit)

Shells tested: PowerShell, Command Prompt (cmd)

Playwright CLI: Latest version installed via npm

Steps to Reproduce:

Open the target page containing a login form.

Identify the textbox for username (ref: e33), labeled "Job number/mobile phone number".

Run the following command:

bash
npx playwright-cli fill e33 "10000001"

Observe the error:

text
error: 'text' argument: expected string, received number

Expected Behavior:
The command should fill the textbox with the string "10000001" without type-related errors.

Actual Behavior:
The CLI rejects the numeric string argument and reports a type mismatch.

Additional Context:

Page snapshot (relevant portion):

text
- generic [ref=e30]:
      - generic [ref=e31]:
        - textbox "Job number/mobile phone number" [ref=e33]
        - textbox "Password" [ref=e37]
      - generic [ref=e38]:
        - button "Login" [disabled] [ref=e39]
        - paragraph [ref=e40]:
          - generic [ref=e41]:
            - generic [ref=e42]: Change password
            - generic [ref=e44]: Forgot password

The issue occurs regardless of shell environment (PowerShell/cmd).

Question:
Is there a special syntax or workaround in playwright-cli to ensure numeric strings are treated as plain text inputs? Any guidance on resolving this type coercion issue would be appreciated.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions