API reference
Get an instance of the Appetize client.
const client = await window.appetize.getClient('#my_iframe')
Parameters
Name | Type | Description |
---|---|---|
selector | string | A query selector string pointing to the embedded iframe |
Listens for an event of the given name
client.on(event, data => {
console.log(data)
})
Event | Data Type | Description |
---|---|---|
queue | { type: 'account' | 'session' , position: number } | Your position in queue for the device.
If type is account you have reached the maximum amount of concurrent sessions for your account and are in queue for the next available slot.
If type is session , you are in a queue to wait for the next available device. |
error | string | An error has occurred |
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> |
Update the configured app, device, operating system, or other launch options.
Note: This will end any active sessions.
await client.config(config)
Parameters
Name | Type | Description |
---|---|---|
config | Record<string, any> |
Changes the loaded Appetize app of the iframe. This will restart your session, and you can also pass in
config
as well.Listens for an event of the given name
session.on(event, data => {
console.log(data)
})
Event | Data Type | Description |
---|---|---|
log | { message: string } | |
network | Record<string, any> | Intercepted network request or responses. |
error | string | An error has occurred on the session |
action | Record<string, any> | An action has been recorded |
interaction | Record<string, any> | Session received interaction from the user |
inactivityWarning | { secondsRemaining: number } | Session is about to timeout due to inactivity. |
Ends the session
await session.end()
Rotates the device 90 degrees
await session.rotate('right')
Parameters
Name | Type | Description |
---|---|---|
direction | "left" | "right" | The direction to rotate |
Takes a screenshot of the device and returns the data
const { data, mimeType } = await session.screenshot(format)
Parameters
Name | Type | Description |
---|---|---|
format | "buffer" | "base64" | The format of the screenshot data to return |
Sends a heartbeat to the server, resetting the inactivity timer
await session.heartbeat()
Taps on the screen at the given position
await session.tap({ x: 100, y: 100 })
Parameters
Name | Type | Description |
---|---|---|
coordinates | { x: number, y: number} | The coordinates of the position to tap, relative to the screen. |
Types the given text on the device
await session.type("hello")
Parameters
Name | Type | Description |
---|---|---|
text | string | Text to type |
Sends a single key press to the device
await session.keypress("a")
Parameters
Name | Type | Description |
---|---|---|
key | string | Key to send to the device ('a', 'b', etc.)
Also takes special values for hardware keys:
HOME
VOLUME_UP (android only)
VOLUME_DOWN (android only)
ANDROID_KEYCODE_MENU |
options | { shift?: boolean } | |
Changes the current language and restarts the app
await session.setLanguage("fr")
Parameters
Name | Type | Description |
---|---|---|
language | string | Language code |
Opens a deep-link or web URL
await session.openUrl("https://appetize.io")
Parameters
Name | Type | Description |
---|---|---|
url | string | The URL |
Shakes device (iOS only)
await session.shake()
Simulate a matching fingerprint (Android 8+ only)
await session.biometry({
match: true/false
})
Enables or disables all interactions on the device. Default is true.
await session.allowInteractions(true/false)
Restarts the app
await session.restartApp()
Returns the UI as an XML string
await session.getUI()
Returns information about the adb connection (Android only)
const adb = await session.getAdbInfo()
Returns the URL to chrome dev tools to inspect network logs. Requires proxy to be set to
intercept
const url = await session.getNetworkInspectorUrl()
Play an automation Action or array of Actions.
await session.playAction(action)
Parameters
Name | Type | Description |
---|---|---|
action | Record<string, any> |
Plays an array of actions.
await session.playActions(actions)
Parameters
Name | Type | Description |
---|---|---|
actions | Array<Record<string, any>> |