The client provides methods to configure the device and start a session, while the session provides methods for user interaction.
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> |
A JSON object describing the Configuration options for the device. |
Update the configured app, device, operating system, or other launch options. See Configuration for acceptable values.
Note: This will end any active sessions.
await client.setConfig(config)
Ends the active session or cancels any pending session requests.
await client.endSession()
Executes an adb shell
command on the device (Android only)
{% code overflow="wrap" %}
await session.adbShellCommand("am start -a android.intent.action.VIEW -d https://appetize.io/")
{% endcode %}
Enables or disables all interactions on the device.
await session.allowInteractions(false)
Sets the biometry enrollment status (iOS Only)
await session.biometryEnrollment(true/false)
Simulate a matching fingerprint (Android 8+ only) or Face ID (iOS)
await session.biometry({
match: true/false
})
Ends the session
await session.end()
{% hint style="warning" %}
Experimental
The data structure of the response is subject to change
{% endhint %}
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: [...] }
]
*/
Sends a heartbeat to the server, resetting the inactivity timer of the session
await session.heartbeat()
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)
Opens a deep-link or web URL
await session.openUrl("https://appetize.io")
Launches the specified application using the provided appId
.
{% hint style="info" %} 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. {% endhint %}
await session.launchApp(appId)
Parameters
Name | Type | Description |
---|---|---|
appId |
string |
Android: |
Restarts the app
await session.restartApp()
Reinstalls the app
await session.reinstallApp()
Rotates the device 90 degrees left or right
await session.rotate('left')
await session.rotate('right')
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')
Shakes device
await session.shake()
Toggles the soft keyboard (iOS only)
await session.toggleSoftKeyboard()
Changes the current language.
await session.setLanguage("fr")
{% hint style="warning" %}
If your app does not automatically handle language/locale changes, you would need to explicitly call restartApp for this to take effect.
Some apps might also cache data in the previously used language. In these cases use reinstallApp to clear any previous cached data.
{% endhint %}
Types the given text
await session.type("hello")
{% hint style="warning" %} 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. {% endhint %}
{% hint style="info" %} The maximum file size for uploading media is 50 MB. {% endhint %}
Upload media to the device.
await session.addMedia(file)