Edit this Doc Execute Mobile Command

Execute a native mobile command

Example Usage

driver.executeScript("mobile: scroll", ImmutableMap.of("direction", "down"));

self.driver.execute_script("mobile: scroll", {'direction': 'down'})

// webdriver.io example
var result = browser.execute('mobile: scroll', {direction: 'down'})



// wd example
await driver.execute('mobile: scroll', {direction: 'down'});

@driver.execute_script("mobile: scroll", { "direction" => "down"})

// TODO C# sample

// TODO PHP sample

Description

Execute a variety of native, mobile commands that aren't associated with a specific endpoint

Syntax is execute("mobile: <commandName>", <JSON serializable argument>) (see Execute Script for more details on syntax).

List of available commands:

IOS

Command Description Argument Argument Example
mobile:viewportScreenshot Like screenshot but only includes contents of viewport

IOS (XCUITest Only)

Command Description Argument Argument Example
mobile:startPerfRecord Starts performance profiling for the device under test
mobile:stopPerfRecord Stops performance profiling for the device under test
mobile:startLogsBroadcast Starts iOS system logs broadcast websocket on the same host and port where Appium server is running at /ws/session/:sessionId:/appium/syslog endpoint.
mobile:stopLogsBroadcast Stops the iOS system logs broadcasting websocket server started by mobile:startLogsBroadcast
mobile:swipe refer to Automating Mobile Gestures For iOS With WebDriverAgent/XCTest Backend
mobile:scroll refer to Automating Mobile Gestures For iOS With WebDriverAgent/XCTest Backend
mobile:pinch refer to Automating Mobile Gestures For iOS With WebDriverAgent/XCTest Backend
mobile:doubleTap refer to Automating Mobile Gestures For iOS With WebDriverAgent/XCTest Backend
mobile:touchAndHold refer to Automating Mobile Gestures For iOS With WebDriverAgent/XCTest Backend
mobile:twoFingerTap refer to Automating Mobile Gestures For iOS With WebDriverAgent/XCTest Backend
mobile:tap refer to Automating Mobile Gestures For iOS With WebDriverAgent/XCTest Backend
mobile:dragFromToForDuration refer to Automating Mobile Gestures For iOS With WebDriverAgent/XCTest Backend
mobile:selectPickerWheelValue refer to Automating Mobile Gestures For iOS With WebDriverAgent/XCTest Backend
mobile:alert refer to Automating Mobile Gestures For iOS With WebDriverAgent/XCTest Backend
mobile:installApp refer to XCUITest Mobile App Managemenet
mobile:removeApp refer to XCUITest Mobile App Managemenet
mobile:isAppInstalled refer to XCUITest Mobile App Managemenet
mobile:launchApp refer to XCUITest Mobile App Managemenet
mobile:terminateApp refer to XCUITest Mobile App Managemenet
mobile:activateApp refer to XCUITest Mobile App Managemenet
mobile:queryAppState refer to XCUITest Mobile App Managemenet
mobile:setPasteboard refer to IOS Pasteboard Guide
mobile:getPasteboard refer to IOS Pasteboard Guide
mobile:installCertificate refer to IOS Pasteboard Guide
mobile:getContexts Retrieve available contexts, along with the url and title associated with each webview (see get contexts)

Android

Command Description Argument Argument Example
mobile:shell Execute ADB shell commands (requires server flag --relaxed-security to be set) ADB shell string am start -n com.example.demo/com.example.test.MainActivity
mobile:startLogsBroadcast Starts Android logcat broadcast websocket on the same host and port where Appium is running at /ws/session/:sessionId:/appium/logcat endpoint
mobile:stopLogsBroadcast Stops the logcat broadcasting websocket server started by mobile:startLogsBroadcast
mobile:batteryInfo Reads the battery information from the device under test
mobile:acceptAlert Accepts an on-screen alert Optional button label to click on
mobile:dismissAlert Dismisses an on-screen alert Optional button label to click on

Android (UiAutomator2 only)

Command Description Argument Argument Example
mobile:scrollBackTo Scroll from one element to another {elementId, elementToId} {elementId: 2, elementToId: 1}
mobile:viewportScreenshot Like screenshot but only includes contents of viewport
mobile:deepLink Opens a deep-link URL for testing Instant Apps {url, package} {url: "https://www.site.com/", package: "com.site.SomeAndroidPackage"}
mobile:mobileGetDeviceInfo Gets device information like manufacturer and model. Read GetDeviceInfo for more details.

Support

Appium Server

Platform Driver Platform Versions Appium Version Driver Version
iOS XCUITest 9.3+ 1.6.0+ All
UIAutomation 8.0 to 9.3 All All
Android Espresso ?+ 1.9.0+ All
UiAutomator2 ?+ 1.6.0+ All
UiAutomator 4.2+ All All
Mac Mac ?+ 1.6.4+ All
Windows Windows 10+ 1.6.0+ All

Appium Clients

Language Support Documentation
Java All seleniumhq.github.io
Python All selenium-python.readthedocs.io
Javascript (WebdriverIO) All
Javascript (WD) All github.com
Ruby All www.rubydoc.info
PHP All github.com
C# All github.com

HTTP API Specifications

Endpoint

GET /wd/hub/session/:session_id/execute

URL Parameters

name description
session_id ID of the session to route the command to

JSON Parameters

name type description
script string The mobile command to execute
args array The JSON serializable arguments

Response

The command result (any)

See Also