Control Automotive Sessions in CarPlay and Android Auto
Digital.ai Testing allows you to explicitly control automotive projection sessions during test execution using script commands. This is useful when testing applications that integrate with:
- Apple CarPlay (iOS)
- Android Auto (Android)
You can dynamically start and stop automotive sessions within your test flow instead of relying on automatic session initialization.
Overview
| Command | Description |
|---|---|
automotive.start | Initializes and activates an automotive session |
automotive.stop | Terminates and cleans up the automotive session |
When to Use This Feature
- You need manual control over automotive sessions
- Your test requires starting/stopping projection mid-execution
- You are not using the
automotiveProjectioncapability
If the session is already configured with the automotiveProjection capability, these commands cannot be used and will result in an error.
automotive.start
Initializes and activates an automotive session. This command prepares the device for automotive projection and ensures that the session is ready before test execution begins.
Parameters
| Parameter | Platform | Required | Description |
|---|---|---|---|
resolution | Android | Yes | DHU resolution (DhuResolution enum) |
iOS (CarPlay)
- Initializes CarPlay session
- Verifies CarPlay is running
Android (Android Auto)
- Starts Android Auto (DHU)
- Verifies session is active
Ensure port forwarding remains stable if multiple start commands are used.
Example
iOS
driver.executeScript("automotive.start", Map.of());
automotive.stop
Terminates and cleans up the automotive session. This command ensures that all automotive-related processes are stopped and the device is returned to a normal state for further test execution.
iOS
- Stops CarPlay process
- Sets image rate to 0
- Stops video generation
Android
- Terminates Android Auto session
Example
driver.executeScript("automotive.stop");
Execution Rules and Constraints
Capability Conflict
If the session is already started using the automotiveProjection capability:
automotive.startandautomotive.stopmust not be executed- An error is thrown indicating that manual commands are not allowed
Missing Start Command
If automotive.stop is executed without a prior automotive.start:
- An exception is thrown
Multiple Stop Commands
- Multiple
automotive.stopcommands are handled safely - No error is thrown if the session is already terminated
Missing Stop Command
If the test execution ends without calling automotive.stop:
- The automotive session is automatically terminated
- Cleanup is handled gracefully by the system
Best Practices
- Use
automotive.startonly when explicit control is required - Avoid mixing capability-based automotive sessions with command-based control
- Always include
automotive.stopin long-running test flows - Validate device state after stopping the session before continuing tests
Example Workflow
- Start automotive session using
automotive.start - Execute automotive-specific test scenarios (CarPlay / Android Auto)
- Stop automotive session using
automotive.stop - Continue with standard mobile test execution if required