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 ofActionRunner
as 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 childBasicActionComposer
to associatedActionRunner
after thisBasicActionComposer
is done.protected List<Composable>
Get all actions in the action sequence.getChild()
Get childBasicActionComposer
.Get the content of the last page when thisActionComposer
is marked as failed andthe flag to keep fail information
is enabled.Get the url of the last page when thisActionComposer
is marked as failed andthe flag to keep fail information
is enabled.Get parentBasicActionComposer
.boolean
hasChild()
Check whether thisBasicActionComposer
has childBasicActionComposer
.boolean
Check whether thisBasicActionComposer
has parentBasicActionComposer
.boolean
isFail()
Check if thisBasicActionComposer
has been marked as failed.boolean
Check if thisBasicActionComposer
is done without being marked as failed.keepFailInfo
(boolean flag) Enable/Disable the function of keeping fail information when thisActionComposer
is marked as failed.onDone
(Consumer<ActionComposer> onDoneFunc) Set the function to be executed when thisActionComposer
is done.onFail
(Consumer<ActionComposer> onFailFunc) Set the function to be executed when thisActionComposer
is marked as failed.onSuccess
(Consumer<ActionComposer> onSuccessFunc) Set the function to be executed when thisActionComposer
is finished without being marked as failed.void
run()
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.boolean
skipped()
Check ifActionComposer.skipToFail()
orActionComposer.skipToSuccess()
of thisActionComposer
has been invoked.void
Skip the execution of remaining actions and mark thisBasicActionComposer
as failed.void
Skip 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, switchToWindow
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, whenCompleteAsync
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.kquiet.browser.ActionComposer
isDone
Methods 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:ActionComposer
Set associatedActionRunner
.- Specified by:
setActionRunner
in interfaceActionComposer
- Overrides:
setActionRunner
in classAbstractActionComposer
- Parameters:
actionRunner
- action runner to set- Returns:
- self reference
-
setVariable
Description copied from interface:ActionComposer
Set variable value.- Specified by:
setVariable
in interfaceActionComposer
- Overrides:
setVariable
in classAbstractActionComposer
- Parameters:
variableName
- variable namevalue
- variable value- Returns:
- self reference
-
continueWith
Delegate the execution of given childBasicActionComposer
to associatedActionRunner
after thisBasicActionComposer
is done. EveryBasicActionComposer
has at most one parent/childBasicActionComposer
. If thisBasicActionComposer
already has a childBasicActionComposer
, the original childBasicActionComposer
will 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 childBasicActionComposer
and thisBasicActionComposer
will hand it to associatedActionRunner
when finished, and then let theActionRunner
schedule the execution.- Parameters:
childActionComposer
- theBasicActionComposer
to be executed- Returns:
- child
BasicActionComposer
-
hasChild
public boolean hasChild()Check whether thisBasicActionComposer
has childBasicActionComposer
.- Returns:
true
whether thisBasicActionComposer
has childBasicActionComposer
;false
otherwise
-
getChild
Get childBasicActionComposer
.- Returns:
- child
BasicActionComposer
if exists;null
otherwise
-
hasParent
public boolean hasParent()Check whether thisBasicActionComposer
has parentBasicActionComposer
.- Returns:
true
whether thisBasicActionComposer
has parentBasicActionComposer
;false
otherwise
-
getParent
Get parentBasicActionComposer
.- Returns:
- parent
BasicActionComposer
if exists;null
otherwise
-
onFail
Description copied from interface:ActionComposer
Set the function to be executed when thisActionComposer
is marked as failed.- Specified by:
onFail
in interfaceActionComposer
- Overrides:
onFail
in classAbstractActionComposer
- Parameters:
onFailFunc
- the function to be executed- Returns:
- self reference
-
onSuccess
Description copied from interface:ActionComposer
Set the function to be executed when thisActionComposer
is finished without being marked as failed.- Specified by:
onSuccess
in interfaceActionComposer
- Overrides:
onSuccess
in classAbstractActionComposer
- Parameters:
onSuccessFunc
- the function to be executed- Returns:
- self reference
-
onDone
Description copied from interface:ActionComposer
Set the function to be executed when thisActionComposer
is done. This function is executed after fail function and success function.- Specified by:
onDone
in interfaceActionComposer
- Overrides:
onDone
in classAbstractActionComposer
- Parameters:
onDoneFunc
- the function to be executed- Returns:
- self reference
-
setName
Description copied from interface:ActionComposer
Set the name of thisActionComposer
.- Specified by:
setName
in interfaceActionComposer
- Overrides:
setName
in classAbstractActionComposer
- Parameters:
name
- name- Returns:
- self reference
-
setPriority
Description copied from class:AbstractActionComposer
Set the priority of thisAbstractActionComposer
.- Overrides:
setPriority
in classAbstractActionComposer
- Parameters:
priority
- priority- Returns:
- self reference
-
skipped
public boolean skipped()Description copied from interface:ActionComposer
Check ifActionComposer.skipToFail()
orActionComposer.skipToSuccess()
of thisActionComposer
has been invoked.- Returns:
true
if any of both methods has been invoked; otherwisefalse
-
isFail
public boolean isFail()Check if thisBasicActionComposer
has been marked as failed.- Returns:
true
if thisBasicActionComposer
has been marked as failed;false
otherwise
-
isSuccessfulDone
public boolean isSuccessfulDone()Check if thisBasicActionComposer
is done without being marked as failed.- Returns:
true
if thisBasicActionComposer
is done without being marked as failed;false
otherwise
-
getFailUrl
Description copied from interface:ActionComposer
Get the url of the last page when thisActionComposer
is marked as failed andthe flag to keep fail information
is enabled.- Returns:
- the url represented by
String
-
getFailPage
Description copied from interface:ActionComposer
Get the content of the last page when thisActionComposer
is marked as failed andthe flag to keep fail information
is enabled.- Returns:
- the content represented by
String
-
keepFailInfo
Description copied from interface:ActionComposer
Enable/Disable the function of keeping fail information when thisActionComposer
is 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
-true
to enable;false
to disable- Returns:
- self reference
-
setFocusWindow
Description copied from interface:ActionComposer
Set the specified window as the focus window.- Specified by:
setFocusWindow
in interfaceActionComposer
- Overrides:
setFocusWindow
in classAbstractActionComposer
- Parameters:
windowIdentity
- the window identity to set as the focus window- Returns:
- self reference
-
addToHead
Description copied from interface:DynamicActionSequence
Add action to the head of the action sequence.- Specified by:
addToHead
in interfaceDynamicActionSequence
- Overrides:
addToHead
in classAbstractActionComposer
- Parameters:
action
- action to add- Returns:
- self reference
-
addToTail
Description copied from interface:DynamicActionSequence
Add action to the tail of the action sequence.- Specified by:
addToTail
in interfaceDynamicActionSequence
- Overrides:
addToTail
in classAbstractActionComposer
- Parameters:
action
- action to add- Returns:
- self reference
-
addToPosition
Description copied from interface:DynamicActionSequence
Add action to the specified position of the action sequence.- Specified by:
addToPosition
in interfaceDynamicActionSequence
- Overrides:
addToPosition
in classAbstractActionComposer
- Parameters:
action
- action to addposition
- the position(zero-based) to add given action- Returns:
- self reference
-
getAllActionInSequence
Description copied from class:AbstractActionComposer
Get all actions in the action sequence.- Overrides:
getAllActionInSequence
in classAbstractActionComposer
- Returns:
- list of actions
-
skipToFail
public void skipToFail()Skip the execution of remaining actions and mark thisBasicActionComposer
as 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
-