Package org.kquiet.browser
Class BasicActionComposer
java.lang.Object
java.util.concurrent.CompletableFuture<Void>
org.kquiet.browser.AbstractActionComposer
org.kquiet.browser.BasicActionComposer
- All Implemented Interfaces:
Runnable,CompletionStage<Void>,Future<Void>,ActionComposer,DynamicActionSequence,Prioritized
BasicActionComposer provides basic implementation of ActionComposer. In addition
to the actions added by add*() methods, BasicActionComposer has two extra/internal
actions which are executed at the beginning and the end respectively:
- The action executed at the beginning is called as Initial Action, which opens a new
browser window and set it as focus window with an empty register name. All actions
should be executed against this focus window to be isolated from other
ActionComposer, however it could be changed by actions if necessary. If no focus window is specified, it will use the root window ofActionRunneras its focus window. - The action executed at the end is called as Final Action, which closes all registered windows.
- Author:
- Kimberly
-
Nested Class Summary
Nested classes/interfaces inherited from class java.util.concurrent.CompletableFuture
CompletableFuture.AsynchronousCompletionTask -
Field Summary
Fields inherited from class org.kquiet.browser.AbstractActionComposer
executionContextStack, totalCostWatch -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddToHead(Composable action) Add action to the head of the action sequence.addToPosition(Composable action, int position) Add action to the specified position of the action sequence.addToTail(Composable action) Add action to the tail of the action sequence.continueWith(BasicActionComposer childActionComposer) Delegate the execution of given childBasicActionComposerto associatedActionRunnerafter thisBasicActionComposeris done.protected List<Composable>Get all actions in the action sequence.getChild()Get childBasicActionComposer.Get the content of the last page when thisActionComposeris marked as failed andthe flag to keep fail informationis enabled.Get the url of the last page when thisActionComposeris marked as failed andthe flag to keep fail informationis enabled.Get parentBasicActionComposer.booleanhasChild()Check whether thisBasicActionComposerhas childBasicActionComposer.booleanCheck whether thisBasicActionComposerhas parentBasicActionComposer.booleanisFail()Check if thisBasicActionComposerhas been marked as failed.booleanCheck if thisBasicActionComposeris done without being marked as failed.keepFailInfo(boolean flag) Enable/Disable the function of keeping fail information when thisActionComposeris marked as failed.onDone(Consumer<ActionComposer> onDoneFunc) Set the function to be executed when thisActionComposeris done.onFail(Consumer<ActionComposer> onFailFunc) Set the function to be executed when thisActionComposeris marked as failed.onSuccess(Consumer<ActionComposer> onSuccessFunc) Set the function to be executed when thisActionComposeris finished without being marked as failed.voidrun()setActionRunner(ActionRunner actionRunner) Set associatedActionRunner.setCloseWindow(boolean closeWindowFlag) Determine whether close all registered windows at the end.setFocusWindow(String windowIdentity) Set the specified window as the focus window.Set the name of thisActionComposer.setOpenWindow(boolean openWindowFlag) Determine whether open a window as focus window at the begining.setPriority(int priority) Set the priority of thisAbstractActionComposer.setVariable(String variableName, Object value) Set variable value.booleanskipped()Check ifActionComposer.skipToFail()orActionComposer.skipToSuccess()of thisActionComposerhas been invoked.voidSkip the execution of remaining actions and mark thisBasicActionComposeras failed.voidSkip the execution of remaining actions.Methods inherited from class org.kquiet.browser.AbstractActionComposer
actionPerformed, actionPerforming, addToHeadByContext, addToPositionByContext, addToTailByContext, callBrowser, getActionPerformedFunction, getActionPerformingFunction, getActionRunner, getCostTime, getDoneFunction, getErrors, getFailFunction, getFocusWindow, getName, getPriority, getRegisteredWindow, getRegisteredWindows, getRootWindow, getSuccessFunction, getVariable, getWebDriver, perform, registerWindow, switchToFocusWindow, switchToInnerFrame, switchToTop, switchToWindowMethods inherited from class java.util.concurrent.CompletableFuture
acceptEither, acceptEitherAsync, acceptEitherAsync, allOf, anyOf, applyToEither, applyToEitherAsync, applyToEitherAsync, cancel, complete, completeAsync, completeAsync, completedFuture, completedStage, completeExceptionally, completeOnTimeout, copy, defaultExecutor, delayedExecutor, delayedExecutor, exceptionally, exceptionallyAsync, exceptionallyAsync, exceptionallyCompose, exceptionallyComposeAsync, exceptionallyComposeAsync, failedFuture, failedStage, get, get, getNow, getNumberOfDependents, handle, handleAsync, handleAsync, isCancelled, isCompletedExceptionally, isDone, join, minimalCompletionStage, newIncompleteFuture, obtrudeException, obtrudeValue, orTimeout, runAfterBoth, runAfterBothAsync, runAfterBothAsync, runAfterEither, runAfterEitherAsync, runAfterEitherAsync, runAsync, runAsync, supplyAsync, supplyAsync, thenAccept, thenAcceptAsync, thenAcceptAsync, thenAcceptBoth, thenAcceptBothAsync, thenAcceptBothAsync, thenApply, thenApplyAsync, thenApplyAsync, thenCombine, thenCombineAsync, thenCombineAsync, thenCompose, thenComposeAsync, thenComposeAsync, thenRun, thenRunAsync, thenRunAsync, toCompletableFuture, toString, whenComplete, whenCompleteAsync, whenCompleteAsyncMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.kquiet.browser.ActionComposer
isDoneMethods inherited from interface org.kquiet.browser.DynamicActionSequence
add
-
Constructor Details
-
BasicActionComposer
public BasicActionComposer()Create anBasicActionComposer.
-
-
Method Details
-
run
public void run() -
setActionRunner
Description copied from interface:ActionComposerSet associatedActionRunner.- Specified by:
setActionRunnerin interfaceActionComposer- Overrides:
setActionRunnerin classAbstractActionComposer- Parameters:
actionRunner- action runner to set- Returns:
- self reference
-
setVariable
Description copied from interface:ActionComposerSet variable value.- Specified by:
setVariablein interfaceActionComposer- Overrides:
setVariablein classAbstractActionComposer- Parameters:
variableName- variable namevalue- variable value- Returns:
- self reference
-
continueWith
Delegate the execution of given childBasicActionComposerto associatedActionRunnerafter thisBasicActionComposeris done. EveryBasicActionComposerhas at most one parent/childBasicActionComposer. If thisBasicActionComposeralready has a childBasicActionComposer, the original childBasicActionComposerwill be postponed.For example, before calling this method: ComposerA->ChildOfComposerA->GrandChildOfComposerA; after: ComposerA->NewChildOfComposerA->ChildOfComposerA->GrandChildOfComposerA.
This method works differently as methods of
CompletableFuture. It just keeps the reference of childBasicActionComposerand thisBasicActionComposerwill hand it to associatedActionRunnerwhen finished, and then let theActionRunnerschedule the execution.- Parameters:
childActionComposer- theBasicActionComposerto be executed- Returns:
- child
BasicActionComposer
-
hasChild
public boolean hasChild()Check whether thisBasicActionComposerhas childBasicActionComposer.- Returns:
truewhether thisBasicActionComposerhas childBasicActionComposer;falseotherwise
-
getChild
Get childBasicActionComposer.- Returns:
- child
BasicActionComposerif exists;nullotherwise
-
hasParent
public boolean hasParent()Check whether thisBasicActionComposerhas parentBasicActionComposer.- Returns:
truewhether thisBasicActionComposerhas parentBasicActionComposer;falseotherwise
-
getParent
Get parentBasicActionComposer.- Returns:
- parent
BasicActionComposerif exists;nullotherwise
-
onFail
Description copied from interface:ActionComposerSet the function to be executed when thisActionComposeris marked as failed.- Specified by:
onFailin interfaceActionComposer- Overrides:
onFailin classAbstractActionComposer- Parameters:
onFailFunc- the function to be executed- Returns:
- self reference
-
onSuccess
Description copied from interface:ActionComposerSet the function to be executed when thisActionComposeris finished without being marked as failed.- Specified by:
onSuccessin interfaceActionComposer- Overrides:
onSuccessin classAbstractActionComposer- Parameters:
onSuccessFunc- the function to be executed- Returns:
- self reference
-
onDone
Description copied from interface:ActionComposerSet the function to be executed when thisActionComposeris done. This function is executed after fail function and success function.- Specified by:
onDonein interfaceActionComposer- Overrides:
onDonein classAbstractActionComposer- Parameters:
onDoneFunc- the function to be executed- Returns:
- self reference
-
setName
Description copied from interface:ActionComposerSet the name of thisActionComposer.- Specified by:
setNamein interfaceActionComposer- Overrides:
setNamein classAbstractActionComposer- Parameters:
name- name- Returns:
- self reference
-
setPriority
Description copied from class:AbstractActionComposerSet the priority of thisAbstractActionComposer.- Overrides:
setPriorityin classAbstractActionComposer- Parameters:
priority- priority- Returns:
- self reference
-
skipped
public boolean skipped()Description copied from interface:ActionComposerCheck ifActionComposer.skipToFail()orActionComposer.skipToSuccess()of thisActionComposerhas been invoked.- Returns:
trueif any of both methods has been invoked; otherwisefalse
-
isFail
public boolean isFail()Check if thisBasicActionComposerhas been marked as failed.- Returns:
trueif thisBasicActionComposerhas been marked as failed;falseotherwise
-
isSuccessfulDone
public boolean isSuccessfulDone()Check if thisBasicActionComposeris done without being marked as failed.- Returns:
trueif thisBasicActionComposeris done without being marked as failed;falseotherwise
-
getFailUrl
Description copied from interface:ActionComposerGet the url of the last page when thisActionComposeris marked as failed andthe flag to keep fail informationis enabled.- Returns:
- the url represented by
String
-
getFailPage
Description copied from interface:ActionComposerGet the content of the last page when thisActionComposeris marked as failed andthe flag to keep fail informationis enabled.- Returns:
- the content represented by
String
-
keepFailInfo
Description copied from interface:ActionComposerEnable/Disable the function of keeping fail information when thisActionComposeris marked as failed. The function of keeping fail information takes about one second to complete, however this may seem wasteful in many applications, hence this method can be used to determine keep or not.- Parameters:
flag-trueto enable;falseto disable- Returns:
- self reference
-
setFocusWindow
Description copied from interface:ActionComposerSet the specified window as the focus window.- Specified by:
setFocusWindowin interfaceActionComposer- Overrides:
setFocusWindowin classAbstractActionComposer- Parameters:
windowIdentity- the window identity to set as the focus window- Returns:
- self reference
-
addToHead
Description copied from interface:DynamicActionSequenceAdd action to the head of the action sequence.- Specified by:
addToHeadin interfaceDynamicActionSequence- Overrides:
addToHeadin classAbstractActionComposer- Parameters:
action- action to add- Returns:
- self reference
-
addToTail
Description copied from interface:DynamicActionSequenceAdd action to the tail of the action sequence.- Specified by:
addToTailin interfaceDynamicActionSequence- Overrides:
addToTailin classAbstractActionComposer- Parameters:
action- action to add- Returns:
- self reference
-
addToPosition
Description copied from interface:DynamicActionSequenceAdd action to the specified position of the action sequence.- Specified by:
addToPositionin interfaceDynamicActionSequence- Overrides:
addToPositionin classAbstractActionComposer- Parameters:
action- action to addposition- the position(zero-based) to add given action- Returns:
- self reference
-
getAllActionInSequence
Description copied from class:AbstractActionComposerGet all actions in the action sequence.- Overrides:
getAllActionInSequencein classAbstractActionComposer- Returns:
- list of actions
-
skipToFail
public void skipToFail()Skip the execution of remaining actions and mark thisBasicActionComposeras failed. -
skipToSuccess
public void skipToSuccess()Skip the execution of remaining actions. -
setOpenWindow
Determine whether open a window as focus window at the begining.- Parameters:
openWindowFlag-true: open;false: not open- Returns:
- self reference
-
setCloseWindow
Determine whether close all registered windows at the end.- Parameters:
closeWindowFlag-true: close;false: not close- Returns:
- self reference
-