Appetize Docs
HomeDemoUploadPricing
  • Introduction
  • Platform
    • App Management
      • Uploading Apps
        • Android
        • iOS
      • App Dashboard
      • Running Apps
      • App Permissions
    • Device Sandbox
    • Embedding
    • Sharing
    • Session Inactivity Timeout
    • Query Params Reference
  • Features
    • Devices & OS Versions
    • Network Traffic Monitor
    • Debug Logs
    • UI Automation
    • Proxy
    • Language & Locale
    • Mock Location
    • Deep links
    • Launch Params
    • Media
    • Auto-grant Permissions
    • Custom Branding
    • Custom Launch Pages
    • Advanced Features
      • Android
        • ADB tunnel
        • Hide Password Visibility
      • Reserved Devices
  • Account
    • Invite your team
    • Single Sign-On
      • OpenID Connect
      • SAML
      • Azure Active Directory
      • Google Workspace (GSuite)
    • Reporting
      • Session History
      • Usage Summary
  • Infrastructure
    • Configure Network Access
    • Enterprise Hosting Options
  • JavaScript SDK
    • Configuration
    • Automation
      • Device commands
      • Touch interactions
    • API reference
      • Initialization
      • Client
      • Session
      • Types
        • AdbConnectionInfo
        • AppetizeApp
        • AndroidElementAttributes
        • Coordinates
        • DeviceInfo
        • Element
        • ElementBounds
        • IOSAccessibilityElement
        • IOSElementAttributes
        • NetworkRequest
        • NetworkResponse
        • SessionConfig
        • SwipeMove
        • RecordedAction
        • RecordedSwipeAction
        • RecordedKeypressAction
        • RecordedPosition
        • RecordedTapAction
        • RecordedTouchAction
        • UserInteraction
  • Testing
    • Getting Started
    • Writing Tests
    • Running Tests
    • Test Configuration
    • Continuous Integration
    • Record Tests (experimental)
    • Trace Viewer
    • Web Tests on Mobile Browsers
  • REST API
    • Create new app
    • Update existing app
    • Direct file uploads
    • Delete app
    • List apps
    • Usage summary
    • Devices & OS Versions
      • v1
    • IP Blocks
      • v1
    • Sample code
  • Guides & Samples
    • Impersonation
    • Automate Sign-in Flow
    • Screenshot Automation
    • Unlock Device
    • Validate Analytics Events
    • Lock Your Device to One App
    • Test Accessibility Font Sizes
    • Common testing scenarios
    • Samples Repository
  • Deprecated
    • Cross-document messages
  • Changelog
  • Additional Support
    • Knowledge Base
    • Support Request
Powered by GitBook
On this page
  • Client
  • startSession()
  • setConfig()
  • endSession()
  • Session
  • adbShellCommand()
  • allowInteractions()
  • biometryEnrollment()
  • biometry()
  • end()
  • getUI()
  • heartbeat()
  • keypress()
  • openUrl()
  • launchApp(appId)
  • restartApp()
  • reinstallApp()
  • rotate()
  • screenshot()
  • shake()
  • toggleSoftKeyboard()
  • setLanguage()
  • type()
  • addMedia(file)
  1. JavaScript SDK
  2. Automation

Device commands

PreviousAutomationNextTouch interactions

Last updated 5 months ago

The client provides methods to configure the device and start a session, while the session provides methods for user interaction.

Client

startSession()

Starts a session with the requested app, device, operating system, and other launch options.

const session = await client.startSession()

Parameters

Name
Type
Description

config?

Record<string, any>

setConfig()

Update the configured app, device, operating system, or other launch options. See for acceptable values.

Note: This will end any active sessions.

await client.setConfig(config)

endSession()

Ends the active session or cancels any pending session requests.

await client.endSession()

Session

adbShellCommand()

Executes an adb shell command on the device (Android only)

await session.adbShellCommand("am start -a android.intent.action.VIEW -d https://appetize.io/")

allowInteractions()

Enables or disables all interactions on the device.

await session.allowInteractions(false)

biometryEnrollment()

Sets the biometry enrollment status (iOS Only)

await session.biometryEnrollment(true/false)

biometry()

Simulate a matching fingerprint (Android 8+ only) or Face ID (iOS)

await session.biometry({
    match: true/false
})

end()

Ends the session

await session.end()

getUI()

Experimental The data structure of the response is subject to change

Returns an array of elements describing the current UI on the device.

const ui = await session.getUI()

/*
[
  { type: 'app', appId: 'com.my.app', children: [...] },
  { type: 'app', appId: 'com.apple.springboard', children: [...] }
]
*/

heartbeat()

Sends a heartbeat to the server, resetting the inactivity timer of the session

await session.heartbeat()

keypress()

Sends a single key press to the device.

await session.keypress("a")

This can also be used to send hardware keys:

  • HOME

  • VOLUME_UP (Android)

  • VOLUME_DOWN (Android)

  • ANDROID_KEYCODE_MENU (Android)

  • LOCK_SCREEN (Android)

  • UNLOCK_SCREEN (Android)

  • TOGGLE_SCREEN_LOCK (iOS)

openUrl()

Opens a deep-link or web URL

await session.openUrl("https://appetize.io")

launchApp(appId)

Launches the specified application using the provided appId.

If the app is already running, it will be brought to the foreground instead of being relaunched. If the app was originally launched with params or a launchUrl, these will also be passed with this method.

await session.launchApp(appId)

Parameters

Name
Type
Description

appId

string

Android: The app's package name / appId (e.g., com.example.app) or packageName/activityName. If no activity name is specified, it defaults to the main launch activity. iOS: The app's bundle identifier (e.g., com.example.app).

restartApp()

Restarts the app

await session.restartApp()

reinstallApp()

Reinstalls the app

await session.reinstallApp()

rotate()

Rotates the device 90 degrees left or right

await session.rotate('left')

await session.rotate('right')

screenshot()

Takes a screenshot of the device and returns the data as a buffer.

const { data, mimeType } = await session.screenshot()

Alternatively, it can return the data as a base64 encoded string

const { data, mimeType } = await session.screenshot('base64')

shake()

Shakes device

await session.shake()

toggleSoftKeyboard()

Toggles the soft keyboard (iOS only)

await session.toggleSoftKeyboard()

setLanguage()

Changes the current language.

await session.setLanguage("fr")

type()

Types the given text

await session.type("hello")

Typing is limited to 1000 characters at a time to ensure optimal performance and prevent potential disruptions. For larger payloads, you can use multiple 'type' operations.

addMedia(file)

The maximum file size for uploading media is 50 MB.

Upload media to the device.

await session.addMedia(file)

A JSON object describing the for the device.

If your app does not automatically handle language/locale changes, you would need to explicitly call for this to take effect. Some apps might also cache data in the previously used language. In these cases use to clear any previous cached data.

restartApp
reinstallApp
Configuration
Configuration options