# InstallerSessionBuilder

Import: `import com.install4j.api.test.session.InstallerSessionBuilder;`

```java
public final class InstallerSessionBuilder extends AbstractSessionBuilder
```

Builds and starts an [`InstallerSession`](InstallerSession.md) for the install4j installer.

```
try (InstallerSession session = InstallerSessionBuilder
        .forMediaFile(new File("build/media/myapp-linux-x64.sh"))
        .installationDirectory(new File(tempDir, "install"))
        .start()) {
    session.currentScreen().clickNext();
    ...
}
```

Kotlin extensions

`SessionExtensions.kt` in this package adds `useSession { ... }` as a Kotlin
inline extension: it calls [`InstallerSessionBuilder.start`](InstallerSessionBuilder.md#start), runs the trailing lambda on the resulting
[`InstallerSession`](InstallerSession.md) as `this`, and closes the session afterwards.

```
InstallerSessionBuilder.forMediaFile(media).useSession {
    onScreen("welcome") { clickNext() }
    // ...
}
```

## Inherited from

- [AbstractSessionBuilder](AbstractSessionBuilder.md) — 7 methods

## Methods

| Signature | Returns | Description |
|---|---|---|
| [`forMediaFile(File)`](#formediafile-file) | `InstallerSessionBuilder` | Create a builder for the given installer media file with extension `.exe`, `.sh` or `.dmg`. |
| [`installationDirectory(File)`](#installationdirectory-file) | `InstallerSessionBuilder` | Target directory where the installer should install files. |
| [`timeout(Duration)`](#timeout-duration) | `InstallerSessionBuilder` |  |
| [`arg(String[])`](#arg-string) | `InstallerSessionBuilder` |  |
| [`systemProperty(String, String)`](#systemproperty-string-string) | `InstallerSessionBuilder` |  |
| [`workingDirectory(File)`](#workingdirectory-file) | `InstallerSessionBuilder` |  |
| [`logFile(File)`](#logfile-file) | `InstallerSessionBuilder` |  |
| [`debug(boolean)`](#debug-boolean) | `InstallerSessionBuilder` |  |
| [`start()`](#start) | `InstallerSession` |  |

### forMediaFile(File)

```java
public static InstallerSessionBuilder forMediaFile(File mediaFile)
```

Create a builder for the given installer media file with extension `.exe`,
`.sh` or `.dmg`. The file is extracted on first use and cached on disk for
subsequent runs.

### installationDirectory(File)

```java
public InstallerSessionBuilder installationDirectory(File target)
```

Target directory where the installer should install files. If not set, the session creates
a temporary directory and deletes it on [`InstallerSession.close`](InstallerSession.md#close). User-provided
directories are never deleted.

### timeout(Duration)

```java
public InstallerSessionBuilder timeout(Duration d)
```

### arg(String[])

```java
public InstallerSessionBuilder arg(String... args)
```

### systemProperty(String, String)

```java
public InstallerSessionBuilder systemProperty(String key, String value)
```

### workingDirectory(File)

```java
public InstallerSessionBuilder workingDirectory(File dir)
```

### logFile(File)

```java
public InstallerSessionBuilder logFile(File logFile)
```

### debug(boolean)

```java
public InstallerSessionBuilder debug(boolean debug)
```

### start()

```java
public InstallerSession start()
```

