Add support for browser.on(:response).#294
Conversation
|
@route would appreciate some guidance on this new feature and where I should add the specs and documentation? |
|
@postmodern I was reorganizing specs so currently page specs are in the browser_spec. I think we can create page_spec and put it there. Though it overlaps with network_spec a bit, because |
|
I can't say for certain, but I believe the act of enabling network intercept requires you to authorize the requests to proceed. For example, some of the specs show: https://github.com/rubycdp/ferrum/blob/main/spec/network/exchange_spec.rb#L28 network.intercept
page.on(:request) { |r, _, _| r.continue } |
|
@ttilberg hmm that solved the exception, except now it does not appear that my |
|
@postmodern I took a look but didn’t find a CDP event translation helper for Edit: haha… I just looked at the rest of the context of this issue… lol. I’ll see myself out! |
|
@ttilberg yeah it's added in this PR. Feel free to pull my branch and try to mess with it. I swear it was working last year. |
|
OK I added some echo debugging and the |
* This adds an additional callback for the `Network.responseReceived` event when a response is received. It will look up the `Ferrum::Network::Exchange` object with the matching `requestId` and passes it back to the block, once a response has been received for a request.
152874a to
ff5bf72
Compare
|
Got it, I needed to do |
|
This is useful, I use it as a monkey patch while it's not merged. |
|
Turned out it doesn't work for really heavy and chunked responses (I m testing particular response which returns 20MB), so I needed to use Then I used mapping table to match |
I wanted to be able to have a callback similar to
on(:request)but triggered once a response was received. This adds an additional callback for theNetwork.responseReceivedevent when a response is received. It will look up theFerrum::Network::Exchangeobject with the matchingrequestIdand passes it back to the block, once a response has been received for a request.I didn't know where to add specs for this, since there does not appear to be specs for
Ferrum::Pageor aspec/page_spec.rbfile? I also didn't know where I should mentionbrowser.on(:response)in the README, sincebrowser.on(...)is only mentioned in conjunction to usingbrowser.network.intercept.