Package com.xceptance.xlt.api.actions
Class AbstractLightWeightPageAction
java.lang.Object
com.xceptance.xlt.api.actions.AbstractAction
com.xceptance.xlt.api.actions.AbstractWebAction
com.xceptance.xlt.api.actions.AbstractLightWeightPageAction
AbstractLightWeightPageAction is the base class for all HTML/XML-based actions which do simple page processing only.
In contrast to
AbstractHtmlPageAction
, the loaded page is represented as a single unparsed string. This makes
it harder to pick certain elements of the page, but completely avoids the client-side overhead to parse the page and
represent it as a tree of elements. Especially with complex pages, the overhead may be significantly lower this way.
So this class should be used, if either the page processing is simple enough or the test clients turn out to be the
bottleneck.-
Field Summary
Fields inherited from class com.xceptance.xlt.api.actions.AbstractWebAction
EMPTY_PARAMETER_LIST
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
AbstractLightWeightPageAction
(AbstractWebAction previousAction, String timerName) Creates a new AbstractLightWeightPageAction object and gives it the passed timer name.protected
AbstractLightWeightPageAction
(String timerName) Creates a new AbstractLightWeightPageAction object and gives it the passed timer name. -
Method Summary
Modifier and TypeMethodDescriptionReturns the unparsed content of the web page loaded by this action.int
Returns the response code of the last loaded page.Returns the light-weight page generated by this action.Returns the action that was passed as the previous action to the constructor.getURL()
Returns the URL that was used to load the page.protected void
Creates an URL from the passed string, loads the page using HTTP GET and stores it internally.protected void
Loads the page using HTTP GET from the passed URL and stores it internally.protected void
loadPage
(URL url, HttpMethod method, List<NameValuePair> requestParameters) Loads the page using the given request method from the passed URL and stores it internally.void
run()
The run method must restore the state in case we constructed another action in between to prevalidate conditions.void
Sets the given light-weight page object to be the result of this action.Methods inherited from class com.xceptance.xlt.api.actions.AbstractWebAction
addResponseProcessor, closeWebClient, createWebRequestSettings, getWebClient
Methods inherited from class com.xceptance.xlt.api.actions.AbstractAction
execute, executeThinkTime, getThinkTime, getThinkTimeDeviation, getTimerName, postValidate, preValidate, preValidateSafe, setThinkTime, setThinkTime, setThinkTimeDeviation, setThinkTimeDeviation, setTimerName
-
Constructor Details
-
AbstractLightWeightPageAction
Creates a new AbstractLightWeightPageAction object and gives it the passed timer name. This constructor is typically used for an intermediate action in a sequence of actions, i.e. it has a previous action.- Parameters:
previousAction
- the action that preceded the current actiontimerName
- the name of the timer that is associated with this action
-
AbstractLightWeightPageAction
Creates a new AbstractLightWeightPageAction object and gives it the passed timer name. This constructor is typically used for the first action in a sequence of actions, i.e. it has no previous action.- Parameters:
timerName
- the name of the timer that is associated with this action
-
-
Method Details
-
getPreviousAction
Returns the action that was passed as the previous action to the constructor. Allows to access data collected during the previous action.- Overrides:
getPreviousAction
in classAbstractWebAction
- Returns:
- the previous action (may be null)
-
getLightWeightPage
Returns the light-weight page generated by this action.- Returns:
- the page
-
getContent
Returns the unparsed content of the web page loaded by this action.- Returns:
- the content of the loaded page as string
-
getHttpResponseCode
public int getHttpResponseCode()Returns the response code of the last loaded page.- Returns:
- the HTTP response code
-
getURL
Returns the URL that was used to load the page. Subsequent actions may use this value to create new URLs based on this URL.- Returns:
- the URL
-
run
The run method must restore the state in case we constructed another action in between to prevalidate conditions.- Overrides:
run
in classAbstractWebAction
- Throws:
Throwable
- if an error occurred while running the action
-
setLightWeightPage
Sets the given light-weight page object to be the result of this action. Typically, the light-weight page is generated by one of theloadPage()
methods and need not be set explicitly.- Parameters:
page
- the page to set
-
loadPage
Loads the page using HTTP GET from the passed URL and stores it internally. The URL is stored for further reference.- Parameters:
url
- the target URL- Throws:
Exception
- if an error occurred while loading the page
-
loadPage
Creates an URL from the passed string, loads the page using HTTP GET and stores it internally. The URL is stored for further reference.- Parameters:
urlAsString
- an URL as string- Throws:
Exception
- if an error occurred while loading the page
-
loadPage
protected void loadPage(URL url, HttpMethod method, List<NameValuePair> requestParameters) throws Exception Loads the page using the given request method from the passed URL and stores it internally. The specified request parameters are added either to the request body if the request method isHttpMethod.POST
or appended to the query string of the target URL for any other request method.- Parameters:
url
- the target URLmethod
- the HTTP request method to be usedrequestParameters
- the list of custom parameters to add- Throws:
Exception
- if an error occurred while loading the page
-