Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do we have a document or example on how to use some events like Network.responseReceived... #2675

Closed
phileba opened this issue Jun 23, 2020 · 8 comments

Comments

@phileba
Copy link

phileba commented Jun 23, 2020

Do we have a document or example on how to use some event likes

Network.requestWillBeSent
Network.requestIntercepted
Network.responseReceived
Network.loadingFinished
Network.loadingFailed
@phileba phileba changed the title Do we have a document on how to user some event likes Network.responseReceived Do we have a document or example on how to use some events like Network.responseReceived... Jun 23, 2020
@mxschmitt
Copy link
Member

Since these are normal CDP events, you can use the CDP documentation: https://chromedevtools.github.io/devtools-protocol/tot/Network/#event-loadingFailed

And our CDP example (client.on): https://playwright.dev/#version=v1.1.1&path=docs%2Fapi.md&q=class-cdpsession

@pavelfeldman
Copy link
Member

Overall, Playwright discourages the direct use of CDP. Our goal is to be vendor independent while CDP limits your tests to Chromium only.

It is useful for us to know when something is missing in the Playwright API so that we could expose it universally for all the browsers. Could you share what you are trying to do? Events that you lost all bubble up through the Playwright API...

@phileba
Copy link
Author

phileba commented Jun 24, 2020

Overall, Playwright discourages the direct use of CDP. Our goal is to be vendor-independent while CDP limits your tests to Chromium only.

It is useful for us to know when something is missing in the Playwright API so that we could expose it universally for all the browsers. Could you share what you are trying to do? Events that you lost all bubble up through the Playwright API...

I'm trying to port my existing project which written by puppeteer to playwright so I need to do some code transformation cause the difference.

@aslushnikov
Copy link
Collaborator

I'm trying to port my existing project which written by puppeteer to playwright so I need to do some code transformation cause the difference.

@phileba Interesting! Did you rely on CDP in your puppeteer project as well?

@shirshak55
Copy link

shirshak55 commented Jun 24, 2020

can we do something like await the promise if we receive json file which url matches with regex? Personally I do it with Network.responseReceived. Page.waitForResponse didn't worked in puppeteer last time i used..

Most of the time while working i must rely on cdp like working on websockets etc :(

@aslushnikov
Copy link
Collaborator

aslushnikov commented Jun 24, 2020

Most of the time while working i must rely on cdp like working on websockets etc :(

@shirshak55 WebSockets are missing indeed - I created a separate FR to track the progress there. Is there anything else that's missing?

Page.waitForResponse didn't worked in puppeteer last time i used..

@shirshak55 chances are, it works in Playwright! I'd highly recommend trying it out. If something doesn't work indeed, please let us know - we'd be happy to fix it.

@phileba
Copy link
Author

phileba commented Jun 25, 2020

Did you rely on CDP in your puppeteer project as well?

yep, there are some places which I'm using CDP and 1 of them is #2704

@pavelfeldman
Copy link
Member

@phileba : https://chromedevtools.github.io/devtools-protocol/ is the best source of info on CDP. You have a CDP sessions, so you can enable agents and communicate with the browser. Explaining how to work with CDP is outside of the scope of Playwright, so sadly you are on ypur own there. I will comment on your hightlight bug separately!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants