Class AbstractHtmlPageAction
- java.lang.Object
-
- com.xceptance.xlt.api.actions.AbstractAction
-
- com.xceptance.xlt.api.actions.AbstractWebAction
-
- com.xceptance.xlt.api.actions.AbstractHtmlPageAction
-
- Direct Known Subclasses:
AbstractHtmlUnitScriptAction
public abstract class AbstractHtmlPageAction extends AbstractWebAction
AbstractHtmlPageAction is the base class for all HTML-based actions. In contrast toAbstractLightWeightPageAction
, the loaded page is parsed and stored internally as a tree of elements. This makes it easy to locate and query/manipulate a certain page element.In case JavaScript processing is enabled, the loaded pages might start JS background jobs (via window.setTimeout() and window.setInterval()). In order to wait for these jobs to finish, an optional waiting time can be specified for each of the page loading methods. The framework will not return from these methods unless either all background jobs are finished or the specified waiting time is exceeded. Note that in the latter case any pending (i.e. scheduled, but not running yet) background job is removed, while any running job is left running. If no waiting time is specified, a default waiting time is read from the configuration.
Note that if the specified waiting time is negative, the framework will not wait for any job to finish, nor will it cancel pending jobs.
- See Also:
AbstractLightWeightPageAction
-
-
Field Summary
-
Fields inherited from class com.xceptance.xlt.api.actions.AbstractWebAction
EMPTY_PARAMETER_LIST
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractHtmlPageAction(AbstractWebAction previousAction, java.lang.String timerName)
Creates a new AbstractHtmlPageAction object and gives it the passed timer name.protected
AbstractHtmlPageAction(java.lang.String timerName)
Creates a new AbstractHtmlPageAction object and gives it the passed timer name.
-
Method Summary
All Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description HtmlPage
getHtmlPage()
Returns the parsed HTML page object generated by this action.protected java.util.List<NetworkData>
getNetworkDataSet()
Returns the network data set.AbstractHtmlPageAction
getPreviousAction()
Returns the action that was passed as the previous action to the constructor.protected void
loadPage(java.lang.String urlAsString)
Loads the page using HTTP GET from the passed URL.protected void
loadPage(java.lang.String urlAsString, long waitingTime)
Loads the page using HTTP GET from the passed URL.protected void
loadPage(java.net.URL url)
Loads the page using HTTP GET from the passed URL.protected void
loadPage(java.net.URL url, long waitingTime)
Loads the page using HTTP GET from the passed URL and waits for background task to be finished.protected void
loadPage(java.net.URL url, HttpMethod method, java.util.List<NameValuePair> requestParameters)
Loads the page using the given request method from the passed URL.protected void
loadPage(java.net.URL url, HttpMethod method, java.util.List<NameValuePair> requestParameters, long waitingTime)
Loads the page using the given request method from the passed URL.protected void
loadPageByClick(HtmlElement element)
Loads the page by "clicking" the passed HTML element.protected void
loadPageByClick(HtmlElement element, long waitingTime)
Loads the page by "clicking" the passed HTML element.protected void
loadPageByDragAndDrop(HtmlElement draggable, HtmlElement dropTarget)
Loads the page by drag and dropprotected void
loadPageByDragAndDrop(HtmlElement draggable, HtmlElement dropTarget, long waitingTime)
Loads the page by drag and dropprotected void
loadPageByFormClick(HtmlForm form, java.lang.String elementToClick)
Loads the page by "clicking" the passed HTML element in the specified HTML form element.protected void
loadPageByFormClick(HtmlForm form, java.lang.String elementToClick, boolean randomPosition)
Deprecated.As of XLT 4.9.0, useloadPageByFormClick(HtmlForm, String)
instead.protected void
loadPageByFormClick(HtmlForm form, java.lang.String elementToClick, boolean randomPosition, long waitingTime)
Deprecated.As of XLT 4.9.0, useloadPageByFormClick(HtmlForm, String, long)
instead.protected void
loadPageByFormClick(HtmlForm form, java.lang.String elementToClick, long waitingTime)
Loads the page by "clicking" the passed HTML element in the specified HTML form element.protected void
loadPageByFormSubmit(HtmlForm form)
Loads the page by submitting the given form.protected void
loadPageByFormSubmit(HtmlForm form, long waitingTime)
Loads the page by submitting the given form.protected void
loadPageByFormSubmit(HtmlForm form, SubmittableElement element)
Loads the page by submitting the given form.protected void
loadPageByFormSubmit(HtmlForm form, SubmittableElement element, long waitingTime)
Loads the page by submitting the given form.protected void
loadPageBySelect(HtmlSelect select, java.lang.String optionValue)
Loads the page by selecting an option of the given HTML select element.protected void
loadPageBySelect(HtmlSelect select, java.lang.String optionValue, long waitingTime)
Loads the page by selecting an option from the given HTML select element.protected void
loadPageBySelect(HtmlSelect select, HtmlOption option)
Loads the page by selecting an option form the given HTML select element.protected void
loadPageBySelect(HtmlSelect select, HtmlOption option, long waitingTime)
Loads the page by selecting an option from the given HTML select element.protected void
loadPageByTypingKeys(HtmlElement element, java.lang.String text)
Loads the page by typing keys.protected void
loadPageByTypingKeys(HtmlElement element, java.lang.String text, long waitingTime)
Loads the page by typing keys.void
run()
The run method must restore the state in case we constructed another action in between to prevalidate conditions.void
setHtmlPage(HtmlPage htmlPage)
Sets the given HTML page object to be the result of this action.void
setHtmlPage(HtmlPage htmlPage, long waitingTime)
Sets the given HTML page object to be the result of this action and waits for background task to be finished.-
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 Detail
-
AbstractHtmlPageAction
protected AbstractHtmlPageAction(AbstractWebAction previousAction, java.lang.String timerName)
Creates a new AbstractHtmlPageAction 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
-
AbstractHtmlPageAction
protected AbstractHtmlPageAction(java.lang.String timerName)
Creates a new AbstractHtmlPageAction 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 Detail
-
getHtmlPage
public HtmlPage getHtmlPage()
Returns the parsed HTML page object generated by this action.- Returns:
- the page
-
getPreviousAction
public AbstractHtmlPageAction getPreviousAction()
Returns the action that was passed as the previous action to the constructor. Allows access to data collected during the previous action.- Overrides:
getPreviousAction
in classAbstractWebAction
- Returns:
- the previous action (may be null)
-
run
public void run() throws java.lang.Throwable
The run method must restore the state in case we constructed another action in between to prevalidate conditions.- Overrides:
run
in classAbstractWebAction
- Throws:
java.lang.Throwable
- if an error occurred while running the action
-
setHtmlPage
public void setHtmlPage(HtmlPage htmlPage)
Sets the given HTML page object to be the result of this action. Typically, the HTML page is generated by one of theloadPage...()
methods and need not be set explicitly.- Parameters:
htmlPage
- the page to set
-
setHtmlPage
public void setHtmlPage(HtmlPage htmlPage, long waitingTime)
Sets the given HTML page object to be the result of this action and waits for background task to be finished. Typically, the HTML page is generated by one of theloadPage...()
methods and need not be set explicitly.- Parameters:
htmlPage
- the page to setwaitingTime
- Waiting time for all background tasks on the page to be finished
-
loadPage
protected void loadPage(java.net.URL url, HttpMethod method, java.util.List<NameValuePair> requestParameters, long waitingTime) throws java.lang.Exception
Loads the page using the given request method from the passed URL. 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 addwaitingTime
- Waiting time for all background tasks on the page to be finished- Throws:
java.lang.Exception
- if an error occurred while loading the page
-
loadPage
protected void loadPage(java.net.URL url, HttpMethod method, java.util.List<NameValuePair> requestParameters) throws java.lang.Exception
Loads the page using the given request method from the passed URL. 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:
java.lang.Exception
- if an error occurred while loading the page
-
loadPage
protected void loadPage(java.net.URL url, long waitingTime) throws java.lang.Exception
Loads the page using HTTP GET from the passed URL and waits for background task to be finished.- Parameters:
url
- the target URLwaitingTime
- Waiting time for all background tasks on the page to be finished- Throws:
java.lang.Exception
- if an error occurred while loading the page
-
loadPage
protected void loadPage(java.net.URL url) throws java.lang.Exception
Loads the page using HTTP GET from the passed URL.- Parameters:
url
- the target URL- Throws:
java.lang.Exception
- if an error occurred while loading the page
-
loadPage
protected void loadPage(java.lang.String urlAsString, long waitingTime) throws java.lang.Exception
Loads the page using HTTP GET from the passed URL.- Parameters:
urlAsString
- the target URL as stringwaitingTime
- Waiting time for all background tasks on the page to be finished- Throws:
java.lang.Exception
- if an error occurred while loading the page
-
loadPage
protected void loadPage(java.lang.String urlAsString) throws java.lang.Exception
Loads the page using HTTP GET from the passed URL.- Parameters:
urlAsString
- the target URL as string- Throws:
java.lang.Exception
- if an error occurred while loading the page
-
loadPageByClick
protected void loadPageByClick(HtmlElement element, long waitingTime) throws java.lang.Exception
Loads the page by "clicking" the passed HTML element.- Parameters:
element
- the HTML element to clickwaitingTime
- Waiting time for all background tasks on the page to be finished- Throws:
java.lang.Exception
- if an error occurred while loading the page
-
loadPageByClick
protected void loadPageByClick(HtmlElement element) throws java.lang.Exception
Loads the page by "clicking" the passed HTML element.- Parameters:
element
- the HTML element to click- Throws:
java.lang.Exception
- if an error occurred while loading the page
-
loadPageByDragAndDrop
protected void loadPageByDragAndDrop(HtmlElement draggable, HtmlElement dropTarget, long waitingTime) throws java.lang.Exception
Loads the page by drag and drop- Parameters:
draggable
- the dragged objectdropTarget
- the element on which to drop- Throws:
java.lang.Exception
- if an error occurred while loading the page
-
loadPageByDragAndDrop
protected void loadPageByDragAndDrop(HtmlElement draggable, HtmlElement dropTarget) throws java.lang.Exception
Loads the page by drag and drop- Parameters:
draggable
- the dragged objectdropTarget
- the element on which to drop- Throws:
java.lang.Exception
- if an error occurred while loading the page
-
loadPageByFormClick
@Deprecated protected void loadPageByFormClick(HtmlForm form, java.lang.String elementToClick, boolean randomPosition, long waitingTime) throws java.lang.Exception
Deprecated.As of XLT 4.9.0, useloadPageByFormClick(HtmlForm, String, long)
instead.Loads the page by "clicking" the passed HTML element in the specified HTML form element. This method skips hidden elements and reports an error if a suitable element to click on was not found.- Parameters:
form
- the HTML formelementToClick
- the HTML element to click, cannot be a hidden element, this can be the name or the id. The name will be tried first, after that the id.randomPosition
- (parameter ignored)waitingTime
- Waiting time for all background tasks on the page to be finished- Throws:
java.lang.Exception
- if an error occurred while loading the pageElementMissingException
- if we do not have an element to click on
-
loadPageByFormClick
@Deprecated protected void loadPageByFormClick(HtmlForm form, java.lang.String elementToClick, boolean randomPosition) throws java.lang.Exception
Deprecated.As of XLT 4.9.0, useloadPageByFormClick(HtmlForm, String)
instead.Loads the page by "clicking" the passed HTML element in the specified HTML form element. This method skips hidden elements and reports an error if a suitable element to click on was not found.- Parameters:
form
- the HTML formelementToClick
- the HTML element to click, cannot be a hidden element, this can be the name or the id. The name will be tried first, after that the id.randomPosition
- (parameter ignored)- Throws:
java.lang.Exception
- if an error occurred while loading the pageElementMissingException
- if we do not have an element to click on
-
loadPageByFormClick
protected void loadPageByFormClick(HtmlForm form, java.lang.String elementToClick, long waitingTime) throws java.lang.Exception
Loads the page by "clicking" the passed HTML element in the specified HTML form element.- Parameters:
form
- the HTML formelementToClick
- the HTML element to click, cannot be a hidden element, this can be the name or the id. The name will be tried first, after that the id.waitingTime
- Waiting time for all background tasks on the page to be finished- Throws:
java.lang.Exception
- if an error occurred while loading the page
-
loadPageByFormClick
protected void loadPageByFormClick(HtmlForm form, java.lang.String elementToClick) throws java.lang.Exception
Loads the page by "clicking" the passed HTML element in the specified HTML form element.- Parameters:
form
- the HTML formelementToClick
- the HTML element to click- Throws:
java.lang.Exception
- if an error occurred while loading the page
-
loadPageBySelect
protected void loadPageBySelect(HtmlSelect select, java.lang.String optionValue) throws java.lang.Exception
Loads the page by selecting an option of the given HTML select element.- Parameters:
select
- the HTML select elementoptionValue
- the value of the HTML option to select- Throws:
java.lang.Exception
-
loadPageBySelect
protected void loadPageBySelect(HtmlSelect select, java.lang.String optionValue, long waitingTime) throws java.lang.Exception
Loads the page by selecting an option from the given HTML select element.- Parameters:
select
- the HTML selectoptionValue
- the value of the HTML option to selectwaitingTime
- Waiting time for all background tasks on the page to be finished- Throws:
java.lang.Exception
-
loadPageBySelect
protected void loadPageBySelect(HtmlSelect select, HtmlOption option)
Loads the page by selecting an option form the given HTML select element.- Parameters:
select
- the HTML selectoption
- the HTML option to select
-
loadPageBySelect
protected void loadPageBySelect(HtmlSelect select, HtmlOption option, long waitingTime) throws java.lang.Exception
Loads the page by selecting an option from the given HTML select element.- Parameters:
select
- the HTML selectoption
- the HTML option to selectwaitingTime
- Waiting time for all background tasks on the page to be finished- Throws:
java.lang.Exception
-
loadPageByFormSubmit
protected void loadPageByFormSubmit(HtmlForm form, SubmittableElement element, long waitingTime) throws java.lang.Exception
Loads the page by submitting the given form. Form submission is triggered by the given submittable element.- Parameters:
form
- the HTML form to submitelement
- the submittable element used to trigger form submissionwaitingTime
- Waiting time for all background tasks on the page to be finished- Throws:
java.lang.Exception
-
loadPageByFormSubmit
protected void loadPageByFormSubmit(HtmlForm form, SubmittableElement element) throws java.lang.Exception
Loads the page by submitting the given form. Form submission is triggered by the given submittable element.- Parameters:
form
- the HTML form to submitelement
- the submittable element used to trigger form submission- Throws:
java.lang.Exception
-
loadPageByFormSubmit
protected void loadPageByFormSubmit(HtmlForm form, long waitingTime) throws java.lang.Exception
Loads the page by submitting the given form.- Parameters:
form
- the HTML form to submitwaitingTime
- Waiting time for all background tasks on the page to be finished- Throws:
java.lang.Exception
-
loadPageByFormSubmit
protected void loadPageByFormSubmit(HtmlForm form) throws java.lang.Exception
Loads the page by submitting the given form.- Parameters:
form
- the HTML form to submit- Throws:
java.lang.Exception
-
loadPageByTypingKeys
protected void loadPageByTypingKeys(HtmlElement element, java.lang.String text, long waitingTime) throws java.lang.Exception
Loads the page by typing keys. Whether or not the page is reloaded depends on the key event handlers attached to the target HTML element.- Parameters:
element
- the target HTML elementtext
- the text to typewaitingTime
- Waiting time for all background tasks on the page to be finished- Throws:
java.lang.Exception
-
loadPageByTypingKeys
protected void loadPageByTypingKeys(HtmlElement element, java.lang.String text) throws java.lang.Exception
Loads the page by typing keys. Whether or not the page is reloaded depends on the key event handlers attached to the target HTML element.- Parameters:
element
- the target HTML elementtext
- the text to type- Throws:
java.lang.Exception
-
getNetworkDataSet
protected java.util.List<NetworkData> getNetworkDataSet()
Returns the network data set.- Returns:
- network data as set
-
-