1

I am trying to capture the graphql response from the network response tab using the selenium4 dev tool. enter image description here

I have tried the below code and its prints all data from the 30 + requests available on the network response but I just want to fetch graphql file and print the response available with graphql request.

        DevTools finalDevTools = devTools;
        devTools.addListener(Network.responseReceived(), responseReceived -> {


                    requestIds[0] = responseReceived.getRequestId();
                    String url = responseReceived.getResponse().getUrl();

                    int status = responseReceived.getResponse().getStatus();
                    String type = responseReceived.getType().toJson();
                    String headers = responseReceived.getResponse().getHeaders().toString();

                    String responseBody = finalDevTools.send(Network.getResponseBody(requestIds[0])).getBody();
                    System.out.println(responseBody);
            }); 
SeleniumUser
  • 4,065
  • 2
  • 7
  • 30

0 Answers0