I am trying to extract an attribute from html response.
<html>
<head></head>
<body>
<script type="text/javascript" src="/sso/js/jquery/1/jquery.min.js?20190218"></script>
{serviceUrl: 'https://abcd/12345', serviceTicket: 'ABCD-123-1271821818sdsdbbsdgw3-pas'}
</body>
</html>
The response for a webservice gives me the above html response from which i wanted to extract value of an serviceUrl attribute but its giving me nullpointer exception . In the below code , res is the html response stored as String.
Response res = given()
.queryParam("logintoken", logintoken)
.when()
.get("/sso/login")
.then().assertThat().statusCode(200).extract().response();
Document doc = Jsoup.parse(res.toString());
Element link = doc.select("script").first();
String serviceUrl = link.attr("serviceUrl");
System.out.println(serviceUrl);
I expect the serviceUrl in the last statement to bring me back https://abcd/12345 but it gives me null pointer exception