Сообщество IT-специалистов
Ответы на любые вопросы об IT
Профессиональное развитие в IT
Удаленная работа для IT-специалистов
public void test3() { final RequestId[] requestIdCaptures = new RequestId[1]; chromeDevTools.addListener(Network.responseReceived(), (ResponseReceived event) -> { Response response = event.getResponse(); // System.err.println(response.getStatus()); if (response.getStatus().toString().startsWith("4")) { System.err.println(response.getUrl() + " has failed with status code " + response.getStatus()); } // collect request id for some purpose requestIdCaptures[0] = event.getRequestId(); if (cnt++ < 10) System.err .println(String.format("Network request %s response status: %s", event.getRequestId(), event.getResponse().getStatus())); try { Network.GetResponseBodyResponse responseBody = chromeDevTools .send(Network.getResponseBody(event.getRequestId())); String body = responseBody.getBody(); if (responseBody.getBase64Encoded()) { try { body = new String(Base64.decodeBase64(body.getBytes("UTF8"))); } catch (UnsupportedEncodingException e) { System.err.println("Exception (ignored): " + e.toString()); } } System.err.println("response body:\n" + (body.length() > 100 ? body.substring(0, 100) + "..." : body)); } catch (DevToolsException e) { System.err.println("Web Driver exception (ignored): " + Utils.processExceptionMessage(e.getMessage())); } }); chromeDevTools.send(Network.setCacheDisabled(true)); driver.get(url); }