-
-
Couldn't load subscription status.
- Fork 8.6k
Description
Description
Feature and motivation
Selenium already has some Network Intercept BiDi APi which is given in the example of BiDi API. However, this API can only be used to deal with some meta-data and headers. At the moment I must rely on CDP to inspect the payload.
I would be grateful and it would help me a great deal to have a true cross-browser implementation that makes use of the WebDriver BiDi spec that can now capture the request/response with header and body.
Usage example
Implement something similar to getUrl() or getHeaders(); but to get the payload of a request / response.
e.g. #java
// Listener für Request & Response:
network.onBeforeRequestSent(request -> {
System.out.println("REQUEST URL: " + request.getRequest().getUrl());
System.out.println("REQUEST HEADERS: " + request.getRequest().getHeaders());
System.out.println("REQUEST BODY: " + request.getRequest().getBody());
});
network.onResponseStarted(response -> {
System.out.println("RESPONSE URL: " + response.getResponseData().getUrl());
System.out.println("RESPONSE HEADERS: " + response.getResponseData().getHeaders());
System.out.println("RESPONSE BODY: " + response.getResponseData().getBody());
});
It is now supported in:
- the sepc: network.addDataCollector and network.getData
- Firefox 143:
- Chrome: https://github.com/GoogleChromeLabs/chromium-bidi/blob/main/src/bidiMapper/modules/network/NetworkStorage.ts#L518
More information
#16261
#11872
w3c/webdriver-bidi#958
w3c/webdriver-bidi#877
w3c/webdriver-bidi#1011
fyi: @TamsilAmani @titusfortner
Have you considered any alternatives or workarounds?
I tried to use devTools.send and devTools.addListener but was not able to get it to work in Firefox (only Chrome), using BIDI to get the url in both worked but I'm looking for a cross-browser way of inspecting the body of request/responses.