Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/playwright-core/src/tools/cli-client/minimist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export function minimist(args: string[], opts?: MinimistOptions): MinimistArgs {
} else {
setArg(key, strings[key] ? '' : true);
}
} else if ((/^-[^-]+/).test(arg)) {
} else if ((/^-[^-]+/).test(arg) && !(/^-\.?\d/).test(arg)) {
const letters = arg.slice(1, -1).split('');

let broken = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ playwright-cli mousedown right
playwright-cli mouseup
playwright-cli mouseup right
playwright-cli mousewheel 0 100
playwright-cli mousewheel 0 -100
```

### Save as
Expand Down
10 changes: 9 additions & 1 deletion tests/mcp/cli-parsing.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* limitations under the License.
*/

import { test, expect } from './cli-fixtures';
import { test, expect, eventsPage } from './cli-fixtures';

test('unknown option', async ({ cli, server }) => {
const { error, exitCode } = await cli('open', '--some-option', 'value', 'about:blank');
Expand Down Expand Up @@ -73,6 +73,14 @@ test('wrong argument type', async ({ cli, server }) => {
expect(press.exitCode).toBe(0);
});

test('negative number argument', { annotation: { type: 'issue', description: 'https://github.com/microsoft/playwright/issues/42321' } }, async ({ cli, server }) => {
server.setContent('/', eventsPage, 'text/html');
await cli('open', server.PREFIX);
const { exitCode } = await cli('mousewheel', '0', '-100');
expect(exitCode).toBe(0);
await expect.poll(() => cli('snapshot').then(result => result.inlineSnapshot)).toContain('wheel 0 -100');
});

test('should preserve leading zeros in string arguments', async ({ cli, server }) => {
server.setContent('/', `<input type=text>`, 'text/html');
await cli('open', server.PREFIX);
Expand Down