Appium
getLogTypes
Get available log types.
Appium command. More details can be found in the official protocol docs.
Usage
await driver.getLogTypes()
Returns
- <String[]>
logTypes: The list of available log types, example: browser, driver.
getLogs
Get the log for a given log type. Log buffer is reset after each request.
Appium command. More details can be found in the official protocol docs.
Usage
await driver.getLogs(type)
Parameters
| Name | Type | Details |
|---|---|---|
type | string | the log type |
Returns
- <Object[]>
logs: The list of log entries.
getSession
Retrieve the capabilities of the current session.
Appium command. More details can be found in the official protocol docs.
This protocol command is deprecated
Use getAppiumSessionCapabilities instead
Usage
await driver.getSession()
Returns
- <Object>
capabilities: An object describing the session's capabilities.
getAppiumContext
Appium command. More details can be found in the official protocol docs.
Usage
await driver.getAppiumContext()
Returns
- <Context>
context: a string representing the current context or null representing 'no context'
switchAppiumContext
Appium command. More details can be found in the official protocol docs.
Usage
await driver.switchAppiumContext(name)
Parameters
| Name | Type | Details |
|---|---|---|
name | string | a string representing an available context |
getAppiumContexts
Appium command. More details can be found in the official protocol docs.
Usage
await driver.getAppiumContexts()
Returns
- <Context[]>
contexts: an array of strings representing available contexts, e.g. 'WEBVIEW', or 'NATIVE'
getAppiumCommands
Retrieve the endpoints and BiDi commands supported in the current session.
Appium command. More details can be found in the official protocol docs.
Usage
await driver.getAppiumCommands()
Returns
- <Object>
commands: Supported endpoints and BiDi commands, each grouped into common, driver-specific, and plugin-specific endpoints/commands.
getAppiumExtensions
Retrieve the extension commands supported in the current session.
Appium command. More details can be found in the official protocol docs.
Usage
await driver.getAppiumExtensions()
Returns
- <Object>
commands: Supported extension commands, grouped into driver-specific and plugin-specific commands.
getAppiumSessionCapabilities
Retrieve the capabilities of the current session.
Appium command. More details can be found in the official protocol docs.
Usage
await driver.getAppiumSessionCapabilities()
Returns
- <Object>
capabilities: An object describing the session's capabilities.
startRecordingScreen
Start recording the screen.
Appium command. More details can be found in the official protocol docs.
Usage
await driver.startRecordingScreen(options)
Parameters
| Name | Type | Details |
|---|---|---|
optionsoptional | object | Appium driver-specific recording options (refer to driver docs) |
Returns
- <string>
response: Empty string, or the base64 encoded string of a previous screen recording, if forceRestart and remotePath are not set
Support
- iOS: XCUITest (9.3+)
- Android: UiAutomator (4.2+)
- Windows: Windows (10+)
stopRecordingScreen
Stop recording the screen.
Appium command. More details can be found in the official protocol docs.
Usage
await driver.stopRecordingScreen(options)
Parameters
| Name | Type | Details |
|---|---|---|
optionsoptional | object | Appium driver-specific recording options (refer to driver docs) |
Returns
- <string>
response: Base64 encoded string of the screen recording, or an empty string if the remotePath option is set
Support
- iOS: XCUITest (9.3+)
- Android: UiAutomator (4.2+)
- Windows: Windows (10+)
rotateDevice
Rotate the device in three dimensions.
Appium command. More details can be found in the official protocol docs.
Usage
await driver.rotateDevice(x, y, z)
Parameters
| Name | Type | Details |
|---|---|---|
x | number | x offset to use for the center of the rotate gesture |
y | number | y offset to use for the center of the rotate gesture |
z | number | z offset to use for the center of the rotate gesture |
Support
- iOS: UIAutomation (8.0 to 9.3)
- Android: UiAutomator (4.2+)
installApp
Install the given app onto the device.
Appium command. More details can be found in the official protocol docs.
Usage
await driver.installApp(appPath, options)
Parameters
| Name | Type | Details |
|---|---|---|
appPath | string | Path to application .apk file |
optionsoptional | object | Driver-specific installation options |
Support
- iOS: XCUITest (9.3+), UIAutomation (8.0 to 9.3)
- Android: UiAutomator (4.2+)
activateApp
Activate the given app on the device
Appium command. More details can be found in the official protocol docs.
Usage
await driver.activateApp(appId, bundleId, options)
Parameters
| Name | Type | Details |
|---|---|---|
appIdoptional | string | App package ID (required for Android) |
bundleIdoptional | string | Bundle ID (required for iOS) |
optionsoptional | object | Driver-specific launch options |
Support
- iOS: XCUITest (9.3+)
- Android: UiAutomator (4.2+)
removeApp
Remove an app from the device.
Appium command. More details can be found in the official protocol docs.
Usage
await driver.removeApp(appId, bundleId, options)
Parameters
| Name | Type | Details |
|---|---|---|
appIdoptional | string | App package ID (required for Android) |
bundleIdoptional | string | Bundle ID (required for iOS) |
optionsoptional | object | Driver-specific uninstall options |
Returns
- <boolean>
didRemovalSucceed: Return true if uninstall was successful, false if not
Support
- iOS: XCUITest (9.3+), UIAutomation (8.0 to 9.3)
- Android: UiAutomator (4.2+)
terminateApp
Terminate the given app on the device
Appium command. More details can be found in the official protocol docs.
Usage
await driver.terminateApp(appId, bundleId, options)
Parameters
| Name | Type | Details |
|---|---|---|
appIdoptional | string | App package ID (required for Android) |
bundleIdoptional | string | Bundle ID (required for iOS) |
optionsoptional | object | Driver-specific termination options |
Support
- iOS: XCUITest (9.3+)
- Android: UiAutomator (4.2+)
isAppInstalled
Check whether the specified app is installed on the device.
Appium command. More details can be found in the official protocol docs.
Usage
await driver.isAppInstalled(appId, bundleId)
Parameters
| Name | Type | Details |
|---|---|---|
appIdoptional | string | App package ID (required for Android) |
bundleIdoptional | string | Bundle ID (required for iOS) |
Returns
- <boolean>
isAppInstalled: Return true if installed, false if not
Support
- iOS: XCUITest (9.3+), UIAutomation (8.0 to 9.3)
- Android: UiAutomator (4.2+)
queryAppState
Get the given app status on the device
Appium command. More details can be found in the official protocol docs.
Usage
await driver.queryAppState(appId, bundleId)
Parameters
| Name | Type | Details |
|---|---|---|
appIdoptional | string | App package ID (required for Android) |
bundleIdoptional | string | Bundle ID (required for iOS) |
Returns
- <number>
appStatus: 0 is not installed. 1 is not running. 2 is running in background suspended. 3 is running in background. 4 is running in foreground
Support
- iOS: XCUITest (9.3+)
- Android: UiAutomator (4.2+)
hideKeyboard
Hide soft keyboard.
Appium command. More details can be found in the official protocol docs.
Usage
await driver.hideKeyboard(strategy, key, keyCode, keyName)
Parameters
| Name | Type | Details |
|---|---|---|
strategyoptional | string | hide keyboard strategy (UIAutomation only), available strategies - 'press', 'pressKey', 'swipeDown', 'tapOut', 'tapOutside', 'default' |
keyoptional | string | key value if strategy is 'pressKey' |
keyCodeoptional | string | key code if strategy is 'pressKey' |
keyNameoptional | string | key name if strategy is 'pressKey' |
Support
- iOS: XCUITest (9.3+), UIAutomation (8.0 to 9.3)
- Android: UiAutomator (4.2+)
- Windows: Windows (10+)
isKeyboardShown
Whether or not the soft keyboard is shown.
Appium command. More details can be found in the official protocol docs.
Usage
await driver.isKeyboardShown()
Returns
- <boolean>
isKeyboardShown: True if the keyboard is shown
Support
- iOS: XCUITest (9.3+), UIAutomation (8.0 to 9.3)
- Android: UiAutomator (4.2+)
- Windows: Windows (10+)
pushFile
Place a file onto the device in a particular place.
Appium command. More details can be found in the official protocol docs.
Usage
await driver.pushFile(path, data)
Parameters
| Name | Type | Details |
|---|---|---|
path | string | path to install the data to |
data | string | contents of file in base64 |
Support
- iOS: XCUITest (9.3+), UIAutomation (8.0 to 9.3)
- Android: UiAutomator (4.2+)
- Windows: Windows (10+)
pullFile
Retrieve a file from the device's file system.
Appium command. More details can be found in the official protocol docs.
Usage
await driver.pullFile(path)
Parameters
| Name | Type | Details |
|---|---|---|
path | string | path on the device to pull file from |
Returns
- <string>
response: Contents of file in base64
Support
- iOS: XCUITest (9.3+), UIAutomation (8.0 to 9.3)
- Android: UiAutomator (4.2+)
- Windows: Windows (10+)
pullFolder
Retrieve a folder from the device's file system.
Appium command. More details can be found in the official protocol docs.
Usage
await driver.pullFolder(path)
Parameters
| Name | Type | Details |
|---|---|---|
path | string | path to an entire folder on the device |
Returns
- <string>
response: Zip file of the folder contents in base64
Support
- iOS: XCUITest (9.3+), UIAutomation (8.0 to 9.3)
- Android: UiAutomator (4.2+)
- Windows: Windows (10+)
getDeviceTime
Get the time on the device.
Appium command. More details can be found in the official protocol docs.
Usage
await driver.getDeviceTime()
Returns
- <string>
time: Time on the device
Support
- iOS: XCUITest (9.3+), UIAutomation (8.0 to 9.3)
- Android: UiAutomator (4.2+)
getSettings
Retrieve the current session settings.
Appium command. More details can be found in the official protocol docs.
Usage
await driver.getSettings()
Returns
- <object>
settings: JSON hash of all the currently specified settings, see Settings API
Support
- iOS: XCUITest (9.3+), UIAutomation (8.0 to 9.3)
- Android: UiAutomator (4.2+)
- Windows: Windows (10+)
updateSettings
Update the session settings.
Appium command. More details can be found in the official protocol docs.
Usage
await driver.updateSettings(settings)
Parameters
| Name | Type | Details |
|---|---|---|
settings | object | key/value object with settings to update |
Support
- iOS: XCUITest (9.3+), UIAutomation (8.0 to 9.3)
- Android: UiAutomator (4.2+)
- Windows: Windows (10+)
executeDriverScript
Execute a script in a child process. This approach helps minimize potential latency associated with each command. Using this command in Appium 2 or later requires installing the execute-driver plugin.
Appium command. More details can be found in the official protocol docs.
Usage
await driver.executeDriverScript(script, type, timeout)
Parameters
| Name | Type | Details |
|---|---|---|
script | string | The script to execute. It has access to a 'driver' object which represents a WebdriverIO session attached to the current server. |
typeoptional | string | The language/framework used in the script. Currently, only 'webdriverio' is supported and is the default. |
timeoutoptional | number | The number of milliseconds the script should be allowed to run before being killed by the Appium server. Defaults to the equivalent of 1 hour. |
Returns
- <object>
result: An object containing two fields: 'result', which is the return value of the script itself, and 'logs', which contains 3 inner fields, 'log', 'warn', and 'error', which hold an array of strings logged by console.log, console.warn, and console.error in the script's execution.
getEvents
Get events logged in the current session.
Appium command. More details can be found in the official protocol docs.
Usage
await driver.getEvents(type)
Parameters
| Name | Type | Details |
|---|---|---|
typeoptional | string, string[] | One or more event types to filter the returned events |
Returns
- <object>
result: A JSON hash of events like{'commands' => [{'cmd' => 123455, ....}], 'startTime' => 1572954894127, }.
Support
- Android: UiAutomator (4.2+)
- iOS: XCUITest (9.3+)
logEvent
Log a custom event.
Appium command. More details can be found in the official protocol docs.
Usage
await driver.logEvent(vendor, event)
Parameters
| Name | Type | Details |
|---|---|---|
vendor | string | Name of the namespace (vendor) used to prefix the event |
event | string | Name of the event |
Support
- Android: UiAutomator (4.2+)
- iOS: XCUITest (9.3+)
compareImages
Compare two images using the specified mode of comparison. Using this command in Appium 2 or later requires installing the images plugin.
Appium command. More details can be found in the official protocol docs.
Usage
await driver.compareImages(mode, firstImage, secondImage, options)
Parameters
| Name | Type | Details |
|---|---|---|
mode | string | One of possible comparison modes: 'matchFeatures', 'getSimilarity', 'matchTemplate'. |
firstImage | string | Base64-encoded image file. |
secondImage | string | Base64-encoded image file. |
options=[object Object]optional | object | The supported values of this property depend on the mode value. See Appium documentation for more details. |
Returns
- <object>
result: The content of the resulting dictionary depends on themodeandoptionsvalues. See Appium documentation for more details.
availableIMEEngines
List all available IME engines on the device. To use an engine, it has to be present in this list.
Appium command. More details can be found in the official protocol docs.
Usage
await driver.availableIMEEngines()
Returns
- <String[]>
engines: A list of available engines
Support
- Android: UiAutomator (4.2+)
getActiveIMEEngine
Get the name of the active IME engine. The name string is platform specific.
Appium command. More details can be found in the official protocol docs.
Usage
await driver.getActiveIMEEngine()
Returns
- <String>
engine: The name of the active IME engine
Support
- Android: UiAutomator (4.2+)
isIMEActivated
Indicates whether IME input is active at the moment
Appium command. More details can be found in the official protocol docs.
Usage
await driver.isIMEActivated()
Returns
- <Boolean>
isActive: true if IME input is available and currently active, false otherwise
Support
- Android: UiAutomator (4.2+)
deactivateIMEEngine
De-activates the currently-active IME engine.
Appium command. More details can be found in the official protocol docs.
Usage
await driver.deactivateIMEEngine()
Support
- Android: UiAutomator (4.2+)
activateIMEEngine
Activates an IME engine.
Appium command. More details can be found in the official protocol docs.
Usage
await driver.activateIMEEngine(engine)
Parameters
| Name | Type | Details |
|---|---|---|
engine | string | name of the engine to activate |
Support
- Android: UiAutomator (4.2+)
getOrientation
Get the current device orientation.
Appium command. More details can be found in the official protocol docs.
Usage
await driver.getOrientation()
Returns
- <String>
orientation: The current orientation corresponding to a value defined in ScreenOrientation:LANDSCAPE|PORTRAIT.
Support
- Android: UiAutomator (4.2+)
- iOS: XCUITest (9.3+)
setOrientation
Set the device orientation
Appium command. More details can be found in the official protocol docs.
Usage
await driver.setOrientation(orientation)
Parameters
| Name | Type | Details |
|---|---|---|
orientation | string | the new browser orientation as defined in ScreenOrientation: LANDSCAPE|PORTRAIT |
Support
- Android: UiAutomator (4.2+)
- iOS: XCUITest (9.3+)
getGeoLocation
Get the current geo location.
Appium command. More details can be found in the official protocol docs.
Usage
await driver.getGeoLocation()
Returns
- <Object>
location: The current geo location.
setGeoLocation
Set the current geo location.
Appium command. More details can be found in the official protocol docs.
Usage
await driver.setGeoLocation(location)
Parameters
| Name | Type | Details |
|---|---|---|
location | object | the new location ({latitude: number, longitude: number, altitude: number}) |