Skip to main content

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

CommandDescription
automotive.startInitializes and activates an automotive session
automotive.stopTerminates 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 automotiveProjection capability
info

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

ParameterPlatformRequiredDescription
resolutionAndroidYesDHU resolution (DhuResolution enum)

iOS (CarPlay)

  • Initializes CarPlay session
  • Verifies CarPlay is running

Android (Android Auto)

  • Starts Android Auto (DHU)
  • Verifies session is active
note

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.start and automotive.stop must 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.stop commands 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.start only when explicit control is required
  • Avoid mixing capability-based automotive sessions with command-based control
  • Always include automotive.stop in long-running test flows
  • Validate device state after stopping the session before continuing tests

Example Workflow

  1. Start automotive session using automotive.start
  2. Execute automotive-specific test scenarios (CarPlay / Android Auto)
  3. Stop automotive session using automotive.stop
  4. Continue with standard mobile test execution if required