Class Response
- java.lang.Object
-
- com.facilita.fc.web.Response
-
public class Response extends java.lang.ObjectDescribes an HTTP response returned by a web server. When aRequestis sent to the server, then a correspondingResponseobject will be generated.e.g.
TheRequest request1 = getWebBrowser().createRequest(HttpMethod.GET, new Url("http://www.testplant.com/"), 1); Response response1 = request1.send();Responseobject 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 booleancontainsHeader(java.lang.String header)Returnstrueif thisResponsecontains a particular HTTP response header.voiddelete()java.lang.Stringextract(ExtractionCursor cursor, java.lang.String before, java.lang.String after)Extracts text from the response content - everything between (but not including) the specifiedbeforeandafterStringobjects - returning an emptyStringif they cannot be found.java.lang.Stringextract(ExtractionCursor cursor, java.lang.String before, java.lang.String after, boolean caseSensitive)Extracts text from the response content - everything between (but not including) the specifiedbeforeandafterStringobjects - returning an emptyStringif they cannot be found, and specifying whether the search will be case-sensitive.java.lang.Stringextract(ExtractionCursor cursor, java.lang.String before, java.lang.String after, ActionType failAction)Extracts text from the response content - everything between (but not including) the specifiedbeforeandafterStringobjects - returning an emptyStringif they cannot be found, and specifying what action to take in case of failure.java.lang.Stringextract(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 specifiedbeforeandafterStringobjects - returning an emptyStringif they cannot be found, specifying whether the search will be case-sensitive, and specifying what action to take in case of failure.java.lang.Stringextract(ExtractionCursor cursor, java.lang.String before, java.lang.String after, SearchFlags matchFlags)Extracts text from the response content - everything between (but not including) the specifiedbeforeandafterStringobjects - returning an emptyStringif they cannot be found.java.lang.Stringextract(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 specifiedbeforeandafterStringobjects - returning an emptyStringif they cannot be found, and specifying whether the search will be case-sensitive.java.lang.Stringextract(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 specifiedbeforeandafterStringobjects - returning thedefaultValueif they cannot be found.java.lang.Stringextract(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 specifiedbeforeandafterStringobjects - returning thedefaultValueif they cannot be found, and specifying whether the search will be case-sensitive.java.lang.Stringextract(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 ofbeforeandafterStringobjects - returning an emptyStringif they cannot be found.java.lang.Stringextract(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 ofbeforeandafterStringobjects - returning an emptyStringif they cannot be found, and specifying whether the search will be case-sensitive.java.lang.Stringextract(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 ofbeforeandafterStringobjects - returning an emptyStringif they cannot be found, and specifying what action to take in case of failure.java.lang.Stringextract(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 ofbeforeandafterStringobjects - returning an emptyStringif they cannot be found, specifying whether the search will be case-sensitive, and what action to take in case of failure.java.lang.Stringextract(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 ofbeforeandafterStringobjects - returning thedefaultValueif they cannot be found.java.lang.Stringextract(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 ofbeforeandafterStringobjects - returning thedefaultValueif they cannot be found, and specifying whether the search will be case-sensitive.java.lang.Stringextract(java.lang.String before, java.lang.String after)Extracts text from the response content - everything between (but not including) the specifiedbeforeandafterStringobjects - returning an emptyStringif they cannot be found.java.lang.Stringextract(java.lang.String before, java.lang.String after, boolean caseSensitive)Extracts text from the response content - everything between (but not including) the specifiedbeforeandafterStringobjects - returning an emptyStringif they cannot be found, and specifying whether the search will be case-sensitive.java.lang.Stringextract(java.lang.String before, java.lang.String after, ActionType failAction)Extracts text from the response content - everything between (but not including) the specifiedbeforeandafterStringobjects - returning an emptyStringif they cannot be found, and specifying what action to take in case of failure.java.lang.Stringextract(java.lang.String before, java.lang.String after, ActionType failAction, boolean caseSensitive)Extracts text from the response content - everything between (but not including) the specifiedbeforeandafterStringobjects - returning an emptyStringif they cannot be found, specifying whether the search will be case-sensitive, and specifying what action to take in case of failure.java.lang.Stringextract(java.lang.String before, java.lang.String after, java.lang.String defaultValue)Extracts text from the response content - everything between (but not including) the specifiedbeforeandafterStringobjects - returning thedefaultValueif they cannot be found.java.lang.Stringextract(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 specifiedbeforeandafterStringobjects - returning thedefaultValueif they cannot be found, and specifying whether the search will be case-sensitive.java.lang.Stringextract(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 ofbeforeandafterStringobjects - returning an emptyStringif they cannot be found.java.lang.Stringextract(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 ofbeforeandafterStringobjects - returning an emptyStringif they cannot be found, and specifying whether the search will be case-sensitive.java.lang.Stringextract(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 ofbeforeandafterStringobjects - returning an emptyStringif they cannot be found, specifying whether the search will be case-sensitive, and what action to take in case of failure.java.lang.Stringextract(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 ofbeforeandafterStringobjects - returning an emptyStringif they cannot be found, specifying whether the search will be case-sensitive, and what action to take in case of failure.java.lang.Stringextract(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 ofbeforeandafterStringobjects - returning thedefaultValueif they cannot be found.java.lang.Stringextract(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 ofbeforeandafterStringobjects - returning thedefaultValueif they cannot be found, and specifying whether the search will be case-sensitive.FormextractForm(int formIndex)Extracts the nth HTMLFormfrom the response content.FormextractForm(int formIndex, ActionType failAction)Extracts the nth HTMLFormfrom the response content, and takes the specifiedfailActionif no matching form can be found.FormextractForm(java.lang.String formName)Extracts an HTMLFormwith the specifiedformNamefrom the response content.FormextractForm(java.lang.String formName, ActionType failAction)Extracts an HTMLFormwith the specifiedformNamefrom the response content, and takes the specifiedfailActionif no matching form can be found.java.util.List<Form>extractForms()Extracts all the HTMLFormobjects from the response content.java.lang.StringextractFromEnd(ExtractionCursor cursor, java.lang.String after, java.lang.String before)Extracts text from the response content, starting from the end.java.lang.StringextractFromEnd(ExtractionCursor cursor, java.lang.String after, java.lang.String before, boolean caseSensitive)Extracts text from the response content, starting from the end.java.lang.StringextractFromEnd(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.StringextractFromEnd(ExtractionCursor cursor, java.lang.String after, java.lang.String before, ActionType failAction)Extracts text from the response content, starting from the end.java.lang.StringextractFromEnd(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.StringextractFromEnd(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.StringextractFromEnd(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.StringextractFromEnd(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.StringextractFromEnd(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.StringextractFromEnd(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.StringextractFromEnd(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.StringextractFromEnd(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.StringextractFromEnd(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.StringextractFromEnd(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.StringextractFromEnd(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.StringextractFromEnd(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.StringextractFromEnd(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.StringextractFromEnd(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.StringextractFromEnd(java.lang.String after, java.lang.String before)Extracts text from the response content, starting from the end.java.lang.StringextractFromEnd(java.lang.String after, java.lang.String before, boolean caseSensitive)Extracts text from the response content, starting from the end.java.lang.StringextractFromEnd(java.lang.String after, java.lang.String before, boolean caseSensitive, SearchFlags matchFlags)Extracts text from the response content, starting from the end.java.lang.StringextractFromEnd(java.lang.String after, java.lang.String before, ActionType failAction)Extracts text from the response content, starting from the end.java.lang.StringextractFromEnd(java.lang.String after, java.lang.String before, ActionType failAction, boolean caseSensitive)Extracts text from the response content, starting from the end.java.lang.StringextractFromEnd(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.StringextractFromEnd(java.lang.String after, java.lang.String before, java.lang.String defaultValue)Extracts text from the response content, starting from the end.java.lang.StringextractFromEnd(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.StringextractFromEnd(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.StringextractFromEnd(java.util.List<java.lang.String> after, java.lang.String before)Extracts text from the response content starting from the end.java.lang.StringextractFromEnd(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.StringextractFromEnd(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.StringextractFromEnd(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.StringextractFromEnd(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.StringextractFromEnd(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.StringextractFromEnd(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.StringextractFromEnd(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.StringextractFromEnd(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.RegExpMatchListextractRegExp(ExtractionCursor cursor, java.lang.String regExp)Extracts multipleStringobjects from the response content, wherever the specified regular expression matches.RegExpMatchListextractRegExp(ExtractionCursor cursor, java.lang.String regExp, boolean caseSensitive)Extracts multipleStringobjects from the response content, wherever the specified regular expression matches, and specifying whether the search will be case-sensitive.java.lang.StringextractRegExp(ExtractionCursor cursor, java.lang.String beforeRegExp, java.lang.String afterRegExp, SearchFlags matchFlags)Extracts text from the response content - everything between (but not including) the specifiedbeforeandafterStringobjects - returning an emptyStringif they cannot be found.java.lang.StringextractRegExp(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 specifiedbeforeandafterStringobjects - returning an emptyStringif they cannot be found, and specifying whether the search will be case-sensitive.java.lang.StringextractXPath(java.lang.String xpathExpression, ActionType failAction)Returns a string object from the HTML or XML response content that matches the given XPath expression.booleanfind(ExtractionCursor cursor, java.lang.String text)Finds the specifiedtextwithin thisResponse.booleanfind(ExtractionCursor cursor, java.lang.String text, boolean caseSensitive)Finds the specifiedtextwithin thisResponse, specifying whether the search will be case-sensitive.booleanfind(ExtractionCursor cursor, java.lang.String text, ActionType failAction)Finds the specifiedtextwithin thisResponse, specifying what action to take in case of failure.booleanfind(ExtractionCursor cursor, java.lang.String text, ActionType failAction, boolean caseSensitive)Finds the specifiedtextwithin thisResponse, specifying whether the search will be case-sensitive, and what action to take in case of failure.UrlgetAnchor(int n, ActionType failAction)Gets the nth anchor in thisResponse.longgetBytesDownloaded()Gets the number of bytes downloaded from the server.java.lang.StringgetCharEncoding()Gets the character encoding that is used to decode the data contained in thisResponse, for example"UTF-8".java.lang.StringgetCharSet()Gets the value of the"charset"parameter specified in the"Content-Type"HTTP response header.java.lang.StringgetContent()Gets the content of thisResponse, using the current encoding (as defined bygetCharEncoding()) to decode the data.org.json.simple.JSONObjectgetContentAsJson()Gets an org.json.simple JSON object representation of this Response.org.w3c.dom.DocumentgetContentAsXml()Gets an XML DOM representation of thisResponse.java.lang.StringgetContentEncoding()Gets the value of the"Content-Encoding"HTTP response header.longgetContentLength()Gets the length in bytes of the response content.java.lang.StringgetContentType()Gets the value of the"Content-Type"HTTP response header.static longgetCPtr(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.StringgetHeaderValue(java.lang.String header)Gets the value of an HTTP response header contained in thisResponse.java.lang.StringgetHeaderValue(java.lang.String header, int index)Gets the value of the nth instance of an HTTP response header contained in thisResponse.java.lang.StringgetMessageBody()Gets the body of the message from the correspondingRequest.HttpMethodgetMethod()Gets theHttpMethodthat was used to send theRequest.byte[]getRawContent()Gets the raw content of thisResponse.intgetReceiveTime()Gets the time at which the response was received from the server (measured in milliseconds since the start of the test).ResponsegetRedirectedFrom()Gets theResponsefrom which thisResponsehas been redirected.ResponsegetRedirectedFrom(int depth)Gets theResponsefrom which thisResponsehas been redirected.java.lang.StringgetReferer()Gets the value of the"Referer"HTTP response header.HttpStatusgetResult()Gets the HTTP status code received from the server when thisResponsewas served.java.lang.StringgetResultString()Gets the HTTP result returned by the server, e.g.HTTP/1.1 200 OKintgetSendTime()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 ofResponseobjects that describe HTTP responses to sub-requests associated with the top-levelRequestsent to the web server.java.lang.StringgetTitle()Gets the HTML title of thisResponse.UrlgetUrl()java.lang.StringgetUrlString()Gets the URL that was used in the correspondingRequest, as aString.java.lang.StringgetUserAgent()Gets the value of the"User-Agent"HTTP response header.java.lang.StringgetVersion()Get the version of HTTP that was used to send this responsebooleanhasReferer()Returnstrueif thisResponsecontains an HTTP"Referer"response header.booleanhasTitle()Returnstrueif thisResponsecontains an HTML title.voidresetCharEncoding()Resets the character encoding that is used to decode the data contained in thisResponse.booleanrfind(ExtractionCursor cursor, java.lang.String text)Finds the specifiedtextwithin thisResponse, starting from the end of the content.booleanrfind(ExtractionCursor cursor, java.lang.String text, boolean caseSensitive)Finds the specifiedtextwithin thisResponse, starting from the end of the content, and specifying whether the search will be case-sensitive.booleanrfind(ExtractionCursor cursor, java.lang.String text, ActionType failAction)Finds the specifiedtextwithin thisResponse, starting from the end of the content, specifying what action to take in case of failure.booleanrfind(ExtractionCursor cursor, java.lang.String text, ActionType failAction, boolean caseSensitive)Finds the specifiedtextwithin 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.voidsetCharEncoding(java.lang.String charEncoding)Sets the character encoding that is used to decode the data contained in thisResponse.booleanverifyContains(java.lang.String text)Returnstrueif the content of thisResponsecontains the specifiedtext.booleanverifyContains(java.lang.String text, boolean caseSensitive)Returnstrueif the content of thisResponsecontains the specifiedtext, specifying whether the search will be case-sensitive.booleanverifyContains(java.lang.String text, ActionType failAction)Returnstrueif the content of thisResponsecontains the specifiedtext, specifying what action to take in case of failure.booleanverifyContains(java.lang.String text, ActionType failAction, boolean caseSensitive)Returnstrueif the content of thisResponsecontains the specifiedtext, specifying whether the search will be case-sensitive, and what action to take in case of failure.booleanverifyResult(HttpStatus expectedResult)Verify that the response code of this Response matches the specifiedexpectedResult.booleanverifyResult(HttpStatus expectedResult, ActionType action)Verify that the response code of this Response matches the specifiedexpectedResult, and takes the specifiedactionif it does not.booleanverifyTitle(java.lang.String title)Verifies that the title of thisResponsepage matches the specifiedtitle.booleanverifyTitle(java.lang.String title, ActionType action)Verifies that the title of thisResponsepage matches the specifiedtitle, and takes the specifiedactionif it does not.booleanwasRedirected()Returnstrueif thisResponsewas 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 theHttpMethodthat 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
HttpMethodthat was used in theRequest - Throws:
java.lang.Exception- an internal error occurred
-
getUrl
public Url getUrl()
Gets theUrlthat 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
Urlused in the correspondingRequest - See Also:
getUrlString()
-
getRedirectedFrom
public Response getRedirectedFrom()
Gets theResponsefrom which thisResponsehas been redirected.If a request returns a redirect response code (e.g.
301or302), then eggPlant Performance will automatically follow the redirect, and theResponseobject 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
Responsewhich thisResponsehas been redirected from, ornullif no redirection occurred - See Also:
wasRedirected(),Request.setFollowRedirects(boolean),WebBrowser.setDefaultFollowRedirects(boolean)
-
getRedirectedFrom
public Response getRedirectedFrom(int depth)
Gets theResponsefrom which thisResponsehas been redirected.If a request returns a redirect response code (e.g.
301or302), then eggPlant Performance will automatically follow the redirect, and theResponseobject 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
Responsewhich thisResponsehas been redirected from, ornullif 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 thisResponsewas served. The most common status code is200 OK, although other codes between200and299also 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()
Returnstrueif thisResponsewas 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:
trueif the request was redirected- See Also:
getRedirectedFrom()
-
containsHeader
public boolean containsHeader(java.lang.String header) throws java.io.UnsupportedEncodingExceptionReturnstrueif thisResponsecontains 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:
trueif thisResponsecontains 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.UnsupportedEncodingExceptionGets 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
Stringif 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.UnsupportedEncodingExceptionGets 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
Stringif 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 emptyStringif 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 emptyStringif no such response header exists - See Also:
getHeaderValue(String),containsHeader(String),hasReferer()
-
hasReferer
public boolean hasReferer()
Returnstrueif thisResponsecontains an HTTP"Referer"response header.- Returns:
trueif thisResponsecontains 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 emptyStringif 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 emptyStringif none was found - See Also:
getContentType(),getCharEncoding()
-
getHeaderKeys
public java.util.List<java.lang.String> getHeaderKeys() throws com.facilita.exception.InternalErrorGets 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 emptyStringif 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 ofResponseobjects that describe HTTP responses to sub-requests associated with the top-levelRequestsent 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
ListofResponseobjects 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.UnsupportedEncodingExceptionGets 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.ExceptionGets an XML DOM representation of thisResponse.e.g. if the content of the HTTP
Responseis 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 themyFormform andmySelectselect 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 thisResponseas 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.ExceptionGets 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
Responseas abytearray - See Also:
getCharEncoding(),setCharEncoding(java.lang.String),getContent()
-
getTitle
public java.lang.String getTitle() throws java.io.UnsupportedEncodingExceptionGets 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 TitleIf 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
Stringif no title was found - Throws:
java.io.UnsupportedEncodingException- The encoding is not supported- See Also:
hasTitle(),verifyTitle(String),getCharEncoding()
-
hasTitle
public boolean hasTitle()
Returnstrueif thisResponsecontains 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:
trueif thisResponsecontains an HTML title- See Also:
getTitle(),verifyTitle(String)
-
extractForm
public Form extractForm(java.lang.String formName)
Extracts an HTMLFormwith the specifiedformNamefrom 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 theFormto look for in the response- Returns:
- a
Formwith the specifiedformName
-
extractForm
public Form extractForm(java.lang.String formName, ActionType failAction) throws java.lang.Exception
Extracts an HTMLFormwith the specifiedformNamefrom the response content, and takes the specifiedfailActionif 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 theFormto look for in the responsefailAction- the action to take if no matching form can be found- Returns:
- a
Formwith the specifiedformName - Throws:
java.lang.Exception- An error occurred during the extraction.
-
extractForm
public Form extractForm(int formIndex)
Extracts the nth HTMLFormfrom 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 theFormto look for in the response- Returns:
- the nth
Formin the response
-
extractForm
public Form extractForm(int formIndex, ActionType failAction) throws java.lang.Exception
Extracts the nth HTMLFormfrom the response content, and takes the specifiedfailActionif 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 theFormto look for in the responsefailAction- the action to take if no matching form can be found- Returns:
- the nth
Formin 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 HTMLFormobjects 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
Formobjects in the response - Throws:
com.facilita.exception.InternalError- An internal error occurred
-
verifyTitle
public boolean verifyTitle(java.lang.String title) throws java.io.UnsupportedEncodingExceptionVerifies that the title of thisResponsepage matches the specifiedtitle.The title of a
Responseobject is extracted from between the<title></title>tags in the HTML page content. This method is a simple way to check that aResponseobject 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 thisResponseobject is expected to contain- Returns:
trueif the title of thisResponseobject 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.UnsupportedEncodingExceptionVerifies that the title of thisResponsepage matches the specifiedtitle, and takes the specifiedactionif it does not.The title of a
Responseobject is extracted from between the<title></title>tags in the HTML page content. This method is a simple way to check that aResponseobject 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 thisResponseobject is expected to containaction- the action to take if the expectedtitleis not found- Returns:
trueif the title of thisResponseobject 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:
trueif the HTTP status of thisResponseobject 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 specifiedactionif 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:
trueif the HTTP status of thisResponseobject 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 specifiedtextwithin thisResponse, specifying whether the search will be case-sensitive. Information about the success/failure of this method will be stored in theExtractionCursorobject 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- anExtractionCursorobject 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-trueif the search should be case-sensitive- Returns:
trueif the specifiedtextwas 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 specifiedtextwithin thisResponse. Information about the success/failure of this method will be stored in theExtractionCursorobject 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- anExtractionCursorobject 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:
trueif the specifiedtextwas 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 specifiedtextwithin 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 theExtractionCursorobject 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- anExtractionCursorobject 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-trueif the search should be case-sensitive- Returns:
trueif the specifiedtextwas 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 specifiedtextwithin thisResponse, starting from the end of the content. Information about the success/failure of this method will be stored in theExtractionCursorobject 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- anExtractionCursorobject 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:
trueif the specifiedtextwas 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 specifiedbeforeandafterStringobjects - returning thedefaultValueif 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 theExtractionCursorobject 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- anExtractionCursorobject 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 returnedStringstarts immediately after this text occurs in the contentafter- this text is searched for in the response content after thebeforetext has been found, and the returnedStringends immediately before this text occurs in the contentdefaultValue- the value to return if either thebeforeoraftertext cannot be foundcaseSensitive-trueif the search should be case-sensitive- Returns:
- the extracted text, or
defaultValueif 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 specifiedbeforeandafterStringobjects - returning thedefaultValueif they cannot be found. Information about the success/failure of this method will be stored in theExtractionCursorobject 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- anExtractionCursorobject 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 returnedStringstarts immediately after this text occurs in the contentafter- this text is searched for in the response content after thebeforetext has been found, and the returnedStringends immediately before this text occurs in the contentdefaultValue- the value to return if either thebeforeoraftertext cannot be found- Returns:
- the extracted text, or
defaultValueif 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 ofbeforeandafterStringobjects - returning thedefaultValueif 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 theExtractionCursorobject passed.Supplying a
List<String>ofbeforevalues enables you to express more complicated extraction patterns. eggPlant Performance searches for the firstStringin the list, and searches for the secondStringafter the position at which the firstStringwas found. This continues until the finalStringis matched, after which the extracted response content is returned untilafteris 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- anExtractionCursorobject to store the success/failure of the action, and the index in the response at which the match was foundbefore- eachStringin thisListis searched for sequentially in the response content, and the returnedStringstarts immediately after all theStringobjects have been matched in the contentafter- this text is searched for in the response content after thebeforetext has been found, and the returnedStringends immediately before this text occurs in the contentdefaultValue- the value to return if either thebeforeoraftertext cannot be foundcaseSensitive-trueif the search should be case-sensitive- Returns:
- the extracted text, or
defaultValueif 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 ofbeforeandafterStringobjects - returning thedefaultValueif they cannot be found. Information about the success/failure of this method will be stored in theExtractionCursorobject passed. The search is case-sensitive.Supplying a
List<String>ofbeforevalues enables you to express more complicated extraction patterns. eggPlant Performance searches for the firstStringin the list, and searches for the secondStringafter the position at which the firstStringwas found. This continues until the finalStringis matched, after which the extracted response content is returned untilafteris 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- anExtractionCursorobject to store the success/failure of the action, and the index in the response at which the match was foundbefore- eachStringin thisListis searched for sequentially in the response content, and the returnedStringstarts immediately after all theStringobjects have been matched in the contentafter- this text is searched for in the response content after thebeforetext has been found, and the returnedStringends immediately before this text occurs in the contentdefaultValue- the value to return if either thebeforeoraftertext cannot be found- Returns:
- the extracted text, or
defaultValueif 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 ofbeforeandafterStringobjects - returning an emptyStringif 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 theExtractionCursorobject passed.Supplying a
List<String>ofbeforevalues enables you to express more complicated extraction patterns. eggPlant Performance searches for the firstStringin the list, and searches for the secondStringafter the position at which the firstStringwas found. This continues until the finalStringis matched, after which the extracted response content is returned untilafteris 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- anExtractionCursorobject to store the success/failure of the action, and the index in the response at which the match was foundbefore- eachStringin thisListis searched for sequentially in the response content, and the returnedStringstarts immediately after all theStringobjects have been matched in the contentafter- this text is searched for in the response content after thebeforetext has been found, and the returnedStringends immediately before this text occurs in the contentcaseSensitive-trueif the search should be case-sensitive- Returns:
- the extracted text, or an empty
Stringif 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 ofbeforeandafterStringobjects - returning an emptyStringif they cannot be found. Information about the success/failure of this method will be stored in theExtractionCursorobject passed. The search is case-sensitive.Supplying a
List<String>ofbeforevalues enables you to express more complicated extraction patterns. eggPlant Performance searches for the firstStringin the list, and searches for the secondStringafter the position at which the firstStringwas found. This continues until the finalStringis matched, after which the extracted response content is returned untilafteris 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- anExtractionCursorobject to store the success/failure of the action, and the index in the response at which the match was foundbefore- eachStringin thisListis searched for sequentially in the response content, and the returnedStringstarts immediately after all theStringobjects have been matched in the contentafter- this text is searched for in the response content after thebeforetext has been found, and the returnedStringends immediately before this text occurs in the content- Returns:
- the extracted text, or an empty
Stringif 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 specifiedbeforeandafterStringobjects - returning an emptyStringif 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 theExtractionCursorobject 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- anExtractionCursorobject 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 returnedStringstarts immediately after this text occurs in the contentafter- this text is searched for in the response content after thebeforetext has been found, and the returnedStringends immediately before this text occurs in the contentcaseSensitive-trueif the search should be case-sensitive- Returns:
- the extracted text, or an empty
Stringif 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 specifiedbeforeandafterStringobjects - returning an emptyStringif they cannot be found. Information about the success/failure of this method will be stored in theExtractionCursorobject 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- anExtractionCursorobject 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 returnedStringstarts immediately after this text occurs in the contentafter- this text is searched for in the response content after thebeforetext has been found, and the returnedStringends immediately before this text occurs in the content- Returns:
- the extracted text, or an empty
Stringif 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.UnsupportedEncodingExceptionExtracts text from the response content - everything between (but not including) the specifiedbeforeandafterStringobjects - returning thedefaultValueif 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 returnedStringstarts immediately after this text occurs in the contentafter- this text is searched for in the response content after thebeforetext has been found, and the returnedStringends immediately before this text occurs in the contentdefaultValue- the value to return if either thebeforeoraftertext cannot be foundcaseSensitive-trueif the search should be case-sensitive- Returns:
- the extracted text, or
defaultValueif 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.UnsupportedEncodingExceptionExtracts text from the response content - everything between (but not including) the specifiedbeforeandafterStringobjects - returning thedefaultValueif 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 returnedStringstarts immediately after this text occurs in the contentafter- this text is searched for in the response content after thebeforetext has been found, and the returnedStringends immediately before this text occurs in the contentdefaultValue- the value to return if either thebeforeoraftertext cannot be found- Returns:
- the extracted text, or
defaultValueif 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.UnsupportedEncodingExceptionExtracts text from the response content - everything between (but not including) the specified list ofbeforeandafterStringobjects - returning thedefaultValueif they cannot be found, and specifying whether the search will be case-sensitive.Supplying a
List<String>ofbeforevalues enables you to express more complicated extraction patterns. eggPlant Performance searches for the firstStringin the list, and searches for the secondStringafter the position at which the firstStringwas found. This continues until the finalStringis matched, after which the extracted response content is returned untilafteris 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- eachStringin thisListis searched for sequentially in the response content, and the returnedStringstarts immediately after all theStringobjects have been matched in the contentafter- this text is searched for in the response content after thebeforetext has been found, and the returnedStringends immediately before this text occurs in the contentdefaultValue- the value to return if either thebeforeoraftertext cannot be foundcaseSensitive-trueif the search should be case-sensitive- Returns:
- the extracted text, or
defaultValueif 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.UnsupportedEncodingExceptionExtracts text from the response content - everything between (but not including) the specified list ofbeforeandafterStringobjects - returning thedefaultValueif they cannot be found. The search is case-sensitive.Supplying a
List<String>ofbeforevalues enables you to express more complicated extraction patterns. eggPlant Performance searches for the firstStringin the list, and searches for the secondStringafter the position at which the firstStringwas found. This continues until the finalStringis matched, after which the extracted response content is returned untilafteris 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- eachStringin thisListis searched for sequentially in the response content, and the returnedStringstarts immediately after all theStringobjects have been matched in the contentafter- this text is searched for in the response content after thebeforetext has been found, and the returnedStringends immediately before this text occurs in the contentdefaultValue- the value to return if either thebeforeoraftertext cannot be found- Returns:
- the extracted text, or
defaultValueif 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.UnsupportedEncodingExceptionExtracts text from the response content - everything between (but not including) the specified list ofbeforeandafterStringobjects - returning an emptyStringif they cannot be found, and specifying whether the search will be case-sensitive.Supplying a
List<String>ofbeforevalues enables you to express more complicated extraction patterns. eggPlant Performance searches for the firstStringin the list, and searches for the secondStringafter the position at which the firstStringwas found. This continues until the finalStringis matched, after which the extracted response content is returned untilafteris 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- eachStringin thisListis searched for sequentially in the response content, and the returnedStringstarts immediately after all theStringobjects have been matched in the contentafter- this text is searched for in the response content after thebeforetext has been found, and the returnedStringends immediately before this text occurs in the contentcaseSensitive-trueif the search should be case-sensitive- Returns:
- the extracted text, or an empty
Stringif 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.UnsupportedEncodingExceptionExtracts text from the response content - everything between (but not including) the specified list ofbeforeandafterStringobjects - returning an emptyStringif they cannot be found. The search is case-sensitive.Supplying a
List<String>ofbeforevalues enables you to express more complicated extraction patterns. eggPlant Performance searches for the firstStringin the list, and searches for the secondStringafter the position at which the firstStringwas found. This continues until the finalStringis matched, after which the extracted response content is returned untilafteris 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- eachStringin thisListis searched for sequentially in the response content, and the returnedStringstarts immediately after all theStringobjects have been matched in the contentafter- this text is searched for in the response content after thebeforetext has been found, and the returnedStringends immediately before this text occurs in the content- Returns:
- the extracted text, or an empty
Stringif 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.UnsupportedEncodingExceptionExtracts text from the response content - everything between (but not including) the specifiedbeforeandafterStringobjects - returning an emptyStringif 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 returnedStringstarts immediately after this text occurs in the contentafter- this text is searched for in the response content after thebeforetext has been found, and the returnedStringends immediately before this text occurs in the contentcaseSensitive-trueif the search should be case-sensitive- Returns:
- the extracted text, or an empty
Stringif 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.UnsupportedEncodingExceptionExtracts text from the response content - everything between (but not including) the specifiedbeforeandafterStringobjects - returning an emptyStringif 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 returnedStringstarts immediately after this text occurs in the contentafter- this text is searched for in the response content after thebeforetext has been found, and the returnedStringends immediately before this text occurs in the content- Returns:
- the extracted text, or an empty
Stringif 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.UnsupportedEncodingExceptionExtracts text from the response content - everything between (but not including) the specifiedbeforeandafterStringobjects - returning an emptyStringif 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 returnedStringstarts immediately after this text occurs in the contentafter- this text is searched for in the response content after thebeforetext has been found, and the returnedStringends immediately before this text occurs in the contentfailAction- the action to take iftextcannot be foundcaseSensitive-trueif the search should be case-sensitive- Returns:
- the extracted text, or an empty
Stringif 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.UnsupportedEncodingExceptionExtracts text from the response content - everything between (but not including) the specifiedbeforeandafterStringobjects - returning an emptyStringif 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 returnedStringstarts immediately after this text occurs in the contentafter- this text is searched for in the response content after thebeforetext has been found, and the returnedStringends immediately before this text occurs in the contentfailAction- the action to take iftextcannot be found- Returns:
- the extracted text, or an empty
Stringif 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.UnsupportedEncodingExceptionExtracts text from the response content - everything between (but not including) the specified list ofbeforeandafterStringobjects - returning an emptyStringif 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>ofbeforevalues enables you to express more complicated extraction patterns. eggPlant Performance searches for the firstStringin the list, and searches for the secondStringafter the position at which the firstStringwas found. This continues until the finalStringis matched, after which the extracted response content is returned untilafteris 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- eachStringin thisListis searched for sequentially in the response content, and the returnedStringstarts immediately after all theStringobjects have been matched in the contentafter- this text is searched for in the response content after thebeforetext has been found, and the returnedStringends immediately before this text occurs in the contentfailAction- the action to take iftextcannot be foundcaseSensitive-trueif the search should be case-sensitive- Returns:
- the extracted text, or an empty
Stringif 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.UnsupportedEncodingExceptionExtracts text from the response content - everything between (but not including) the specified list ofbeforeandafterStringobjects - returning an emptyStringif 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>ofbeforevalues enables you to express more complicated extraction patterns. eggPlant Performance searches for the firstStringin the list, and searches for the secondStringafter the position at which the firstStringwas found. This continues until the finalStringis matched, after which the extracted response content is returned untilafteris 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- eachStringin thisListis searched for sequentially in the response content, and the returnedStringstarts immediately after all theStringobjects have been matched in the contentafter- this text is searched for in the response content after thebeforetext has been found, and the returnedStringends immediately before this text occurs in the contentfailAction- the action to take iftextcannot be found- Returns:
- the extracted text, or an empty
Stringif 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 specifiedafterandbeforestring objects will be returned. If either value cannot be found, thedefaultValuewill be returned.Information about the success/failure of this method will be stored in the
ExtractionCursorobject 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- AnExtractionCursorobject 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 theaftertext has been found, and the returned string ends immediately after this text occurs in the content.defaultValue- The value to return if either thebeforeoraftertext cannot be found.caseSensitive-trueif the search should be case-sensitive.matchFlags- anSearchFlagsenumerated value to indicate what should be searched: SEARCH_IN_BODY, SEARCH_IN_HEADERS or SEARCH_IN_BOTH- Returns:
- The extracted text, or
defaultValueif 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 specifiedafterandbeforestring objects will be returned. If either value cannot be found, thedefaultValuewill be returned.Information about the success/failure of this method will be stored in the
ExtractionCursorobject 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- AnExtractionCursorobject 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 theaftertext has been found, and the returned string ends immediately after this text occurs in the content.defaultValue- The value to return if either thebeforeoraftertext cannot be found.caseSensitive-trueif the search should be case-sensitive.- Returns:
- The extracted text, or
defaultValueif 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 specifiedafterandbeforestring objects will be returned. If either value cannot be found, thedefaultValuewill be returned.Information about the success/failure of this method will be stored in the
ExtractionCursorobject 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- AnExtractionCursorobject 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 theaftertext has been found, and the returned string ends immediately after this text occurs in the content.defaultValue- The value to return if either thebeforeoraftertext cannot be found.- Returns:
- The extracted text, or
defaultValueif 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 specifiedafterandbeforestring objects will be returned.Information about the success/failure of this method will be stored in the
ExtractionCursorobject 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- AnExtractionCursorobject 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 theaftertext has been found, and the returned string ends immediately after this text occurs in the content.caseSensitive-trueif the search should be case-sensitive.matchFlags- anSearchFlagsenumerated 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 specifiedafterandbeforestring objects will be returned.Information about the success/failure of this method will be stored in the
ExtractionCursorobject 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- AnExtractionCursorobject 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 theaftertext has been found, and the returned string ends immediately after this text occurs in the content.caseSensitive-trueif 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 specifiedafterandbeforestring objects will be returned.Information about the success/failure of this method will be stored in the
ExtractionCursorobject 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- AnExtractionCursorobject 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 theaftertext 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 specifiedafterandbeforestring objects will be returned.Information about the success/failure of this method will be stored in the
ExtractionCursorobject 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- AnExtractionCursorobject 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 theaftertext has been found, and the returned string ends immediately after this text occurs in the content.failAction- the action to take iftextcannot be foundcaseSensitive-trueif the search should be case-sensitive.matchFlags- anSearchFlagsenumerated 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 specifiedafterandbeforestring objects will be returned.Information about the success/failure of this method will be stored in the
ExtractionCursorobject 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- AnExtractionCursorobject 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 theaftertext has been found, and the returned string ends immediately after this text occurs in the content.failAction- the action to take iftextcannot be foundcaseSensitive-trueif 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 specifiedafterandbeforestring objects will be returned.Information about the success/failure of this method will be stored in the
ExtractionCursorobject 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- AnExtractionCursorobject 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 theaftertext has been found, and the returned string ends immediately after this text occurs in the content.failAction- the action to take iftextcannot 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 ofafterandbeforestring 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 untilbeforeis 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- AnExtractionCursorobject 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 theaftertext has been found, and the returned string ends immediately after this text occurs in the content.defaultValue- The value to return if either thebeforeoraftertext cannot be found.caseSensitive-trueif the search should be case-sensitive.matchFlags- anSearchFlagsenumerated value to indicate what should be searched: SEARCH_IN_BODY, SEARCH_IN_HEADERS or SEARCH_IN_BOTH- Returns:
- The extracted text, or
defaultValueif 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 ofafterandbeforestring 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 untilbeforeis 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- AnExtractionCursorobject 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 theaftertext has been found, and the returned string ends immediately after this text occurs in the content.defaultValue- The value to return if either thebeforeoraftertext cannot be found.caseSensitive-trueif the search should be case-sensitive.- Returns:
- The extracted text, or
defaultValueif 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 ofafterandbeforestring 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 untilbeforeis 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- AnExtractionCursorobject 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 theaftertext has been found, and the returned string ends immediately after this text occurs in the content.defaultValue- The value to return if either thebeforeoraftertext cannot be found.- Returns:
- The extracted text, or
defaultValueif 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 ofafterandbeforestring 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 untilbeforeis 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- AnExtractionCursorobject 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 theaftertext has been found, and the returned string ends immediately after this text occurs in the content.caseSensitive-trueif the search should be case-sensitive.matchFlags- anSearchFlagsenumerated 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 ofafterandbeforestring 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 untilbeforeis 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- AnExtractionCursorobject 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 theaftertext has been found, and the returned string ends immediately after this text occurs in the content.caseSensitive-trueif 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 ofafterandbeforestring 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 untilbeforeis 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- AnExtractionCursorobject 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 theaftertext 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 ofafterandbeforestring 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 untilbeforeis 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- AnExtractionCursorobject 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 theaftertext has been found, and the returned string ends immediately after this text occurs in the content.failAction- the action to take iftextcannot be foundcaseSensitive-trueif the search should be case-sensitive.matchFlags- anSearchFlagsenumerated 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 ofafterandbeforestring 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 untilbeforeis 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- AnExtractionCursorobject 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 theaftertext has been found, and the returned string ends immediately after this text occurs in the content.failAction- the action to take iftextcannot be foundcaseSensitive-trueif 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 ofafterandbeforestring 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 untilbeforeis 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- AnExtractionCursorobject 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 theaftertext has been found, and the returned string ends immediately after this text occurs in the content.failAction- the action to take iftextcannot 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.UnsupportedEncodingExceptionExtracts text from the response content, starting from the end. Everything between (but not including) the specifiedafterandbeforestring objects will be returned. If either value cannot be found, thedefaultValuewill 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 theaftertext has been found, and the returned string ends immediately after this text occurs in the content.defaultValue- The value to return if either thebeforeoraftertext cannot be found.caseSensitive-trueif the search should be case-sensitive.matchFlags- anSearchFlagsenumerated value to indicate what should be searched: SEARCH_IN_BODY, SEARCH_IN_HEADERS or SEARCH_IN_BOTH- Returns:
- The extracted text, or
defaultValueif 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.UnsupportedEncodingExceptionExtracts text from the response content, starting from the end. Everything between (but not including) the specifiedafterandbeforestring objects will be returned. If either value cannot be found, thedefaultValuewill 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 theaftertext has been found, and the returned string ends immediately after this text occurs in the content.defaultValue- The value to return if either thebeforeoraftertext cannot be found.caseSensitive-trueif the search should be case-sensitive.- Returns:
- The extracted text, or
defaultValueif 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.UnsupportedEncodingExceptionExtracts text from the response content, starting from the end. Everything between (but not including) the specifiedafterandbeforestring objects will be returned. If either value cannot be found, thedefaultValuewill 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 theaftertext has been found, and the returned string ends immediately after this text occurs in the content.defaultValue- The value to return if either thebeforeoraftertext cannot be found.- Returns:
- The extracted text, or
defaultValueif 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.UnsupportedEncodingExceptionExtracts text from the response content, starting from the end. Everything between (but not including) the specifiedafterandbeforestring 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 theaftertext has been found, and the returned string ends immediately after this text occurs in the content.caseSensitive-trueif the search should be case-sensitive.matchFlags- anSearchFlagsenumerated 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.UnsupportedEncodingExceptionExtracts text from the response content, starting from the end. Everything between (but not including) the specifiedafterandbeforestring 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 theaftertext has been found, and the returned string ends immediately after this text occurs in the content.caseSensitive-trueif 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.UnsupportedEncodingExceptionExtracts text from the response content, starting from the end. Everything between (but not including) the specifiedafterandbeforestring 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 theaftertext 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.UnsupportedEncodingExceptionExtracts text from the response content, starting from the end. Everything between (but not including) the specifiedafterandbeforestring 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 theaftertext has been found, and the returned string ends immediately after this text occurs in the content.failAction- the action to take iftextcannot be foundcaseSensitive-trueif the search should be case-sensitive.matchFlags- anSearchFlagsenumerated 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.UnsupportedEncodingExceptionExtracts text from the response content, starting from the end. Everything between (but not including) the specifiedafterandbeforestring 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 theaftertext has been found, and the returned string ends immediately after this text occurs in the content.failAction- the action to take iftextcannot be foundcaseSensitive-trueif 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.UnsupportedEncodingExceptionExtracts text from the response content, starting from the end. Everything between (but not including) the specifiedafterandbeforestring 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 theaftertext has been found, and the returned string ends immediately after this text occurs in the content.failAction- the action to take iftextcannot 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.UnsupportedEncodingExceptionExtracts text from the response content starting from the end. Everything between (but not including) the specified list ofafterandbeforestring 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 untilbeforeis 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 theaftertext has been found, and the returned string ends immediately after this text occurs in the content.defaultValue- The value to return if either thebeforeoraftertext cannot be found.caseSensitive-trueif the search should be case-sensitive.matchFlags- anSearchFlagsenumerated value to indicate what should be searched: SEARCH_IN_BODY, SEARCH_IN_HEADERS or SEARCH_IN_BOTH- Returns:
- The extracted text, or
defaultValueif 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.UnsupportedEncodingExceptionExtracts text from the response content starting from the end. Everything between (but not including) the specified list ofafterandbeforestring 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 untilbeforeis 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 theaftertext has been found, and the returned string ends immediately after this text occurs in the content.defaultValue- The value to return if either thebeforeoraftertext cannot be found.caseSensitive-trueif the search should be case-sensitive.- Returns:
- The extracted text, or
defaultValueif 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.UnsupportedEncodingExceptionExtracts text from the response content starting from the end. Everything between (but not including) the specified list ofafterandbeforestring 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 untilbeforeis 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 theaftertext has been found, and the returned string ends immediately after this text occurs in the content.defaultValue- The value to return if either thebeforeoraftertext cannot be found.- Returns:
- The extracted text, or
defaultValueif 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.UnsupportedEncodingExceptionExtracts text from the response content starting from the end. Everything between (but not including) the specified list ofafterandbeforestring 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 untilbeforeis 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 theaftertext has been found, and the returned string ends immediately after this text occurs in the content.caseSensitive-trueif the search should be case-sensitive.matchFlags- anSearchFlagsenumerated 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.UnsupportedEncodingExceptionExtracts text from the response content starting from the end. Everything between (but not including) the specified list ofafterandbeforestring 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 untilbeforeis 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 theaftertext has been found, and the returned string ends immediately after this text occurs in the content.caseSensitive-trueif 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.UnsupportedEncodingExceptionExtracts text from the response content starting from the end. Everything between (but not including) the specified list ofafterandbeforestring 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 untilbeforeis 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 theaftertext 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.UnsupportedEncodingExceptionExtracts text from the response content starting from the end. Everything between (but not including) the specified list ofafterandbeforestring 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 untilbeforeis 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 theaftertext has been found, and the returned string ends immediately after this text occurs in the content.failAction- the action to take iftextcannot be foundcaseSensitive-trueif the search should be case-sensitive.matchFlags- anSearchFlagsenumerated 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.UnsupportedEncodingExceptionExtracts text from the response content starting from the end. Everything between (but not including) the specified list ofafterandbeforestring 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 untilbeforeis 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 theaftertext has been found, and the returned string ends immediately after this text occurs in the content.failAction- the action to take iftextcannot be foundcaseSensitive-trueif 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.UnsupportedEncodingExceptionExtracts text from the response content starting from the end. Everything between (but not including) the specified list ofafterandbeforestring 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 untilbeforeis 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 theaftertext has been found, and the returned string ends immediately after this text occurs in the content.failAction- the action to take iftextcannot 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.InternalErrorExtracts 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
beforeandaftermarkers. 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- aStringbefore an item to be extractedafter- aStringafter an item to be extractedcaseSensitive-trueif the search should be case-sensitivemaxItems- the maximum number of items to extract- Returns:
- a list containing the extracted
Stringobjects - 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.InternalErrorExtracts a list of items from thisResponse, specifying whether the search should be case-sensitive.A search is made for multiple occurrences of the
beforeandaftermarkers. 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- aStringoccurring immediately before an item to be extractedafter- aStringoccurring immediately after an item to be extractedcaseSensitive-trueif the search should be case-sensitive- Returns:
- a list containing the extracted
Stringobjects - 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.InternalErrorExtracts a list of items from thisResponse.A search is made for multiple occurrences of the
beforeandaftermarkers. 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- aStringoccurring immediately before an item to be extractedafter- aStringoccurring immediately after an item to be extracted- Returns:
- a list containing the extracted
Stringobjects - 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
beforeandaftermarkers. 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- anExtractionCursorobject to store the success/failure of the action, and the index in the response at which the last match was foundbefore- aStringoccurring immediately before an item to be extractedafter- aStringoccurring immediately after an item to be extractedendAt- only return matches that occur before this text in the responsecaseSensitive-trueif the search should be case-sensitivemaxItems- the maximum number of items to extract- Returns:
- a list containing the extracted
Stringobjects - 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
beforeandaftermarkers. 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- anExtractionCursorobject to store the success/failure of the action, and the index in the response at which the last match was foundbefore- aStringoccurring immediately before an item to be extractedafter- aStringoccurring immediately after an item to be extractedendAt- only return matches that occur before this text in the responsecaseSensitive-trueif the search should be case-sensitive- Returns:
- a list containing the extracted
Stringobjects - 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
beforeandaftermarkers. 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- anExtractionCursorobject to store the success/failure of the action, and the index in the response at which the last match was foundbefore- aStringoccurring immediately before an item to be extractedafter- aStringoccurring immediately after an item to be extractedendAt- only return matches that occur before this text in the response- Returns:
- a list containing the extracted
Stringobjects - 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
beforeandaftermarkers. 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- anExtractionCursorobject to store the success/failure of the action, and the index in the response at which the last match was foundbefore- aStringoccurring immediately before an item to be extractedafter- aStringoccurring immediately after an item to be extracted- Returns:
- a list containing the extracted
Stringobjects - 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 multipleStringobjects 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 theExtractionCursorobject 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- anExtractionCursorobject 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-trueif the search should be case-sensitive- Returns:
- a
RegExpMatchListcontaining the list of matches
-
extractRegExp
public RegExpMatchList extractRegExp(ExtractionCursor cursor, java.lang.String regExp)
Extracts multipleStringobjects from the response content, wherever the specified regular expression matches. Information about the success/failure of this method will be stored in theExtractionCursorobject 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- anExtractionCursorobject 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
RegExpMatchListcontaining the list of matches
-
extractXPath
public java.lang.String extractXPath(java.lang.String xpathExpression, ActionType failAction) throws java.lang.Exception, java.io.UnsupportedEncodingExceptionReturns 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
Stringif 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.UnsupportedEncodingExceptionReturnstrueif the content of thisResponsecontains 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-trueif the search should be case-sensitive- Returns:
trueif the text was found- Throws:
java.io.UnsupportedEncodingException- The encoding is not supported
-
verifyContains
public boolean verifyContains(java.lang.String text) throws java.io.UnsupportedEncodingExceptionReturnstrueif the content of thisResponsecontains 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:
trueif 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 specifiedtextwithin 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 theExtractionCursorobject 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- anExtractionCursorobject 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 iftextcannot be foundcaseSensitive-trueif the search should be case-sensitive- Returns:
trueif the specifiedtextwas 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 specifiedtextwithin thisResponse, specifying what action to take in case of failure. Information about the success/failure of this method will be stored in theExtractionCursorobject 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- anExtractionCursorobject 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 iftextcannot be found- Returns:
trueif the specifiedtextwas 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 specifiedtextwithin 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 theExtractionCursorobject 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- anExtractionCursorobject 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 iftextcannot be foundcaseSensitive-trueif the search should be case-sensitive- Returns:
trueif the specifiedtextwas 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 specifiedtextwithin 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 theExtractionCursorobject 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- anExtractionCursorobject 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 iftextcannot be found- Returns:
trueif the specifiedtextwas 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 specifiedbeforeandafterStringobjects - returning an emptyStringif 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 theExtractionCursorobject 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- anExtractionCursorobject 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 returnedStringstarts immediately after this text occurs in the contentafter- this text is searched for in the response content after thebeforetext has been found, and the returnedStringends immediately before this text occurs in the contentfailAction- the action to take iftextcannot be foundcaseSensitive-trueif the search should be case-sensitive- Returns:
- the extracted text, or an empty
Stringif 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 specifiedbeforeandafterStringobjects - returning an emptyStringif 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 theExtractionCursorobject 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- anExtractionCursorobject 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 returnedStringstarts immediately after this text occurs in the contentafter- this text is searched for in the response content after thebeforetext has been found, and the returnedStringends immediately before this text occurs in the contentfailAction- the action to take iftextcannot be found- Returns:
- the extracted text, or an empty
Stringif 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 ofbeforeandafterStringobjects - returning an emptyStringif 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 theExtractionCursorobject passed.Supplying a
List<String>ofbeforevalues enables you to express more complicated extraction patterns. eggPlant Performance searches for the firstStringin the list, and searches for the secondStringafter the position at which the firstStringwas found. This continues until the finalStringis matched, after which the extracted response content is returned untilafteris 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- anExtractionCursorobject to store the success/failure of the action, and the index in the response at which the match was foundbefore- eachStringin thisListis searched for sequentially in the response content, and the returnedStringstarts immediately after all theStringobjects have been matched in the contentafter- this text is searched for in the response content after thebeforetext has been found, and the returnedStringends immediately before this text occurs in the contentfailAction- the action to take iftextcannot be foundcaseSensitive-trueif the search should be case-sensitive- Returns:
- the extracted text, or an empty
Stringif 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 ofbeforeandafterStringobjects - returning an emptyStringif 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 theExtractionCursorobject passed. The search is case-sensitive.Supplying a
List<String>ofbeforevalues enables you to express more complicated extraction patterns. eggPlant Performance searches for the firstStringin the list, and searches for the secondStringafter the position at which the firstStringwas found. This continues until the finalStringis matched, after which the extracted response content is returned untilafteris 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- anExtractionCursorobject to store the success/failure of the action, and the index in the response at which the match was foundbefore- eachStringin thisListis searched for sequentially in the response content, and the returnedStringstarts immediately after all theStringobjects have been matched in the contentafter- this text is searched for in the response content after thebeforetext has been found, and the returnedStringends immediately before this text occurs in the contentfailAction- the action to take iftextcannot be found- Returns:
- the extracted text, or an empty
Stringif 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 specifiedbeforeandafterStringobjects - returning an emptyStringif they cannot be found. Information about the success/failure of this method will be stored in theExtractionCursorobject passed. The search is case-sensitive.The
matchFlagsparameter 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- anExtractionCursorobject 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 returnedStringstarts immediately after this text occurs in the contentafter- this text is searched for in the response content after thebeforetext has been found, and the returnedStringends immediately before this text occurs in the contentmatchFlags- anSearchFlagsenumerated value to indicate what should be searched: SEARCH_IN_BODY, SEARCH_IN_HEADERS or SEARCH_IN_BOTH- Returns:
- the extracted text, or an empty
Stringif 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 specifiedbeforeandafterStringobjects - returning an emptyStringif 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 theExtractionCursorobject passed.The
matchFlagsparameter 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- anExtractionCursorobject 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 returnedStringstarts immediately after this text occurs in the contentafter- this text is searched for in the response content after thebeforetext has been found, and the returnedStringends immediately before this text occurs in the contentmatchFlags- anSearchFlagsenumerated value to indicate what should be searched: SEARCH_IN_BODY, SEARCH_IN_HEADERS or SEARCH_IN_BOTHcaseSensitive-trueif the search should be case-sensitive- Returns:
- the extracted text, or an empty
Stringif 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 specifiedbeforeandafterStringobjects - returning an emptyStringif they cannot be found. Information about the success/failure of this method will be stored in theExtractionCursorobject passed. The search is case-sensitive.The
matchFlagsparameter 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- anExtractionCursorobject 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 returnedStringstarts immediately after this text occurs in the contentafterRegExp- this text is searched for in the response content after thebeforetext has been found, and the returnedStringends immediately before this text occurs in the contentmatchFlags- anSearchFlagsenumerated value to indicate what should be searched: SEARCH_IN_BODY, SEARCH_IN_HEADERS or SEARCH_IN_BOTH- Returns:
- the extracted text, or an empty
Stringif 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 specifiedbeforeandafterStringobjects - returning an emptyStringif 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 theExtractionCursorobject passed.The
matchFlagsparameter 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- anExtractionCursorobject 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 returnedStringstarts immediately after this text occurs in the contentafterRegExp- this text is searched for in the response content after thebeforetext has been found, and the returnedStringends immediately before this text occurs in the contentmatchFlags- anSearchFlagsenumerated value to indicate what should be searched: SEARCH_IN_BODY, SEARCH_IN_HEADERS or SEARCH_IN_BOTHcaseSensitive-trueif the search should be case-sensitive- Returns:
- the extracted text, or an empty
Stringif 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
beforeandaftermarkers. The text between each occurrence of the markers is extracted and appended to the list.The
matchFlagsparameter 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- anExtractionCursorobject to store the success/failure of the action, and the index in the response at which the last match was foundbefore- aStringoccurring immediately before an item to be extractedafter- aStringoccurring immediately after an item to be extractedmatchFlags- anSearchFlagsenumerated value to indicate what should be searched: SEARCH_IN_BODY, SEARCH_IN_HEADERS or SEARCH_IN_BOTH- Returns:
- a list containing the extracted
Stringobjects
-
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
beforeandaftermarkers. The text between each occurrence of the markers is extracted and appended to the list.The
matchFlagsparameter 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- anExtractionCursorobject to store the success/failure of the action, and the index in the response at which the last match was foundbefore- aStringoccurring immediately before an item to be extractedafter- aStringoccurring immediately after an item to be extractedmatchFlags- anSearchFlagsenumerated 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
Stringobjects
-
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
beforeandaftermarkers. The text between each occurrence of the markers is extracted and appended to the list.The
matchFlagsparameter 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- anExtractionCursorobject to store the success/failure of the action, and the index in the response at which the last match was foundbefore- aStringoccurring immediately before an item to be extractedafter- aStringoccurring immediately after an item to be extractedmatchFlags- anSearchFlagsenumerated 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-trueif the search should be case-sensitive- Returns:
- a list containing the extracted
Stringobjects
-
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
beforeandaftermarkers. The text between each occurrence of the markers is extracted and appended to the list.The
matchFlagsparameter 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- anExtractionCursorobject to store the success/failure of the action, and the index in the response at which the last match was foundbefore- aStringoccurring immediately before an item to be extractedafter- aStringoccurring immediately after an item to be extractedmatchFlags- anSearchFlagsenumerated 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-trueif the search should be case-sensitivemaxItems- the maximum number of items to extract- Returns:
- a list containing the extracted
Stringobjects
-
verifyContains
public boolean verifyContains(java.lang.String text, ActionType failAction, boolean caseSensitive) throws java.io.UnsupportedEncodingExceptionReturnstrueif the content of thisResponsecontains 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 iftextcannot be foundcaseSensitive-trueif the search should be case-sensitive- Returns:
trueif 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.UnsupportedEncodingExceptionReturnstrueif the content of thisResponsecontains 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 iftextcannot be found- Returns:
trueif 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
-
-