跳转至

Mobile JSON Wire Protocol

The following is a list of legacy Mobile JSON Wire Protocol (MJSONWP) endpoints used in Appium.

getRotation

GET /session/:sessionId/rotation

MJSONWP documentation: Device Rotation

Retrieves the current spatial orientation of the device under test.

Response

Rotation - an object with the following properties:

Name Description Type
x Degrees by which the device is rotated on its X axis number
y Degrees by which the device is rotated on its Y axis number
z Degrees by which the device is rotated on its Z axis number

setRotation

POST /session/:sessionId/rotation

MJSONWP documentation: Device Rotation

Sets the spatial orientation of the device under test.

Parameters

Name Description Type
x Degrees by which the device is rotated on its X axis number
y Degrees by which the device is rotated on its Y axis number
z Degrees by which the device is rotated on its Z axis number

Response

null

getCurrentContext

GET /session/:sessionId/context

MJSONWP documentation: Webviews and Other Contexts

Retrieves the active application context.

Response

string - the name of the active context

setContext

POST /session/:sessionId/context

MJSONWP documentation: Webviews and Other Contexts

Sets an application context as the active context.

Parameters

Name Description Type
name Name of the context to set as the active one string

Response

null

getContexts

GET /session/:sessionId/contexts

MJSONWP documentation: Webviews and Other Contexts

Retrieves all available application contexts.

Response

string[] - the names of available contexts

getNetworkConnection

GET /session/:sessionId/network_connection

MJSONWP documentation: Device Modes

Retrieves the current state of network types (data, Wi-Fi, airplane mode).

Deprecated

Please use driver-specific extension methods such as mobile: getConnectivity

Response

NetworkConnectionState - a number indicating the current network state:

Value Data Wi-Fi Airplane Mode
0 OFF OFF OFF
1 OFF OFF ON
2 OFF ON OFF
4 ON OFF OFF
6 ON ON OFF

setNetworkConnection

POST /session/:sessionId/network_connection

MJSONWP documentation: Device Modes

Sets the state of network types (data, Wi-Fi, airplane mode).

Deprecated

Please use driver-specific extension methods such as mobile: setConnectivity

Parameters

Name
Description
Type
parameters Object containing the type key, whose value is the desired network state {"type":NetworkConnectionState}

Response

NetworkConnectionState - the new network state