browser icon indicating copy to clipboard operation
browser copied to clipboard

CDP: Add support for Emulation.setUserAgentOverride

Open scattter opened this issue 1 month ago • 2 comments

hello, i meet some error when i use clould offer. I have try to ask ai, read docs, but i failed.

below is my code

import { chromium, devices, Locator, Page } from 'playwright';

const browser = await chromium.connectOverCDP(
  'wss://euwest.cloud.lightpanda.io/ws?token=xxxx'
);
this.logger.log('browser launch', PlaywrightService.name);
const s9 = devices['Galaxy S9+'];
const context = await browser.newContext({
  ...s9,
});
const page = await context.newPage();
// ...

Error info: ERROR browserContext.newPage: Protocol error (Emulation.setUserAgentOverride): UnknownMethod - { stack: [ 'PlaywrightService' ], error: { name: 'Error' } }

playwright version is: 1.50.1

maybe is version not match?

thank you very much!

scattter avatar Oct 11 '25 10:10 scattter

Hello @scattter

Thanks for the issue. The error comes because we don't support Emulation.setUserAgentOverride.

> {"id":32,"method":"Emulation.setUserAgentOverride","params":{"userAgent":"Mozilla/5.0 (Linux; Android 8.0.0; SM-G965U Build/R16NW) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.37 Mobile Safari/537.36","userAgentMetadata":{"mobile":true,"model":"","architecture":"arm","platform":"Android","platformVersion":"8.0.0"}},"sessionId":"SID-1"}
< {"id":32,"error":{"code":-31998,"message":"UnknownMethod"},"sessionId":"SID-1"}

I will take a look on it. In the meantime, you can achieve the connection by removing the s9 parameter passed to the newContext.

krichprollsch avatar Oct 11 '25 14:10 krichprollsch

Hello @scattter

Thanks for the issue. The error comes because we don't support Emulation.setUserAgentOverride.

> {"id":32,"method":"Emulation.setUserAgentOverride","params":{"userAgent":"Mozilla/5.0 (Linux; Android 8.0.0; SM-G965U Build/R16NW) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/141.0.7390.37 Mobile Safari/537.36","userAgentMetadata":{"mobile":true,"model":"","architecture":"arm","platform":"Android","platformVersion":"8.0.0"}},"sessionId":"SID-1"}
< {"id":32,"error":{"code":-31998,"message":"UnknownMethod"},"sessionId":"SID-1"}

I will take a look on it. In the meantime, you can achieve the connection by removing the s9 parameter passed to the newContext.

@krichprollsch ok, i get it. thank you.👍

scattter avatar Oct 13 '25 01:10 scattter