diff --git a/serenity-browserstack/src/main/java/net/serenitybdd/plugins/browserstack/BrowserStackTestSession.java b/serenity-browserstack/src/main/java/net/serenitybdd/plugins/browserstack/BrowserStackTestSession.java index c1fd5e1ad..5878906d3 100644 --- a/serenity-browserstack/src/main/java/net/serenitybdd/plugins/browserstack/BrowserStackTestSession.java +++ b/serenity-browserstack/src/main/java/net/serenitybdd/plugins/browserstack/BrowserStackTestSession.java @@ -176,15 +176,16 @@ private String getSessionProperty(String propertyName) { return null; } + String sessionBody = null; try { HttpClient httpClient = HttpClients.custom().setDefaultRequestConfig(RequestConfig.custom(). setCookieSpec(CookieSpecs.STANDARD).build()).build(); HttpGet querySessionInfo = new HttpGet(getSessionUri()); HttpEntity sessionDetails = httpClient.execute(querySessionInfo).getEntity(); - String sessionBody = EntityUtils.toString(sessionDetails, charsetOf(sessionDetails)); + sessionBody = EntityUtils.toString(sessionDetails, charsetOf(sessionDetails)); sessionElement = gson.fromJson(sessionBody, JsonElement.class); } catch (IOException | JsonSyntaxException | JsonIOException e) { - LOGGER.error("Failed to connect to Browserstack API.", e); + LOGGER.error("Failed to connect to Browserstack API for session " + sessionId + System.lineSeparator() + sessionBody, e); } if (sessionElement == null) {