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.booleanCheck if has next phase to execute.booleanisDone()When the state of action is one of the following, then it's called done.booleanisFail()When the action is marked as failed(ActionState.COMPLETE_WITH_ERROR), then it's called fail.voidSignals that no more phases to execute.voidperform()Perform action.protected abstract voidPerform multiple-phased browser action.protected voidsetActionState(ActionState actionState) Set the state of thisMultiPhaseAction.setComposer(ActionComposer containingComposer) Set containing composer.protected voidSwitch to top for firefox.toString()
-
Constructor Details
-
MultiPhaseAction
public MultiPhaseAction()
-
-
Method Details
-
noNextPhase
public void noNextPhase()Description copied from interface:MultiPhasedSignals that no more phases to execute.- Specified by:
noNextPhasein interfaceMultiPhased
-
hasNextPhase
public boolean hasNextPhase()Description copied from interface:MultiPhasedCheck if has next phase to execute.- Specified by:
hasNextPhasein interfaceMultiPhased- Returns:
trueif has next phase to execute;falseotherwise
-
perform
public void perform()Description copied from interface:ComposablePerform action.- Specified by:
performin 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:
isDonein interfaceComposable- Returns:
trueif the action is done;falseotherwise
-
isFail
public boolean isFail()When the action is marked as failed(ActionState.COMPLETE_WITH_ERROR), then it's called fail.- Specified by:
isFailin interfaceComposable- Returns:
trueif the action is failed;falseotherwise
-
getErrors
Description copied from interface:ComposableGet the errors occurred during execution.- Specified by:
getErrorsin 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:ComposableGet containing composer.- Specified by:
getComposerin interfaceComposable- Returns:
- containing composer
-
setComposer
Description copied from interface:ComposableSet containing composer.- Specified by:
setComposerin 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.
-