Verisoft Wiki

You can retrieve data from DevTools during test execution by using static methods that organize the data in a structured way, making it easier to fetch and continue with your tests. Below are the available methods for fetching different types of data.

You have to enable it by adding the following to your application.properties:

enableDevTools=true

Methods Overview:

1. Request Data:

2. Response Data:

3. Console Logs:


Example Usage

Here’s an example of how you might use these methods to fetch request, response, and console log data during a test:

// Get all responses
List<ResponseReceived> allResponses = DevtoolsCDP.getAllResponses(driver);

// Filter responses with a 200 OK status code
for (ResponseReceived response : allResponses) {
if (response.getStatus() == 200) {
System.out.println("Successful Response URL: " + response.getUrl());
System.out.println("Response Status: " + response.getStatus());
// Manipulate the response data, e.g., check response body content
String responseBody = response.getBody();
if (responseBody.contains("success")) {
System.out.println("Response body contains 'success'.");
}
}
}

Conclusion

These methods provide an efficient way to retrieve and organize data from DevTools, allowing you to easily interact with requests, responses, and console logs during test execution.