Interface Session
- All Superinterfaces:
AutoCloseable
- All Known Subinterfaces:
InstallerApplicationSession, InstallerSession, UninstallerSession
Shared base for
InstallerSession, UninstallerSession and
InstallerApplicationSession. Provides screen and dialog access log access and lifecycle.
Every wait method has a no-arg form that uses the builder-configured default timeout and a
Duration overload. Wait methods throw a typed
InstallerTestException subtype on timeout. They
never return null.
Kotlin extensions
The SessionExtensions.kt file in this package adds Kotlin-only convenience
extensions on top of this interface. Each is a thin inline wrapper that waits for the matching
screen or dialog, runs the given trailing lambda on the handle as this, and returns
the handle.
session.onScreen(id) { ... }— wrapswaitForScreenId(String).session.onCurrentScreen { ... }— wrapscurrentScreen().session.onDialog(predicate) { ... }— wrapsdialog(DialogMatcher).session.onAlert { ... }— wrapsalert().session.onFileChooser { ... }— wrapsfileChooser().session.onLanguageDialog { ... }— wrapslanguageDialog().session.onRunningProcessesDialog { ... }— wrapsrunningProcessesDialog().session.onCreateUserDialog { ... }— wrapscreateUserDialog().session.onPasswordDialog { ... }— wrapspasswordDialog().session["varName"]— operator form ofgetVariable(String).
Example:
session.onScreen("installDir") {
directoryChooser().setDirectory(target)
clickNext()
}
session.onAlert { clickYes() }
val installedAs: String? = session["installedAs"] as String?
-
Method Summary
Modifier and TypeMethodDescriptionalert()Wait for a JOptionPane-built alert.Same asalert()with an explicit timeout.intBlock until the installer-application thread exits and return its exit code.intSame asawaitExit()with an explicit timeout.voidclose()Callsterminate()if the session is still running, then deletes the extraction cache for media-file based sessions and deletes the auto-created installation directory if the session created it.Wait for the create-user dialog shown by the "Create User..." button of a "Windows user selector" form component.createUserDialog(Duration timeout) Same ascreateUserDialog()with an explicit timeout.The currently active wizard screen.currentScreen(Duration timeout) Same ascurrentScreen()with an explicit timeout.dialog(DialogMatcher matcher) Wait for a modal dialog whose backing window matches the givenDialogMatcher.dialog(DialogMatcher matcher, Duration timeout) Same asdialog(DialogMatcher)with an explicit timeout.Wait for the modal JFileChooser dialog shown by a Browse button.fileChooser(Duration timeout) Same asfileChooser()with an explicit timeout.The active installation directory.The current installer language id, e.g.The installer log file being captured by this session.getVariable(String name) Returns the installer variable with the given name, ornullif no variable with that name is set on the installer context.booleanWhether the installer-application thread has exited.Wait for the startup language-selection dialog.languageDialog(Duration timeout) Same aslanguageDialog()with an explicit timeout.default voidnavigateUntil(int maxHops, Predicate<String> isTerminal) Advance the wizard one screen at a time until the given predicate matches the current screen id.default voidnavigateUntilScreen(String terminalScreenId, int maxHops) Advance the wizard until the screen with the given id is the active screen.Wait for the credentials prompt of a password dialog.passwordDialog(Duration timeout) Same aspasswordDialog()with an explicit timeout.readLog()Read the entire installer log as a string.Wait for the running-processes dialog shown by a "Check for running processes" action.runningProcessesDialog(Duration timeout) Same asrunningProcessesDialog()with an explicit timeout.voidForce a shutdown by interrupting the installer thread and tearing down.Wait until the active screen changes.waitForScreenChange(Duration timeout) Same aswaitForScreenChange()with an explicit timeout.Wait until the screen with the given id becomes the active screen.waitForScreenId(String id, Duration timeout) Same aswaitForScreenId(String)with an explicit timeout.
-
Method Details
-
currentScreen
The currently active wizard screen. -
currentScreen
Same ascurrentScreen()with an explicit timeout. -
dialog
Wait for a modal dialog whose backing window matches the givenDialogMatcher. The matcher sees everyJDialogand any non-wizardJFramecurrently shown. UseDialogMatcher.any()to accept the first dialog of any kind. -
dialog
Same asdialog(DialogMatcher)with an explicit timeout. -
alert
Wait for a JOptionPane-built alert. -
alert
Same asalert()with an explicit timeout. -
fileChooser
Wait for the modal JFileChooser dialog shown by a Browse button. -
fileChooser
Same asfileChooser()with an explicit timeout. -
languageDialog
Wait for the startup language-selection dialog. -
languageDialog
Same aslanguageDialog()with an explicit timeout. -
runningProcessesDialog
Wait for the running-processes dialog shown by a "Check for running processes" action. -
runningProcessesDialog
Same asrunningProcessesDialog()with an explicit timeout. -
createUserDialog
Wait for the create-user dialog shown by the "Create User..." button of a "Windows user selector" form component. -
createUserDialog
Same ascreateUserDialog()with an explicit timeout. -
passwordDialog
Wait for the credentials prompt of a password dialog. -
passwordDialog
Same aspasswordDialog()with an explicit timeout. -
waitForScreenId
Wait until the screen with the given id becomes the active screen. -
waitForScreenId
Same aswaitForScreenId(String)with an explicit timeout. -
waitForScreenChange
Wait until the active screen changes. -
waitForScreenChange
Same aswaitForScreenChange()with an explicit timeout. -
getLanguageId
The current installer language id, e.g."en","de". -
getInstallationDirectory
The active installation directory. May differ from the value passed toSessionBuilder.installationDirectory(...)if a screen let the user change it. -
getVariable
Returns the installer variable with the given name, ornullif no variable with that name is set on the installer context. The value must beSerializablein subprocess mode. -
getLogFile
The installer log file being captured by this session. -
readLog
Read the entire installer log as a string. -
awaitExit
int awaitExit()Block until the installer-application thread exits and return its exit code. ThrowsTimeoutExceptionif it does not exit within the builder-configured default timeout. -
awaitExit
Same asawaitExit()with an explicit timeout. -
isFinished
boolean isFinished()Whether the installer-application thread has exited. Useful in test loops that may race with an auto-finish terminal screen. When this istrue, navigation operations andcurrentScreen()no longer work because the wizard frame has been disposed. -
terminate
void terminate()Force a shutdown by interrupting the installer thread and tearing down. Always succeeds. -
close
void close()Callsterminate()if the session is still running, then deletes the extraction cache for media-file based sessions and deletes the auto-created installation directory if the session created it.- Specified by:
closein interfaceAutoCloseable
-