Class AbstractHtmlPageAction
- Direct Known Subclasses:
AbstractHtmlUnitScriptAction
AbstractLightWeightPageAction
, 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:
-
Field Summary
Fields inherited from class com.xceptance.xlt.api.actions.AbstractWebAction
EMPTY_PARAMETER_LIST
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
AbstractHtmlPageAction
(AbstractWebAction previousAction, String timerName) Creates a new AbstractHtmlPageAction object and gives it the passed timer name.protected
AbstractHtmlPageAction
(String timerName) Creates a new AbstractHtmlPageAction object and gives it the passed timer name. -
Method Summary
Modifier and TypeMethodDescriptionReturns the parsed HTML page object generated by this action.protected List
<NetworkData> Returns the network data set.Returns the action that was passed as the previous action to the constructor.protected void
Loads the page using HTTP GET from the passed URL.protected void
Loads the page using HTTP GET from the passed URL.protected void
Loads the page using HTTP GET from the passed URL.protected void
Loads the page using HTTP GET from the passed URL and waits for background task to be finished.protected void
loadPage
(URL url, HttpMethod method, List<NameValuePair> requestParameters) Loads the page using the given request method from the passed URL.protected void
loadPage
(URL url, HttpMethod method, 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, String elementToClick) Loads the page by "clicking" the passed HTML element in the specified HTML form element.protected void
loadPageByFormClick
(HtmlForm form, String elementToClick, boolean randomPosition) Deprecated.protected void
loadPageByFormClick
(HtmlForm form, String elementToClick, boolean randomPosition, long waitingTime) Deprecated.As of XLT 4.9.0, useloadPageByFormClick(HtmlForm, String, long)
instead.protected void
loadPageByFormClick
(HtmlForm form, 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, String optionValue) Loads the page by selecting an option of the given HTML select element.protected void
loadPageBySelect
(HtmlSelect select, 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, String text) Loads the page by typing keys.protected void
loadPageByTypingKeys
(HtmlElement element, 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 Details
-
AbstractHtmlPageAction
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
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 Details
-
getHtmlPage
Returns the parsed HTML page object generated by this action.- Returns:
- the page
-
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
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
-
setHtmlPage
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
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(URL url, HttpMethod method, List<NameValuePair> requestParameters, long waitingTime) throws 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:
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. 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
-
loadPage
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:
Exception
- if an error occurred while loading the page
-
loadPage
Loads the page using HTTP GET from the passed URL.- Parameters:
url
- the target URL- Throws:
Exception
- if an error occurred while loading the page
-
loadPage
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:
Exception
- if an error occurred while loading the page
-
loadPage
Loads the page using HTTP GET from the passed URL.- Parameters:
urlAsString
- the target URL as string- Throws:
Exception
- if an error occurred while loading the page
-
loadPageByClick
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:
Exception
- if an error occurred while loading the page
-
loadPageByClick
Loads the page by "clicking" the passed HTML element.- Parameters:
element
- the HTML element to click- Throws:
Exception
- if an error occurred while loading the page
-
loadPageByDragAndDrop
protected void loadPageByDragAndDrop(HtmlElement draggable, HtmlElement dropTarget, long waitingTime) throws Exception Loads the page by drag and drop- Parameters:
draggable
- the dragged objectdropTarget
- the element on which to drop- Throws:
Exception
- if an error occurred while loading the page
-
loadPageByDragAndDrop
protected void loadPageByDragAndDrop(HtmlElement draggable, HtmlElement dropTarget) throws Exception Loads the page by drag and drop- Parameters:
draggable
- the dragged objectdropTarget
- the element on which to drop- Throws:
Exception
- if an error occurred while loading the page
-
loadPageByFormClick
@Deprecated protected void loadPageByFormClick(HtmlForm form, String elementToClick, boolean randomPosition, long waitingTime) throws 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:
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, String elementToClick, boolean randomPosition) throws 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:
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, String elementToClick, long waitingTime) throws 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:
Exception
- if an error occurred while loading the page
-
loadPageByFormClick
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:
Exception
- if an error occurred while loading the page
-
loadPageBySelect
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:
Exception
-
loadPageBySelect
protected void loadPageBySelect(HtmlSelect select, String optionValue, long waitingTime) throws 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:
Exception
-
loadPageBySelect
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 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:
Exception
-
loadPageByFormSubmit
protected void loadPageByFormSubmit(HtmlForm form, SubmittableElement element, long waitingTime) throws 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:
Exception
-
loadPageByFormSubmit
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:
Exception
-
loadPageByFormSubmit
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:
Exception
-
loadPageByFormSubmit
Loads the page by submitting the given form.- Parameters:
form
- the HTML form to submit- Throws:
Exception
-
loadPageByTypingKeys
protected void loadPageByTypingKeys(HtmlElement element, String text, long waitingTime) throws 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:
Exception
-
loadPageByTypingKeys
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:
Exception
-
getNetworkDataSet
Returns the network data set.- Returns:
- network data as set
-
loadPageByFormClick(HtmlForm, String)
instead.