Package org.kquiet.browser
Class ActionComposerBuilder
java.lang.Object
org.kquiet.browser.ActionComposerBuilder
ActionComposerBuilder
is resposible to build a ActionComposer
in a fluent way.
New ActionComposerBuilder
instance is required before building a ActionComposer
.
Below example constructs an ActionComposer
that searches for the link to source code
of ActionComposerBuilder
, and then click it:
ActionComposer actionComposer = new ActionComposerBuilder() .prepareActionSequence() .getUrl("https://github.com/kquiet/auto-browser/find/main") .waitUntil(ExpectedConditions.elementToBeClickable(By.id("tree-finder-field")), 3000) .sendKey(By.id("tree-finder-field"), "ActionComposerBuilder") .waitUntil(ExpectedConditions.elementToBeClickable( By.xpath("//mark[text()='ActionComposerBuilder']")), 3000) .click(By.xpath("//mark[text()='ActionComposerBuilder']")) .returnToComposerBuilder() .buildBasic();
More complicated ActionComposer
can be built through built-in actions
. ActionComposerBuilder
includes inner builders
for these actions as well.
- Author:
- Kimberly
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionSet the function to be executed after any managed action of buildingActionComposer
is performed.Set the function to be executed when any managed action of buildingActionComposer
is performed.<T extends ActionComposer>
TFinish building theActionComposer
.<T extends ActionComposer>
TFinish building theActionComposer
with its name.<T extends ActionComposer>
TFinish building theActionComposer
with its name.Finish building theBasicActionComposer
.buildBasic
(String name) Finish building theBasicActionComposer
with its name.onDone
(Consumer<ActionComposer> func) Set the function to be executed when the execution of buildingActionComposer
finishes.onFail
(Consumer<ActionComposer> func) Set the function to be executed when the execution of buildingActionComposer
fails.onSuccess
(Consumer<ActionComposer> func) Set the function to be executed when the execution of buildingActionComposer
succeeds.Start building a sequence of actions.
-
Constructor Details
-
ActionComposerBuilder
public ActionComposerBuilder()Create a newActionComposerBuilder
.
-
-
Method Details
-
onFail
Set the function to be executed when the execution of buildingActionComposer
fails.- Parameters:
func
- the function to be executed- Returns:
- this
ActionComposerBuilder
- See Also:
-
onSuccess
Set the function to be executed when the execution of buildingActionComposer
succeeds.- Parameters:
func
- the function to be executed- Returns:
- this
ActionComposerBuilder
- See Also:
-
onDone
Set the function to be executed when the execution of buildingActionComposer
finishes.- Parameters:
func
- the function to be executed- Returns:
- this
ActionComposerBuilder
- See Also:
-
actionPerforming
Set the function to be executed when any managed action of buildingActionComposer
is performed.- Parameters:
func
- the function to be executed- Returns:
- this
ActionComposerBuilder
- See Also:
-
actionPerformed
Set the function to be executed after any managed action of buildingActionComposer
is performed.- Parameters:
func
- the function to be executed- Returns:
- this
ActionComposerBuilder
- See Also:
-
buildBasic
Finish building theBasicActionComposer
.- Returns:
- the built
BasicActionComposer
-
buildBasic
Finish building theBasicActionComposer
with its name.- Parameters:
name
- name ofBasicActionComposer
- Returns:
- the built
BasicActionComposer
-
build
public <T extends ActionComposer> T build(Class<T> composerType) throws ClassNotFoundException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException Finish building theActionComposer
.- Type Parameters:
T
- the type ofActionComposer
to build- Parameters:
composerType
- the type ofActionComposer
to build- Returns:
- the built
ActionComposer
- Throws:
ClassNotFoundException
- if the class of composer type cannot be locatedInstantiationException
- if the class of composer type represents an abstract class, an interface, an array class, a primitive type, or void; or if the class has no nullary constructor; or if the instantiation fails for some other reasonIllegalAccessException
- if the class of composer type or its nullary constructor is not accessibleSecurityException
- the class loader ofActionComposerBuilder
failed checks on access or permission of the class loader of composer type's classNoSuchMethodException
- if the class of composer type doesn't have a constructorInvocationTargetException
- if the underlying constructor of composer type throws an exceptionIllegalArgumentException
- if the class of composer type doesn't have a zero-argument constructor
-
build
public <T extends ActionComposer> T build(Class<T> composerType, String name) throws ClassNotFoundException, InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException Finish building theActionComposer
with its name.- Type Parameters:
T
- the type ofActionComposer
to build- Parameters:
composerType
- the type ofActionComposer
to buildname
- name ofActionComposer
- Returns:
- the built
ActionComposer
- Throws:
ClassNotFoundException
- if the class of composer type cannot be locatedInstantiationException
- if the class of composer type represents an abstract class, an interface, an array class, a primitive type, or void; or if the class has no nullary constructor; or if the instantiation fails for some other reasonIllegalAccessException
- if the class of composer type or its nullary constructor is not accessibleSecurityException
- the class loader ofActionComposerBuilder
failed checks on access or permission of the class loader of composer type's classNoSuchMethodException
- if the class of composer type doesn't have a constructorInvocationTargetException
- if the underlying constructor of composer type throws an exceptionIllegalArgumentException
- if the class of composer type doesn't have a zero-argument constructor
-
build
Finish building theActionComposer
with its name.- Type Parameters:
T
- the type ofActionComposer
to build- Parameters:
actionComposer
- the instance ofActionComposer
to buildname
- name ofActionComposer
- Returns:
- the built
ActionComposer
-
prepareActionSequence
Start building a sequence of actions.
-