Get Started
This guide builds the minimum complete Device Park workflow for a test runner: authenticate once, select capacity, reserve a device, create a managed session and return the device safely.
At the end, the runner will have handled these identifiers correctly:
Identifier | Created by | Used for |
|---|---|---|
serial or devicePoolId | Device or pool selection | Allocation targeting |
allocationId | Create Allocation | Session start, allocation status and release |
sessionId | Start Session | Session stop, Appium logs and screen recordings |
Read How Device Park Works first if allocation, Device Park session and Appium session are new concepts.
Before You Begin
Make sure you have:
- installed the Java or Node.js SDK
- received clientId and clientSecret from your Device Park administrator
- access to at least one Device Park device or pool
Set the credentials:
export DEVICEPARK_CLIENT_ID=your-client-id
export DEVICEPARK_CLIENT_SECRET=your-client-secretUse the Java or TypeScript tab consistently as you move through the lifecycle. Both tabs perform the same Device Park operation.
Imports
import java.nio.file.Files;
import java.nio.file.Paths;
import io.testinium.devicepark.DeviceParkApiClient;
import io.testinium.devicepark.authentication.credentials.Credentials;
import io.testinium.devicepark.model.allocation.Allocation;
import io.testinium.devicepark.model.allocation.DeviceAllocationRequest;
import io.testinium.devicepark.model.common.PageDto;
import io.testinium.devicepark.model.devices.Device;
import io.testinium.devicepark.model.devices.ListDevicesRequest;
import io.testinium.devicepark.model.sessions.DeviceStartSessionRequest;
import io.testinium.devicepark.model.sessions.Session;
import io.testinium.devicepark.model.sessions.screenRecord.ScreenRecord;
import io.testinium.devicepark.model.sessions.screenRecord.ScreenRecordPaginationRequest;Step 1: Create the Client
Create one client and reuse it for the complete flow.
DeviceParkApiClient client = DeviceParkApiClient.builder()
.url("https://devicepark.testinium.io")
.credentials(Credentials.of(
System.getenv("DEVICEPARK_CLIENT_ID"),
System.getenv("DEVICEPARK_CLIENT_SECRET")))
.build();The client obtains and renews access tokens automatically.
Step 2: Select a Device
List devices and select a serial from the returned page.
Use a serial when the scenario requires one exact device. If any device from a managed group is acceptable, list pools and create the allocation with devicePoolId instead.
PageDto<Device> devices = client.devices().list(
ListDevicesRequest.builder().page(0).size(20).build());
Device selectedDevice = devices.data().stream()
.findFirst()
.orElseThrow(() -> new IllegalStateException("No device is available"));If the test can use any device from a managed group, list pools and use pool.id instead of a serial.
Step 3: Create an Allocation
Reserve the selected device.
Allocation allocation = client.allocations().create(
DeviceAllocationRequest.builder()
.serial(selectedDevice.serial())
.priority(3)
.build());
if (allocation.allocationId() == null) {
throw new IllegalStateException("Allocation id is missing");
}When deviceSerial is null or queue position is greater than zero, inspect the allocation until Device Park assigns a device. Reuse the existing allocationId; do not create duplicate allocations while waiting.
Do not create another allocation while waiting. Poll or inspect the same allocationId until a device is assigned or your test-runner deadline is reached.
Step 4: Start a Session
Start the session with the active allocation.
Session session = client.sessions().start(
DeviceStartSessionRequest.builder()
.allocationId(allocation.allocationId())
.userId(42L)
.userEmail("[email protected]")
.companyId(7L)
.companyName("Example Company")
.videoRecording(true)
.build());Store sessionId. Use your Appium client to run automation commands for this session.
The SDK manages the Device Park session. Appium capability creation and automation commands remain in the Appium client or test framework.
Step 5: Stop the Session
Stop the session after the test finishes:
client.sessions().stop(session.sessionId());Stopping the session does not release the allocation. You can start another session with the same active allocationId.
Step 6: Collect Artifacts
Download the Appium log when it is needed for troubleshooting:
byte[] log = client.sessions().logs(session.sessionId());
Files.write(Paths.get("appium.log"), log);If recording was enabled, list screen records after the session has finalized:
PageDto<ScreenRecord> records = client.sessions().screenRecords(
session.sessionId(),
ScreenRecordPaginationRequest.builder().page(0).size(20).build());
System.out.println(records.data());Step 7: Release the Allocation
Release the device after the final session:
client.allocations().delete(allocation.allocationId());
client.close();Production test runners should stop sessions and release allocations from cleanup code so failed tests do not leave resources active.
The snippets above explain each business step separately. Use the complete examples for a self-contained program with imports, validation and cleanup: