Package org.kquiet.browser
Class BasicActionRunner
java.lang.Object
org.kquiet.browser.BasicActionRunner
- All Implemented Interfaces:
Closeable,AutoCloseable,ActionRunner
BasicActionRunner maintains two prioritized thread pool internally to execute
ActionComposer and browser actions separatedly. The thread pool for
ActionComposer allows multiple ones to be run concurrently(depends on parameter values in
constructors). The thread pool for browser actions is single-threaded, so only one browser action
is executed at a time(due to the constraint of WebDriver).- Author:
- Kimberly
-
Constructor Summary
ConstructorsConstructorDescriptionCreate anBasicActionRunnerwithPageLoadStrategy.NONEas page load strategy,BrowserType.CHROMEas browser type, and at most oneActionComposeris allowed to be executed at a time.BasicActionRunner(int maxConcurrentComposer) Create anBasicActionRunnerwithPageLoadStrategy.NONEas page load strategy andBrowserType.CHROMEas browser type.BasicActionRunner(org.openqa.selenium.PageLoadStrategy pageLoadStrategy, BrowserType browserType) Create anBasicActionRunnerwith specified page load strategy, browser type, name, and at most oneActionComposeris allowed to be executed at a time.BasicActionRunner(org.openqa.selenium.PageLoadStrategy pageLoadStrategy, BrowserType browserType, int maxConcurrentComposer) Create anBasicActionRunnerwith specified page load strategy, browser type, name, and max number of concurrent composer. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()executeAction(Runnable browserAction, int priority) Execute browser action with specified priority.executeComposer(ActionComposer actionComposer) Execute givenActionComposer.getName()Get the name of thisActionRunner.Get the identity of root window(the initial window as the browser started).org.openqa.selenium.WebDriverGet associatedWebDriver.booleanThis method checks the existence of root window and use the result as the result of browser's aliveness.booleanisPaused()Check whether thisActionRunneris paused or not.voidpause()Stop executing queuedActionComposeror browser action, but the running ones will keep running.voidresume()Resume to executing queuedActionComposeror browser action (if any).Set the name of thisActionRunner.
-
Constructor Details
-
BasicActionRunner
public BasicActionRunner()Create anBasicActionRunnerwithPageLoadStrategy.NONEas page load strategy,BrowserType.CHROMEas browser type, and at most oneActionComposeris allowed to be executed at a time. -
BasicActionRunner
public BasicActionRunner(int maxConcurrentComposer) Create anBasicActionRunnerwithPageLoadStrategy.NONEas page load strategy andBrowserType.CHROMEas browser type.- Parameters:
maxConcurrentComposer- the max number ofActionComposerthat could be executed by thisBasicActionRunnerconcurrently.
-
BasicActionRunner
public BasicActionRunner(org.openqa.selenium.PageLoadStrategy pageLoadStrategy, BrowserType browserType) Create anBasicActionRunnerwith specified page load strategy, browser type, name, and at most oneActionComposeris allowed to be executed at a time.- Parameters:
pageLoadStrategy- page load strategybrowserType- the type of browser- See Also:
-
BasicActionRunner
public BasicActionRunner(org.openqa.selenium.PageLoadStrategy pageLoadStrategy, BrowserType browserType, int maxConcurrentComposer) Create anBasicActionRunnerwith specified page load strategy, browser type, name, and max number of concurrent composer.- Parameters:
pageLoadStrategy- page load strategybrowserType- the type of browsermaxConcurrentComposer- max number ofActionComposerthat could be executed concurrently- See Also:
-
-
Method Details
-
getName
Description copied from interface:ActionRunnerGet the name of thisActionRunner.- Specified by:
getNamein interfaceActionRunner- Returns:
- name represented as
String
-
setName
Description copied from interface:ActionRunnerSet the name of thisActionRunner.- Specified by:
setNamein interfaceActionRunner- Parameters:
name- the name to set- Returns:
- this
ActionRunner
-
getRootWindowIdentity
Description copied from interface:ActionRunnerGet the identity of root window(the initial window as the browser started).- Specified by:
getRootWindowIdentityin interfaceActionRunner- Returns:
- identity represented as
String
-
executeAction
Description copied from interface:ActionRunnerExecute browser action with specified priority.- Specified by:
executeActionin interfaceActionRunner- Parameters:
browserAction- browser action to executepriority- priority of action- Returns:
- a
CompletableFuturerepresenting the pending completion of given browser action
-
executeComposer
Description copied from interface:ActionRunnerExecute givenActionComposer.- Specified by:
executeComposerin interfaceActionRunner- Parameters:
actionComposer-ActionComposerto execute- Returns:
- a
CompletableFuturerepresenting the pending completion of givenActionComposer
-
getWebDriver
public org.openqa.selenium.WebDriver getWebDriver()Description copied from interface:ActionRunnerGet associatedWebDriver.- Specified by:
getWebDriverin interfaceActionRunner- Returns:
- the
WebDriverthisActionRunneris using
-
isBrowserAlive
public boolean isBrowserAlive()This method checks the existence of root window and use the result as the result of browser's aliveness. When a negative result is acquired, users can choose tocloseActionRunnerand create a new one.- Specified by:
isBrowserAlivein interfaceActionRunner- Returns:
trueif the root window exists;falseotherwise
-
pause
public void pause()Stop executing queuedActionComposeror browser action, but the running ones will keep running.- Specified by:
pausein interfaceActionRunner
-
resume
public void resume()Resume to executing queuedActionComposeror browser action (if any).- Specified by:
resumein interfaceActionRunner
-
isPaused
public boolean isPaused()Description copied from interface:ActionRunnerCheck whether thisActionRunneris paused or not.- Specified by:
isPausedin interfaceActionRunner- Returns:
trueif paused;falseotherwise
-
close
public void close()- Specified by:
closein interfaceActionRunner- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-