puppeteer package and had problems.Definitions by: in index.d.ts) so they can respond.The definition for "page._client" is missing or more accurate, the attribute "_client" is missing.
let page = await browser.newPage();
page._client.send(...) // <-
Although JavaScript doesn't have native support for private properties, the community more or less has settled on using the _-prefix to denote that this property/variable should not be used outside of the specific package. Since it is not part of the public API of puppeteer (it is not mentioned in their API-Documentation), it should not be exposed via our typings.
This would be really bad, because many options like setting the downloadfolder, downloadbehaviour and more can only be controlled by this attribute. All answers on questions related to those settings are pointing to that attribute and methode. So you HAVE to use it, regardless of the status of the documentation. Everybody who wants to use typescript with puppeteer and needs to change settings will encounter this problem. And i think most coders will maybe just switch back to plain js.
What about implementing it as "any" but noting within the type-definition that this is maybe experimental?
@mhombach I think a better solution to resolve the situation would be to poke the puppeteer developers to make this api public.
Besides, the workaround by casting to any works regardless of our types:
const page = await browser.newPage();
// simply cast to any
(page as any)._client.send();
EDIT: They already have an issue about this: https://github.com/GoogleChrome/puppeteer/issues/299
I believe this is now exposed (and typed) as CDPSession
const client = await page.target().createCDPSession();
await client.send('Emulation.clearDeviceMetricsOverride')
Most helpful comment