Cross-document messages

Interact with the virtual device via a Javascript post-message API

Cross-document messaging, when enabled via the &xdocMsg=true query parameter, allows you to issue commands to the embedded iFrame via Javascript via postMessage(message, targetOrigin).

Messages without any parameters can be passed directly as strings, e.g.

postMessage('requestSession', '*')

Messages with parameters should be passed as objects with the message name in the type field. E.g.

postMessage({ type: 'mouseclick', x: 100, y:100 }, '*')

Sendable Messages

requestSession

Equivalent to clicking play

postMessage('requestSession', '*')

emitHomeButton

Taps the home button for iOS apps when available

postMessage('emitHomeButton', '*')

rotateLeft

Rotates counter-clockwise

rotateRight

Rotates clockwise

setScale

Sets device scale to a value between 10 and 100

saveScreenshot

Prompts user to download screenshot

getScreenshot

Sends screenshot data directly to parent window. See the screenshot event the iFrame posts to the parent.

heartbeat

Sends heartbeat to prevent inactivity timeout

mouseclick

Sends click event at the provided coordinates

pasteText

Pastes the provided text

keypress

Sends keypress. key should be a string that identifies the key pressed, e.g. 'a'. Acceptable values on Android also include 'volumeUp' and 'volumeDown'.

language

Sets language, restarts app

location

Sets location. value should be 2-length array that contains [latitude, longitude]

url

Opens deep-link or regular URL in Safari

shakeDevice

Send shake gesture to iOS apps

androidKeycodeMenu

Sends Android KEYCODE_MENU command

adbShellCommand

Executes an adb shell command on an Android device.

If a session is already running the command will be executed immediately. If the session has not been started, the command will execute upon start.

biometryMatch

(Android 8+ only) simulate a matching fingerprint

biometryNonMatch

(Android 8+ only) simulate a non-matching fingerprint

disableInteractions

Disables all user interactions

enableInteractions

Re-enables all user interactions

restartApp

Kills and restarts app in same session

endSession

Ends the session

Receivable Messages

The iFrame also posts messages to the parent window via message event. You can listen for them with an event handler on the window:

userInteractionReceived

Session has received an interaction from the user

heartbeatReceived

Heartbeat event received

orientationChanged

Device orientation has changed

sessionRequested

Session has been requested

userError

An error occurred while starting session

sessionQueued

You have entered a system-level queue (awaiting device availability)

sessionQueuedPosition

Position of session queue

accountQueued

You have entered an account-level queue (concurrent users)

accountQueuedPosition

Account queue position

appLaunch

App launch command sent

firstFrameReceived

First frame received

timeoutWarning

Session is about to timeout in 10 seconds

sessionEnded

Session has ended

screenshot

Screenshot data received

sessionConnecting

Passes the identifying token for the session

chromeDevToolsUrl

URL to view dev tools for the device (only if network intercept enabled)

interceptResponse

Intercepted network response.

This is only emitted if network intercept enabled (proxy=intercept query param)

interceptRequest

Intercepted network request.

This is only emitted if network intercept enabled (proxy=intercept query param)

debug

Logged messages from the device.

This is only emitted if debug log is enabled (debug=true query param)

deviceDimensions

The dimensions of the current device. If the screenOnly query param is true, the dimensions will be for the screen.

app

Information for the application

Check out our JSFiddle.net example to see these messages in action!

Last updated