Closed shirshak55 closed 4 years ago
^^ @JoelEinbinder a ts types bug?
page.context()
needs to be casted to ChromiumBrowserContext
in order to use CDPSession
@JoelEinbinder yep thanks I wrote
const session = await (page.context() as ChromiumBrowserContext).newCDPSession(page)
and it works but can you let me know why it requires page argument when it is already given page.context()
? I am asking because puppeteer doesn't use to require page argument? I think new syntax is not that ergonomic tbh.
Thanks :)
The page parameter is strange indeed, as is the requirement to cast to ChromiumBrowserContext
. Since all 3 supported browsers use CDP, it's unclear to me why the newCDPSession()
method is not available in e.g FFBrowserContext
.
Edit: I stand corrected, this is not true. See https://github.com/microsoft/playwright/issues/2484#issuecomment-652828709
@Niek Yea casting and additional page argument is not ergonomic . And the api to launch persistent and non persistent is so different i was so shocked :(
Since all 3 supported browsers use CDP
@Niek this is not actually the case.
- Juggler
Since all 3 supported browsers use CDP
@Niek this is not actually the case.
- In Chromium we rely on CDP
- In WebKit we rely on "Web Inspector Remote Debugging Protocol"
- In Firefox we rely on "Juggler" protocol
Apologies @aslushnikov, I assumed Playwright (just like Puppeteer) used CDP for FF now that it's built-in (and enabled in at least the nightly builds). But reading https://github.com/microsoft/playwright/issues/1765#issuecomment-613178363 that's not the case until the CDP support in FF is more mature.
I am converting all my puppeteer code which used to look like this.
https://github.com/shirshak55/scrapper-tools/blob/master/src/fastPage/index.ts#L113
So we went to docs and saw this
But now i am seeing error on typescript like this
Property newCDPSession doesn't exists on type BrowserContext