How to fix Playwright "Protocol error (...): invalid argument"?

Playwright

A protocol invalid-argument error means a browser command received unsupported or malformed input.

Validate option shapes and browser-specific support before calling the API.

// Example: permission must be valid and context must have a proper origin.
await context.grantPermissions(['geolocation'], {
  origin: 'https://example.com',
});

If it is browser-specific, reproduce in Chromium/WebKit/Firefox separately and gate behavior by project.