Skip to content

[🚀 Feature]: [BIDI] Add commands to retrieve req/rsp bodies #16514

@newsgrep

Description

@newsgrep

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:

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    B-devtoolsIncludes everything BiDi or Chrome DevTools relatedI-enhancementSomething could be better

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions