Skip to content

[CLI]: Negative positional arguments are parsed as flags, breaking mousewheel scroll-up #42321

Description

Version

@playwright/cli 0.1.18 (playwright-core 1.63.0-alpha-2026-08-05); also reproduces on 0.1.14

Steps to reproduce

Serve any scrollable page, then:

playwright-cli mousewheel 0 300     # works, page scrolls down
playwright-cli mousewheel 0 -100    # fails

Actual

Unknown options: --0, --1

Exit code 1, and the page receives no wheel event at all (verified with a
capture-phase wheel listener counting by sign: up stays 0, scrollY unchanged).

Since mousewheel <dx> <dy> takes both deltas as positional arguments, scrolling
up is unreachable through this command.

Expected

mousewheel 0 -100 scrolls up.

Root cause

packages/playwright-core/src/tools/cli-client/minimist.ts: -100 matches the
short-flag branch /^-[^-]+/, which has no escape for numeric arguments, so the
value never reaches _:

minimist(['mousewheel', '0', '-100'])
// => { _: ['mousewheel', '0'], '0': true, '1': true }

The vendored parser inherits this from minimist, but the CLI pairs it with commands
whose positional arguments are legitimately signed, so any negative positional is
unreachable — not just wheel deltas.

Workaround

playwright-cli mousewheel 0 -- -100   # => up=1, scrollY 300 -> 200

Suggested fix

Treat an argument matching /^-\d/ (or the numeric pattern already used inside that
branch) as positional, the way commander and yargs do. Related positional-parsing
fixes on the same parser: #39148, #39215.

Also worth noting: the bundled skills/playwright-cli/SKILL.md only ever shows
mousewheel 0 100, so an agent following it hits this the first time it needs to
scroll up.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    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