Execute Mobile Command
Execute a native mobile command
Example Usage
// Java
driver.executeScript("mobile: scroll", ImmutableMap.of("direction", "down"));
# Python
self.driver.execute_script("mobile: scroll", {'direction': 'down'})
// Javascript
// webdriver.io example
var result = browser.execute('mobile: scroll', {direction: 'down'})
// wd example
await driver.execute('mobile: scroll', {direction: 'down'});
# Ruby
# ruby_lib example
execute_script("mobile: scroll", { "direction" => "down"})
# ruby_lib_core example
@driver.execute_script("mobile: scroll", { "direction" => "down"})
# PHP
// TODO PHP sample
// C#
// TODO C# 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) | ||
mobile:batteryInfo | Reads the battery information from the device under test | ||
mobile:pressButton | Press a physical button. The supported button name is is home. volumeup and volumedown are available for real devices | {name} |
{name: "home"} |
mobile:enrollBiometric | Enroll (or unenroll) an iOS Simulator to use biometrics | {isEnabled} |
{isEnabled: true} |
mobile:sendBiometricMatch | Send a matching or non-matching biometric input to an iOS Simulator. 'type' must be touchId or faceId . Match is a boolean indicating if it's a matching or non-matching input |
{type, match} |
{type: "touchId", match: true} |
mobile:isBiometricEnrolled | Check if an iOS Simulator is enrolled or not. Returns true if enrolled, false if not enrolled. |
||
mobile:clearKeychains | Clear the keychains for an iOS Simulator |
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 | |
mobile:performEditorAction | Performs the given editor action on the focused input field. The following action names are supported: normal, unspecified, none, go, search, send, next, done, previous . |
{action} | {action: "previous"} |
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:getDeviceInfo | Gets device information like manufacturer and model. Read GetDeviceInfo for more details. |
Android (Espresso only)
Command | Description | Argument | Argument Example |
---|---|---|---|
mobile:swipe | Perform the "swipe" view action | {elementId, direction} |
{elementId: 2, direction: "down|up|left|right"} |
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
)