Package org.kquiet.browser
Class AbstractActionComposer
- All Implemented Interfaces:
Runnable,CompletionStage<Void>,Future<Void>,ActionComposer,DynamicActionSequence,Prioritized
- Direct Known Subclasses:
BasicActionComposer
public abstract class AbstractActionComposer
extends CompletableFuture<Void>
implements ActionComposer
AbstractActionComposer implements most methods of ActionComposer to lay ground
works for possible subclasses. AbstractActionComposer itself is a subclass of CompletableFuture, so any subclass of AbstractActionComposer should complete itself
explictly in Runnable.run().- Author:
- Kimberly
-
Nested Class Summary
Nested classes/interfaces inherited from class java.util.concurrent.CompletableFuture
CompletableFuture.AsynchronousCompletionTask -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final Stack<DynamicActionSequence>The execution context stack of thisAbstractActionComposer, theDynamicActionSequencemust be pushed into this stack before any action in it gets executed to reflect execution context.protected final StopwatchThe stop watch used to measure run cost of thisAbstractActionComposer. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionSet the function to be executed after any managed action is performed.Set the function to be executed when any managed action is performed.addToHead(Composable action) Add action to the head of the action sequence.addToHeadByContext(Composable action) Add action to the head of the action sequence of execution context.addToPosition(Composable action, int position) Add action to the specified position of the action sequence.addToPositionByContext(Composable action, int position) Add action to specified position of the action sequence of execution context.addToTail(Composable action) Add action to the tail of the action sequence.addToTailByContext(Composable action) Add action to the tail of the action sequence of execution context.callBrowser(Runnable runnable) protected Function<ActionComposer,Consumer<Composable>> Get the function to be executed after any managed action is performed.protected Function<ActionComposer,Consumer<Composable>> Get the function to be executed when any managed action is performed.protected ActionRunnerGet associatedActionRunner.protected List<Composable>Get all actions in the action sequence.Get total execution time of thisAbstractActionComposer.protected Consumer<ActionComposer>Get the function to be executed when finished.Get the error list from executed actions.protected Consumer<ActionComposer>Get the function executed when failed.Get the window identity of focus window.getName()Get the name of thisActionComposer.intGet priority.getRegisteredWindow(String registerName) Get registered window by given name.Get all registered windows.Get the window identity of root window.protected Consumer<ActionComposer>Get the function executed when finished without fail.getVariable(String variableName) Get the value of specified variable.org.openqa.selenium.WebDriverGetWebDriverfrom associatedActionRunner.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.voidperform(Composable action) Perform action.booleanregisterWindow(String name, String windowIdentity) Register a window to keep window identity.setActionRunner(ActionRunner actionRunner) Set associatedActionRunner.setFocusWindow(String windowIdentity) Set the specified window as the focus window.Set the name of thisActionComposer.setPriority(int priority) Set the priority of thisAbstractActionComposer.setVariable(String variableName, Object value) Set variable value.booleanSwitch browser's focus window to thisActionComposer's focus window.voidswitchToInnerFrame(List<org.openqa.selenium.By> frameBySequence) Switch to send future commands to a frame.booleanSwitch the focus of future commands to either the first frame on the page, or the main document when a page contains iframes.booleanswitchToWindow(String windowIdentity) Switch browser's focus window to specified window.Methods 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
getFailPage, getFailUrl, isDone, isFail, isSuccessfulDone, keepFailInfo, skipped, skipToFail, skipToSuccessMethods inherited from interface org.kquiet.browser.DynamicActionSequence
add
-
Field Details
-
executionContextStack
The execution context stack of thisAbstractActionComposer, theDynamicActionSequencemust be pushed into this stack before any action in it gets executed to reflect execution context. -
totalCostWatch
The stop watch used to measure run cost of thisAbstractActionComposer.
-
-
Constructor Details
-
AbstractActionComposer
public AbstractActionComposer()Create anAbstractActionComposer.
-
-
Method Details
-
setActionRunner
Description copied from interface:ActionComposerSet associatedActionRunner.- Specified by:
setActionRunnerin interfaceActionComposer- Parameters:
actionRunner- action runner to set- Returns:
- self reference
-
getActionRunner
Get associatedActionRunner.- Returns:
ActionRunner
-
getRootWindow
Description copied from interface:ActionComposerGet the window identity of root window.- Specified by:
getRootWindowin interfaceActionComposer- Returns:
- window identity represented by
String
-
registerWindow
Description copied from interface:ActionComposerRegister a window to keep window identity.- Specified by:
registerWindowin interfaceActionComposer- Parameters:
name- register namewindowIdentity- window identity- Returns:
trueif register name is not null and window identity are not empty and the register name isn't registered;falseotherwise
-
getRegisteredWindow
Description copied from interface:ActionComposerGet registered window by given name.- Specified by:
getRegisteredWindowin interfaceActionComposer- Parameters:
registerName- register name of window- Returns:
- window identity
-
getRegisteredWindows
Description copied from interface:ActionComposerGet all registered windows.- Specified by:
getRegisteredWindowsin interfaceActionComposer- Returns:
- all registered windows represented by
Map(register name paire with window identity)
-
getVariable
Description copied from interface:ActionComposerGet the value of specified variable.- Specified by:
getVariablein interfaceActionComposer- Parameters:
variableName- variable name- Returns:
- variable value
-
setVariable
Description copied from interface:ActionComposerSet variable value.- Specified by:
setVariablein interfaceActionComposer- Parameters:
variableName- variable namevalue- variable value- Returns:
- self reference
-
callBrowser
Description copied from interface:ActionComposer- Specified by:
callBrowserin interfaceActionComposer- Parameters:
runnable- the object whose run method will be invoked- Returns:
- a
CompletableFuturerepresenting pending completion of givenRunnable
-
perform
Description copied from interface:ActionComposerPerform action. AnyComposableshould be performed by this method.- Specified by:
performin interfaceActionComposer- Parameters:
action- action to perform
-
switchToFocusWindow
public boolean switchToFocusWindow()Description copied from interface:ActionComposerSwitch browser's focus window to thisActionComposer's focus window.- Specified by:
switchToFocusWindowin interfaceActionComposer- Returns:
trueif switch success;falseotherwise
-
switchToWindow
Description copied from interface:ActionComposerSwitch browser's focus window to specified window.- Specified by:
switchToWindowin interfaceActionComposer- Parameters:
windowIdentity- the window identity to switch to- Returns:
trueif switch success;falseotherwise
-
switchToInnerFrame
Description copied from interface:ActionComposerSwitch to send future commands to a frame.- Specified by:
switchToInnerFramein interfaceActionComposer- Parameters:
frameBySequence- the sequence of the frame locating mechanism
-
switchToTop
public boolean switchToTop()Description copied from interface:ActionComposerSwitch the focus of future commands to either the first frame on the page, or the main document when a page contains iframes.- Specified by:
switchToTopin interfaceActionComposer- Returns:
trueif switch success;falseotherwise
-
onFail
Description copied from interface:ActionComposerSet the function to be executed when thisActionComposeris marked as failed.- Specified by:
onFailin interfaceActionComposer- Parameters:
onFailFunc- the function to be executed- Returns:
- self reference
-
getFailFunction
Get the function executed when failed.- Returns:
- the function consuming
ActionComposer
-
onSuccess
Description copied from interface:ActionComposerSet the function to be executed when thisActionComposeris finished without being marked as failed.- Specified by:
onSuccessin interfaceActionComposer- Parameters:
onSuccessFunc- the function to be executed- Returns:
- self reference
-
getSuccessFunction
Get the function executed when finished without fail.- Returns:
- the function consuming
ActionComposer
-
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- Parameters:
onDoneFunc- the function to be executed- Returns:
- self reference
-
getActionPerformedFunction
Get the function to be executed after any managed action is performed.- Returns:
- the function consuming
ActionComposer
-
actionPerformed
Description copied from interface:ActionComposerSet the function to be executed after any managed action is performed.- Specified by:
actionPerformedin interfaceActionComposer- Parameters:
func- the function to be executed- Returns:
- self reference
-
getActionPerformingFunction
Get the function to be executed when any managed action is performed.- Returns:
- the function consuming
ActionComposer
-
actionPerforming
Description copied from interface:ActionComposerSet the function to be executed when any managed action is performed.- Specified by:
actionPerformingin interfaceActionComposer- Parameters:
func- the function to be executed- Returns:
- self reference
-
getDoneFunction
Get the function to be executed when finished.- Returns:
- the function consuming
ActionComposer
-
getName
Description copied from interface:ActionComposerGet the name of thisActionComposer.- Specified by:
getNamein interfaceActionComposer- Returns:
- name represented by
String
-
setName
Description copied from interface:ActionComposerSet the name of thisActionComposer.- Specified by:
setNamein interfaceActionComposer- Parameters:
name- name- Returns:
- self reference
-
getPriority
public int getPriority()Description copied from interface:PrioritizedGet priority. Smaller value means higher priority.- Specified by:
getPriorityin interfacePrioritized- Returns:
- priority
-
setPriority
Set the priority of thisAbstractActionComposer.- Parameters:
priority- priority- Returns:
- self reference
-
getCostTime
Get total execution time of thisAbstractActionComposer.- Returns:
- the total execution time represented by
Duration
-
getWebDriver
public org.openqa.selenium.WebDriver getWebDriver()Description copied from interface:ActionComposerGetWebDriverfrom associatedActionRunner. Use this with caution because the associatedActionRunneruse the sameWebDriverwhen executing browser actions, howeverWebDriveris not thread-safe.A safer way to use this is to encapsulate the process in a
Runnable, or use built-incustom action, and then execute it throughActionRunner.executeAction(java.lang.Runnable, int).- Specified by:
getWebDriverin interfaceActionComposer- Returns:
- the
WebDriverof associatedActionRunner.
-
getFocusWindow
Description copied from interface:ActionComposerGet the window identity of focus window.- Specified by:
getFocusWindowin interfaceActionComposer- Returns:
- window identity represented by
String
-
setFocusWindow
Description copied from interface:ActionComposerSet the specified window as the focus window.- Specified by:
setFocusWindowin interfaceActionComposer- 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- 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- 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- Parameters:
action- action to addposition- the position(zero-based) to add given action- Returns:
- self reference
-
addToHeadByContext
Description copied from interface:ActionComposerAdd action to the head of the action sequence of execution context.- Specified by:
addToHeadByContextin interfaceActionComposer- Parameters:
action- action to add- Returns:
- execution context of actions
-
addToTailByContext
Description copied from interface:ActionComposerAdd action to the tail of the action sequence of execution context.- Specified by:
addToTailByContextin interfaceActionComposer- Parameters:
action- action to add- Returns:
- execution context of actions
-
addToPositionByContext
Description copied from interface:ActionComposerAdd action to specified position of the action sequence of execution context.- Specified by:
addToPositionByContextin interfaceActionComposer- Parameters:
action- action to addposition- the position(zero-based) to add given action- Returns:
- execution context of actions
-
getAllActionInSequence
Get all actions in the action sequence.- Returns:
- list of actions
-
getErrors
Get the error list from executed actions.- Specified by:
getErrorsin interfaceActionComposer- Returns:
- a list of
Exception
-