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 buildingActionComposeris performed.Set the function to be executed when any managed action of buildingActionComposeris performed.<T extends ActionComposer>
TFinish building theActionComposer.<T extends ActionComposer>
TFinish building theActionComposerwith its name.<T extends ActionComposer>
TFinish building theActionComposerwith its name.Finish building theBasicActionComposer.buildBasic(String name) Finish building theBasicActionComposerwith its name.onDone(Consumer<ActionComposer> func) Set the function to be executed when the execution of buildingActionComposerfinishes.onFail(Consumer<ActionComposer> func) Set the function to be executed when the execution of buildingActionComposerfails.onSuccess(Consumer<ActionComposer> func) Set the function to be executed when the execution of buildingActionComposersucceeds.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 buildingActionComposerfails.- Parameters:
func- the function to be executed- Returns:
- this
ActionComposerBuilder - See Also:
-
onSuccess
Set the function to be executed when the execution of buildingActionComposersucceeds.- Parameters:
func- the function to be executed- Returns:
- this
ActionComposerBuilder - See Also:
-
onDone
Set the function to be executed when the execution of buildingActionComposerfinishes.- Parameters:
func- the function to be executed- Returns:
- this
ActionComposerBuilder - See Also:
-
actionPerforming
Set the function to be executed when any managed action of buildingActionComposeris 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 buildingActionComposeris performed.- Parameters:
func- the function to be executed- Returns:
- this
ActionComposerBuilder - See Also:
-
buildBasic
Finish building theBasicActionComposer.- Returns:
- the built
BasicActionComposer
-
buildBasic
Finish building theBasicActionComposerwith 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 ofActionComposerto build- Parameters:
composerType- the type ofActionComposerto 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 ofActionComposerBuilderfailed 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 theActionComposerwith its name.- Type Parameters:
T- the type ofActionComposerto build- Parameters:
composerType- the type ofActionComposerto 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 ofActionComposerBuilderfailed 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 theActionComposerwith its name.- Type Parameters:
T- the type ofActionComposerto build- Parameters:
actionComposer- the instance ofActionComposerto buildname- name ofActionComposer- Returns:
- the built
ActionComposer
-
prepareActionSequence
Start building a sequence of actions.
-