public interface ExtractableResponse<R extends ResponseOptions<R>> extends ResponseBodyExtractionOptions
Usage example:
Response response = get("/lotto"); String body = response.getBody().asString(); String headerValue = response.getHeader("headerName"); String cookieValue = response.getCookie("cookieName");
You can also map the response body to a Java object automatically. REST Assured will use Jackson, Gson and JAXB to accommodate this:
Message message = get("/message").as(Message.class);
Modifier and Type | Method and Description |
---|---|
ResponseBodyExtractionOptions |
body()
Returns the response body
|
String |
contentType()
Get the content type of the response
|
String |
cookie(String name)
Get a single cookie value associated with the given name.
|
Map<String,String> |
cookies()
The response cookies as simple name/value pair.
|
Cookie |
detailedCookie(String name)
Get a single cookie including all attributes associated with the given name.
|
Cookies |
detailedCookies()
The response cookies with all the attributes.
|
String |
header(String name)
Get a single header value associated with the given name.
|
Headers |
headers()
The response headers.
|
R |
response() |
String |
sessionId()
Get the session id from the response.
|
int |
statusCode()
Get the status code of the response.
|
String |
statusLine()
Get the status line of the response.
|
long |
time() |
long |
timeIn(TimeUnit timeUnit) |
as, as, as, as, as, as, as, htmlPath, jsonPath, jsonPath, path, xmlPath, xmlPath, xmlPath
asByteArray, asInputStream, asString
ResponseBodyExtractionOptions body()
Headers headers()
String header(String name)
Headers.getList(String)
in order to get all values.null
if value was not found.Map<String,String> cookies()
detailedCookies()
.Cookies detailedCookies()
String cookie(String name)
detailedCookie(String)
.null
if value was not found.Cookie detailedCookie(String name)
null
if value was not found.String contentType()
null
if not found.String statusLine()
String sessionId()
SessionConfig
.null
if not defined.int statusCode()
R response()
long time()
long timeIn(TimeUnit timeUnit)
Copyright © 2010–2019. All rights reserved.