Class Response
- java.lang.Object
-
- com.facilita.fc.web.Response
-
public class Response extends java.lang.Object
Describes an HTTP response returned by a web server. When aRequest
is sent to the server, then a correspondingResponse
object will be generated.e.g.
TheRequest request1 = getWebBrowser().createRequest(HttpMethod.GET, new Url("http://www.testplant.com/"), 1); Response response1 = request1.send();
Response
object contains information about the response from the web server, such as the HTTP status code, the HTTP response headers, and the actual content of the response. The response may also contain sub-responses, such as images, CSS files, or javascript. These can be accessed using thegetSubResponses()
method.- See Also:
Request
-
-
Constructor Summary
Constructors Constructor Description Response(long cPtr, boolean cMemoryOwn)
For internal use only.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
containsHeader(java.lang.String header)
Returnstrue
if thisResponse
contains a particular HTTP response header.void
delete()
java.lang.String
extract(ExtractionCursor cursor, java.lang.String before, java.lang.String after)
Extracts text from the response content - everything between (but not including) the specifiedbefore
andafter
String
objects - returning an emptyString
if they cannot be found.java.lang.String
extract(ExtractionCursor cursor, java.lang.String before, java.lang.String after, boolean caseSensitive)
Extracts text from the response content - everything between (but not including) the specifiedbefore
andafter
String
objects - returning an emptyString
if they cannot be found, and specifying whether the search will be case-sensitive.java.lang.String
extract(ExtractionCursor cursor, java.lang.String before, java.lang.String after, ActionType failAction)
Extracts text from the response content - everything between (but not including) the specifiedbefore
andafter
String
objects - returning an emptyString
if they cannot be found, and specifying what action to take in case of failure.java.lang.String
extract(ExtractionCursor cursor, java.lang.String before, java.lang.String after, ActionType failAction, boolean caseSensitive)
Extracts text from the response content - everything between (but not including) the specifiedbefore
andafter
String
objects - returning an emptyString
if they cannot be found, specifying whether the search will be case-sensitive, and specifying what action to take in case of failure.java.lang.String
extract(ExtractionCursor cursor, java.lang.String before, java.lang.String after, SearchFlags matchFlags)
Extracts text from the response content - everything between (but not including) the specifiedbefore
andafter
String
objects - returning an emptyString
if they cannot be found.java.lang.String
extract(ExtractionCursor cursor, java.lang.String before, java.lang.String after, SearchFlags matchFlags, boolean caseSensitive)
Extracts text from the response content - everything between (but not including) the specifiedbefore
andafter
String
objects - returning an emptyString
if they cannot be found, and specifying whether the search will be case-sensitive.java.lang.String
extract(ExtractionCursor cursor, java.lang.String before, java.lang.String after, java.lang.String defaultValue)
Extracts text from the response content - everything between (but not including) the specifiedbefore
andafter
String
objects - returning thedefaultValue
if they cannot be found.java.lang.String
extract(ExtractionCursor cursor, java.lang.String before, java.lang.String after, java.lang.String defaultValue, boolean caseSensitive)
Extracts text from the response content - everything between (but not including) the specifiedbefore
andafter
String
objects - returning thedefaultValue
if they cannot be found, and specifying whether the search will be case-sensitive.java.lang.String
extract(ExtractionCursor cursor, java.util.List<java.lang.String> before, java.lang.String after)
Extracts text from the response content - everything between (but not including) the specified list ofbefore
andafter
String
objects - returning an emptyString
if they cannot be found.java.lang.String
extract(ExtractionCursor cursor, java.util.List<java.lang.String> before, java.lang.String after, boolean caseSensitive)
Extracts text from the response content - everything between (but not including) the specified list ofbefore
andafter
String
objects - returning an emptyString
if they cannot be found, and specifying whether the search will be case-sensitive.java.lang.String
extract(ExtractionCursor cursor, java.util.List<java.lang.String> before, java.lang.String after, ActionType failAction)
Extracts text from the response content - everything between (but not including) the specified list ofbefore
andafter
String
objects - returning an emptyString
if they cannot be found, and specifying what action to take in case of failure.java.lang.String
extract(ExtractionCursor cursor, java.util.List<java.lang.String> before, java.lang.String after, ActionType failAction, boolean caseSensitive)
Extracts text from the response content - everything between (but not including) the specified list ofbefore
andafter
String
objects - returning an emptyString
if they cannot be found, specifying whether the search will be case-sensitive, and what action to take in case of failure.java.lang.String
extract(ExtractionCursor cursor, java.util.List<java.lang.String> before, java.lang.String after, java.lang.String defaultValue)
Extracts text from the response content - everything between (but not including) the specified list ofbefore
andafter
String
objects - returning thedefaultValue
if they cannot be found.java.lang.String
extract(ExtractionCursor cursor, java.util.List<java.lang.String> before, java.lang.String after, java.lang.String defaultValue, boolean caseSensitive)
Extracts text from the response content - everything between (but not including) the specified list ofbefore
andafter
String
objects - returning thedefaultValue
if they cannot be found, and specifying whether the search will be case-sensitive.java.lang.String
extract(java.lang.String before, java.lang.String after)
Extracts text from the response content - everything between (but not including) the specifiedbefore
andafter
String
objects - returning an emptyString
if they cannot be found.java.lang.String
extract(java.lang.String before, java.lang.String after, boolean caseSensitive)
Extracts text from the response content - everything between (but not including) the specifiedbefore
andafter
String
objects - returning an emptyString
if they cannot be found, and specifying whether the search will be case-sensitive.java.lang.String
extract(java.lang.String before, java.lang.String after, ActionType failAction)
Extracts text from the response content - everything between (but not including) the specifiedbefore
andafter
String
objects - returning an emptyString
if they cannot be found, and specifying what action to take in case of failure.java.lang.String
extract(java.lang.String before, java.lang.String after, ActionType failAction, boolean caseSensitive)
Extracts text from the response content - everything between (but not including) the specifiedbefore
andafter
String
objects - returning an emptyString
if they cannot be found, specifying whether the search will be case-sensitive, and specifying what action to take in case of failure.java.lang.String
extract(java.lang.String before, java.lang.String after, java.lang.String defaultValue)
Extracts text from the response content - everything between (but not including) the specifiedbefore
andafter
String
objects - returning thedefaultValue
if they cannot be found.java.lang.String
extract(java.lang.String before, java.lang.String after, java.lang.String defaultValue, boolean caseSensitive)
Extracts text from the response content - everything between (but not including) the specifiedbefore
andafter
String
objects - returning thedefaultValue
if they cannot be found, and specifying whether the search will be case-sensitive.java.lang.String
extract(java.util.List<java.lang.String> before, java.lang.String after)
Extracts text from the response content - everything between (but not including) the specified list ofbefore
andafter
String
objects - returning an emptyString
if they cannot be found.java.lang.String
extract(java.util.List<java.lang.String> before, java.lang.String after, boolean caseSensitive)
Extracts text from the response content - everything between (but not including) the specified list ofbefore
andafter
String
objects - returning an emptyString
if they cannot be found, and specifying whether the search will be case-sensitive.java.lang.String
extract(java.util.List<java.lang.String> before, java.lang.String after, ActionType failAction)
Extracts text from the response content - everything between (but not including) the specified list ofbefore
andafter
String
objects - returning an emptyString
if they cannot be found, specifying whether the search will be case-sensitive, and what action to take in case of failure.java.lang.String
extract(java.util.List<java.lang.String> before, java.lang.String after, ActionType failAction, boolean caseSensitive)
Extracts text from the response content - everything between (but not including) the specified list ofbefore
andafter
String
objects - returning an emptyString
if they cannot be found, specifying whether the search will be case-sensitive, and what action to take in case of failure.java.lang.String
extract(java.util.List<java.lang.String> before, java.lang.String after, java.lang.String defaultValue)
Extracts text from the response content - everything between (but not including) the specified list ofbefore
andafter
String
objects - returning thedefaultValue
if they cannot be found.java.lang.String
extract(java.util.List<java.lang.String> before, java.lang.String after, java.lang.String defaultValue, boolean caseSensitive)
Extracts text from the response content - everything between (but not including) the specified list ofbefore
andafter
String
objects - returning thedefaultValue
if they cannot be found, and specifying whether the search will be case-sensitive.Form
extractForm(int formIndex)
Extracts the nth HTMLForm
from the response content.Form
extractForm(int formIndex, ActionType failAction)
Extracts the nth HTMLForm
from the response content, and takes the specifiedfailAction
if no matching form can be found.Form
extractForm(java.lang.String formName)
Extracts an HTMLForm
with the specifiedformName
from the response content.Form
extractForm(java.lang.String formName, ActionType failAction)
Extracts an HTMLForm
with the specifiedformName
from the response content, and takes the specifiedfailAction
if no matching form can be found.java.util.List<Form>
extractForms()
Extracts all the HTMLForm
objects from the response content.java.lang.String
extractFromEnd(ExtractionCursor cursor, java.lang.String after, java.lang.String before)
Extracts text from the response content, starting from the end.java.lang.String
extractFromEnd(ExtractionCursor cursor, java.lang.String after, java.lang.String before, boolean caseSensitive)
Extracts text from the response content, starting from the end.java.lang.String
extractFromEnd(ExtractionCursor cursor, java.lang.String after, java.lang.String before, boolean caseSensitive, SearchFlags matchFlags)
Extracts text from the response content, starting from the end.java.lang.String
extractFromEnd(ExtractionCursor cursor, java.lang.String after, java.lang.String before, ActionType failAction)
Extracts text from the response content, starting from the end.java.lang.String
extractFromEnd(ExtractionCursor cursor, java.lang.String after, java.lang.String before, ActionType failAction, boolean caseSensitive)
Extracts text from the response content, starting from the end.java.lang.String
extractFromEnd(ExtractionCursor cursor, java.lang.String after, java.lang.String before, ActionType failAction, boolean caseSensitive, SearchFlags matchFlags)
Extracts text from the response content, starting from the end.java.lang.String
extractFromEnd(ExtractionCursor cursor, java.lang.String after, java.lang.String before, java.lang.String defaultValue)
Extracts text from the response content, starting from the end.java.lang.String
extractFromEnd(ExtractionCursor cursor, java.lang.String after, java.lang.String before, java.lang.String defaultValue, boolean caseSensitive)
Extracts text from the response content, starting from the end.java.lang.String
extractFromEnd(ExtractionCursor cursor, java.lang.String after, java.lang.String before, java.lang.String defaultValue, boolean caseSensitive, SearchFlags matchFlags)
Extracts text from the response content, starting from the end.java.lang.String
extractFromEnd(ExtractionCursor cursor, java.util.List<java.lang.String> after, java.lang.String before)
Extracts text from the response content starting from the end.java.lang.String
extractFromEnd(ExtractionCursor cursor, java.util.List<java.lang.String> after, java.lang.String before, boolean caseSensitive)
Extracts text from the response content starting from the end.java.lang.String
extractFromEnd(ExtractionCursor cursor, java.util.List<java.lang.String> after, java.lang.String before, boolean caseSensitive, SearchFlags matchFlags)
Extracts text from the response content starting from the end.java.lang.String
extractFromEnd(ExtractionCursor cursor, java.util.List<java.lang.String> after, java.lang.String before, ActionType failAction)
Extracts text from the response content starting from the end.java.lang.String
extractFromEnd(ExtractionCursor cursor, java.util.List<java.lang.String> after, java.lang.String before, ActionType failAction, boolean caseSensitive)
Extracts text from the response content starting from the end.java.lang.String
extractFromEnd(ExtractionCursor cursor, java.util.List<java.lang.String> after, java.lang.String before, ActionType failAction, boolean caseSensitive, SearchFlags matchFlags)
Extracts text from the response content starting from the end.java.lang.String
extractFromEnd(ExtractionCursor cursor, java.util.List<java.lang.String> after, java.lang.String before, java.lang.String defaultValue)
Extracts text from the response content starting from the end.java.lang.String
extractFromEnd(ExtractionCursor cursor, java.util.List<java.lang.String> after, java.lang.String before, java.lang.String defaultValue, boolean caseSensitive)
Extracts text from the response content starting from the end.java.lang.String
extractFromEnd(ExtractionCursor cursor, java.util.List<java.lang.String> after, java.lang.String before, java.lang.String defaultValue, boolean caseSensitive, SearchFlags matchFlags)
Extracts text from the response content starting from the end.java.lang.String
extractFromEnd(java.lang.String after, java.lang.String before)
Extracts text from the response content, starting from the end.java.lang.String
extractFromEnd(java.lang.String after, java.lang.String before, boolean caseSensitive)
Extracts text from the response content, starting from the end.java.lang.String
extractFromEnd(java.lang.String after, java.lang.String before, boolean caseSensitive, SearchFlags matchFlags)
Extracts text from the response content, starting from the end.java.lang.String
extractFromEnd(java.lang.String after, java.lang.String before, ActionType failAction)
Extracts text from the response content, starting from the end.java.lang.String
extractFromEnd(java.lang.String after, java.lang.String before, ActionType failAction, boolean caseSensitive)
Extracts text from the response content, starting from the end.java.lang.String
extractFromEnd(java.lang.String after, java.lang.String before, ActionType failAction, boolean caseSensitive, SearchFlags matchFlags)
Extracts text from the response content, starting from the end.java.lang.String
extractFromEnd(java.lang.String after, java.lang.String before, java.lang.String defaultValue)
Extracts text from the response content, starting from the end.java.lang.String
extractFromEnd(java.lang.String after, java.lang.String before, java.lang.String defaultValue, boolean caseSensitive)
Extracts text from the response content, starting from the end.java.lang.String
extractFromEnd(java.lang.String after, java.lang.String before, java.lang.String defaultValue, boolean caseSensitive, SearchFlags matchFlags)
Extracts text from the response content, starting from the end.java.lang.String
extractFromEnd(java.util.List<java.lang.String> after, java.lang.String before)
Extracts text from the response content starting from the end.java.lang.String
extractFromEnd(java.util.List<java.lang.String> after, java.lang.String before, boolean caseSensitive)
Extracts text from the response content starting from the end.java.lang.String
extractFromEnd(java.util.List<java.lang.String> after, java.lang.String before, boolean caseSensitive, SearchFlags matchFlags)
Extracts text from the response content starting from the end.java.lang.String
extractFromEnd(java.util.List<java.lang.String> after, java.lang.String before, ActionType failAction)
Extracts text from the response content starting from the end.java.lang.String
extractFromEnd(java.util.List<java.lang.String> after, java.lang.String before, ActionType failAction, boolean caseSensitive)
Extracts text from the response content starting from the end.java.lang.String
extractFromEnd(java.util.List<java.lang.String> after, java.lang.String before, ActionType failAction, boolean caseSensitive, SearchFlags matchFlags)
Extracts text from the response content starting from the end.java.lang.String
extractFromEnd(java.util.List<java.lang.String> after, java.lang.String before, java.lang.String defaultValue)
Extracts text from the response content starting from the end.java.lang.String
extractFromEnd(java.util.List<java.lang.String> after, java.lang.String before, java.lang.String defaultValue, boolean caseSensitive)
Extracts text from the response content starting from the end.java.lang.String
extractFromEnd(java.util.List<java.lang.String> after, java.lang.String before, java.lang.String defaultValue, boolean caseSensitive, SearchFlags matchFlags)
Extracts text from the response content starting from the end.java.util.List<java.lang.String>
extractList(ExtractionCursor cursor, java.lang.String before, java.lang.String after)
Extracts a list of items from thisResponse
.java.util.List<java.lang.String>
extractList(ExtractionCursor cursor, java.lang.String before, java.lang.String after, SearchFlags matchFlags)
Extracts a list of items from thisResponse
.java.util.List<java.lang.String>
extractList(ExtractionCursor cursor, java.lang.String before, java.lang.String after, SearchFlags matchFlags, java.lang.String endAt)
Extracts a list of items from thisResponse
.java.util.List<java.lang.String>
extractList(ExtractionCursor cursor, java.lang.String before, java.lang.String after, SearchFlags matchFlags, java.lang.String endAt, boolean caseSensitive)
Extracts a list of items from thisResponse
.java.util.List<java.lang.String>
extractList(ExtractionCursor cursor, java.lang.String before, java.lang.String after, SearchFlags matchFlags, java.lang.String endAt, boolean caseSensitive, int maxItems)
Extracts a list of items from thisResponse
.java.util.List<java.lang.String>
extractList(ExtractionCursor cursor, java.lang.String before, java.lang.String after, java.lang.String endAt)
Extracts a list of items from thisResponse
.java.util.List<java.lang.String>
extractList(ExtractionCursor cursor, java.lang.String before, java.lang.String after, java.lang.String endAt, boolean caseSensitive)
Extracts a list of items from thisResponse
.java.util.List<java.lang.String>
extractList(ExtractionCursor cursor, java.lang.String before, java.lang.String after, java.lang.String endAt, boolean caseSensitive, int maxItems)
Extracts a list of items from thisResponse
.java.util.List<java.lang.String>
extractList(java.lang.String before, java.lang.String after)
Extracts a list of items from thisResponse
.java.util.List<java.lang.String>
extractList(java.lang.String before, java.lang.String after, boolean caseSensitive)
Extracts a list of items from thisResponse
, specifying whether the search should be case-sensitive.java.util.List<java.lang.String>
extractList(java.lang.String before, java.lang.String after, boolean caseSensitive, int maxItems)
Extracts a list of items from thisResponse
, specifying whether the search should be case-sensitive, and the maximum number of items to extract.RegExpMatchList
extractRegExp(ExtractionCursor cursor, java.lang.String regExp)
Extracts multipleString
objects from the response content, wherever the specified regular expression matches.RegExpMatchList
extractRegExp(ExtractionCursor cursor, java.lang.String regExp, boolean caseSensitive)
Extracts multipleString
objects from the response content, wherever the specified regular expression matches, and specifying whether the search will be case-sensitive.java.lang.String
extractRegExp(ExtractionCursor cursor, java.lang.String beforeRegExp, java.lang.String afterRegExp, SearchFlags matchFlags)
Extracts text from the response content - everything between (but not including) the specifiedbefore
andafter
String
objects - returning an emptyString
if they cannot be found.java.lang.String
extractRegExp(ExtractionCursor cursor, java.lang.String beforeRegExp, java.lang.String afterRegExp, SearchFlags matchFlags, boolean caseSensitive)
Extracts text from the response content - everything between (but not including) the specifiedbefore
andafter
String
objects - returning an emptyString
if they cannot be found, and specifying whether the search will be case-sensitive.java.lang.String
extractXPath(java.lang.String xpathExpression, ActionType failAction)
Returns a string object from the HTML or XML response content that matches the given XPath expression.boolean
find(ExtractionCursor cursor, java.lang.String text)
Finds the specifiedtext
within thisResponse
.boolean
find(ExtractionCursor cursor, java.lang.String text, boolean caseSensitive)
Finds the specifiedtext
within thisResponse
, specifying whether the search will be case-sensitive.boolean
find(ExtractionCursor cursor, java.lang.String text, ActionType failAction)
Finds the specifiedtext
within thisResponse
, specifying what action to take in case of failure.boolean
find(ExtractionCursor cursor, java.lang.String text, ActionType failAction, boolean caseSensitive)
Finds the specifiedtext
within thisResponse
, specifying whether the search will be case-sensitive, and what action to take in case of failure.Url
getAnchor(int n, ActionType failAction)
Gets the nth anchor in thisResponse
.long
getBytesDownloaded()
Gets the number of bytes downloaded from the server.java.lang.String
getCharEncoding()
Gets the character encoding that is used to decode the data contained in thisResponse
, for example"UTF-8"
.java.lang.String
getCharSet()
Gets the value of the"charset"
parameter specified in the"Content-Type"
HTTP response header.java.lang.String
getContent()
Gets the content of thisResponse
, using the current encoding (as defined bygetCharEncoding()
) to decode the data.org.json.simple.JSONObject
getContentAsJson()
Gets an org.json.simple JSON object representation of this Response.org.w3c.dom.Document
getContentAsXml()
Gets an XML DOM representation of thisResponse
.java.lang.String
getContentEncoding()
Gets the value of the"Content-Encoding"
HTTP response header.long
getContentLength()
Gets the length in bytes of the response content.java.lang.String
getContentType()
Gets the value of the"Content-Type"
HTTP response header.static long
getCPtr(Response obj)
For internal use only.java.util.List<java.lang.String>
getHeaderKeys()
Gets a list of names of all the HTTP response headers set in thisResponse
.java.lang.String
getHeaderValue(java.lang.String header)
Gets the value of an HTTP response header contained in thisResponse
.java.lang.String
getHeaderValue(java.lang.String header, int index)
Gets the value of the nth instance of an HTTP response header contained in thisResponse
.java.lang.String
getMessageBody()
Gets the body of the message from the correspondingRequest
.HttpMethod
getMethod()
Gets theHttpMethod
that was used to send theRequest
.byte[]
getRawContent()
Gets the raw content of thisResponse
.int
getReceiveTime()
Gets the time at which the response was received from the server (measured in milliseconds since the start of the test).Response
getRedirectedFrom()
Gets theResponse
from which thisResponse
has been redirected.Response
getRedirectedFrom(int depth)
Gets theResponse
from which thisResponse
has been redirected.java.lang.String
getReferer()
Gets the value of the"Referer"
HTTP response header.HttpStatus
getResult()
Gets the HTTP status code received from the server when thisResponse
was served.java.lang.String
getResultString()
Gets the HTTP result returned by the server, e.g.HTTP/1.1 200 OK
int
getSendTime()
Gets the time at which the request was sent to the server (measured in milliseconds since the start of the test).java.util.List<Response>
getSubResponses()
Gets a list ofResponse
objects that describe HTTP responses to sub-requests associated with the top-levelRequest
sent to the web server.java.lang.String
getTitle()
Gets the HTML title of thisResponse
.Url
getUrl()
java.lang.String
getUrlString()
Gets the URL that was used in the correspondingRequest
, as aString
.java.lang.String
getUserAgent()
Gets the value of the"User-Agent"
HTTP response header.java.lang.String
getVersion()
Get the version of HTTP that was used to send this responseboolean
hasReferer()
Returnstrue
if thisResponse
contains an HTTP"Referer"
response header.boolean
hasTitle()
Returnstrue
if thisResponse
contains an HTML title.void
resetCharEncoding()
Resets the character encoding that is used to decode the data contained in thisResponse
.boolean
rfind(ExtractionCursor cursor, java.lang.String text)
Finds the specifiedtext
within thisResponse
, starting from the end of the content.boolean
rfind(ExtractionCursor cursor, java.lang.String text, boolean caseSensitive)
Finds the specifiedtext
within thisResponse
, starting from the end of the content, and specifying whether the search will be case-sensitive.boolean
rfind(ExtractionCursor cursor, java.lang.String text, ActionType failAction)
Finds the specifiedtext
within thisResponse
, starting from the end of the content, specifying what action to take in case of failure.boolean
rfind(ExtractionCursor cursor, java.lang.String text, ActionType failAction, boolean caseSensitive)
Finds the specifiedtext
within thisResponse
, starting from the end of the content, specifying whether the search will be case-sensitive, and what action to take in case of failure.void
setCharEncoding(java.lang.String charEncoding)
Sets the character encoding that is used to decode the data contained in thisResponse
.boolean
verifyContains(java.lang.String text)
Returnstrue
if the content of thisResponse
contains the specifiedtext
.boolean
verifyContains(java.lang.String text, boolean caseSensitive)
Returnstrue
if the content of thisResponse
contains the specifiedtext
, specifying whether the search will be case-sensitive.boolean
verifyContains(java.lang.String text, ActionType failAction)
Returnstrue
if the content of thisResponse
contains the specifiedtext
, specifying what action to take in case of failure.boolean
verifyContains(java.lang.String text, ActionType failAction, boolean caseSensitive)
Returnstrue
if the content of thisResponse
contains the specifiedtext
, specifying whether the search will be case-sensitive, and what action to take in case of failure.boolean
verifyResult(HttpStatus expectedResult)
Verify that the response code of this Response matches the specifiedexpectedResult
.boolean
verifyResult(HttpStatus expectedResult, ActionType action)
Verify that the response code of this Response matches the specifiedexpectedResult
, and takes the specifiedaction
if it does not.boolean
verifyTitle(java.lang.String title)
Verifies that the title of thisResponse
page matches the specifiedtitle
.boolean
verifyTitle(java.lang.String title, ActionType action)
Verifies that the title of thisResponse
page matches the specifiedtitle
, and takes the specifiedaction
if it does not.boolean
wasRedirected()
Returnstrue
if thisResponse
was the result of a redirected request.
-
-
-
Method Detail
-
getCPtr
public static long getCPtr(Response obj)
For internal use only. Of no interest to the user.- Parameters:
obj
- a reference to an object of this class- Returns:
- a long containing the address of the CPP wrapped object
-
delete
public void delete()
-
getMethod
public HttpMethod getMethod() throws java.lang.Exception
Gets theHttpMethod
that was used to send theRequest
.e.g.
Request request1 = getWebBrowser().createRequest(HttpMethod.GET, url1, 1); Response response1 = request1.send(); HttpMethod method = response1.getMethod(); // method will be HttpMethod.GET
- Returns:
- the
HttpMethod
that was used in theRequest
- Throws:
java.lang.Exception
- an internal error occurred
-
getUrl
public Url getUrl()
Gets theUrl
that was used in the correspondingRequest
.e.g.
Request request1 = getWebBrowser().createRequest(HttpMethod.GET, url1, 1); Response response1 = request1.send(); Url url2 = response1.getUrl(); // url2 == url1
- Returns:
- the
Url
used in the correspondingRequest
- See Also:
getUrlString()
-
getRedirectedFrom
public Response getRedirectedFrom()
Gets theResponse
from which thisResponse
has been redirected.If a request returns a redirect response code (e.g.
301
or302
), then eggPlant Performance will automatically follow the redirect, and theResponse
object returned fromRequest.send()
will be the final destination (assumingRequest.setFollowRedirects(boolean)
has been set totrue
). In this situation, this method can be used to examine the earlier responses in the redirect chain.e.g.
If the request was not redirected, then this method returnsRequest request1 = getWebBrowser().createRequest(HttpMethod.GET, url1, 1); Response response1 = request1.send(); if (response1.wasRedirected()) { Response redirectedResponse = response1.getRedirectedFrom(); ... }
null
.- Returns:
- the
Response
which thisResponse
has been redirected from, ornull
if no redirection occurred - See Also:
wasRedirected()
,Request.setFollowRedirects(boolean)
,WebBrowser.setDefaultFollowRedirects(boolean)
-
getRedirectedFrom
public Response getRedirectedFrom(int depth)
Gets theResponse
from which thisResponse
has been redirected.If a request returns a redirect response code (e.g.
301
or302
), then eggPlant Performance will automatically follow the redirect, and theResponse
object returned fromRequest.send()
will be the final destination (assumingRequest.setFollowRedirects(boolean)
has been set totrue
). In this situation, this method can be used to examine the earlier responses in the redirect chain.e.g.
If the request was not redirected, then this method returnsRequest request1 = getWebBrowser().createRequest(HttpMethod.GET, url1, 1); Response response1 = request1.send(); if (response1.wasRedirected()) { Response redirectedResponse = response1.getRedirectedFrom(2); ... }
null
.- Parameters:
depth
- how far to traverse up the redirect chain- Returns:
- the
Response
which thisResponse
has been redirected from, ornull
if no redirection occurred - See Also:
wasRedirected()
,Request.setFollowRedirects(boolean)
,WebBrowser.setDefaultFollowRedirects(boolean)
-
getUrlString
public java.lang.String getUrlString()
Gets the URL that was used in the correspondingRequest
, as aString
.e.g.
Request request1 = getWebBrowser().createRequest(HttpMethod.GET, url1, 1); Response response1 = request1.send(); String urlString = response1.getUrlString(); // urlString == url1.toString()
- Returns:
- the URL used in the corresponding
Request
- See Also:
getUrl()
-
getMessageBody
public java.lang.String getMessageBody()
Gets the body of the message from the correspondingRequest
. For example, if this object is a response to a POST request, then this method will return the POST data that was sent.e.g.
request.setMessageBody("my post data"); Response response = request.send(); String postData = response.getMessageBody(); // postData == "my post data"
- Returns:
- the body of the message
- See Also:
Request.setMessageBody(java.lang.String)
-
getResult
public HttpStatus getResult()
Gets the HTTP status code received from the server when thisResponse
was served. The most common status code is200 OK
, although other codes between200
and299
also indicate success.e.g.
if (!response.getResult().isSuccess()) { error(response.getResultString()); }
- Returns:
- the HTTP status code received from the server
-
getResultString
public java.lang.String getResultString()
Gets the HTTP result returned by the server, e.g.HTTP/1.1 200 OK
- Returns:
- the HTTP result
- See Also:
getResult()
-
wasRedirected
public boolean wasRedirected()
Returnstrue
if thisResponse
was the result of a redirected request. If this method returnstrue
, then a call togetRedirectedFrom()
will succeed.e.g.
Request request1 = getWebBrowser().createRequest(HttpMethod.GET, url1, 1); Response response1 = request1.send(); if (response1.wasRedirected()) { Response redirectedResponse = response1.getRedirectedFrom(); ... }
- Returns:
true
if the request was redirected- See Also:
getRedirectedFrom()
-
containsHeader
public boolean containsHeader(java.lang.String header) throws java.io.UnsupportedEncodingException
Returnstrue
if thisResponse
contains a particular HTTP response header.e.g.
if (response.containsHeader("Last-Modified")) { String lastModified = response.getHeaderValue("Last-Modified"); ... }
- Parameters:
header
- the header to check for- Returns:
true
if thisResponse
contains the specifiedheader
- Throws:
java.io.UnsupportedEncodingException
- The encoding is not supported- See Also:
getHeaderValue(java.lang.String)
-
getHeaderValue
public java.lang.String getHeaderValue(java.lang.String header) throws java.io.UnsupportedEncodingException
Gets the value of an HTTP response header contained in thisResponse
.e.g.
if (response.containsHeader("Last-Modified")) { String lastModified = response.getHeaderValue("Last-Modified"); ... }
- Parameters:
header
- the HTTP response header to look for- Returns:
- the value of the header, or an empty
String
if the header does not exist - Throws:
java.io.UnsupportedEncodingException
- The encoding is not supported- See Also:
containsHeader(java.lang.String)
,getHeaderValue(String, int)
-
getHeaderValue
public java.lang.String getHeaderValue(java.lang.String header, int index) throws java.io.UnsupportedEncodingException
Gets the value of the nth instance of an HTTP response header contained in thisResponse
.e.g.
if (response.containsHeader("Set-Cookie")) { // Get the value of the 2nd Set-Cookie header in the response String lastModified = response.getHeaderValue("Set-Cookie", 1); ... }
- Parameters:
header
- the HTTP response header to look forindex
- the zero-based index of the response header to look for- Returns:
- the value of the header, or an empty
String
if the header does not exist - Throws:
java.io.UnsupportedEncodingException
- The encoding is not supported- See Also:
containsHeader(java.lang.String)
,getHeaderValue(String)
-
getUserAgent
public java.lang.String getUserAgent()
Gets the value of the"User-Agent"
HTTP response header.- Returns:
- the value of the
"User-Agent"
HTTP response header, or an emptyString
if no such response header exists - See Also:
getHeaderValue(String)
,containsHeader(String)
-
getReferer
public java.lang.String getReferer()
Gets the value of the"Referer"
HTTP response header.- Returns:
- the value of the
"Referer"
HTTP response header, or an emptyString
if no such response header exists - See Also:
getHeaderValue(String)
,containsHeader(String)
,hasReferer()
-
hasReferer
public boolean hasReferer()
Returnstrue
if thisResponse
contains an HTTP"Referer"
response header.- Returns:
true
if thisResponse
contains an HTTP"Referer"
response header
-
getContentType
public java.lang.String getContentType()
Gets the value of the"Content-Type"
HTTP response header.- Returns:
- the value of the
"Content-Type"
HTTP response header, or an emptyString
if no such response header exists - See Also:
getHeaderValue(String)
,containsHeader(String)
,getCharSet()
-
getCharSet
public java.lang.String getCharSet()
Gets the value of the"charset"
parameter specified in the"Content-Type"
HTTP response header.For example, if the
"Content-Type"
header is as follows:
then this method would returnContent-Type: text/html; charset=utf-8
"utf-8"
. If no charset is specifed, or if there is no"Content-Type"
header, then this method will return an emptyString
.- Returns:
- the charset extracted from the
"Content-Type"
header, or an emptyString
if none was found - See Also:
getContentType()
,getCharEncoding()
-
getHeaderKeys
public java.util.List<java.lang.String> getHeaderKeys() throws com.facilita.exception.InternalError
Gets a list of names of all the HTTP response headers set in thisResponse
.- Returns:
- a list of names of all the HTTP response headers set in this
Response
- Throws:
com.facilita.exception.InternalError
- An internal error occurred
-
getContentEncoding
public java.lang.String getContentEncoding()
Gets the value of the"Content-Encoding"
HTTP response header.- Returns:
- the value of the
"Content-Encoding"
HTTP response header, or an emptyString
if no such response header exists - See Also:
getHeaderValue(String)
,containsHeader(String)
-
getContentLength
public long getContentLength()
Gets the length in bytes of the response content.Note that this method returns the actual length of the content, not the value specified by the
"Content-Length"
HTTP header. In many cases the values will be the same, but not always (e.g. if the content was compressed).- Returns:
- the length in bytes of the response content
- See Also:
getContent()
,getRawContent()
,getBytesDownloaded()
-
getBytesDownloaded
public long getBytesDownloaded()
Gets the number of bytes downloaded from the server.Note that this method returns the actual number of bytes downloaded from the server. If the content was compressed then this will be less than the length of the content.
- Returns:
- the number of bytes downloaded from the server.
- See Also:
getContent()
,getRawContent()
,getContentLength()
-
getSubResponses
public java.util.List<Response> getSubResponses() throws com.facilita.exception.InternalError
Gets a list ofResponse
objects that describe HTTP responses to sub-requests associated with the top-levelRequest
sent to the web server.Once a server responds to a
Request
, eggPlant Performance will parse the HTML in the response, looking for additional resources that need to be downloaded (such as images, stylesheets or javascript files). These resources will be requested from the server. In addition, sub-requests that have been explicitly added usingRequest.addSubRequest(Url)
will also be requested from the server.- Returns:
- a
List
ofResponse
objects corresponding to sub-requests sent to the server, in the order in which the responses were received - Throws:
com.facilita.exception.InternalError
- An internal error occurred
-
getSendTime
public int getSendTime()
Gets the time at which the request was sent to the server (measured in milliseconds since the start of the test).- Returns:
- the time at which the request was sent to the server, in milliseconds since the start of the test
-
getReceiveTime
public int getReceiveTime()
Gets the time at which the response was received from the server (measured in milliseconds since the start of the test).- Returns:
- the time at which the response was received from the server, in milliseconds since the start of the test
-
getAnchor
public Url getAnchor(int n, ActionType failAction)
Gets the nth anchor in thisResponse
.- Parameters:
n
- the zero-based index of the anchor to findfailAction
- the action to take in the case that no anchor could be found- Returns:
- the nth anchor in this
Response
-
getContent
public java.lang.String getContent() throws java.io.UnsupportedEncodingException
Gets the content of thisResponse
, using the current encoding (as defined bygetCharEncoding()
) to decode the data.e.g:
// Interpret the content of the Response object as a utf-8 String response.setCharEncoding("utf-8"); String decodedUtf8Content = response.getContent();
- Returns:
- the decoded content of this
Response
- Throws:
java.io.UnsupportedEncodingException
- The encoding is not supported- See Also:
getCharEncoding()
,setCharEncoding(java.lang.String)
,getRawContent()
-
getContentAsXml
public org.w3c.dom.Document getContentAsXml() throws java.lang.Exception
Gets an XML DOM representation of thisResponse
.e.g. if the content of the HTTP
Response
is as follows:
The values of the<html> <body> <form name="myForm"> Select: <select name="mySelect"> <option value="1">1</option> <option value="2">2</option> </select> </form> </body> </html>
<option>
elements can be retrieved from the XML content of the Response by using XPath to search in themyForm
form andmySelect
select element in the HTML.e.g.
import javax.xml.xpath.XPath; import javax.xml.xpath.XPathConstants; import javax.xml.xpath.XPathExpression; import javax.xml.xpath.XPathFactory; import org.w3c.dom.Document; import org.w3c.dom.NodeList; ... // Represent the response as an XML document Document document = response.getContentAsXml(); // Create an XPath expression to find the option nodes in the 'mySelect' select box in the 'myForm' form XPathFactory xPathFactory = XPathFactory.newInstance(); XPath xPath = xPathFactory.newXPath(); XPathExpression findOptionsExpression = xPath.compile("//form[@name='myForm']/select[@name='mySelect']/option"); // Evaluate the XPath expression to find all the nodes we are interested in NodeList optionNodes = (NodeList)findOptionsExpression.evaluate(document, XPathConstants.NODESET); // Loop through the matching nodes and print the values for (int i = 0; i < optionNodes.getLength(); i++) { writeMessage(optionNodes.item(i).getAttributes().getNamedItem("value").getTextContent()); }
- Returns:
- an XML DOM representation of this
Response
- Throws:
java.lang.Exception
- unable to represent thisResponse
as an XML document, possibly because it is not valid XML- See Also:
getContent()
,getRawContent()
,getContentAsJson()
-
getContentAsJson
public org.json.simple.JSONObject getContentAsJson() throws java.lang.Exception
Gets an org.json.simple JSON object representation of this Response.The following example demonstrates iterating through the elements of the JSON content of a Response.
import org.json.simple.JSONObject; ... Response response = request.send(); JSONObject jsonObject = response.getContentAsJson(); for (Iterator<String> iterator = jsonObject.keySet().iterator(); iterator.hasNext();) { String key = (String) iterator.next(); writeMessage(String.format("Key: %s, value: %s", key, jsonObject.get(key))); }
- Returns:
- An org.json.simple JSON object representation of this
Response
. - Throws:
java.lang.Exception
- Unable to convert response into a JSON object- See Also:
getContent()
,getRawContent()
,getContentAsXml()
-
getRawContent
public byte[] getRawContent()
Gets the raw content of thisResponse
. If the content is expected to be text, then you should usegetContent()
instead of this method.- Returns:
- the content of this
Response
as abyte
array - See Also:
getCharEncoding()
,setCharEncoding(java.lang.String)
,getContent()
-
getTitle
public java.lang.String getTitle() throws java.io.UnsupportedEncodingException
Gets the HTML title of thisResponse
. An HTML title is defined as the text between the HTML<title>
tags.e.g. in the HTML
<title>My Page Title</title>
the title isMy Page Title
If the response does not contain HTML, or does not contain an HTML title, then this method returns an empty
String
. The HTML is interpreted using the current character encoding (as defined bygetCharEncoding()
).- Returns:
- the HTML title of the response, or an empty
String
if no title was found - Throws:
java.io.UnsupportedEncodingException
- The encoding is not supported- See Also:
hasTitle()
,verifyTitle(String)
,getCharEncoding()
-
hasTitle
public boolean hasTitle()
Returnstrue
if thisResponse
contains an HTML title. An HTML title is defined as the text between the HTML<title>
tags.e.g. in the HTML
<title>My Page Title</title>
the title isMy Page Title
- Returns:
true
if thisResponse
contains an HTML title- See Also:
getTitle()
,verifyTitle(String)
-
extractForm
public Form extractForm(java.lang.String formName)
Extracts an HTMLForm
with the specifiedformName
from the response content. The usual reason for extracting a form is because some of the data on the form is needed in a subsequent request.e.g.
Response response1 = request1.send(); // Find the loginForm in the response, and store it in a variable Form loginForm = response1.extractForm("loginForm"); ... // Create a POST request that will send the modified loginForm back to the server Request request2 = getWebBrowser().createRequest(HttpMethod.POST, url2, 2); // Fill in the form by specifying a username/password loginForm.getInputElement("username").setValue("Bob Jones"); loginForm.getInputElement("password").setValue("Pa55word"); // Attach the form to the request and send it to the server request2.setMessageBody(loginForm); Response response2 = request2.send();
- Parameters:
formName
- the name of theForm
to look for in the response- Returns:
- a
Form
with the specifiedformName
-
extractForm
public Form extractForm(java.lang.String formName, ActionType failAction) throws java.lang.Exception
Extracts an HTMLForm
with the specifiedformName
from the response content, and takes the specifiedfailAction
if no matching form can be found. The usual reason for extracting a form is because some of the data on the form is needed in a subsequent request.e.g.
Response response1 = request1.send(); // Find the loginForm in the response, and store it in a variable Form loginForm = response1.extractForm("loginForm", ActionType.ACT_WARNING); ... // Create a POST request that will send the modified loginForm back to the server Request request2 = getWebBrowser().createRequest(HttpMethod.POST, url2, 2); // Fill in the form by specifying a username/password loginForm.getInputElement("username").setValue("Bob Jones"); loginForm.getInputElement("password").setValue("Pa55word"); // Attach the form to the request and send it to the server request2.setMessageBody(loginForm); Response response2 = request2.send();
- Parameters:
formName
- the name of theForm
to look for in the responsefailAction
- the action to take if no matching form can be found- Returns:
- a
Form
with the specifiedformName
- Throws:
java.lang.Exception
- An error occurred during the extraction.
-
extractForm
public Form extractForm(int formIndex)
Extracts the nth HTMLForm
from the response content. The usual reason for extracting a form is because some of the data on the form is needed in a subsequent request.e.g.
Response response1 = request1.send(); // Find the first form in the response, and store it in a variable Form loginForm = response1.extractForm(0); ... // Create a POST request that will send the modified loginForm back to the server Request request2 = getWebBrowser().createRequest(HttpMethod.POST, url2, 2); // Fill in the form by specifying a username/password loginForm.getInputElement("username").setValue("Bob Jones"); loginForm.getInputElement("password").setValue("Pa55word"); // Attach the form to the request and send it to the server request2.setMessageBody(loginForm); Response response2 = request2.send();
- Parameters:
formIndex
- the zero-based index of theForm
to look for in the response- Returns:
- the nth
Form
in the response
-
extractForm
public Form extractForm(int formIndex, ActionType failAction) throws java.lang.Exception
Extracts the nth HTMLForm
from the response content, and takes the specifiedfailAction
if no matching form can be found. The usual reason for extracting a form is because some of the data on the form is needed in a subsequent request.e.g.
Response response1 = request1.send(); // Find the first form in the response, and store it in a variable Form loginForm = response1.extractForm(0, ActionType.ACT_WARNING); ... // Create a POST request that will send the modified loginForm back to the server Request request2 = getWebBrowser().createRequest(HttpMethod.POST, url2, 2); // Fill in the form by specifying a username/password loginForm.getInputElement("username").setValue("Bob Jones"); loginForm.getInputElement("password").setValue("Pa55word"); // Attach the form to the request and send it to the server request2.setMessageBody(loginForm); Response response2 = request2.send();
- Parameters:
formIndex
- the zero-based index of theForm
to look for in the responsefailAction
- the action to take if no matching form can be found- Returns:
- the nth
Form
in the response - Throws:
java.lang.Exception
- An error occurred during the extraction.
-
extractForms
public java.util.List<Form> extractForms() throws com.facilita.exception.InternalError
Extracts all the HTMLForm
objects from the response content. The usual reason for extracting a form is because some of the data on the form is needed in a subsequent request.e.g.
Response response1 = request1.send(); // Find a form in the response, and store it in a variable List<Form> forms = response1.extractForms(); // This is a dynamic page, sometimes the login form is the second on the page Form loginForm = null; if (forms.size() == 2) { loginForm = forms.get(1); } else { loginForm = forms.get(0); } ... // Create a POST request that will send the modified loginForm back to the server Request request2 = getWebBrowser().createRequest(HttpMethod.POST, url2, 2); // Fill in the form by specifying a username/password loginForm.getInputElement("username").setValue("Bob Jones"); loginForm.getInputElement("password").setValue("Pa55word"); // Attach the form to the request and send it to the server request2.setMessageBody(loginForm); Response response2 = request2.send();
- Returns:
- all the HTML
Form
objects in the response - Throws:
com.facilita.exception.InternalError
- An internal error occurred
-
verifyTitle
public boolean verifyTitle(java.lang.String title) throws java.io.UnsupportedEncodingException
Verifies that the title of thisResponse
page matches the specifiedtitle
.The title of a
Response
object is extracted from between the<title></title>
tags in the HTML page content. This method is a simple way to check that aResponse
object returned fromRequest.send()
orRequest.sendTopLevel()
methods contains the page that you are expecting it to. If the method returnsfalse
, likely causes may include a dropped network connection or an error page returned by the server.e.g.
When a script is generated from a trace, calls toResponse response = request.send(); if (!response.verifyTitle("Login successful")) { // Login failed - we didn't get the page title we expected nextIteration(); }
verifyTitle()
are inserted after everyRequest.send()
method call and the page titles from the recorded responses are automatically inserted as parameters.- Parameters:
title
- the title that thisResponse
object is expected to contain- Returns:
true
if the title of thisResponse
object matches the specifiedtitle
- Throws:
java.io.UnsupportedEncodingException
- The encoding is not supported- See Also:
getTitle()
,hasTitle()
-
verifyTitle
public boolean verifyTitle(java.lang.String title, ActionType action) throws java.lang.Exception, java.io.UnsupportedEncodingException
Verifies that the title of thisResponse
page matches the specifiedtitle
, and takes the specifiedaction
if it does not.The title of a
Response
object is extracted from between the<title></title>
tags in the HTML page content. This method is a simple way to check that aResponse
object returned fromRequest.send()
orRequest.sendTopLevel()
methods contains the page that you are expecting it to. If the method returnsfalse
, likely causes may include a dropped network connection or an error page returned by the server.e.g.
When a script is generated from a trace, calls toResponse response = request.send(); // Check the title, and move to the next iteration if we detect that the login was unsuccessful response.verifyTitle("Login successful", ActionType.ACT_NEXT_ITERATION);
verifyTitle()
are inserted after everyRequest.send()
method call and the page titles from the recorded responses are automatically inserted as parameters.- Parameters:
title
- the title that thisResponse
object is expected to containaction
- the action to take if the expectedtitle
is not found- Returns:
true
if the title of thisResponse
object matches the specifiedtitle
- Throws:
java.io.UnsupportedEncodingException
- The encoding is not supportedjava.lang.Exception
- See Also:
getTitle()
,hasTitle()
-
verifyResult
public boolean verifyResult(HttpStatus expectedResult)
Verify that the response code of this Response matches the specifiedexpectedResult
.When a script is generated from a trace, calls to
VerifyResult()
are inserted after everyRequest.send()
method call and the result from the recorded responses are automatically inserted as parameters.- Parameters:
expectedResult
- The HTTP status code that this response is expected to have.- Returns:
true
if the HTTP status of thisResponse
object matches theexpectedResult
-
verifyResult
public boolean verifyResult(HttpStatus expectedResult, ActionType action) throws java.lang.Exception
Verify that the response code of this Response matches the specifiedexpectedResult
, and takes the specifiedaction
if it does not.When a script is generated from a trace, calls to
VerifyResult()
are inserted after everyRequest.send()
method call and the result from the recorded responses are automatically inserted as parameters.- Parameters:
expectedResult
- The HTTP status code that this response is expected to have.action
- the action to take if the HTTP status code does not match theexpectedResult
- Returns:
true
if the HTTP status of thisResponse
object matches theexpectedResult
- Throws:
java.lang.Exception
- Failed to verify the result
-
find
public boolean find(ExtractionCursor cursor, java.lang.String text, boolean caseSensitive) throws java.io.UnsupportedEncodingException
Finds the specifiedtext
within thisResponse
, specifying whether the search will be case-sensitive. Information about the success/failure of this method will be stored in theExtractionCursor
object passed.e.g:
Response response = request.send(); ExtractionCursor cursor = new ExtractionCursor(); if (!response.find(cursor, "page loaded successfully", false)) { warn("Page did not load successfully: " + cursor.getErrorMessage()); nextIteration(); } writeMessage(String.format("Text found at position %d", cursor.getIndex()));
- Parameters:
cursor
- anExtractionCursor
object to store the success/failure of the action, and the index in the response at which the match was foundtext
- the text to search forcaseSensitive
-true
if the search should be case-sensitive- Returns:
true
if the specifiedtext
was found in thisResponse
- Throws:
java.io.UnsupportedEncodingException
- The encoding is not supported
-
find
public boolean find(ExtractionCursor cursor, java.lang.String text) throws java.io.UnsupportedEncodingException
Finds the specifiedtext
within thisResponse
. Information about the success/failure of this method will be stored in theExtractionCursor
object passed. The search is case-sensitive.e.g:
Response response = request.send(); ExtractionCursor cursor = new ExtractionCursor(); if (!response.find(cursor, "page loaded successfully")) { warn("Page did not load successfully: " + cursor.getErrorMessage()); nextIteration(); } writeMessage(String.format("Text found at position %d", cursor.getIndex()));
- Parameters:
cursor
- anExtractionCursor
object to store the success/failure of the action, and the index in the response at which the match was foundtext
- the text to search for- Returns:
true
if the specifiedtext
was found in thisResponse
- Throws:
java.io.UnsupportedEncodingException
- The encoding is not supported
-
rfind
public boolean rfind(ExtractionCursor cursor, java.lang.String text, boolean caseSensitive) throws java.io.UnsupportedEncodingException
Finds the specifiedtext
within thisResponse
, starting from the end of the content, and specifying whether the search will be case-sensitive. Information about the success/failure of this method will be stored in theExtractionCursor
object passed.e.g:
Response response = request.send(); ExtractionCursor cursor = new ExtractionCursor(); if (!response.rfind(cursor, "page loaded successfully", false)) { warn("Page did not load successfully: " + cursor.getErrorMessage()); nextIteration(); } writeMessage(String.format("Text found at position %d", cursor.getIndex()));
- Parameters:
cursor
- anExtractionCursor
object to store the success/failure of the action, and the index in the response at which the match was foundtext
- the text to search forcaseSensitive
-true
if the search should be case-sensitive- Returns:
true
if the specifiedtext
was found in thisResponse
- Throws:
java.io.UnsupportedEncodingException
- The encoding is not supported
-
rfind
public boolean rfind(ExtractionCursor cursor, java.lang.String text) throws java.io.UnsupportedEncodingException
Finds the specifiedtext
within thisResponse
, starting from the end of the content. Information about the success/failure of this method will be stored in theExtractionCursor
object passed. The search is case-sensitive.e.g:
Response response = request.send(); ExtractionCursor cursor = new ExtractionCursor(); if (!response.rfind(cursor, "page loaded successfully")) { warn("Page did not load successfully: " + cursor.getErrorMessage()); nextIteration(); } writeMessage(String.format("Text found at position %d", cursor.getIndex()));
- Parameters:
cursor
- anExtractionCursor
object to store the success/failure of the action, and the index in the response at which the match was foundtext
- the text to search for- Returns:
true
if the specifiedtext
was found in thisResponse
- Throws:
java.io.UnsupportedEncodingException
- The encoding is not supported
-
extract
public java.lang.String extract(ExtractionCursor cursor, java.lang.String before, java.lang.String after, java.lang.String defaultValue, boolean caseSensitive) throws java.io.UnsupportedEncodingException
Extracts text from the response content - everything between (but not including) the specifiedbefore
andafter
String
objects - returning thedefaultValue
if they cannot be found, and specifying whether the search will be case-sensitive. Information about the success/failure of this method will be stored in theExtractionCursor
object passed.e.g.
Response response = request.send(); ExtractionCursor cursor = new ExtractionCursor(); // extract the value from the HTML text, defaulting to "Joe Jones" if the value cannot be found // <input type="text" name="f_customer" size="32" maxlength="32" value="Joe Smith"> String extractedText = response.extract( cursor, "value=\"", "\"", "Joe Jones", true); if (cursor.succeeded()) { writeMessage(String.format("The value %s was found at position %d", extractedText, cursor.getIndex())); }
- Parameters:
cursor
- anExtractionCursor
object to store the success/failure of the action, and the index in the response at which the match was foundbefore
- this text is searched for in the response content, and the returnedString
starts immediately after this text occurs in the contentafter
- this text is searched for in the response content after thebefore
text has been found, and the returnedString
ends immediately before this text occurs in the contentdefaultValue
- the value to return if either thebefore
orafter
text cannot be foundcaseSensitive
-true
if the search should be case-sensitive- Returns:
- the extracted text, or
defaultValue
if the extract failed - Throws:
java.io.UnsupportedEncodingException
- The encoding is not supported
-
extract
public java.lang.String extract(ExtractionCursor cursor, java.lang.String before, java.lang.String after, java.lang.String defaultValue) throws java.io.UnsupportedEncodingException
Extracts text from the response content - everything between (but not including) the specifiedbefore
andafter
String
objects - returning thedefaultValue
if they cannot be found. Information about the success/failure of this method will be stored in theExtractionCursor
object passed. The search is case-sensitive.e.g.
Response response = request.send(); ExtractionCursor cursor = new ExtractionCursor(); // extract the value from the HTML text, defaulting to "Joe Jones" if the value cannot be found // <input type="text" name="f_customer" size="32" maxlength="32" value="Joe Smith"> String extractedText = response.extract( cursor, "value=\"", "\"", "Joe Jones"); if (cursor.succeeded()) { writeMessage(String.format("The value %s was found at position %d", extractedText, cursor.getIndex())); }
- Parameters:
cursor
- anExtractionCursor
object to store the success/failure of the action, and the index in the response at which the match was foundbefore
- this text is searched for in the response content, and the returnedString
starts immediately after this text occurs in the contentafter
- this text is searched for in the response content after thebefore
text has been found, and the returnedString
ends immediately before this text occurs in the contentdefaultValue
- the value to return if either thebefore
orafter
text cannot be found- Returns:
- the extracted text, or
defaultValue
if the extract failed - Throws:
java.io.UnsupportedEncodingException
- The encoding is not supported
-
extract
public java.lang.String extract(ExtractionCursor cursor, java.util.List<java.lang.String> before, java.lang.String after, java.lang.String defaultValue, boolean caseSensitive) throws java.io.UnsupportedEncodingException
Extracts text from the response content - everything between (but not including) the specified list ofbefore
andafter
String
objects - returning thedefaultValue
if they cannot be found, and specifying whether the search will be case-sensitive. Information about the success/failure of this method will be stored in theExtractionCursor
object passed.Supplying a
List<String>
ofbefore
values enables you to express more complicated extraction patterns. eggPlant Performance searches for the firstString
in the list, and searches for the secondString
after the position at which the firstString
was found. This continues until the finalString
is matched, after which the extracted response content is returned untilafter
is matched. See the example below, in which a known unique name (f_custid
) is used to narrow the search.e.g.
Response response = request.send(); ExtractionCursor cursor = new ExtractionCursor(); // extract the f_custid value from the HTML text, defaulting to "00000" if the value cannot be found // <input type="text" name="f_customer" size="32" maxlength="32" value="Joe Smith"> // <input type="text" name="f_custid" size="10" maxlength="10" value="12345"> // <input type="text" name="f_account" size="10" maxlength="10" value="9876543"> ArrayList<String> before = new ArrayList<String>(); before.add("f_custid"); before.add("value=\""); String extractedText = response.extract( cursor, before, "\"", "00000", true); if (cursor.succeeded()) { writeMessage(String.format("The value %s was found at position %d", extractedText, cursor.getIndex())); }
- Parameters:
cursor
- anExtractionCursor
object to store the success/failure of the action, and the index in the response at which the match was foundbefore
- eachString
in thisList
is searched for sequentially in the response content, and the returnedString
starts immediately after all theString
objects have been matched in the contentafter
- this text is searched for in the response content after thebefore
text has been found, and the returnedString
ends immediately before this text occurs in the contentdefaultValue
- the value to return if either thebefore
orafter
text cannot be foundcaseSensitive
-true
if the search should be case-sensitive- Returns:
- the extracted text, or
defaultValue
if the extract failed - Throws:
java.io.UnsupportedEncodingException
- The encoding is not supported
-
extract
public java.lang.String extract(ExtractionCursor cursor, java.util.List<java.lang.String> before, java.lang.String after, java.lang.String defaultValue) throws java.io.UnsupportedEncodingException
Extracts text from the response content - everything between (but not including) the specified list ofbefore
andafter
String
objects - returning thedefaultValue
if they cannot be found. Information about the success/failure of this method will be stored in theExtractionCursor
object passed. The search is case-sensitive.Supplying a
List<String>
ofbefore
values enables you to express more complicated extraction patterns. eggPlant Performance searches for the firstString
in the list, and searches for the secondString
after the position at which the firstString
was found. This continues until the finalString
is matched, after which the extracted response content is returned untilafter
is matched. See the example below, in which a known unique name (f_custid
) is used to narrow the search.e.g.
Response response = request.send(); ExtractionCursor cursor = new ExtractionCursor(); // extract the f_custid value from the HTML text, defaulting to "00000" if the value cannot be found // <input type="text" name="f_customer" size="32" maxlength="32" value="Joe Smith"> // <input type="text" name="f_custid" size="10" maxlength="10" value="12345"> // <input type="text" name="f_account" size="10" maxlength="10" value="9876543"> ArrayList<String> before = new ArrayList<String>(); before.add("f_custid"); before.add("value=\""); String extractedText = response.extract( cursor, before, "\"", "00000"); if (cursor.succeeded()) { writeMessage(String.format("The value %s was found at position %d", extractedText, cursor.getIndex())); }
- Parameters:
cursor
- anExtractionCursor
object to store the success/failure of the action, and the index in the response at which the match was foundbefore
- eachString
in thisList
is searched for sequentially in the response content, and the returnedString
starts immediately after all theString
objects have been matched in the contentafter
- this text is searched for in the response content after thebefore
text has been found, and the returnedString
ends immediately before this text occurs in the contentdefaultValue
- the value to return if either thebefore
orafter
text cannot be found- Returns:
- the extracted text, or
defaultValue
if the extract failed - Throws:
java.io.UnsupportedEncodingException
- The encoding is not supported
-
extract
public java.lang.String extract(ExtractionCursor cursor, java.util.List<java.lang.String> before, java.lang.String after, boolean caseSensitive) throws java.io.UnsupportedEncodingException
Extracts text from the response content - everything between (but not including) the specified list ofbefore
andafter
String
objects - returning an emptyString
if they cannot be found, and specifying whether the search will be case-sensitive. Information about the success/failure of this method will be stored in theExtractionCursor
object passed.Supplying a
List<String>
ofbefore
values enables you to express more complicated extraction patterns. eggPlant Performance searches for the firstString
in the list, and searches for the secondString
after the position at which the firstString
was found. This continues until the finalString
is matched, after which the extracted response content is returned untilafter
is matched. See the example below, in which a known unique name (f_custid
) is used to narrow the search.e.g.
Response response = request.send(); ExtractionCursor cursor = new ExtractionCursor(); // extract the f_custid value from the HTML text // <input type="text" name="f_customer" size="32" maxlength="32" value="Joe Smith"> // <input type="text" name="f_custid" size="10" maxlength="10" value="12345"> // <input type="text" name="f_account" size="10" maxlength="10" value="9876543"> ArrayList<String> before = new ArrayList<String>(); before.add("f_custid"); before.add("value=\""); String extractedText = response.extract( cursor, before, "\"", true); if (cursor.succeeded()) { writeMessage(String.format("The value %s was found at position %d", extractedText, cursor.getIndex())); }
- Parameters:
cursor
- anExtractionCursor
object to store the success/failure of the action, and the index in the response at which the match was foundbefore
- eachString
in thisList
is searched for sequentially in the response content, and the returnedString
starts immediately after all theString
objects have been matched in the contentafter
- this text is searched for in the response content after thebefore
text has been found, and the returnedString
ends immediately before this text occurs in the contentcaseSensitive
-true
if the search should be case-sensitive- Returns:
- the extracted text, or an empty
String
if the extract failed - Throws:
java.io.UnsupportedEncodingException
- The encoding is not supported
-
extract
public java.lang.String extract(ExtractionCursor cursor, java.util.List<java.lang.String> before, java.lang.String after) throws java.io.UnsupportedEncodingException
Extracts text from the response content - everything between (but not including) the specified list ofbefore
andafter
String
objects - returning an emptyString
if they cannot be found. Information about the success/failure of this method will be stored in theExtractionCursor
object passed. The search is case-sensitive.Supplying a
List<String>
ofbefore
values enables you to express more complicated extraction patterns. eggPlant Performance searches for the firstString
in the list, and searches for the secondString
after the position at which the firstString
was found. This continues until the finalString
is matched, after which the extracted response content is returned untilafter
is matched. See the example below, in which a known unique name (f_custid
) is used to narrow the search.e.g.
Response response = request.send(); ExtractionCursor cursor = new ExtractionCursor(); // extract the f_custid value from the HTML text // <input type="text" name="f_customer" size="32" maxlength="32" value="Joe Smith"> // <input type="text" name="f_custid" size="10" maxlength="10" value="12345"> // <input type="text" name="f_account" size="10" maxlength="10" value="9876543"> ArrayList<String> before = new ArrayList<String>(); before.add("f_custid"); before.add("value=\""); String extractedText = response.extract( cursor, before, "\""); if (cursor.succeeded()) { writeMessage(String.format("The value %s was found at position %d", extractedText, cursor.getIndex())); }
- Parameters:
cursor
- anExtractionCursor
object to store the success/failure of the action, and the index in the response at which the match was foundbefore
- eachString
in thisList
is searched for sequentially in the response content, and the returnedString
starts immediately after all theString
objects have been matched in the contentafter
- this text is searched for in the response content after thebefore
text has been found, and the returnedString
ends immediately before this text occurs in the content- Returns:
- the extracted text, or an empty
String
if the extract failed - Throws:
java.io.UnsupportedEncodingException
- The encoding is not supported
-
extract
public java.lang.String extract(ExtractionCursor cursor, java.lang.String before, java.lang.String after, boolean caseSensitive) throws java.io.UnsupportedEncodingException
Extracts text from the response content - everything between (but not including) the specifiedbefore
andafter
String
objects - returning an emptyString
if they cannot be found, and specifying whether the search will be case-sensitive. Information about the success/failure of this method will be stored in theExtractionCursor
object passed.e.g.
Response response = request.send(); ExtractionCursor cursor = new ExtractionCursor(); // extract the value from the HTML text // <input type="text" name="f_customer" size="32" maxlength="32" value="Joe Smith"> String extractedText = response.extract( cursor, "value=\"", "\"", true); if (cursor.succeeded()) { writeMessage(String.format("The value %s was found at position %d", extractedText, cursor.getIndex())); }
- Parameters:
cursor
- anExtractionCursor
object to store the success/failure of the action, and the index in the response at which the match was foundbefore
- this text is searched for in the response content, and the returnedString
starts immediately after this text occurs in the contentafter
- this text is searched for in the response content after thebefore
text has been found, and the returnedString
ends immediately before this text occurs in the contentcaseSensitive
-true
if the search should be case-sensitive- Returns:
- the extracted text, or an empty
String
if the extract failed - Throws:
java.io.UnsupportedEncodingException
- The encoding is not supported
-
extract
public java.lang.String extract(ExtractionCursor cursor, java.lang.String before, java.lang.String after) throws java.io.UnsupportedEncodingException
Extracts text from the response content - everything between (but not including) the specifiedbefore
andafter
String
objects - returning an emptyString
if they cannot be found. Information about the success/failure of this method will be stored in theExtractionCursor
object passed. The search is case-sensitive.e.g.
Response response = request.send(); ExtractionCursor cursor = new ExtractionCursor(); // extract the value from the HTML text // <input type="text" name="f_customer" size="32" maxlength="32" value="Joe Smith"> String extractedText = response.extract( cursor, "value=\"", "\""); if (cursor.succeeded()) { writeMessage(String.format("The value %s was found at position %d", extractedText, cursor.getIndex())); }
- Parameters:
cursor
- anExtractionCursor
object to store the success/failure of the action, and the index in the response at which the match was foundbefore
- this text is searched for in the response content, and the returnedString
starts immediately after this text occurs in the contentafter
- this text is searched for in the response content after thebefore
text has been found, and the returnedString
ends immediately before this text occurs in the content- Returns:
- the extracted text, or an empty
String
if the extract failed - Throws:
java.io.UnsupportedEncodingException
- The encoding is not supported
-
extract
public java.lang.String extract(java.lang.String before, java.lang.String after, java.lang.String defaultValue, boolean caseSensitive) throws java.io.UnsupportedEncodingException
Extracts text from the response content - everything between (but not including) the specifiedbefore
andafter
String
objects - returning thedefaultValue
if they cannot be found, and specifying whether the search will be case-sensitive.e.g.
Response response = request.send(); // extract the value from the HTML text, defaulting to "Joe Jones" if the value cannot be found // <input type="text" name="f_customer" size="32" maxlength="32" value="Joe Smith"> String extractedText = response.extract( "value=\"", "\"", "Joe Jones", true);
- Parameters:
before
- this text is searched for in the response content, and the returnedString
starts immediately after this text occurs in the contentafter
- this text is searched for in the response content after thebefore
text has been found, and the returnedString
ends immediately before this text occurs in the contentdefaultValue
- the value to return if either thebefore
orafter
text cannot be foundcaseSensitive
-true
if the search should be case-sensitive- Returns:
- the extracted text, or
defaultValue
if the extract failed - Throws:
java.io.UnsupportedEncodingException
- The encoding is not supported
-
extract
public java.lang.String extract(java.lang.String before, java.lang.String after, java.lang.String defaultValue) throws java.io.UnsupportedEncodingException
Extracts text from the response content - everything between (but not including) the specifiedbefore
andafter
String
objects - returning thedefaultValue
if they cannot be found.e.g.
Response response = request.send(); // extract the value from the HTML text, defaulting to "Joe Jones" if the value cannot be found // <input type="text" name="f_customer" size="32" maxlength="32" value="Joe Smith"> String extractedText = response.extract( "value=\"", "\"", "Joe Jones");
- Parameters:
before
- this text is searched for in the response content, and the returnedString
starts immediately after this text occurs in the contentafter
- this text is searched for in the response content after thebefore
text has been found, and the returnedString
ends immediately before this text occurs in the contentdefaultValue
- the value to return if either thebefore
orafter
text cannot be found- Returns:
- the extracted text, or
defaultValue
if the extract failed - Throws:
java.io.UnsupportedEncodingException
- The encoding is not supported
-
extract
public java.lang.String extract(java.util.List<java.lang.String> before, java.lang.String after, java.lang.String defaultValue, boolean caseSensitive) throws java.io.UnsupportedEncodingException
Extracts text from the response content - everything between (but not including) the specified list ofbefore
andafter
String
objects - returning thedefaultValue
if they cannot be found, and specifying whether the search will be case-sensitive.Supplying a
List<String>
ofbefore
values enables you to express more complicated extraction patterns. eggPlant Performance searches for the firstString
in the list, and searches for the secondString
after the position at which the firstString
was found. This continues until the finalString
is matched, after which the extracted response content is returned untilafter
is matched. See the example below, in which a known unique name (f_custid
) is used to narrow the search.e.g.
Response response = request.send(); // extract the f_custid value from the HTML text, defaulting to "00000" if the value cannot be found // <input type="text" name="f_customer" size="32" maxlength="32" value="Joe Smith"> // <input type="text" name="f_custid" size="10" maxlength="10" value="12345"> // <input type="text" name="f_account" size="10" maxlength="10" value="9876543"> ArrayList<String> before = new ArrayList<String>(); before.add("f_custid"); before.add("value=\""); String extractedText = response.extract( before, "\"", "00000", true);
- Parameters:
before
- eachString
in thisList
is searched for sequentially in the response content, and the returnedString
starts immediately after all theString
objects have been matched in the contentafter
- this text is searched for in the response content after thebefore
text has been found, and the returnedString
ends immediately before this text occurs in the contentdefaultValue
- the value to return if either thebefore
orafter
text cannot be foundcaseSensitive
-true
if the search should be case-sensitive- Returns:
- the extracted text, or
defaultValue
if the extract failed - Throws:
java.io.UnsupportedEncodingException
- The encoding is not supported
-
extract
public java.lang.String extract(java.util.List<java.lang.String> before, java.lang.String after, java.lang.String defaultValue) throws java.io.UnsupportedEncodingException
Extracts text from the response content - everything between (but not including) the specified list ofbefore
andafter
String
objects - returning thedefaultValue
if they cannot be found. The search is case-sensitive.Supplying a
List<String>
ofbefore
values enables you to express more complicated extraction patterns. eggPlant Performance searches for the firstString
in the list, and searches for the secondString
after the position at which the firstString
was found. This continues until the finalString
is matched, after which the extracted response content is returned untilafter
is matched. See the example below, in which a known unique name (f_custid
) is used to narrow the search.e.g.
Response response = request.send(); // extract the f_custid value from the HTML text, defaulting to "00000" if the value cannot be found // <input type="text" name="f_customer" size="32" maxlength="32" value="Joe Smith"> // <input type="text" name="f_custid" size="10" maxlength="10" value="12345"> // <input type="text" name="f_account" size="10" maxlength="10" value="9876543"> ArrayList<String> before = new ArrayList<String>(); before.add("f_custid"); before.add("value=\""); String extractedText = response.extract( before, "\"", "00000");
- Parameters:
before
- eachString
in thisList
is searched for sequentially in the response content, and the returnedString
starts immediately after all theString
objects have been matched in the contentafter
- this text is searched for in the response content after thebefore
text has been found, and the returnedString
ends immediately before this text occurs in the contentdefaultValue
- the value to return if either thebefore
orafter
text cannot be found- Returns:
- the extracted text, or
defaultValue
if the extract failed - Throws:
java.io.UnsupportedEncodingException
- The encoding is not supported
-
extract
public java.lang.String extract(java.util.List<java.lang.String> before, java.lang.String after, boolean caseSensitive) throws java.io.UnsupportedEncodingException
Extracts text from the response content - everything between (but not including) the specified list ofbefore
andafter
String
objects - returning an emptyString
if they cannot be found, and specifying whether the search will be case-sensitive.Supplying a
List<String>
ofbefore
values enables you to express more complicated extraction patterns. eggPlant Performance searches for the firstString
in the list, and searches for the secondString
after the position at which the firstString
was found. This continues until the finalString
is matched, after which the extracted response content is returned untilafter
is matched. See the example below, in which a known unique name (f_custid
) is used to narrow the search.e.g.
Response response = request.send(); // extract the f_custid value from the HTML text // <input type="text" name="f_customer" size="32" maxlength="32" value="Joe Smith"> // <input type="text" name="f_custid" size="10" maxlength="10" value="12345"> // <input type="text" name="f_account" size="10" maxlength="10" value="9876543"> ArrayList<String> before = new ArrayList<String>(); before.add("f_custid"); before.add("value=\""); String extractedText = response.extract( before, "\"", true);
- Parameters:
before
- eachString
in thisList
is searched for sequentially in the response content, and the returnedString
starts immediately after all theString
objects have been matched in the contentafter
- this text is searched for in the response content after thebefore
text has been found, and the returnedString
ends immediately before this text occurs in the contentcaseSensitive
-true
if the search should be case-sensitive- Returns:
- the extracted text, or an empty
String
if the extract failed - Throws:
java.io.UnsupportedEncodingException
- The encoding is not supported
-
extract
public java.lang.String extract(java.util.List<java.lang.String> before, java.lang.String after) throws java.io.UnsupportedEncodingException
Extracts text from the response content - everything between (but not including) the specified list ofbefore
andafter
String
objects - returning an emptyString
if they cannot be found. The search is case-sensitive.Supplying a
List<String>
ofbefore
values enables you to express more complicated extraction patterns. eggPlant Performance searches for the firstString
in the list, and searches for the secondString
after the position at which the firstString
was found. This continues until the finalString
is matched, after which the extracted response content is returned untilafter
is matched. See the example below, in which a known unique name (f_custid
) is used to narrow the search.e.g.
Response response = request.send(); // extract the f_custid value from the HTML text // <input type="text" name="f_customer" size="32" maxlength="32" value="Joe Smith"> // <input type="text" name="f_custid" size="10" maxlength="10" value="12345"> // <input type="text" name="f_account" size="10" maxlength="10" value="9876543"> ArrayList<String> before = new ArrayList<String>(); before.add("f_custid"); before.add("value=\""); String extractedText = response.extract( before, "\"");
- Parameters:
before
- eachString
in thisList
is searched for sequentially in the response content, and the returnedString
starts immediately after all theString
objects have been matched in the contentafter
- this text is searched for in the response content after thebefore
text has been found, and the returnedString
ends immediately before this text occurs in the content- Returns:
- the extracted text, or an empty
String
if the extract failed - Throws:
java.io.UnsupportedEncodingException
- The encoding is not supported
-
extract
public java.lang.String extract(java.lang.String before, java.lang.String after, boolean caseSensitive) throws java.io.UnsupportedEncodingException
Extracts text from the response content - everything between (but not including) the specifiedbefore
andafter
String
objects - returning an emptyString
if they cannot be found, and specifying whether the search will be case-sensitive.e.g.
Response response = request.send(); // extract the value from the HTML text // <input type="text" name="f_customer" size="32" maxlength="32" value="Joe Smith"> String extractedText = response.extract( "value=\"", "\"", true);
- Parameters:
before
- this text is searched for in the response content, and the returnedString
starts immediately after this text occurs in the contentafter
- this text is searched for in the response content after thebefore
text has been found, and the returnedString
ends immediately before this text occurs in the contentcaseSensitive
-true
if the search should be case-sensitive- Returns:
- the extracted text, or an empty
String
if the extract failed - Throws:
java.io.UnsupportedEncodingException
- The encoding is not supported
-
extract
public java.lang.String extract(java.lang.String before, java.lang.String after) throws java.io.UnsupportedEncodingException
Extracts text from the response content - everything between (but not including) the specifiedbefore
andafter
String
objects - returning an emptyString
if they cannot be found. The search is case-sensitive.e.g.
Response response = request.send(); // extract the value from the HTML text // <input type="text" name="f_customer" size="32" maxlength="32" value="Joe Smith"> String extractedText = response.extract( "value=\"", "\"");
- Parameters:
before
- this text is searched for in the response content, and the returnedString
starts immediately after this text occurs in the contentafter
- this text is searched for in the response content after thebefore
text has been found, and the returnedString
ends immediately before this text occurs in the content- Returns:
- the extracted text, or an empty
String
if the extract failed - Throws:
java.io.UnsupportedEncodingException
- The encoding is not supported
-
extract
public java.lang.String extract(java.lang.String before, java.lang.String after, ActionType failAction, boolean caseSensitive) throws java.io.UnsupportedEncodingException
Extracts text from the response content - everything between (but not including) the specifiedbefore
andafter
String
objects - returning an emptyString
if they cannot be found, specifying whether the search will be case-sensitive, and specifying what action to take in case of failure.e.g.
Response response = request.send(); // extract the value from the HTML text // <input type="text" name="f_customer" size="32" maxlength="32" value="Joe Smith"> String extractedText = response.extract( "value=\"", "\"", ActionType.ACT_WARNING, true);
- Parameters:
before
- this text is searched for in the response content, and the returnedString
starts immediately after this text occurs in the contentafter
- this text is searched for in the response content after thebefore
text has been found, and the returnedString
ends immediately before this text occurs in the contentfailAction
- the action to take iftext
cannot be foundcaseSensitive
-true
if the search should be case-sensitive- Returns:
- the extracted text, or an empty
String
if the extract failed - Throws:
java.io.UnsupportedEncodingException
- The encoding is not supported
-
extract
public java.lang.String extract(java.lang.String before, java.lang.String after, ActionType failAction) throws java.io.UnsupportedEncodingException
Extracts text from the response content - everything between (but not including) the specifiedbefore
andafter
String
objects - returning an emptyString
if they cannot be found, and specifying what action to take in case of failure. The search is case-sensitive.e.g.
Response response = request.send(); // extract the value from the HTML text // <input type="text" name="f_customer" size="32" maxlength="32" value="Joe Smith"> String extractedText = response.extract( "value=\"", "\"", ActionType.ACT_WARNING);
- Parameters:
before
- this text is searched for in the response content, and the returnedString
starts immediately after this text occurs in the contentafter
- this text is searched for in the response content after thebefore
text has been found, and the returnedString
ends immediately before this text occurs in the contentfailAction
- the action to take iftext
cannot be found- Returns:
- the extracted text, or an empty
String
if the extract failed - Throws:
java.io.UnsupportedEncodingException
- The encoding is not supported
-
extract
public java.lang.String extract(java.util.List<java.lang.String> before, java.lang.String after, ActionType failAction, boolean caseSensitive) throws java.io.UnsupportedEncodingException
Extracts text from the response content - everything between (but not including) the specified list ofbefore
andafter
String
objects - returning an emptyString
if they cannot be found, specifying whether the search will be case-sensitive, and what action to take in case of failure.Supplying a
List<String>
ofbefore
values enables you to express more complicated extraction patterns. eggPlant Performance searches for the firstString
in the list, and searches for the secondString
after the position at which the firstString
was found. This continues until the finalString
is matched, after which the extracted response content is returned untilafter
is matched. See the example below, in which a known unique name (f_custid
) is used to narrow the search.e.g.
Response response = request.send(); // extract the f_custid value from the HTML text // <input type="text" name="f_customer" size="32" maxlength="32" value="Joe Smith"> // <input type="text" name="f_custid" size="10" maxlength="10" value="12345"> // <input type="text" name="f_account" size="10" maxlength="10" value="9876543"> ArrayList<String> before = new ArrayList<String>(); before.add("f_custid"); before.add("value=\""); String extractedText = response.extract( before, "\"", ActionType.ACT_WARNING, true);
- Parameters:
before
- eachString
in thisList
is searched for sequentially in the response content, and the returnedString
starts immediately after all theString
objects have been matched in the contentafter
- this text is searched for in the response content after thebefore
text has been found, and the returnedString
ends immediately before this text occurs in the contentfailAction
- the action to take iftext
cannot be foundcaseSensitive
-true
if the search should be case-sensitive- Returns:
- the extracted text, or an empty
String
if the extract failed - Throws:
java.io.UnsupportedEncodingException
- The encoding is not supported
-
extract
public java.lang.String extract(java.util.List<java.lang.String> before, java.lang.String after, ActionType failAction) throws java.io.UnsupportedEncodingException
Extracts text from the response content - everything between (but not including) the specified list ofbefore
andafter
String
objects - returning an emptyString
if they cannot be found, specifying whether the search will be case-sensitive, and what action to take in case of failure.Supplying a
List<String>
ofbefore
values enables you to express more complicated extraction patterns. eggPlant Performance searches for the firstString
in the list, and searches for the secondString
after the position at which the firstString
was found. This continues until the finalString
is matched, after which the extracted response content is returned untilafter
is matched. See the example below, in which a known unique name (f_custid
) is used to narrow the search.e.g.
Response response = request.send(); // extract the f_custid value from the HTML text // <input type="text" name="f_customer" size="32" maxlength="32" value="Joe Smith"> // <input type="text" name="f_custid" size="10" maxlength="10" value="12345"> // <input type="text" name="f_account" size="10" maxlength="10" value="9876543"> ArrayList<String> before = new ArrayList<String>(); before.add("f_custid"); before.add("value=\""); String extractedText = response.extract( before, "\"", ActionType.ACT_WARNING, true);
- Parameters:
before
- eachString
in thisList
is searched for sequentially in the response content, and the returnedString
starts immediately after all theString
objects have been matched in the contentafter
- this text is searched for in the response content after thebefore
text has been found, and the returnedString
ends immediately before this text occurs in the contentfailAction
- the action to take iftext
cannot be found- Returns:
- the extracted text, or an empty
String
if the extract failed - Throws:
java.io.UnsupportedEncodingException
- The encoding is not supported
-
extractFromEnd
public java.lang.String extractFromEnd(ExtractionCursor cursor, java.lang.String after, java.lang.String before, java.lang.String defaultValue, boolean caseSensitive, SearchFlags matchFlags) throws java.io.UnsupportedEncodingException
Extracts text from the response content, starting from the end. Everything between (but not including) the specifiedafter
andbefore
string objects will be returned. If either value cannot be found, thedefaultValue
will be returned.Information about the success/failure of this method will be stored in the
ExtractionCursor
object passed.The following example demonstrates extracting text from a HTML Response.
Response response = request.send(); ExtractionCursor cursor = new ExtractionCursor(); // extract the value from the HTML text, defaulting to "Joe Jones" if the value cannot be found // <input type="text" name="f_customer" size="32" maxlength="32" value="Joe Smith"> String extractedText = response.extractFromEnd( cursor, "\"", "value=\"", "Joe Jones", true, SearchFlags.SEARCH_IN_BOTH); if (cursor.succeeded()) { writeMessage(String.format("The value %s was found at position %d", extractedText, cursor.getIndex())); }
- Parameters:
cursor
- AnExtractionCursor
object to store the success/failure of the action, and the index in the response at which the match was found.after
- This text is searched for in the response content, and the returned string starts immediately before this text occurs in the content.before
- This text is searched for in the response content after theafter
text has been found, and the returned string ends immediately after this text occurs in the content.defaultValue
- The value to return if either thebefore
orafter
text cannot be found.caseSensitive
-true
if the search should be case-sensitive.matchFlags
- anSearchFlags
enumerated value to indicate what should be searched: SEARCH_IN_BODY, SEARCH_IN_HEADERS or SEARCH_IN_BOTH- Returns:
- The extracted text, or
defaultValue
if the extract failed. - Throws:
java.io.UnsupportedEncodingException
- The encoding is not supported
-
extractFromEnd
public java.lang.String extractFromEnd(ExtractionCursor cursor, java.lang.String after, java.lang.String before, java.lang.String defaultValue, boolean caseSensitive) throws java.io.UnsupportedEncodingException
Extracts text from the response content, starting from the end. Everything between (but not including) the specifiedafter
andbefore
string objects will be returned. If either value cannot be found, thedefaultValue
will be returned.Information about the success/failure of this method will be stored in the
ExtractionCursor
object passed.The following example demonstrates extracting text from a HTML Response.
Response response = request.send(); ExtractionCursor cursor = new ExtractionCursor(); // extract the value from the HTML text, defaulting to "Joe Jones" if the value cannot be found // <input type="text" name="f_customer" size="32" maxlength="32" value="Joe Smith"> String extractedText = response.extractFromEnd( cursor, "\"", "value=\"", "Joe Jones", true); if (cursor.succeeded()) { writeMessage(String.format("The value %s was found at position %d", extractedText, cursor.getIndex())); }
- Parameters:
cursor
- AnExtractionCursor
object to store the success/failure of the action, and the index in the response at which the match was found.after
- This text is searched for in the response content, and the returned string starts immediately before this text occurs in the content.before
- This text is searched for in the response content after theafter
text has been found, and the returned string ends immediately after this text occurs in the content.defaultValue
- The value to return if either thebefore
orafter
text cannot be found.caseSensitive
-true
if the search should be case-sensitive.- Returns:
- The extracted text, or
defaultValue
if the extract failed. - Throws:
java.io.UnsupportedEncodingException
- The encoding is not supported
-
extractFromEnd
public java.lang.String extractFromEnd(ExtractionCursor cursor, java.lang.String after, java.lang.String before, java.lang.String defaultValue) throws java.io.UnsupportedEncodingException
Extracts text from the response content, starting from the end. Everything between (but not including) the specifiedafter
andbefore
string objects will be returned. If either value cannot be found, thedefaultValue
will be returned.Information about the success/failure of this method will be stored in the
ExtractionCursor
object passed.The following example demonstrates extracting text from a HTML Response.
Response response = request.send(); ExtractionCursor cursor = new ExtractionCursor(); // extract the value from the HTML text, defaulting to "Joe Jones" if the value cannot be found // <input type="text" name="f_customer" size="32" maxlength="32" value="Joe Smith"> String extractedText = response.extractFromEnd( cursor, "\"", "value=\"", "Joe Jones"); if (cursor.succeeded()) { writeMessage(String.format("The value %s was found at position %d", extractedText, cursor.getIndex())); }
- Parameters:
cursor
- AnExtractionCursor
object to store the success/failure of the action, and the index in the response at which the match was found.after
- This text is searched for in the response content, and the returned string starts immediately before this text occurs in the content.before
- This text is searched for in the response content after theafter
text has been found, and the returned string ends immediately after this text occurs in the content.defaultValue
- The value to return if either thebefore
orafter
text cannot be found.- Returns:
- The extracted text, or
defaultValue
if the extract failed. - Throws:
java.io.UnsupportedEncodingException
- The encoding is not supported
-
extractFromEnd
public java.lang.String extractFromEnd(ExtractionCursor cursor, java.lang.String after, java.lang.String before, boolean caseSensitive, SearchFlags matchFlags) throws java.io.UnsupportedEncodingException
Extracts text from the response content, starting from the end. Everything between (but not including) the specifiedafter
andbefore
string objects will be returned.Information about the success/failure of this method will be stored in the
ExtractionCursor
object passed.The following example demonstrates extracting text from a HTML Response.
Response response = request.send(); ExtractionCursor cursor = new ExtractionCursor(); // extract the value from the HTML text // <input type="text" name="f_customer" size="32" maxlength="32" value="Joe Smith"> String extractedText = response.extractFromEnd( cursor, "\"", "value=\"", true, SearchFlags.SEARCH_IN_BOTH); if (cursor.succeeded()) { writeMessage(String.format("The value %s was found at position %d", extractedText, cursor.getIndex())); }
- Parameters:
cursor
- AnExtractionCursor
object to store the success/failure of the action, and the index in the response at which the match was found.after
- This text is searched for in the response content, and the returned string starts immediately before this text occurs in the content.before
- This text is searched for in the response content after theafter
text has been found, and the returned string ends immediately after this text occurs in the content.caseSensitive
-true
if the search should be case-sensitive.matchFlags
- anSearchFlags
enumerated value to indicate what should be searched: SEARCH_IN_BODY, SEARCH_IN_HEADERS or SEARCH_IN_BOTH- Returns:
- The extracted text, or an empty string if the extract failed.
- Throws:
java.io.UnsupportedEncodingException
- The encoding is not supported
-
extractFromEnd
public java.lang.String extractFromEnd(ExtractionCursor cursor, java.lang.String after, java.lang.String before, boolean caseSensitive) throws java.io.UnsupportedEncodingException
Extracts text from the response content, starting from the end. Everything between (but not including) the specifiedafter
andbefore
string objects will be returned.Information about the success/failure of this method will be stored in the
ExtractionCursor
object passed.The following example demonstrates extracting text from a HTML Response.
Response response = request.send(); ExtractionCursor cursor = new ExtractionCursor(); // extract the value from the HTML text // <input type="text" name="f_customer" size="32" maxlength="32" value="Joe Smith"> String extractedText = response.extractFromEnd( cursor, "\"", "value=\"", true); if (cursor.succeeded()) { writeMessage(String.format("The value %s was found at position %d", extractedText, cursor.getIndex())); }
- Parameters:
cursor
- AnExtractionCursor
object to store the success/failure of the action, and the index in the response at which the match was found.after
- This text is searched for in the response content, and the returned string starts immediately before this text occurs in the content.before
- This text is searched for in the response content after theafter
text has been found, and the returned string ends immediately after this text occurs in the content.caseSensitive
-true
if the search should be case-sensitive.- Returns:
- The extracted text, or an empty string if the extract failed.
- Throws:
java.io.UnsupportedEncodingException
- The encoding is not supported
-
extractFromEnd
public java.lang.String extractFromEnd(ExtractionCursor cursor, java.lang.String after, java.lang.String before) throws java.io.UnsupportedEncodingException
Extracts text from the response content, starting from the end. Everything between (but not including) the specifiedafter
andbefore
string objects will be returned.Information about the success/failure of this method will be stored in the
ExtractionCursor
object passed.The following example demonstrates extracting text from a HTML Response.
Response response = request.send(); ExtractionCursor cursor = new ExtractionCursor(); // extract the value from the HTML text // <input type="text" name="f_customer" size="32" maxlength="32" value="Joe Smith"> String extractedText = response.extractFromEnd( cursor, "\"", "value=\""); if (cursor.succeeded()) { writeMessage(String.format("The value %s was found at position %d", extractedText, cursor.getIndex())); }
- Parameters:
cursor
- AnExtractionCursor
object to store the success/failure of the action, and the index in the response at which the match was found.after
- This text is searched for in the response content, and the returned string starts immediately before this text occurs in the content.before
- This text is searched for in the response content after theafter
text has been found, and the returned string ends immediately after this text occurs in the content.- Returns:
- The extracted text, or an empty string if the extract failed.
- Throws:
java.io.UnsupportedEncodingException
- The encoding is not supported
-
extractFromEnd
public java.lang.String extractFromEnd(ExtractionCursor cursor, java.lang.String after, java.lang.String before, ActionType failAction, boolean caseSensitive, SearchFlags matchFlags) throws java.lang.Exception, java.io.UnsupportedEncodingException
Extracts text from the response content, starting from the end. Everything between (but not including) the specifiedafter
andbefore
string objects will be returned.Information about the success/failure of this method will be stored in the
ExtractionCursor
object passed.The following example demonstrates extracting text from a HTML Response.
Response response = request.send(); ExtractionCursor cursor = new ExtractionCursor(); // extract the value from the HTML text // <input type="text" name="f_customer" size="32" maxlength="32" value="Joe Smith"> String extractedText = response.extractFromEnd( cursor, "\"", "value=\"", ActionType.ACT_WARNING, true, SearchFlags.SEARCH_IN_BOTH); if (cursor.succeeded()) { writeMessage(String.format("The value %s was found at position %d", extractedText, cursor.getIndex())); }
- Parameters:
cursor
- AnExtractionCursor
object to store the success/failure of the action, and the index in the response at which the match was found.after
- This text is searched for in the response content, and the returned string starts immediately before this text occurs in the content.before
- This text is searched for in the response content after theafter
text has been found, and the returned string ends immediately after this text occurs in the content.failAction
- the action to take iftext
cannot be foundcaseSensitive
-true
if the search should be case-sensitive.matchFlags
- anSearchFlags
enumerated value to indicate what should be searched: SEARCH_IN_BODY, SEARCH_IN_HEADERS or SEARCH_IN_BOTH- Returns:
- The extracted text, or an empty string if the extract failed.
- Throws:
java.io.UnsupportedEncodingException
- The encoding is not supportedjava.lang.Exception
-
extractFromEnd
public java.lang.String extractFromEnd(ExtractionCursor cursor, java.lang.String after, java.lang.String before, ActionType failAction, boolean caseSensitive) throws java.lang.Exception, java.io.UnsupportedEncodingException
Extracts text from the response content, starting from the end. Everything between (but not including) the specifiedafter
andbefore
string objects will be returned.Information about the success/failure of this method will be stored in the
ExtractionCursor
object passed.The following example demonstrates extracting text from a HTML Response.
Response response = request.send(); ExtractionCursor cursor = new ExtractionCursor(); // extract the value from the HTML text // <input type="text" name="f_customer" size="32" maxlength="32" value="Joe Smith"> String extractedText = response.extractFromEnd( cursor, "\"", "value=\"", ActionType.ACT_WARNING, true); if (cursor.succeeded()) { writeMessage(String.format("The value %s was found at position %d", extractedText, cursor.getIndex())); }
- Parameters:
cursor
- AnExtractionCursor
object to store the success/failure of the action, and the index in the response at which the match was found.after
- This text is searched for in the response content, and the returned string starts immediately before this text occurs in the content.before
- This text is searched for in the response content after theafter
text has been found, and the returned string ends immediately after this text occurs in the content.failAction
- the action to take iftext
cannot be foundcaseSensitive
-true
if the search should be case-sensitive.- Returns:
- The extracted text, or an empty string if the extract failed.
- Throws:
java.io.UnsupportedEncodingException
- The encoding is not supportedjava.lang.Exception
-
extractFromEnd
public java.lang.String extractFromEnd(ExtractionCursor cursor, java.lang.String after, java.lang.String before, ActionType failAction) throws java.lang.Exception, java.io.UnsupportedEncodingException
Extracts text from the response content, starting from the end. Everything between (but not including) the specifiedafter
andbefore
string objects will be returned.Information about the success/failure of this method will be stored in the
ExtractionCursor
object passed.The following example demonstrates extracting text from a HTML Response.
Response response = request.send(); ExtractionCursor cursor = new ExtractionCursor(); // extract the value from the HTML text // <input type="text" name="f_customer" size="32" maxlength="32" value="Joe Smith"> String extractedText = response.extractFromEnd( cursor, "\"", "value=\"", ActionType.ACT_WARNING); if (cursor.succeeded()) { writeMessage(String.format("The value %s was found at position %d", extractedText, cursor.getIndex())); }
- Parameters:
cursor
- AnExtractionCursor
object to store the success/failure of the action, and the index in the response at which the match was found.after
- This text is searched for in the response content, and the returned string starts immediately before this text occurs in the content.before
- This text is searched for in the response content after theafter
text has been found, and the returned string ends immediately after this text occurs in the content.failAction
- the action to take iftext
cannot be found- Returns:
- The extracted text, or an empty string if the extract failed.
- Throws:
java.io.UnsupportedEncodingException
- The encoding is not supportedjava.lang.Exception
-
extractFromEnd
public java.lang.String extractFromEnd(ExtractionCursor cursor, java.util.List<java.lang.String> after, java.lang.String before, java.lang.String defaultValue, boolean caseSensitive, SearchFlags matchFlags) throws java.io.UnsupportedEncodingException
Extracts text from the response content starting from the end. Everything between (but not including) the specified list ofafter
andbefore
string objects will be returned.Supplying a
List<String>
of after values enables you to express more complicated extraction patterns. eggPlant Performance searches for the first string in the list, and searches for the second string after the position at which the first string was found. This continues until the final string is matched, after which the extracted response content is returned untilbefore
is matched.The following example demonstrates extracting text from a HTML Response.
Response response = request.send(); ExtractionCursor cursor = new ExtractionCursor(); // extract the selected value from the HTML text // <select> // <option value="volvo">Volvo</option> // <option value="saab">Saab</option> // <option value="vw">VW</option> // <option value="audi" selected>Audi</option> // </select> List<String> after = new ArrayList<String>(); after.add("</select>"); after.add("selected"); after.add("\""); String extractedText = response.extractFromEnd( cursor, after, "value=\"", "volvo", true, SearchFlags.SEARCH_IN_BOTH); if (cursor.succeeded()) { writeMessage(String.format("The value %s was found at position %d", extractedText, cursor.getIndex())); }
- Parameters:
cursor
- AnExtractionCursor
object to store the success/failure of the action, and the index in the response at which the match was found.after
- Each string in this List is searched for sequentially in the response content, and the returned string starts immediately before all the string objects have been matched in the content.before
- This text is searched for in the response content after theafter
text has been found, and the returned string ends immediately after this text occurs in the content.defaultValue
- The value to return if either thebefore
orafter
text cannot be found.caseSensitive
-true
if the search should be case-sensitive.matchFlags
- anSearchFlags
enumerated value to indicate what should be searched: SEARCH_IN_BODY, SEARCH_IN_HEADERS or SEARCH_IN_BOTH- Returns:
- The extracted text, or
defaultValue
if the extract failed. - Throws:
java.io.UnsupportedEncodingException
- The encoding is not supported
-
extractFromEnd
public java.lang.String extractFromEnd(ExtractionCursor cursor, java.util.List<java.lang.String> after, java.lang.String before, java.lang.String defaultValue, boolean caseSensitive) throws java.io.UnsupportedEncodingException
Extracts text from the response content starting from the end. Everything between (but not including) the specified list ofafter
andbefore
string objects will be returned.Supplying a
List<String>
of after values enables you to express more complicated extraction patterns. eggPlant Performance searches for the first string in the list, and searches for the second string after the position at which the first string was found. This continues until the final string is matched, after which the extracted response content is returned untilbefore
is matched.The following example demonstrates extracting text from a HTML Response.
Response response = request.send(); ExtractionCursor cursor = new ExtractionCursor(); // extract the selected value from the HTML text // <select> // <option value="volvo">Volvo</option> // <option value="saab">Saab</option> // <option value="vw">VW</option> // <option value="audi" selected>Audi</option> // </select> List<String> after = new ArrayList<String>(); after.add("</select>"); after.add("selected"); after.add("\""); String extractedText = response.extractFromEnd( cursor, after, "value=\"", "volvo", true); if (cursor.succeeded()) { writeMessage(String.format("The value %s was found at position %d", extractedText, cursor.getIndex())); }
- Parameters:
cursor
- AnExtractionCursor
object to store the success/failure of the action, and the index in the response at which the match was found.after
- Each string in this List is searched for sequentially in the response content, and the returned string starts immediately before all the string objects have been matched in the content.before
- This text is searched for in the response content after theafter
text has been found, and the returned string ends immediately after this text occurs in the content.defaultValue
- The value to return if either thebefore
orafter
text cannot be found.caseSensitive
-true
if the search should be case-sensitive.- Returns:
- The extracted text, or
defaultValue
if the extract failed. - Throws:
java.io.UnsupportedEncodingException
- The encoding is not supported
-
extractFromEnd
public java.lang.String extractFromEnd(ExtractionCursor cursor, java.util.List<java.lang.String> after, java.lang.String before, java.lang.String defaultValue) throws java.io.UnsupportedEncodingException
Extracts text from the response content starting from the end. Everything between (but not including) the specified list ofafter
andbefore
string objects will be returned.Supplying a
List<String>
of after values enables you to express more complicated extraction patterns. eggPlant Performance searches for the first string in the list, and searches for the second string after the position at which the first string was found. This continues until the final string is matched, after which the extracted response content is returned untilbefore
is matched.The following example demonstrates extracting text from a HTML Response.
Response response = request.send(); ExtractionCursor cursor = new ExtractionCursor(); // extract the selected value from the HTML text // <select> // <option value="volvo">Volvo</option> // <option value="saab">Saab</option> // <option value="vw">VW</option> // <option value="audi" selected>Audi</option> // </select> List<String> after = new ArrayList<String>(); after.add("</select>"); after.add("selected"); after.add("\""); String extractedText = response.extractFromEnd( cursor, after, "value=\"", "volvo"); if (cursor.succeeded()) { writeMessage(String.format("The value %s was found at position %d", extractedText, cursor.getIndex())); }
- Parameters:
cursor
- AnExtractionCursor
object to store the success/failure of the action, and the index in the response at which the match was found.after
- Each string in this List is searched for sequentially in the response content, and the returned string starts immediately before all the string objects have been matched in the content.before
- This text is searched for in the response content after theafter
text has been found, and the returned string ends immediately after this text occurs in the content.defaultValue
- The value to return if either thebefore
orafter
text cannot be found.- Returns:
- The extracted text, or
defaultValue
if the extract failed. - Throws:
java.io.UnsupportedEncodingException
- The encoding is not supported
-
extractFromEnd
public java.lang.String extractFromEnd(ExtractionCursor cursor, java.util.List<java.lang.String> after, java.lang.String before, boolean caseSensitive, SearchFlags matchFlags) throws java.io.UnsupportedEncodingException
Extracts text from the response content starting from the end. Everything between (but not including) the specified list ofafter
andbefore
string objects will be returned.Supplying a
List<String>
of after values enables you to express more complicated extraction patterns. eggPlant Performance searches for the first string in the list, and searches for the second string after the position at which the first string was found. This continues until the final string is matched, after which the extracted response content is returned untilbefore
is matched.The following example demonstrates extracting text from a HTML Response.
Response response = request.send(); ExtractionCursor cursor = new ExtractionCursor(); // extract the selected value from the HTML text // <select> // <option value="volvo">Volvo</option> // <option value="saab">Saab</option> // <option value="vw">VW</option> // <option value="audi" selected>Audi</option> // </select> List<String> after = new ArrayList<String>(); after.add("</select>"); after.add("selected"); after.add("\""); String extractedText = response.extractFromEnd( cursor, after, "value=\"", true, SearchFlags.SEARCH_IN_BOTH); if (cursor.succeeded()) { writeMessage(String.format("The value %s was found at position %d", extractedText, cursor.getIndex())); }
- Parameters:
cursor
- AnExtractionCursor
object to store the success/failure of the action, and the index in the response at which the match was found.after
- Each string in this List is searched for sequentially in the response content, and the returned string starts immediately before all the string objects have been matched in the content.before
- This text is searched for in the response content after theafter
text has been found, and the returned string ends immediately after this text occurs in the content.caseSensitive
-true
if the search should be case-sensitive.matchFlags
- anSearchFlags
enumerated value to indicate what should be searched: SEARCH_IN_BODY, SEARCH_IN_HEADERS or SEARCH_IN_BOTH- Returns:
- The extracted text, or an empty string if the extract failed.
- Throws:
java.io.UnsupportedEncodingException
- The encoding is not supported
-
extractFromEnd
public java.lang.String extractFromEnd(ExtractionCursor cursor, java.util.List<java.lang.String> after, java.lang.String before, boolean caseSensitive) throws java.io.UnsupportedEncodingException
Extracts text from the response content starting from the end. Everything between (but not including) the specified list ofafter
andbefore
string objects will be returned.Supplying a
List<String>
of after values enables you to express more complicated extraction patterns. eggPlant Performance searches for the first string in the list, and searches for the second string after the position at which the first string was found. This continues until the final string is matched, after which the extracted response content is returned untilbefore
is matched.The following example demonstrates extracting text from a HTML Response.
Response response = request.send(); ExtractionCursor cursor = new ExtractionCursor(); // extract the selected value from the HTML text // <select> // <option value="volvo">Volvo</option> // <option value="saab">Saab</option> // <option value="vw">VW</option> // <option value="audi" selected>Audi</option> // </select> List<String> after = new ArrayList<String>(); after.add("</select>"); after.add("selected"); after.add("\""); String extractedText = response.extractFromEnd( cursor, after, "value=\"", true); if (cursor.succeeded()) { writeMessage(String.format("The value %s was found at position %d", extractedText, cursor.getIndex())); }
- Parameters:
cursor
- AnExtractionCursor
object to store the success/failure of the action, and the index in the response at which the match was found.after
- Each string in this List is searched for sequentially in the response content, and the returned string starts immediately before all the string objects have been matched in the content.before
- This text is searched for in the response content after theafter
text has been found, and the returned string ends immediately after this text occurs in the content.caseSensitive
-true
if the search should be case-sensitive.- Returns:
- The extracted text, or an empty string if the extract failed.
- Throws:
java.io.UnsupportedEncodingException
- The encoding is not supported
-
extractFromEnd
public java.lang.String extractFromEnd(ExtractionCursor cursor, java.util.List<java.lang.String> after, java.lang.String before) throws java.io.UnsupportedEncodingException
Extracts text from the response content starting from the end. Everything between (but not including) the specified list ofafter
andbefore
string objects will be returned.Supplying a
List<String>
of after values enables you to express more complicated extraction patterns. eggPlant Performance searches for the first string in the list, and searches for the second string after the position at which the first string was found. This continues until the final string is matched, after which the extracted response content is returned untilbefore
is matched.The following example demonstrates extracting text from a HTML Response.
Response response = request.send(); ExtractionCursor cursor = new ExtractionCursor(); // extract the selected value from the HTML text // <select> // <option value="volvo">Volvo</option> // <option value="saab">Saab</option> // <option value="vw">VW</option> // <option value="audi" selected>Audi</option> // </select> List<String> after = new ArrayList<String>(); after.add("</select>"); after.add("selected"); after.add("\""); String extractedText = response.extractFromEnd( cursor, after, "value=\""); if (cursor.succeeded()) { writeMessage(String.format("The value %s was found at position %d", extractedText, cursor.getIndex())); }
- Parameters:
cursor
- AnExtractionCursor
object to store the success/failure of the action, and the index in the response at which the match was found.after
- Each string in this List is searched for sequentially in the response content, and the returned string starts immediately before all the string objects have been matched in the content.before
- This text is searched for in the response content after theafter
text has been found, and the returned string ends immediately after this text occurs in the content.- Returns:
- The extracted text, or an empty string if the extract failed.
- Throws:
java.io.UnsupportedEncodingException
- The encoding is not supported
-
extractFromEnd
public java.lang.String extractFromEnd(ExtractionCursor cursor, java.util.List<java.lang.String> after, java.lang.String before, ActionType failAction, boolean caseSensitive, SearchFlags matchFlags) throws java.lang.Exception, java.io.UnsupportedEncodingException
Extracts text from the response content starting from the end. Everything between (but not including) the specified list ofafter
andbefore
string objects will be returned.Supplying a
List<String>
of after values enables you to express more complicated extraction patterns. eggPlant Performance searches for the first string in the list, and searches for the second string after the position at which the first string was found. This continues until the final string is matched, after which the extracted response content is returned untilbefore
is matched.The following example demonstrates extracting text from a HTML Response.
Response response = request.send(); ExtractionCursor cursor = new ExtractionCursor(); // extract the selected value from the HTML text // <select> // <option value="volvo">Volvo</option> // <option value="saab">Saab</option> // <option value="vw">VW</option> // <option value="audi" selected>Audi</option> // </select> List<String> after = new ArrayList<String>(); after.add("</select>"); after.add("selected"); after.add("\""); String extractedText = response.extractFromEnd( cursor, after, "value=\"",, ActionType.ACT_WARNING true, SearchFlags.SEARCH_IN_BOTH); if (cursor.succeeded()) { writeMessage(String.format("The value %s was found at position %d", extractedText, cursor.getIndex())); }
- Parameters:
cursor
- AnExtractionCursor
object to store the success/failure of the action, and the index in the response at which the match was found.after
- Each string in this List is searched for sequentially in the response content, and the returned string starts immediately before all the string objects have been matched in the content.before
- This text is searched for in the response content after theafter
text has been found, and the returned string ends immediately after this text occurs in the content.failAction
- the action to take iftext
cannot be foundcaseSensitive
-true
if the search should be case-sensitive.matchFlags
- anSearchFlags
enumerated value to indicate what should be searched: SEARCH_IN_BODY, SEARCH_IN_HEADERS or SEARCH_IN_BOTH- Returns:
- The extracted text, or an empty string if the extract failed.
- Throws:
java.io.UnsupportedEncodingException
- The encoding is not supportedjava.lang.Exception
-
extractFromEnd
public java.lang.String extractFromEnd(ExtractionCursor cursor, java.util.List<java.lang.String> after, java.lang.String before, ActionType failAction, boolean caseSensitive) throws java.lang.Exception, java.io.UnsupportedEncodingException
Extracts text from the response content starting from the end. Everything between (but not including) the specified list ofafter
andbefore
string objects will be returned.Supplying a
List<String>
of after values enables you to express more complicated extraction patterns. eggPlant Performance searches for the first string in the list, and searches for the second string after the position at which the first string was found. This continues until the final string is matched, after which the extracted response content is returned untilbefore
is matched.The following example demonstrates extracting text from a HTML Response.
Response response = request.send(); ExtractionCursor cursor = new ExtractionCursor(); // extract the selected value from the HTML text // <select> // <option value="volvo">Volvo</option> // <option value="saab">Saab</option> // <option value="vw">VW</option> // <option value="audi" selected>Audi</option> // </select> List<String> after = new ArrayList<String>(); after.add("</select>"); after.add("selected"); after.add("\""); String extractedText = response.extractFromEnd( cursor, after, "value=\"",, ActionType.ACT_WARNING true); if (cursor.succeeded()) { writeMessage(String.format("The value %s was found at position %d", extractedText, cursor.getIndex())); }
- Parameters:
cursor
- AnExtractionCursor
object to store the success/failure of the action, and the index in the response at which the match was found.after
- Each string in this List is searched for sequentially in the response content, and the returned string starts immediately before all the string objects have been matched in the content.before
- This text is searched for in the response content after theafter
text has been found, and the returned string ends immediately after this text occurs in the content.failAction
- the action to take iftext
cannot be foundcaseSensitive
-true
if the search should be case-sensitive.- Returns:
- The extracted text, or an empty string if the extract failed.
- Throws:
java.io.UnsupportedEncodingException
- The encoding is not supportedjava.lang.Exception
-
extractFromEnd
public java.lang.String extractFromEnd(ExtractionCursor cursor, java.util.List<java.lang.String> after, java.lang.String before, ActionType failAction) throws java.lang.Exception, java.io.UnsupportedEncodingException
Extracts text from the response content starting from the end. Everything between (but not including) the specified list ofafter
andbefore
string objects will be returned.Supplying a
List<String>
of after values enables you to express more complicated extraction patterns. eggPlant Performance searches for the first string in the list, and searches for the second string after the position at which the first string was found. This continues until the final string is matched, after which the extracted response content is returned untilbefore
is matched.The following example demonstrates extracting text from a HTML Response.
Response response = request.send(); ExtractionCursor cursor = new ExtractionCursor(); // extract the selected value from the HTML text // <select> // <option value="volvo">Volvo</option> // <option value="saab">Saab</option> // <option value="vw">VW</option> // <option value="audi" selected>Audi</option> // </select> List<String> after = new ArrayList<String>(); after.add("</select>"); after.add("selected"); after.add("\""); String extractedText = response.extractFromEnd( cursor, after, "value=\"", ActionType.ACT_WARNING); if (cursor.succeeded()) { writeMessage(String.format("The value %s was found at position %d", extractedText, cursor.getIndex())); }
- Parameters:
cursor
- AnExtractionCursor
object to store the success/failure of the action, and the index in the response at which the match was found.after
- Each string in this List is searched for sequentially in the response content, and the returned string starts immediately before all the string objects have been matched in the content.before
- This text is searched for in the response content after theafter
text has been found, and the returned string ends immediately after this text occurs in the content.failAction
- the action to take iftext
cannot be found- Returns:
- The extracted text, or an empty string if the extract failed.
- Throws:
java.io.UnsupportedEncodingException
- The encoding is not supportedjava.lang.Exception
-
extractFromEnd
public java.lang.String extractFromEnd(java.lang.String after, java.lang.String before, java.lang.String defaultValue, boolean caseSensitive, SearchFlags matchFlags) throws java.io.UnsupportedEncodingException
Extracts text from the response content, starting from the end. Everything between (but not including) the specifiedafter
andbefore
string objects will be returned. If either value cannot be found, thedefaultValue
will be returned.The following example demonstrates extracting text from a HTML Response.
Response response = request.send(); // extract the value from the HTML text // <input type="text" name="f_customer" size="32" maxlength="32" value="Joe Smith"> String extractedText = response.extractFromEnd( "\"", "value=\"", "Joe Jones", true, SearchFlags.SEARCH_IN_BOTH);
- Parameters:
after
- This text is searched for in the response content, and the returned string starts immediately before this text occurs in the content.before
- This text is searched for in the response content after theafter
text has been found, and the returned string ends immediately after this text occurs in the content.defaultValue
- The value to return if either thebefore
orafter
text cannot be found.caseSensitive
-true
if the search should be case-sensitive.matchFlags
- anSearchFlags
enumerated value to indicate what should be searched: SEARCH_IN_BODY, SEARCH_IN_HEADERS or SEARCH_IN_BOTH- Returns:
- The extracted text, or
defaultValue
if the extract failed. - Throws:
java.io.UnsupportedEncodingException
- The encoding is not supported
-
extractFromEnd
public java.lang.String extractFromEnd(java.lang.String after, java.lang.String before, java.lang.String defaultValue, boolean caseSensitive) throws java.io.UnsupportedEncodingException
Extracts text from the response content, starting from the end. Everything between (but not including) the specifiedafter
andbefore
string objects will be returned. If either value cannot be found, thedefaultValue
will be returned.The following example demonstrates extracting text from a HTML Response.
Response response = request.send(); // extract the value from the HTML text // <input type="text" name="f_customer" size="32" maxlength="32" value="Joe Smith"> String extractedText = response.extractFromEnd( "\"", "value=\"", "Joe Jones", true);
- Parameters:
after
- This text is searched for in the response content, and the returned string starts immediately before this text occurs in the content.before
- This text is searched for in the response content after theafter
text has been found, and the returned string ends immediately after this text occurs in the content.defaultValue
- The value to return if either thebefore
orafter
text cannot be found.caseSensitive
-true
if the search should be case-sensitive.- Returns:
- The extracted text, or
defaultValue
if the extract failed. - Throws:
java.io.UnsupportedEncodingException
- The encoding is not supported
-
extractFromEnd
public java.lang.String extractFromEnd(java.lang.String after, java.lang.String before, java.lang.String defaultValue) throws java.io.UnsupportedEncodingException
Extracts text from the response content, starting from the end. Everything between (but not including) the specifiedafter
andbefore
string objects will be returned. If either value cannot be found, thedefaultValue
will be returned.The following example demonstrates extracting text from a HTML Response.
Response response = request.send(); // extract the value from the HTML text // <input type="text" name="f_customer" size="32" maxlength="32" value="Joe Smith"> String extractedText = response.extractFromEnd( "\"", "value=\"", "Joe Jones");
- Parameters:
after
- This text is searched for in the response content, and the returned string starts immediately before this text occurs in the content.before
- This text is searched for in the response content after theafter
text has been found, and the returned string ends immediately after this text occurs in the content.defaultValue
- The value to return if either thebefore
orafter
text cannot be found.- Returns:
- The extracted text, or
defaultValue
if the extract failed. - Throws:
java.io.UnsupportedEncodingException
- The encoding is not supported
-
extractFromEnd
public java.lang.String extractFromEnd(java.lang.String after, java.lang.String before, boolean caseSensitive, SearchFlags matchFlags) throws java.io.UnsupportedEncodingException
Extracts text from the response content, starting from the end. Everything between (but not including) the specifiedafter
andbefore
string objects will be returned.The following example demonstrates extracting text from a HTML Response.
Response response = request.send(); // extract the value from the HTML text // <input type="text" name="f_customer" size="32" maxlength="32" value="Joe Smith"> String extractedText = response.extractFromEnd( "\"", "value=\"", true, SearchFlags.SEARCH_IN_BOTH);
- Parameters:
after
- This text is searched for in the response content, and the returned string starts immediately before this text occurs in the content.before
- This text is searched for in the response content after theafter
text has been found, and the returned string ends immediately after this text occurs in the content.caseSensitive
-true
if the search should be case-sensitive.matchFlags
- anSearchFlags
enumerated value to indicate what should be searched: SEARCH_IN_BODY, SEARCH_IN_HEADERS or SEARCH_IN_BOTH- Returns:
- The extracted text, or an empty string if the extract failed.
- Throws:
java.io.UnsupportedEncodingException
- The encoding is not supported
-
extractFromEnd
public java.lang.String extractFromEnd(java.lang.String after, java.lang.String before, boolean caseSensitive) throws java.io.UnsupportedEncodingException
Extracts text from the response content, starting from the end. Everything between (but not including) the specifiedafter
andbefore
string objects will be returned.The following example demonstrates extracting text from a HTML Response.
Response response = request.send(); // extract the value from the HTML text // <input type="text" name="f_customer" size="32" maxlength="32" value="Joe Smith"> String extractedText = response.extractFromEnd( "\"", "value=\"", true);
- Parameters:
after
- This text is searched for in the response content, and the returned string starts immediately before this text occurs in the content.before
- This text is searched for in the response content after theafter
text has been found, and the returned string ends immediately after this text occurs in the content.caseSensitive
-true
if the search should be case-sensitive.- Returns:
- The extracted text, or an empty string if the extract failed.
- Throws:
java.io.UnsupportedEncodingException
- The encoding is not supported
-
extractFromEnd
public java.lang.String extractFromEnd(java.lang.String after, java.lang.String before) throws java.io.UnsupportedEncodingException
Extracts text from the response content, starting from the end. Everything between (but not including) the specifiedafter
andbefore
string objects will be returned.The following example demonstrates extracting text from a HTML Response.
Response response = request.send(); // extract the value from the HTML text // <input type="text" name="f_customer" size="32" maxlength="32" value="Joe Smith"> String extractedText = response.extractFromEnd( "\"", "value=\"");
- Parameters:
after
- This text is searched for in the response content, and the returned string starts immediately before this text occurs in the content.before
- This text is searched for in the response content after theafter
text has been found, and the returned string ends immediately after this text occurs in the content.- Returns:
- The extracted text, or an empty string if the extract failed.
- Throws:
java.io.UnsupportedEncodingException
- The encoding is not supported
-
extractFromEnd
public java.lang.String extractFromEnd(java.lang.String after, java.lang.String before, ActionType failAction, boolean caseSensitive, SearchFlags matchFlags) throws java.lang.Exception, java.io.UnsupportedEncodingException
Extracts text from the response content, starting from the end. Everything between (but not including) the specifiedafter
andbefore
string objects will be returned.The following example demonstrates extracting text from a HTML Response.
Response response = request.send(); // extract the value from the HTML text // <input type="text" name="f_customer" size="32" maxlength="32" value="Joe Smith"> String extractedText = response.extractFromEnd( "\"", "value=\"", ActionType.ACT_WARNING, true, SearchFlags.SEARCH_IN_BOTH);
- Parameters:
after
- This text is searched for in the response content, and the returned string starts immediately before this text occurs in the content.before
- This text is searched for in the response content after theafter
text has been found, and the returned string ends immediately after this text occurs in the content.failAction
- the action to take iftext
cannot be foundcaseSensitive
-true
if the search should be case-sensitive.matchFlags
- anSearchFlags
enumerated value to indicate what should be searched: SEARCH_IN_BODY, SEARCH_IN_HEADERS or SEARCH_IN_BOTH- Returns:
- The extracted text, or an empty string if the extract failed.
- Throws:
java.io.UnsupportedEncodingException
- The encoding is not supportedjava.lang.Exception
-
extractFromEnd
public java.lang.String extractFromEnd(java.lang.String after, java.lang.String before, ActionType failAction, boolean caseSensitive) throws java.lang.Exception, java.io.UnsupportedEncodingException
Extracts text from the response content, starting from the end. Everything between (but not including) the specifiedafter
andbefore
string objects will be returned.The following example demonstrates extracting text from a HTML Response.
Response response = request.send(); // extract the value from the HTML text // <input type="text" name="f_customer" size="32" maxlength="32" value="Joe Smith"> String extractedText = response.extractFromEnd( "\"", "value=\"", ActionType.ACT_WARNING, true);
- Parameters:
after
- This text is searched for in the response content, and the returned string starts immediately before this text occurs in the content.before
- This text is searched for in the response content after theafter
text has been found, and the returned string ends immediately after this text occurs in the content.failAction
- the action to take iftext
cannot be foundcaseSensitive
-true
if the search should be case-sensitive.- Returns:
- The extracted text, or an empty string if the extract failed.
- Throws:
java.io.UnsupportedEncodingException
- The encoding is not supportedjava.lang.Exception
-
extractFromEnd
public java.lang.String extractFromEnd(java.lang.String after, java.lang.String before, ActionType failAction) throws java.lang.Exception, java.io.UnsupportedEncodingException
Extracts text from the response content, starting from the end. Everything between (but not including) the specifiedafter
andbefore
string objects will be returned.The following example demonstrates extracting text from a HTML Response.
Response response = request.send(); // extract the value from the HTML text // <input type="text" name="f_customer" size="32" maxlength="32" value="Joe Smith"> String extractedText = response.extractFromEnd( "\"", "value=\"", ActionType.ACT_WARNING);
- Parameters:
after
- This text is searched for in the response content, and the returned string starts immediately before this text occurs in the content.before
- This text is searched for in the response content after theafter
text has been found, and the returned string ends immediately after this text occurs in the content.failAction
- the action to take iftext
cannot be found- Returns:
- The extracted text, or an empty string if the extract failed.
- Throws:
java.io.UnsupportedEncodingException
- The encoding is not supportedjava.lang.Exception
-
extractFromEnd
public java.lang.String extractFromEnd(java.util.List<java.lang.String> after, java.lang.String before, java.lang.String defaultValue, boolean caseSensitive, SearchFlags matchFlags) throws java.io.UnsupportedEncodingException
Extracts text from the response content starting from the end. Everything between (but not including) the specified list ofafter
andbefore
string objects will be returned.Supplying a
List<String>
of after values enables you to express more complicated extraction patterns. eggPlant Performance searches for the first string in the list, and searches for the second string after the position at which the first string was found. This continues until the final string is matched, after which the extracted response content is returned untilbefore
is matched.The following example demonstrates extracting text from a HTML Response.
Response response = request.send(); // extract the selected value from the HTML text // <select> // <option value="volvo">Volvo</option> // <option value="saab">Saab</option> // <option value="vw">VW</option> // <option value="audi" selected>Audi</option> // </select> List<String> after = new ArrayList<String>(); after.add("</select>"); after.add("selected"); after.add("\""); String extractedText = response.extractFromEnd( after, "value=\"", "volvo", true, SearchFlags.SEARCH_IN_BOTH);
- Parameters:
after
- Each string in this List is searched for sequentially in the response content, and the returned string starts immediately before all the string objects have been matched in the content.before
- This text is searched for in the response content after theafter
text has been found, and the returned string ends immediately after this text occurs in the content.defaultValue
- The value to return if either thebefore
orafter
text cannot be found.caseSensitive
-true
if the search should be case-sensitive.matchFlags
- anSearchFlags
enumerated value to indicate what should be searched: SEARCH_IN_BODY, SEARCH_IN_HEADERS or SEARCH_IN_BOTH- Returns:
- The extracted text, or
defaultValue
if the extract failed. - Throws:
java.io.UnsupportedEncodingException
- The encoding is not supported
-
extractFromEnd
public java.lang.String extractFromEnd(java.util.List<java.lang.String> after, java.lang.String before, java.lang.String defaultValue, boolean caseSensitive) throws java.io.UnsupportedEncodingException
Extracts text from the response content starting from the end. Everything between (but not including) the specified list ofafter
andbefore
string objects will be returned.Supplying a
List<String>
of after values enables you to express more complicated extraction patterns. eggPlant Performance searches for the first string in the list, and searches for the second string after the position at which the first string was found. This continues until the final string is matched, after which the extracted response content is returned untilbefore
is matched.The following example demonstrates extracting text from a HTML Response.
Response response = request.send(); // extract the selected value from the HTML text // <select> // <option value="volvo">Volvo</option> // <option value="saab">Saab</option> // <option value="vw">VW</option> // <option value="audi" selected>Audi</option> // </select> List<String> after = new ArrayList<String>(); after.add("</select>"); after.add("selected"); after.add("\""); String extractedText = response.extractFromEnd( after, "value=\"", "volvo", true);
- Parameters:
after
- Each string in this List is searched for sequentially in the response content, and the returned string starts immediately before all the string objects have been matched in the content.before
- This text is searched for in the response content after theafter
text has been found, and the returned string ends immediately after this text occurs in the content.defaultValue
- The value to return if either thebefore
orafter
text cannot be found.caseSensitive
-true
if the search should be case-sensitive.- Returns:
- The extracted text, or
defaultValue
if the extract failed. - Throws:
java.io.UnsupportedEncodingException
- The encoding is not supported
-
extractFromEnd
public java.lang.String extractFromEnd(java.util.List<java.lang.String> after, java.lang.String before, java.lang.String defaultValue) throws java.io.UnsupportedEncodingException
Extracts text from the response content starting from the end. Everything between (but not including) the specified list ofafter
andbefore
string objects will be returned.Supplying a
List<String>
of after values enables you to express more complicated extraction patterns. eggPlant Performance searches for the first string in the list, and searches for the second string after the position at which the first string was found. This continues until the final string is matched, after which the extracted response content is returned untilbefore
is matched.The following example demonstrates extracting text from a HTML Response.
Response response = request.send(); // extract the selected value from the HTML text // <select> // <option value="volvo">Volvo</option> // <option value="saab">Saab</option> // <option value="vw">VW</option> // <option value="audi" selected>Audi</option> // </select> List<String> after = new ArrayList<String>(); after.add("</select>"); after.add("selected"); after.add("\""); String extractedText = response.extractFromEnd( after, "value=\"", "volvo");
- Parameters:
after
- Each string in this List is searched for sequentially in the response content, and the returned string starts immediately before all the string objects have been matched in the content.before
- This text is searched for in the response content after theafter
text has been found, and the returned string ends immediately after this text occurs in the content.defaultValue
- The value to return if either thebefore
orafter
text cannot be found.- Returns:
- The extracted text, or
defaultValue
if the extract failed. - Throws:
java.io.UnsupportedEncodingException
- The encoding is not supported
-
extractFromEnd
public java.lang.String extractFromEnd(java.util.List<java.lang.String> after, java.lang.String before, boolean caseSensitive, SearchFlags matchFlags) throws java.io.UnsupportedEncodingException
Extracts text from the response content starting from the end. Everything between (but not including) the specified list ofafter
andbefore
string objects will be returned.Supplying a
List<String>
of after values enables you to express more complicated extraction patterns. eggPlant Performance searches for the first string in the list, and searches for the second string after the position at which the first string was found. This continues until the final string is matched, after which the extracted response content is returned untilbefore
is matched.The following example demonstrates extracting text from a HTML Response.
Response response = request.send(); // extract the selected value from the HTML text // <select> // <option value="volvo">Volvo</option> // <option value="saab">Saab</option> // <option value="vw">VW</option> // <option value="audi" selected>Audi</option> // </select> List<String> after = new ArrayList<String>(); after.add("</select>"); after.add("selected"); after.add("\""); String extractedText = response.extractFromEnd( after, "value=\"", true, SearchFlags.SEARCH_IN_BOTH);
- Parameters:
after
- Each string in this List is searched for sequentially in the response content, and the returned string starts immediately before all the string objects have been matched in the content.before
- This text is searched for in the response content after theafter
text has been found, and the returned string ends immediately after this text occurs in the content.caseSensitive
-true
if the search should be case-sensitive.matchFlags
- anSearchFlags
enumerated value to indicate what should be searched: SEARCH_IN_BODY, SEARCH_IN_HEADERS or SEARCH_IN_BOTH- Returns:
- The extracted text, or an empty string if the extract failed.
- Throws:
java.io.UnsupportedEncodingException
- The encoding is not supported
-
extractFromEnd
public java.lang.String extractFromEnd(java.util.List<java.lang.String> after, java.lang.String before, boolean caseSensitive) throws java.io.UnsupportedEncodingException
Extracts text from the response content starting from the end. Everything between (but not including) the specified list ofafter
andbefore
string objects will be returned.Supplying a
List<String>
of after values enables you to express more complicated extraction patterns. eggPlant Performance searches for the first string in the list, and searches for the second string after the position at which the first string was found. This continues until the final string is matched, after which the extracted response content is returned untilbefore
is matched.The following example demonstrates extracting text from a HTML Response.
Response response = request.send(); // extract the selected value from the HTML text // <select> // <option value="volvo">Volvo</option> // <option value="saab">Saab</option> // <option value="vw">VW</option> // <option value="audi" selected>Audi</option> // </select> List<String> after = new ArrayList<String>(); after.add("</select>"); after.add("selected"); after.add("\""); String extractedText = response.extractFromEnd( after, "value=\"", true);
- Parameters:
after
- Each string in this List is searched for sequentially in the response content, and the returned string starts immediately before all the string objects have been matched in the content.before
- This text is searched for in the response content after theafter
text has been found, and the returned string ends immediately after this text occurs in the content.caseSensitive
-true
if the search should be case-sensitive.- Returns:
- The extracted text, or an empty string if the extract failed.
- Throws:
java.io.UnsupportedEncodingException
- The encoding is not supported
-
extractFromEnd
public java.lang.String extractFromEnd(java.util.List<java.lang.String> after, java.lang.String before) throws java.io.UnsupportedEncodingException
Extracts text from the response content starting from the end. Everything between (but not including) the specified list ofafter
andbefore
string objects will be returned.Supplying a
List<String>
of after values enables you to express more complicated extraction patterns. eggPlant Performance searches for the first string in the list, and searches for the second string after the position at which the first string was found. This continues until the final string is matched, after which the extracted response content is returned untilbefore
is matched.The following example demonstrates extracting text from a HTML Response.
Response response = request.send(); // extract the selected value from the HTML text // <select> // <option value="volvo">Volvo</option> // <option value="saab">Saab</option> // <option value="vw">VW</option> // <option value="audi" selected>Audi</option> // </select> List<String> after = new ArrayList<String>(); after.add("</select>"); after.add("selected"); after.add("\""); String extractedText = response.extractFromEnd( after, "value=\"");
- Parameters:
after
- Each string in this List is searched for sequentially in the response content, and the returned string starts immediately before all the string objects have been matched in the content.before
- This text is searched for in the response content after theafter
text has been found, and the returned string ends immediately after this text occurs in the content.- Returns:
- The extracted text, or an empty string if the extract failed.
- Throws:
java.io.UnsupportedEncodingException
- The encoding is not supported
-
extractFromEnd
public java.lang.String extractFromEnd(java.util.List<java.lang.String> after, java.lang.String before, ActionType failAction, boolean caseSensitive, SearchFlags matchFlags) throws java.lang.Exception, java.io.UnsupportedEncodingException
Extracts text from the response content starting from the end. Everything between (but not including) the specified list ofafter
andbefore
string objects will be returned.Supplying a
List<String>
of after values enables you to express more complicated extraction patterns. eggPlant Performance searches for the first string in the list, and searches for the second string after the position at which the first string was found. This continues until the final string is matched, after which the extracted response content is returned untilbefore
is matched.The following example demonstrates extracting text from a HTML Response.
Response response = request.send(); // extract the selected value from the HTML text // <select> // <option value="volvo">Volvo</option> // <option value="saab">Saab</option> // <option value="vw">VW</option> // <option value="audi" selected>Audi</option> // </select> List<String> after = new ArrayList<String>(); after.add("</select>"); after.add("selected"); after.add("\""); String extractedText = response.extractFromEnd( after, "value=\"", ActionType.ACT_WARNING, true, SearchFlags.SEARCH_IN_BOTH);
- Parameters:
after
- Each string in this List is searched for sequentially in the response content, and the returned string starts immediately before all the string objects have been matched in the content.before
- This text is searched for in the response content after theafter
text has been found, and the returned string ends immediately after this text occurs in the content.failAction
- the action to take iftext
cannot be foundcaseSensitive
-true
if the search should be case-sensitive.matchFlags
- anSearchFlags
enumerated value to indicate what should be searched: SEARCH_IN_BODY, SEARCH_IN_HEADERS or SEARCH_IN_BOTH- Returns:
- The extracted text, or an empty string if the extract failed.
- Throws:
java.io.UnsupportedEncodingException
- The encoding is not supportedjava.lang.Exception
-
extractFromEnd
public java.lang.String extractFromEnd(java.util.List<java.lang.String> after, java.lang.String before, ActionType failAction, boolean caseSensitive) throws java.lang.Exception, java.io.UnsupportedEncodingException
Extracts text from the response content starting from the end. Everything between (but not including) the specified list ofafter
andbefore
string objects will be returned.Supplying a
List<String>
of after values enables you to express more complicated extraction patterns. eggPlant Performance searches for the first string in the list, and searches for the second string after the position at which the first string was found. This continues until the final string is matched, after which the extracted response content is returned untilbefore
is matched.The following example demonstrates extracting text from a HTML Response.
Response response = request.send(); // extract the selected value from the HTML text // <select> // <option value="volvo">Volvo</option> // <option value="saab">Saab</option> // <option value="vw">VW</option> // <option value="audi" selected>Audi</option> // </select> List<String> after = new ArrayList<String>(); after.add("</select>"); after.add("selected"); after.add("\""); String extractedText = response.extractFromEnd( after, "value=\"", ActionType.ACT_WARNING, true);
- Parameters:
after
- Each string in this List is searched for sequentially in the response content, and the returned string starts immediately before all the string objects have been matched in the content.before
- This text is searched for in the response content after theafter
text has been found, and the returned string ends immediately after this text occurs in the content.failAction
- the action to take iftext
cannot be foundcaseSensitive
-true
if the search should be case-sensitive.- Returns:
- The extracted text, or an empty string if the extract failed.
- Throws:
java.io.UnsupportedEncodingException
- The encoding is not supportedjava.lang.Exception
-
extractFromEnd
public java.lang.String extractFromEnd(java.util.List<java.lang.String> after, java.lang.String before, ActionType failAction) throws java.lang.Exception, java.io.UnsupportedEncodingException
Extracts text from the response content starting from the end. Everything between (but not including) the specified list ofafter
andbefore
string objects will be returned.Supplying a
List<String>
of after values enables you to express more complicated extraction patterns. eggPlant Performance searches for the first string in the list, and searches for the second string after the position at which the first string was found. This continues until the final string is matched, after which the extracted response content is returned untilbefore
is matched.The following example demonstrates extracting text from a HTML Response.
Response response = request.send(); // extract the selected value from the HTML text // <select> // <option value="volvo">Volvo</option> // <option value="saab">Saab</option> // <option value="vw">VW</option> // <option value="audi" selected>Audi</option> // </select> List<String> after = new ArrayList<String>(); after.add("</select>"); after.add("selected"); after.add("\""); String extractedText = response.extractFromEnd( after, "value=\"", ActionType.ACT_WARNING);
- Parameters:
after
- Each string in this List is searched for sequentially in the response content, and the returned string starts immediately before all the string objects have been matched in the content.before
- This text is searched for in the response content after theafter
text has been found, and the returned string ends immediately after this text occurs in the content.failAction
- the action to take iftext
cannot be found- Returns:
- The extracted text, or an empty string if the extract failed.
- Throws:
java.io.UnsupportedEncodingException
- The encoding is not supportedjava.lang.Exception
-
extractList
public java.util.List<java.lang.String> extractList(java.lang.String before, java.lang.String after, boolean caseSensitive, int maxItems) throws java.io.UnsupportedEncodingException, com.facilita.exception.InternalError
Extracts a list of items from thisResponse
, specifying whether the search should be case-sensitive, and the maximum number of items to extract.A search is made for multiple occurrences of the
before
andafter
markers. The text between each occurrence of the markers is extracted and appended to the list.// The response contains the following text within its body // <select> // <option value="volvo">Volvo</option> // <option value="saab">Saab</option> // <option value="mercedes">Mercedes</option> // <option value="audi">Audi</option> // </select> // Searching from the beginning of the web page extract all car model items List<String> matchedStrings = response.extractList("<option value=\"", "\">", true, 10); // contents of matchedStrings = ( volvo, saab, mercedes, audi )
- Parameters:
before
- aString
before an item to be extractedafter
- aString
after an item to be extractedcaseSensitive
-true
if the search should be case-sensitivemaxItems
- the maximum number of items to extract- Returns:
- a list containing the extracted
String
objects - Throws:
java.io.UnsupportedEncodingException
- The encoding is not supportedcom.facilita.exception.InternalError
- An internal error occurred- See Also:
extract(ExtractionCursor, String, String)
,extractRegExp(ExtractionCursor, String)
-
extractList
public java.util.List<java.lang.String> extractList(java.lang.String before, java.lang.String after, boolean caseSensitive) throws java.io.UnsupportedEncodingException, com.facilita.exception.InternalError
Extracts a list of items from thisResponse
, specifying whether the search should be case-sensitive.A search is made for multiple occurrences of the
before
andafter
markers. The text between each occurrence of the markers is extracted and appended to the list.// The response contains the following text within its body // <select> // <option value="volvo">Volvo</option> // <option value="saab">Saab</option> // <option value="mercedes">Mercedes</option> // <option value="audi">Audi</option> // </select> // Searching from the beginning of the web page extract all car model items List<String> matchedStrings = response.extractList("<option value=\"", "\">",true); // contents of matchedStrings = ( volvo, saab, mercedes, audi )
- Parameters:
before
- aString
occurring immediately before an item to be extractedafter
- aString
occurring immediately after an item to be extractedcaseSensitive
-true
if the search should be case-sensitive- Returns:
- a list containing the extracted
String
objects - Throws:
java.io.UnsupportedEncodingException
- The encoding is not supportedcom.facilita.exception.InternalError
- An internal error occurred- See Also:
extract(ExtractionCursor, String, String)
,extractRegExp(ExtractionCursor, String)
-
extractList
public java.util.List<java.lang.String> extractList(java.lang.String before, java.lang.String after) throws java.io.UnsupportedEncodingException, com.facilita.exception.InternalError
Extracts a list of items from thisResponse
.A search is made for multiple occurrences of the
before
andafter
markers. The text between each occurrence of the markers is extracted and appended to the list.// The response contains the following text within its body // <select> // <option value="volvo">Volvo</option> // <option value="saab">Saab</option> // <option value="mercedes">Mercedes</option> // <option value="audi">Audi</option> // </select> // Searching from the beginning of the web page extract all car model items List<String> matchedStrings = response.extractList("<option value=\"", "\">"); // contents of matchedStrings = ( volvo, saab, mercedes, audi )
- Parameters:
before
- aString
occurring immediately before an item to be extractedafter
- aString
occurring immediately after an item to be extracted- Returns:
- a list containing the extracted
String
objects - Throws:
java.io.UnsupportedEncodingException
- The encoding is not supportedcom.facilita.exception.InternalError
- An internal error occurred- See Also:
extract(ExtractionCursor, String, String)
,extractRegExp(ExtractionCursor, String)
-
extractList
public java.util.List<java.lang.String> extractList(ExtractionCursor cursor, java.lang.String before, java.lang.String after, java.lang.String endAt, boolean caseSensitive, int maxItems) throws java.io.UnsupportedEncodingException, com.facilita.exception.InternalError
Extracts a list of items from thisResponse
.A search is made for multiple occurrences of the
before
andafter
markers. The text between each occurrence of the markers is extracted and appended to the list.// The response contains the following text within its body // <select> // <option value="volvo">Volvo</option> // <option value="saab">Saab</option> // <option value="mercedes">Mercedes</option> // <option value="audi">Audi</option> // </select> // Searching from the position marked by the Extraction Cursor, extract the first 2 car model items ExtractionCursor cursor = new ExtractionCursor(); List<String> matchedStrings = response.extractList(cursor, "<option value=\"", "\">","mercedes", true, 2); // contents of matchedStrings = ( volvo, saab )
- Parameters:
cursor
- anExtractionCursor
object to store the success/failure of the action, and the index in the response at which the last match was foundbefore
- aString
occurring immediately before an item to be extractedafter
- aString
occurring immediately after an item to be extractedendAt
- only return matches that occur before this text in the responsecaseSensitive
-true
if the search should be case-sensitivemaxItems
- the maximum number of items to extract- Returns:
- a list containing the extracted
String
objects - Throws:
java.io.UnsupportedEncodingException
- The encoding is not supportedcom.facilita.exception.InternalError
- An internal error occurred- See Also:
extract(ExtractionCursor, String, String)
,extractRegExp(ExtractionCursor, String)
-
extractList
public java.util.List<java.lang.String> extractList(ExtractionCursor cursor, java.lang.String before, java.lang.String after, java.lang.String endAt, boolean caseSensitive) throws java.io.UnsupportedEncodingException, com.facilita.exception.InternalError
Extracts a list of items from thisResponse
.A search is made for multiple occurrences of the
before
andafter
markers. The text between each occurrence of the markers is extracted and appended to the list.// The response contains the following text within its body // <select> // <option value="volvo">Volvo</option> // <option value="saab">Saab</option> // <option value="mercedes">Mercedes</option> // <option value="audi">Audi</option> // </select> // Searching from the position marked by the Extraction Cursor, extract the car model items that appear before "mercedes" ExtractionCursor cursor = new ExtractionCursor(); List<String> matchedStrings = response.extractList(cursor, "<option value=\"", "\">","mercedes", true); // contents of matchedStrings = ( volvo, saab )
- Parameters:
cursor
- anExtractionCursor
object to store the success/failure of the action, and the index in the response at which the last match was foundbefore
- aString
occurring immediately before an item to be extractedafter
- aString
occurring immediately after an item to be extractedendAt
- only return matches that occur before this text in the responsecaseSensitive
-true
if the search should be case-sensitive- Returns:
- a list containing the extracted
String
objects - Throws:
java.io.UnsupportedEncodingException
- The encoding is not supportedcom.facilita.exception.InternalError
- An internal error occurred- See Also:
extract(ExtractionCursor, String, String)
,extractRegExp(ExtractionCursor, String)
-
extractList
public java.util.List<java.lang.String> extractList(ExtractionCursor cursor, java.lang.String before, java.lang.String after, java.lang.String endAt) throws java.io.UnsupportedEncodingException, com.facilita.exception.InternalError
Extracts a list of items from thisResponse
.A search is made for multiple occurrences of the
before
andafter
markers. The text between each occurrence of the markers is extracted and appended to the list.// The response contains the following text within its body // <select> // <option value="volvo">Volvo</option> // <option value="saab">Saab</option> // <option value="mercedes">Mercedes</option> // <option value="audi">Audi</option> // </select> // Searching from the position marked by the Extraction Cursor, extract the car model items that appear before "mercedes" ExtractionCursor cursor = new ExtractionCursor(); List<String> matchedStrings = response.extractList(cursor, "<option value=\"", "\">","mercedes"); // contents of matchedStrings = ( volvo, saab )
- Parameters:
cursor
- anExtractionCursor
object to store the success/failure of the action, and the index in the response at which the last match was foundbefore
- aString
occurring immediately before an item to be extractedafter
- aString
occurring immediately after an item to be extractedendAt
- only return matches that occur before this text in the response- Returns:
- a list containing the extracted
String
objects - Throws:
java.io.UnsupportedEncodingException
- The encoding is not supportedcom.facilita.exception.InternalError
- An internal error occurred- See Also:
extract(ExtractionCursor, String, String)
,extractRegExp(ExtractionCursor, String)
-
extractList
public java.util.List<java.lang.String> extractList(ExtractionCursor cursor, java.lang.String before, java.lang.String after) throws java.io.UnsupportedEncodingException, com.facilita.exception.InternalError
Extracts a list of items from thisResponse
.A search is made for multiple occurrences of the
before
andafter
markers. The text between each occurrence of the markers is extracted and appended to the list.// The response contains the following text within its body // <select> // <option value="volvo">Volvo</option> // <option value="saab">Saab</option> // <option value="mercedes">Mercedes</option> // <option value="audi">Audi</option> // </select> // Searching from the position marked by the Extraction Cursor, extract all the car model items that appear ExtractionCursor cursor = new ExtractionCursor(); List<String> matchedStrings = response.extractList(cursor, "<option value=\"", "\">"); // contents of matchedStrings = ( volvo, saab, mercedes, audi )
- Parameters:
cursor
- anExtractionCursor
object to store the success/failure of the action, and the index in the response at which the last match was foundbefore
- aString
occurring immediately before an item to be extractedafter
- aString
occurring immediately after an item to be extracted- Returns:
- a list containing the extracted
String
objects - Throws:
java.io.UnsupportedEncodingException
- The encoding is not supportedcom.facilita.exception.InternalError
- An internal error occurred- See Also:
extract(ExtractionCursor, String, String)
,extractRegExp(ExtractionCursor, String)
-
extractRegExp
public RegExpMatchList extractRegExp(ExtractionCursor cursor, java.lang.String regExp, boolean caseSensitive)
Extracts multipleString
objects from the response content, wherever the specified regular expression matches, and specifying whether the search will be case-sensitive. Information about the success/failure of this method will be stored in theExtractionCursor
object passed.e.g.
Response response = request.send(); ExtractionCursor cursor = new ExtractionCursor(); // write out the HTML comment lines in the current web page RegExpMatchList matches = response.extractRegExp( cursor, "<!--.*?-->", true); for (int i = 0; i < matches.size(); i++) { writeMessage(matches.get(i).getMatch()); }
- Parameters:
cursor
- anExtractionCursor
object to store the success/failure of the action, and the index in the response at which the match was foundregExp
- the regular expression to matchcaseSensitive
-true
if the search should be case-sensitive- Returns:
- a
RegExpMatchList
containing the list of matches
-
extractRegExp
public RegExpMatchList extractRegExp(ExtractionCursor cursor, java.lang.String regExp)
Extracts multipleString
objects from the response content, wherever the specified regular expression matches. Information about the success/failure of this method will be stored in theExtractionCursor
object passed. The search is case-sensitive.e.g.
Response response = request.send(); ExtractionCursor cursor = new ExtractionCursor(); // write out the HTML comment lines in the current web page RegExpMatchList matches = response.extractRegExp( cursor, "<!--.*?-->"); for (int i = 0; i < matches.size(); i++) { writeMessage(matches.get(i).getMatch()); }
- Parameters:
cursor
- anExtractionCursor
object to store the success/failure of the action, and the index in the response at which the match was foundregExp
- the regular expression to match- Returns:
- a
RegExpMatchList
containing the list of matches
-
extractXPath
public java.lang.String extractXPath(java.lang.String xpathExpression, ActionType failAction) throws java.lang.Exception, java.io.UnsupportedEncodingException
Returns a string object from the HTML or XML response content that matches the given XPath expression.This method is only applicable if the response content is either HTML or XML. The method returns the first element or attribute value that matches the XPath expression.
The following example demonstrates extracting a value from an HTML Response using an XPath expression. The value returned is stored in the required extract variable.
Response response = request.send(); set("xpathExtractVariable", response.extractXPath("/html/body/h1", ActionType.ACT_WARNING)); // Check if a value was extracted. if (getString("xpathExtractVariable").length() > 0) { writeMessage(String.format("xpathExtractVariable: %s", getString("xpathExtractVariable"))); } else { writeMessage("XPath extract found no match"); }
- Parameters:
xpathExpression
- The XPath expression to be applied to the response content.failAction
- The action to take if the extract failed.- Returns:
- The extracted text, or an empty
String
if the extract failed. - Throws:
java.io.UnsupportedEncodingException
- The specified encoding is not supported.java.lang.Exception
- An error occurred
-
verifyContains
public boolean verifyContains(java.lang.String text, boolean caseSensitive) throws java.io.UnsupportedEncodingException
Returnstrue
if the content of thisResponse
contains the specifiedtext
, specifying whether the search will be case-sensitive.e.g.
Response response = request.send(); // Check that the login succeeded. if (!response.verifyContains("Login successful", false)) { error("Login failed"); nextIteration(); }
- Parameters:
text
- the text to look forcaseSensitive
-true
if the search should be case-sensitive- Returns:
true
if the text was found- Throws:
java.io.UnsupportedEncodingException
- The encoding is not supported
-
verifyContains
public boolean verifyContains(java.lang.String text) throws java.io.UnsupportedEncodingException
Returnstrue
if the content of thisResponse
contains the specifiedtext
. The search is case-sensitive.e.g.
Response response = request.send(); // Check that the login succeeded. if (!response.verifyContains("Login successful")) { error("Login failed"); nextIteration(); }
- Parameters:
text
- the text to look for- Returns:
true
if the text was found- Throws:
java.io.UnsupportedEncodingException
- The encoding is not supported
-
find
public boolean find(ExtractionCursor cursor, java.lang.String text, ActionType failAction, boolean caseSensitive) throws java.io.UnsupportedEncodingException
Finds the specifiedtext
within thisResponse
, specifying whether the search will be case-sensitive, and what action to take in case of failure. Information about the success/failure of this method will be stored in theExtractionCursor
object passed.e.g:
Response response = request.send(); ExtractionCursor cursor = new ExtractionCursor(); // If the text below cannot be found in the the response, then move onto the next iteration response.find(cursor, "page loaded successfully", ActionType.ACT_NEXT_ITERATION, false); writeMessage(String.format("Text found at position %d", cursor.getIndex()));
- Parameters:
cursor
- anExtractionCursor
object to store the success/failure of the action, and the index in the response at which the match was foundtext
- the text to search forfailAction
- the action to take iftext
cannot be foundcaseSensitive
-true
if the search should be case-sensitive- Returns:
true
if the specifiedtext
was found in thisResponse
- Throws:
java.io.UnsupportedEncodingException
- The encoding is not supported
-
find
public boolean find(ExtractionCursor cursor, java.lang.String text, ActionType failAction) throws java.lang.Exception, java.io.UnsupportedEncodingException
Finds the specifiedtext
within thisResponse
, specifying what action to take in case of failure. Information about the success/failure of this method will be stored in theExtractionCursor
object passed. The search is case-sensitive.e.g:
Response response = request.send(); ExtractionCursor cursor = new ExtractionCursor(); // If the text below cannot be found in the the response, then move onto the next iteration response.find(cursor, "page loaded successfully", ActionType.ACT_NEXT_ITERATION); writeMessage(String.format("Text found at position %d", cursor.getIndex()));
- Parameters:
cursor
- anExtractionCursor
object to store the success/failure of the action, and the index in the response at which the match was foundtext
- the text to search forfailAction
- the action to take iftext
cannot be found- Returns:
true
if the specifiedtext
was found in thisResponse
- Throws:
java.io.UnsupportedEncodingException
- The encoding is not supportedjava.lang.Exception
-
rfind
public boolean rfind(ExtractionCursor cursor, java.lang.String text, ActionType failAction, boolean caseSensitive) throws java.io.UnsupportedEncodingException
Finds the specifiedtext
within thisResponse
, starting from the end of the content, specifying whether the search will be case-sensitive, and what action to take in case of failure. Information about the success/failure of this method will be stored in theExtractionCursor
object passed.e.g:
Response response = request.send(); ExtractionCursor cursor = new ExtractionCursor(); // If the text cannot be found, move onto the next iteration response.rfind(cursor, "page loaded successfully", ActionType.ACT_NEXT_ITERATION, false); writeMessage(String.format("Text found at position %d", cursor.getIndex()));
- Parameters:
cursor
- anExtractionCursor
object to store the success/failure of the action, and the index in the response at which the match was foundtext
- the text to search forfailAction
- the action to take iftext
cannot be foundcaseSensitive
-true
if the search should be case-sensitive- Returns:
true
if the specifiedtext
was found in thisResponse
- Throws:
java.io.UnsupportedEncodingException
- The encoding is not supported
-
rfind
public boolean rfind(ExtractionCursor cursor, java.lang.String text, ActionType failAction) throws java.lang.Exception, java.io.UnsupportedEncodingException
Finds the specifiedtext
within thisResponse
, starting from the end of the content, specifying what action to take in case of failure. Information about the success/failure of this method will be stored in theExtractionCursor
object passed. The search is case-sensitive.e.g:
Response response = request.send(); ExtractionCursor cursor = new ExtractionCursor(); // If the text cannot be found, move onto the next iteration response.rfind(cursor, "page loaded successfully", ActionType.ACT_NEXT_ITERATION); writeMessage(String.format("Text found at position %d", cursor.getIndex()));
- Parameters:
cursor
- anExtractionCursor
object to store the success/failure of the action, and the index in the response at which the match was foundtext
- the text to search forfailAction
- the action to take iftext
cannot be found- Returns:
true
if the specifiedtext
was found in thisResponse
- Throws:
java.io.UnsupportedEncodingException
- The encoding is not supportedjava.lang.Exception
-
extract
public java.lang.String extract(ExtractionCursor cursor, java.lang.String before, java.lang.String after, ActionType failAction, boolean caseSensitive) throws java.io.UnsupportedEncodingException
Extracts text from the response content - everything between (but not including) the specifiedbefore
andafter
String
objects - returning an emptyString
if they cannot be found, specifying whether the search will be case-sensitive, and specifying what action to take in case of failure. Information about the success/failure of this method will be stored in theExtractionCursor
object passed.e.g.
Response response = request.send(); ExtractionCursor cursor = new ExtractionCursor(); // extract the value from the HTML text // <input type="text" name="f_customer" size="32" maxlength="32" value="Joe Smith"> String extractedText = response.extract( cursor, "value=\"", "\"", ActionType.ACT_WARNING, true); writeMessage(String.format("The value %s was found at position %d", extractedText, cursor.getIndex()));
- Parameters:
cursor
- anExtractionCursor
object to store the success/failure of the action, and the index in the response at which the match was foundbefore
- this text is searched for in the response content, and the returnedString
starts immediately after this text occurs in the contentafter
- this text is searched for in the response content after thebefore
text has been found, and the returnedString
ends immediately before this text occurs in the contentfailAction
- the action to take iftext
cannot be foundcaseSensitive
-true
if the search should be case-sensitive- Returns:
- the extracted text, or an empty
String
if the extract failed - Throws:
java.io.UnsupportedEncodingException
- The encoding is not supported
-
extract
public java.lang.String extract(ExtractionCursor cursor, java.lang.String before, java.lang.String after, ActionType failAction) throws java.lang.Exception, java.io.UnsupportedEncodingException
Extracts text from the response content - everything between (but not including) the specifiedbefore
andafter
String
objects - returning an emptyString
if they cannot be found, and specifying what action to take in case of failure. Information about the success/failure of this method will be stored in theExtractionCursor
object passed. The search is case-sensitive.e.g.
Response response = request.send(); ExtractionCursor cursor = new ExtractionCursor(); // extract the value from the HTML text // <input type="text" name="f_customer" size="32" maxlength="32" value="Joe Smith"> String extractedText = response.extract( cursor, "value=\"", "\"", ActionType.ACT_WARNING); writeMessage(String.format("The value %s was found at position %d", extractedText, cursor.getIndex()));
- Parameters:
cursor
- anExtractionCursor
object to store the success/failure of the action, and the index in the response at which the match was foundbefore
- this text is searched for in the response content, and the returnedString
starts immediately after this text occurs in the contentafter
- this text is searched for in the response content after thebefore
text has been found, and the returnedString
ends immediately before this text occurs in the contentfailAction
- the action to take iftext
cannot be found- Returns:
- the extracted text, or an empty
String
if the extract failed - Throws:
java.io.UnsupportedEncodingException
- The encoding is not supportedjava.lang.Exception
-
extract
public java.lang.String extract(ExtractionCursor cursor, java.util.List<java.lang.String> before, java.lang.String after, ActionType failAction, boolean caseSensitive) throws java.io.UnsupportedEncodingException
Extracts text from the response content - everything between (but not including) the specified list ofbefore
andafter
String
objects - returning an emptyString
if they cannot be found, specifying whether the search will be case-sensitive, and what action to take in case of failure. Information about the success/failure of this method will be stored in theExtractionCursor
object passed.Supplying a
List<String>
ofbefore
values enables you to express more complicated extraction patterns. eggPlant Performance searches for the firstString
in the list, and searches for the secondString
after the position at which the firstString
was found. This continues until the finalString
is matched, after which the extracted response content is returned untilafter
is matched. See the example below, in which a known unique name (f_custid
) is used to narrow the search.e.g.
Response response = request.send(); ExtractionCursor cursor = new ExtractionCursor(); // extract the f_custid value from the HTML text // <input type="text" name="f_customer" size="32" maxlength="32" value="Joe Smith"> // <input type="text" name="f_custid" size="10" maxlength="10" value="12345"> // <input type="text" name="f_account" size="10" maxlength="10" value="9876543"> ArrayList<String> before = new ArrayList<String>(); before.add("f_custid"); before.add("value=\""); String extractedText = response.extract( cursor, before, "\"", ActionType.ACT_WARNING, true); writeMessage(String.format("The value %s was found at position %d", extractedText, cursor.getIndex()));
- Parameters:
cursor
- anExtractionCursor
object to store the success/failure of the action, and the index in the response at which the match was foundbefore
- eachString
in thisList
is searched for sequentially in the response content, and the returnedString
starts immediately after all theString
objects have been matched in the contentafter
- this text is searched for in the response content after thebefore
text has been found, and the returnedString
ends immediately before this text occurs in the contentfailAction
- the action to take iftext
cannot be foundcaseSensitive
-true
if the search should be case-sensitive- Returns:
- the extracted text, or an empty
String
if the extract failed - Throws:
java.io.UnsupportedEncodingException
- The encoding is not supported
-
extract
public java.lang.String extract(ExtractionCursor cursor, java.util.List<java.lang.String> before, java.lang.String after, ActionType failAction) throws java.lang.Exception, java.io.UnsupportedEncodingException
Extracts text from the response content - everything between (but not including) the specified list ofbefore
andafter
String
objects - returning an emptyString
if they cannot be found, and specifying what action to take in case of failure. Information about the success/failure of this method will be stored in theExtractionCursor
object passed. The search is case-sensitive.Supplying a
List<String>
ofbefore
values enables you to express more complicated extraction patterns. eggPlant Performance searches for the firstString
in the list, and searches for the secondString
after the position at which the firstString
was found. This continues until the finalString
is matched, after which the extracted response content is returned untilafter
is matched. See the example below, in which a known unique name (f_custid
) is used to narrow the search.e.g.
Response response = request.send(); ExtractionCursor cursor = new ExtractionCursor(); // extract the f_custid value from the HTML text // <input type="text" name="f_customer" size="32" maxlength="32" value="Joe Smith"> // <input type="text" name="f_custid" size="10" maxlength="10" value="12345"> // <input type="text" name="f_account" size="10" maxlength="10" value="9876543"> ArrayList<String> before = new ArrayList<String>(); before.add("f_custid"); before.add("value=\""); String extractedText = response.extract( cursor, before, "\"", ActionType.ACT_WARNING); writeMessage(String.format("The value %s was found at position %d", extractedText, cursor.getIndex()));
- Parameters:
cursor
- anExtractionCursor
object to store the success/failure of the action, and the index in the response at which the match was foundbefore
- eachString
in thisList
is searched for sequentially in the response content, and the returnedString
starts immediately after all theString
objects have been matched in the contentafter
- this text is searched for in the response content after thebefore
text has been found, and the returnedString
ends immediately before this text occurs in the contentfailAction
- the action to take iftext
cannot be found- Returns:
- the extracted text, or an empty
String
if the extract failed - Throws:
java.io.UnsupportedEncodingException
- The encoding is not supportedjava.lang.Exception
-
extract
public java.lang.String extract(ExtractionCursor cursor, java.lang.String before, java.lang.String after, SearchFlags matchFlags) throws java.io.UnsupportedEncodingException
Extracts text from the response content - everything between (but not including) the specifiedbefore
andafter
String
objects - returning an emptyString
if they cannot be found. Information about the success/failure of this method will be stored in theExtractionCursor
object passed. The search is case-sensitive.The
matchFlags
parameter determines if the response html body, response header(s) or both are searched. e.g.Response response = request.send(); ExtractionCursor cursor = new ExtractionCursor(); // extract the value from the HTML body text, the response header(s) or both: // BODY: <script type=\"text/JavaScript\" src=\"javascript/common.js\"></script>\<noscript>You do not have Javascript enabled.</noscript>\clientSrc=195.234.243.132;\ // HEADER(S): Cache-Control: no-cache, no-store\r\nContent-Type: text/html;charset=UTF-8\r\nContent-Encoding: gzip\r\nExpires: Thu, 01 Jan 1970 00:00:00 GMT\r\nSet-Cookie: clientSrc=195.234.243.264;Path=/;Secure\r\n String extractedText = response.extract( cursor, "clientSrc=", ";", SearchFlags.SEARCH_IN_BODY | SearchFlags.SEARCH_IN_HEADERS | SearchFlags.SEARCH_IN_BOTH); if (cursor.succeeded()) { writeMessage(String.format("The value %s was found at position %d", extractedText, cursor.getIndex())); }
- Parameters:
cursor
- anExtractionCursor
object to store the success/failure of the action, and the index in the response at which the match was foundbefore
- this text is searched for in the response content, and the returnedString
starts immediately after this text occurs in the contentafter
- this text is searched for in the response content after thebefore
text has been found, and the returnedString
ends immediately before this text occurs in the contentmatchFlags
- anSearchFlags
enumerated value to indicate what should be searched: SEARCH_IN_BODY, SEARCH_IN_HEADERS or SEARCH_IN_BOTH- Returns:
- the extracted text, or an empty
String
if the extract failed - Throws:
java.io.UnsupportedEncodingException
- The encoding is not supported
-
extract
public java.lang.String extract(ExtractionCursor cursor, java.lang.String before, java.lang.String after, SearchFlags matchFlags, boolean caseSensitive) throws java.io.UnsupportedEncodingException
Extracts text from the response content - everything between (but not including) the specifiedbefore
andafter
String
objects - returning an emptyString
if they cannot be found, and specifying whether the search will be case-sensitive. Information about the success/failure of this method will be stored in theExtractionCursor
object passed.The
matchFlags
parameter determines if the response html body, response header(s) or both are searched. e.g.Response response = request.send(); ExtractionCursor cursor = new ExtractionCursor(); // extract the value from the HTML body text, the response header(s) or both: // BODY: <script type=\"text/JavaScript\" src=\"javascript/common.js\"></script>\<noscript>You do not have Javascript enabled.</noscript>\clientSrc=195.234.243.132;\ // HEADER(S): Cache-Control: no-cache, no-store\r\nContent-Type: text/html;charset=UTF-8\r\nContent-Encoding: gzip\r\nExpires: Thu, 01 Jan 1970 00:00:00 GMT\r\nSet-Cookie: clientSrc=195.234.243.264;Path=/;Secure\r\n String extractedText = response.extract( cursor, "clientSrc=", ";", SearchFlags.SEARCH_IN_BODY | SearchFlags.SEARCH_IN_HEADERS | SearchFlags.SEARCH_IN_BOTH, true); if (cursor.succeeded()) { writeMessage(String.format("The value %s was found at position %d", extractedText, cursor.getIndex())); }
- Parameters:
cursor
- anExtractionCursor
object to store the success/failure of the action, and the index in the response at which the match was foundbefore
- this text is searched for in the response content, and the returnedString
starts immediately after this text occurs in the contentafter
- this text is searched for in the response content after thebefore
text has been found, and the returnedString
ends immediately before this text occurs in the contentmatchFlags
- anSearchFlags
enumerated value to indicate what should be searched: SEARCH_IN_BODY, SEARCH_IN_HEADERS or SEARCH_IN_BOTHcaseSensitive
-true
if the search should be case-sensitive- Returns:
- the extracted text, or an empty
String
if the extract failed - Throws:
java.io.UnsupportedEncodingException
- The encoding is not supported
-
extractRegExp
public java.lang.String extractRegExp(ExtractionCursor cursor, java.lang.String beforeRegExp, java.lang.String afterRegExp, SearchFlags matchFlags)
Extracts text from the response content - everything between (but not including) the specifiedbefore
andafter
String
objects - returning an emptyString
if they cannot be found. Information about the success/failure of this method will be stored in theExtractionCursor
object passed. The search is case-sensitive.The
matchFlags
parameter determines if the response html body, response header(s) or both are searched. e.g.Response response = request.send(); ExtractionCursor cursor = new ExtractionCursor(); // extract the value from the HTML body text, the response header(s) or both: // BODY: <script type=\"text/JavaScript\" src=\"javascript/common.js\"></script>\<noscript>You do not have Javascript enabled.</noscript>\clientSrc=195.234.243.132;\ // HEADER(S): Cache-Control: no-cache, no-store\r\nContent-Type: text/html;charset=UTF-8\r\nContent-Encoding: gzip\r\nExpires: Thu, 01 Jan 1970 00:00:00 GMT\r\nSet-Cookie: clientSrcHeader=195.234.243.264;Path=/;Secure\r\n String extractedText = response.extractRegExp( cursor, "client[Ss][Rr][Cc]=|client[Ss][Rr][Cc][Hh][Ee][Aa][Dd][Ee][Rr]=", ";", SearchFlags.SEARCH_IN_BODY | SearchFlags.SEARCH_IN_HEADERS | SearchFlags.SEARCH_IN_BOTH); if (cursor.succeeded()) { writeMessage(String.format("The value %s was found at position %d", extractedText, cursor.getIndex())); }
- Parameters:
cursor
- anExtractionCursor
object to store the success/failure of the action, and the index in the response at which the match was foundbeforeRegExp
- this text is searched for in the response content, and the returnedString
starts immediately after this text occurs in the contentafterRegExp
- this text is searched for in the response content after thebefore
text has been found, and the returnedString
ends immediately before this text occurs in the contentmatchFlags
- anSearchFlags
enumerated value to indicate what should be searched: SEARCH_IN_BODY, SEARCH_IN_HEADERS or SEARCH_IN_BOTH- Returns:
- the extracted text, or an empty
String
if the extract failed
-
extractRegExp
public java.lang.String extractRegExp(ExtractionCursor cursor, java.lang.String beforeRegExp, java.lang.String afterRegExp, SearchFlags matchFlags, boolean caseSensitive)
Extracts text from the response content - everything between (but not including) the specifiedbefore
andafter
String
objects - returning an emptyString
if they cannot be found, and specifying whether the search will be case-sensitive. Information about the success/failure of this method will be stored in theExtractionCursor
object passed.The
matchFlags
parameter determines if the response html body, response header(s) or both are searched. e.g.Response response = request.send(); ExtractionCursor cursor = new ExtractionCursor(); // extract the value from the HTML body text, the response header(s) or both: // BODY: <script type=\"text/JavaScript\" src=\"javascript/common.js\"></script>\<noscript>You do not have Javascript enabled.</noscript>\clientSrc=195.234.243.132;\ // HEADER(S): Cache-Control: no-cache, no-store\r\nContent-Type: text/html;charset=UTF-8\r\nContent-Encoding: gzip\r\nExpires: Thu, 01 Jan 1970 00:00:00 GMT\r\nSet-Cookie: clientSrcHeader=195.234.243.264;Path=/;Secure\r\n String extractedText = response.extractRegExp( cursor, "client[Ss][Rr][Cc]=|client[Ss][Rr][Cc][Hh][Ee][Aa][Dd][Ee][Rr]=", ";", SearchFlags.SEARCH_IN_BODY | SearchFlags.SEARCH_IN_HEADERS | SearchFlags.SEARCH_IN_BOTH, true); if (cursor.succeeded()) { writeMessage(String.format("The value %s was found at position %d", extractedText, cursor.getIndex())); }
- Parameters:
cursor
- anExtractionCursor
object to store the success/failure of the action, and the index in the response at which the match was foundbeforeRegExp
- this text is searched for in the response content, and the returnedString
starts immediately after this text occurs in the contentafterRegExp
- this text is searched for in the response content after thebefore
text has been found, and the returnedString
ends immediately before this text occurs in the contentmatchFlags
- anSearchFlags
enumerated value to indicate what should be searched: SEARCH_IN_BODY, SEARCH_IN_HEADERS or SEARCH_IN_BOTHcaseSensitive
-true
if the search should be case-sensitive- Returns:
- the extracted text, or an empty
String
if the extract failed
-
extractList
public java.util.List<java.lang.String> extractList(ExtractionCursor cursor, java.lang.String before, java.lang.String after, SearchFlags matchFlags)
Extracts a list of items from thisResponse
.A search is made for multiple occurrences of the
before
andafter
markers. The text between each occurrence of the markers is extracted and appended to the list.The
matchFlags
parameter determines if the response html body, response header(s) or both are searched.// The response contains the following text within its body // <!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\">\ // <html>\ // <head>\ // <meta HTTP-EQUIV=\"PRAGMA\" CONTENT=\"NO - CACHE\">\ // <title>Extract Test</title>\ // </head>\ // <body>\ // <script type=\"text/JavaScript\" src=\"javascript/common.js\"></script>\ // <noscript>You do not have Javascript enabled.</noscript>\ // clientSrc=195.234.243.132;\ // clientSrc=195.234.243.133;\ // clientSrc=195.234.243.134;\ // clientSrc=195.234.243.135;\ // </body>\ // </html> // // The header(s) are: // Cache-Control: no-cache, no-store\r\nContent-Type: text/html;charset=UTF-8\r\nContent-Encoding: gzip\r\nExpires: Thu, 01 Jan 1970 00:00:00 GMT\r\nSet-Cookie: clientSrc=195.234.243.264;clientSrc=195.234.243.265;clientSrc=195.234.243.266;clientSrc=195.234.243.267;Path=/;Secure\r\n // // Searching from the position marked by the Extraction Cursor, extract all the "clientSrc" values. If SearchFlags.SEARCH_IN_BOTH is used, the body is searched first and, // if the search fails, the header(s) are searched next using a reset cursor. ExtractionCursor cursor = new ExtractionCursor(); List<String> matchedStrings = response.extractList( cursor, "clientSrc=", ";", SearchFlags.SEARCH_IN_BODY | SearchFlags.SEARCH_IN_HEADERS | SearchFlags.SEARCH_IN_BOTH);
- Parameters:
cursor
- anExtractionCursor
object to store the success/failure of the action, and the index in the response at which the last match was foundbefore
- aString
occurring immediately before an item to be extractedafter
- aString
occurring immediately after an item to be extractedmatchFlags
- anSearchFlags
enumerated value to indicate what should be searched: SEARCH_IN_BODY, SEARCH_IN_HEADERS or SEARCH_IN_BOTH- Returns:
- a list containing the extracted
String
objects
-
extractList
public java.util.List<java.lang.String> extractList(ExtractionCursor cursor, java.lang.String before, java.lang.String after, SearchFlags matchFlags, java.lang.String endAt)
Extracts a list of items from thisResponse
.A search is made for multiple occurrences of the
before
andafter
markers. The text between each occurrence of the markers is extracted and appended to the list.The
matchFlags
parameter determines if the response html body, response header(s) or both are searched.// The response contains the following text within its body // <!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\">\ // <html>\ // <head>\ // <meta HTTP-EQUIV=\"PRAGMA\" CONTENT=\"NO - CACHE\">\ // <title>Extract Test</title>\ // </head>\ // <body>\ // <script type=\"text/JavaScript\" src=\"javascript/common.js\"></script>\ // <noscript>You do not have Javascript enabled.</noscript>\ // clientSrc=195.234.243.132;\ // clientSrc=195.234.243.133;\ // clientSrc=195.234.243.134;\ // clientSrc=195.234.243.135;\ // </body>\ // </html> // // The header(s) are: // Cache-Control: no-cache, no-store\r\nContent-Type: text/html;charset=UTF-8\r\nContent-Encoding: gzip\r\nExpires: Thu, 01 Jan 1970 00:00:00 GMT\r\nSet-Cookie: clientSrc=195.234.243.264;clientSrc=195.234.243.265;clientSrc=195.234.243.266;clientSrc=195.234.243.267;Path=/;Secure\r\n // // Searching from the position marked by the Extraction Cursor, extract all the "clientSrc" values. If SearchFlags.SEARCH_IN_BOTH is used, the body is searched first and, // if the search fails, the header(s) are searched next using a reset cursor. ExtractionCursor cursor = new ExtractionCursor(); List<String> matchedStrings = response.extractList( cursor, "clientSrc=", ";", SearchFlags.SEARCH_IN_BODY | SearchFlags.SEARCH_IN_HEADERS | SearchFlags.SEARCH_IN_BOTH, "134");
- Parameters:
cursor
- anExtractionCursor
object to store the success/failure of the action, and the index in the response at which the last match was foundbefore
- aString
occurring immediately before an item to be extractedafter
- aString
occurring immediately after an item to be extractedmatchFlags
- anSearchFlags
enumerated value to indicate what should be searched: SEARCH_IN_BODY, SEARCH_IN_HEADERS or SEARCH_IN_BOTHendAt
- only return matches that occur before this text in the response- Returns:
- a list containing the extracted
String
objects
-
extractList
public java.util.List<java.lang.String> extractList(ExtractionCursor cursor, java.lang.String before, java.lang.String after, SearchFlags matchFlags, java.lang.String endAt, boolean caseSensitive)
Extracts a list of items from thisResponse
.A search is made for multiple occurrences of the
before
andafter
markers. The text between each occurrence of the markers is extracted and appended to the list.The
matchFlags
parameter determines if the response html body, response header(s) or both are searched.// The response contains the following text within its body // <!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\">\ // <html>\ // <head>\ // <meta HTTP-EQUIV=\"PRAGMA\" CONTENT=\"NO - CACHE\">\ // <title>Extract Test</title>\ // </head>\ // <body>\ // <script type=\"text/JavaScript\" src=\"javascript/common.js\"></script>\ // <noscript>You do not have Javascript enabled.</noscript>\ // clientSrc=195.234.243.132;\ // clientSrc=195.234.243.133;\ // clientSrc=195.234.243.134;\ // clientSrc=195.234.243.135;\ // </body>\ // </html> // // The header(s) are: // Cache-Control: no-cache, no-store\r\nContent-Type: text/html;charset=UTF-8\r\nContent-Encoding: gzip\r\nExpires: Thu, 01 Jan 1970 00:00:00 GMT\r\nSet-Cookie: clientSrc=195.234.243.264;clientSrc=195.234.243.265;clientSrc=195.234.243.266;clientSrc=195.234.243.267;Path=/;Secure\r\n // // Searching from the position marked by the Extraction Cursor, extract all the "clientSrc" values. If SearchFlags.SEARCH_IN_BOTH is used, the body is searched first and, // if the search fails, the header(s) are searched next using a reset cursor. ExtractionCursor cursor = new ExtractionCursor(); List<String> matchedStrings = response.extractList( cursor, "clientSrc=", ";", SearchFlags.SEARCH_IN_BODY | SearchFlags.SEARCH_IN_HEADERS | SearchFlags.SEARCH_IN_BOTH, "134", true);
- Parameters:
cursor
- anExtractionCursor
object to store the success/failure of the action, and the index in the response at which the last match was foundbefore
- aString
occurring immediately before an item to be extractedafter
- aString
occurring immediately after an item to be extractedmatchFlags
- anSearchFlags
enumerated value to indicate what should be searched: SEARCH_IN_BODY, SEARCH_IN_HEADERS or SEARCH_IN_BOTHendAt
- only return matches that occur before this text in the responsecaseSensitive
-true
if the search should be case-sensitive- Returns:
- a list containing the extracted
String
objects
-
extractList
public java.util.List<java.lang.String> extractList(ExtractionCursor cursor, java.lang.String before, java.lang.String after, SearchFlags matchFlags, java.lang.String endAt, boolean caseSensitive, int maxItems)
Extracts a list of items from thisResponse
.A search is made for multiple occurrences of the
before
andafter
markers. The text between each occurrence of the markers is extracted and appended to the list.The
matchFlags
parameter determines if the response html body, response header(s) or both are searched.// The response contains the following text within its body // <!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\">\ // <html>\ // <head>\ // <meta HTTP-EQUIV=\"PRAGMA\" CONTENT=\"NO - CACHE\">\ // <title>Extract Test</title>\ // </head>\ // <body>\ // <script type=\"text/JavaScript\" src=\"javascript/common.js\"></script>\ // <noscript>You do not have Javascript enabled.</noscript>\ // clientSrc=195.234.243.132;\ // clientSrc=195.234.243.133;\ // clientSrc=195.234.243.134;\ // clientSrc=195.234.243.135;\ // </body>\ // </html> // // The header(s) are: // Cache-Control: no-cache, no-store\r\nContent-Type: text/html;charset=UTF-8\r\nContent-Encoding: gzip\r\nExpires: Thu, 01 Jan 1970 00:00:00 GMT\r\nSet-Cookie: clientSrc=195.234.243.264;clientSrc=195.234.243.265;clientSrc=195.234.243.266;clientSrc=195.234.243.267;Path=/;Secure\r\n // // Searching from the position marked by the Extraction Cursor, extract all the "clientSrc" values. If SearchFlags.SEARCH_IN_BOTH is used, the body is searched first and, // if the search fails, the header(s) are searched next using a reset cursor. ExtractionCursor cursor = new ExtractionCursor(); List<String> matchedStrings = response.extractList( cursor, "clientSrc=", ";", SearchFlags.SEARCH_IN_BODY | SearchFlags.SEARCH_IN_HEADERS | SearchFlags.SEARCH_IN_BOTH, "134", true, 2);
- Parameters:
cursor
- anExtractionCursor
object to store the success/failure of the action, and the index in the response at which the last match was foundbefore
- aString
occurring immediately before an item to be extractedafter
- aString
occurring immediately after an item to be extractedmatchFlags
- anSearchFlags
enumerated value to indicate what should be searched: SEARCH_IN_BODY, SEARCH_IN_HEADERS or SEARCH_IN_BOTHendAt
- only return matches that occur before this text in the responsecaseSensitive
-true
if the search should be case-sensitivemaxItems
- the maximum number of items to extract- Returns:
- a list containing the extracted
String
objects
-
verifyContains
public boolean verifyContains(java.lang.String text, ActionType failAction, boolean caseSensitive) throws java.io.UnsupportedEncodingException
Returnstrue
if the content of thisResponse
contains the specifiedtext
, specifying whether the search will be case-sensitive, and what action to take in case of failure.e.g.
Response response = request.send(); // Check that the login succeeded, and move onto the next iteration if it did not. response.verifyContains("Login successful", ActionType.ACT_NEXT_ITERATION, false);
- Parameters:
text
- the text to look forfailAction
- the action to take iftext
cannot be foundcaseSensitive
-true
if the search should be case-sensitive- Returns:
true
if the text was found- Throws:
java.io.UnsupportedEncodingException
- The encoding is not supported
-
verifyContains
public boolean verifyContains(java.lang.String text, ActionType failAction) throws java.lang.Exception, java.io.UnsupportedEncodingException
Returnstrue
if the content of thisResponse
contains the specifiedtext
, specifying what action to take in case of failure. The search is case-sensitive.e.g.
Response response = request.send(); // Check that the login succeeded, and move onto the next iteration if it did not. response.verifyContains("Login successful", ActionType.ACT_NEXT_ITERATION);
- Parameters:
text
- the text to look forfailAction
- the action to take iftext
cannot be found- Returns:
true
if the text was found- Throws:
java.io.UnsupportedEncodingException
- The encoding is not supportedjava.lang.Exception
-
setCharEncoding
public void setCharEncoding(java.lang.String charEncoding)
Sets the character encoding that is used to decode the data contained in thisResponse
. Usually, the character encoding will be determined automatically by:- looking for a charset in the response headers (e.g.
Content-Type: text/html; charset=utf-8
) - looking for a meta-tag in the HTML (e.g.
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
- looking for a Byte Order Mark at the beginning of the response data
- defaulting to ISO-8859-1 (latin-1) if none of the above could be found
Therefore, it is not usually necessary to call this method explicitly. However, if some of the information above is incorrect/missing, then you can override the encoding by calling this method.
e.g.
Response response = request.send(); // Use the utf-8 character set to interpret the data in this response response.setCharEncoding("utf-8"); // The utf-8 character set will be used to decode the HTML and determine what the title is response.verifyTitle("我是中国人", ActionType.ACT_NEXT_ITERATION);
- Parameters:
charEncoding
- the character encoding that should be used to decode the data in thisResponse
- See Also:
getCharEncoding()
,resetCharEncoding()
- looking for a charset in the response headers (e.g.
-
getCharEncoding
public java.lang.String getCharEncoding()
Gets the character encoding that is used to decode the data contained in thisResponse
, for example"UTF-8"
.- Returns:
- the character encoding
- See Also:
setCharEncoding(String)
,resetCharEncoding()
-
resetCharEncoding
public void resetCharEncoding()
Resets the character encoding that is used to decode the data contained in thisResponse
. This will force the character encoding to be re-calculated, using the methods described insetCharEncoding(String)
.- See Also:
getCharEncoding()
,setCharEncoding(String)
-
getVersion
public java.lang.String getVersion()
Get the version of HTTP that was used to send this response- Returns:
- the version of HTTP that was used to send this response
-
-