Package org.kquiet.browser.action
Class MultiPhaseAction
java.lang.Object
org.kquiet.browser.action.MultiPhaseAction
- All Implemented Interfaces:
Composable
,MultiPhased
- Direct Known Subclasses:
Click
,Custom
,Extract
,JustWait
,MouseOver
,ReplyAlert
,ScrollToView
,Select
,SendKey
,SinglePhaseAction
,Upload
,WaitUntil
MultiPhaseAction
models a browser action with multiple phases which is executed through
ActionComposer
or ActionRunner
. It will be executed for
multiple times and works just like a loop. noNextPhase()
needs to be invoked to signal
that there is no more phase to execute.
Why multi-phase is required is because WebDriver is not thread-safe. Therefore, ActionRunner
uses a single thread to control the concurrency between
different brwoser actions, and the browser thread shouldn't be occupied for a long time by any
single browser action.
- Author:
- Kimberly
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGet the state of thisMultiPhaseAction
.Get containing composer.Get the total cost time of execution.Get the errors occurred during execution.boolean
Check if has next phase to execute.boolean
isDone()
When the state of action is one of the following, then it's called done.boolean
isFail()
When the action is marked as failed(ActionState.COMPLETE_WITH_ERROR
), then it's called fail.void
Signals that no more phases to execute.void
perform()
Perform action.protected abstract void
Perform multiple-phased browser action.protected void
setActionState
(ActionState actionState) Set the state of thisMultiPhaseAction
.setComposer
(ActionComposer containingComposer) Set containing composer.protected void
Switch to top for firefox.toString()
-
Constructor Details
-
MultiPhaseAction
public MultiPhaseAction()
-
-
Method Details
-
noNextPhase
public void noNextPhase()Description copied from interface:MultiPhased
Signals that no more phases to execute.- Specified by:
noNextPhase
in interfaceMultiPhased
-
hasNextPhase
public boolean hasNextPhase()Description copied from interface:MultiPhased
Check if has next phase to execute.- Specified by:
hasNextPhase
in interfaceMultiPhased
- Returns:
true
if has next phase to execute;false
otherwise
-
perform
public void perform()Description copied from interface:Composable
Perform action.- Specified by:
perform
in interfaceComposable
-
performMultiPhase
protected abstract void performMultiPhase()Perform multiple-phased browser action.noNextPhase()
needs to be invoked to signal that there is no more phase to execute. -
isDone
public boolean isDone()When the state of action is one of the following, then it's called done.- Specified by:
isDone
in interfaceComposable
- Returns:
true
if the action is done;false
otherwise
-
isFail
public boolean isFail()When the action is marked as failed(ActionState.COMPLETE_WITH_ERROR
), then it's called fail.- Specified by:
isFail
in interfaceComposable
- Returns:
true
if the action is failed;false
otherwise
-
getErrors
Description copied from interface:Composable
Get the errors occurred during execution.- Specified by:
getErrors
in interfaceComposable
- Returns:
- the errors as a list of
Exception
-
toString
-
getCostTime
Get the total cost time of execution.- Returns:
- the total cost time represented by
Duration
-
getComposer
Description copied from interface:Composable
Get containing composer.- Specified by:
getComposer
in interfaceComposable
- Returns:
- containing composer
-
setComposer
Description copied from interface:Composable
Set containing composer.- Specified by:
setComposer
in interfaceComposable
- Parameters:
containingComposer
- the containing composer to set- Returns:
- invoking
Composable
-
getActionState
Get the state of thisMultiPhaseAction
.- Returns:
- state represented by
ActionState
-
setActionState
Set the state of thisMultiPhaseAction
.- Parameters:
actionState
- the action state to set
-
switchToTopForFirefox
protected void switchToTopForFirefox()Switch to top for firefox. Firefox doesn't switch focus to top after switching to a window, so this method is required for firefox.
-