Document `executeMobile` commands
ADD
commands-yml/commands/mobile-command.yml
+---
+ name: Execute Mobile Command
+ short_description: Execute a native mobile command
+
+ description:
+ |
+ Execute a variety of native, mobile commands that aren't associated with a specific endpoint
+
+ Syntax is `execute("mobile: <commandName>", <JSON serializable argument>)`
+
+ List of available commands:
+
+ ### IOS
+ | Command | Description | Argument | Argument Example |
+ | ------- | ----------- | -------- | ---------------- |
+ | mobile:viewportScreenshot | Like [screenshot](/commands/session/screenshot/) but only includes contents of viewport | <none> | <none> |
+
+ ### IOS (XCUITest Only)
+ | Command | Description | Argument | Argument Example |
+ | ------- | ----------- | -------- | ---------------- |
+ | mobile:startPerfRecord | Starts performance profiling for the device under test | <none> | |
+ | mobile:stopPerfRecord | Stops performance profiling for the device under test | <none> | |
+ | 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. | <none> | |
+ | mobile:stopLogsBroadcast | Stops the iOS system logs broadcasting websocket server started by `mobile:startLogsBroadcast` | <none> | |
+ | mobile:swipe | refer to [Automating Mobile Gestures For iOS With WebDriverAgent/XCTest Backend](/writing-running-appium/ios/ios-xctest-mobile-gestures/#mobile-swipe) | | |
+ | mobile:scroll | refer to [Automating Mobile Gestures For iOS With WebDriverAgent/XCTest Backend](/writing-running-appium/ios/ios-xctest-mobile-gestures/#mobile-scroll) | | |
+ | mobile:pinch | refer to [Automating Mobile Gestures For iOS With WebDriverAgent/XCTest Backend](/writing-running-appium/ios/ios-xctest-mobile-gestures/#mobile-pinch) | | |
+ | mobile:doubleTap | refer to [Automating Mobile Gestures For iOS With WebDriverAgent/XCTest Backend](/writing-running-appium/ios/ios-xctest-mobile-gestures/#mobile-doubleTap) | | |
+ | mobile:touchAndHold | refer to [Automating Mobile Gestures For iOS With WebDriverAgent/XCTest Backend](/writing-running-appium/ios/ios-xctest-mobile-gestures/#mobile-touchAndHold) | | |
+ | mobile:twoFingerTap | refer to [Automating Mobile Gestures For iOS With WebDriverAgent/XCTest Backend](/writing-running-appium/ios/ios-xctest-mobile-gestures/#mobile-twoFingerTap) | | |
+ | mobile:tap | refer to [Automating Mobile Gestures For iOS With WebDriverAgent/XCTest Backend](/writing-running-appium/ios/ios-xctest-mobile-gestures/#mobile-tap) | | |
+ | mobile:dragFromToForDuration | refer to [Automating Mobile Gestures For iOS With WebDriverAgent/XCTest Backend](/writing-running-appium/ios/ios-xctest-mobile-gestures/#mobile-dragFromToForDuration) | | |
+ | mobile:selectPickerWheelValue | refer to [Automating Mobile Gestures For iOS With WebDriverAgent/XCTest Backend](/writing-running-appium/ios/ios-xctest-mobile-gestures/#mobile-selectPickerWheelValue) | | |
+ | mobile:alert | refer to [Automating Mobile Gestures For iOS With WebDriverAgent/XCTest Backend](/writing-running-appium/ios/ios-xctest-mobile-gestures/#mobile-alert) | | |
+ | mobile:installApp | refer to [XCUITest Mobile App Managemenet](/writing-running-appium/ios/ios-xctest-mobile-apps-management/#mobile-installapp) | | |
+ | mobile:removeApp | refer to [XCUITest Mobile App Managemenet](/writing-running-appium/ios/ios-xctest-mobile-apps-management/#mobile-removeapp) | | |
+ | mobile:isAppInstalled | refer to [XCUITest Mobile App Managemenet](/writing-running-appium/ios/ios-xctest-mobile-apps-management/#mobile-isappinstalled) | | |
+ | mobile:launchApp | refer to [XCUITest Mobile App Managemenet](/writing-running-appium/ios/ios-xctest-mobile-apps-management/#mobile-launchapp) | | |
+ | mobile:terminateApp | refer to [XCUITest Mobile App Managemenet](/writing-running-appium/ios/ios-xctest-mobile-apps-management/#mobile-terminateapp) | | |
+ | mobile:activateApp | refer to [XCUITest Mobile App Managemenet](/writing-running-appium/ios/ios-xctest-mobile-apps-management/#mobile-activateapp) | | |
+ | mobile:queryAppState | refer to [XCUITest Mobile App Managemenet](/writing-running-appium/ios/ios-xctest-mobile-apps-management/#mobile-queryappstate) | | |
+ | mobile:setPasteboard | refer to [IOS Pasteboard Guide](/writing-running-appium/ios/ios-xctest-pasteboard/#mobile-setpasteboard) | | |
+ | mobile:getPasteboard | refer to [IOS Pasteboard Guide](/writing-running-appium/ios/ios-xctest-pasteboard/#mobile-getpasteboard) | | |
+ | mobile:installCertificate | refer to [IOS Pasteboard Guide](/writing-running-appium/ios/ios-xctest-install-certificate.md) | | |
+
+ ### Android
+ | Command | Description | Argument | Argument Example |
+ | ------- | ----------- | -------- | ---------------- |
+ | mobile:shell | Execute [ADB shell](https://developer.android.com/studio/command-line/adb#shellcommands) commands (requires [server flag](/writing-running-appium/server-args/#server-flags) `--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 | <none> | <none> |
+ | mobile:stopLogsBroadcast | Stops the logcat broadcasting websocket server started by `mobile:startLogsBroadcast` | <none> | <none> |
+
+ ### 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](/commands/session/screenshot/) but only includes contents of viewport | <none> | <none> |
+ | mobile:deepLink | Opens a deep-link URL for testing [Instant Apps](https://support.google.com/googleplay/answer/7240211?hl=en) | `{url, package}` | `{url: "https://www.site.com/", package: "com.site.SomeAndroidPackage"}` |
+
+
+ example_usage:
+ java:
+ |
+ driver.executeScript("mobile: scroll", ImmutableMap.of("direction", "down"));;
+
+ python:
+ |
+ self.driver.execute_script("mobile: scroll", {'direction': 'down'})
+ javascript_wd:
+ |
+ await driver.execute('mobile: scroll', {direction: 'down'});
+ javascript_wdio:
+ |
+ var result = browser.execute('mobile: scroll', {direction: 'down'})
+ ruby:
+ |
+ @driver.execute_script("mobile: scroll", { "direction" => "down"})
+ php:
+ |
+ // TODO PHP sample
+ csharp:
+ |
+ // TODO C# sample
+
+ client_docs:
+ java: "https://seleniumhq.github.io/selenium/docs/api/java/org/openqa/selenium/remote/RemoteWebDriver.html#executeScript-java.lang.String-java.lang.Object...-"
+ python: "http://selenium-python.readthedocs.io/api.html#selenium.webdriver.remote.webdriver.WebDriver.execute_script"
+ javascript_wdio: "http://webdriver.io/api/protocol/execute.html"
+ javascript_wd: "https://github.com/admc/wd/blob/master/lib/commands.js#L102"
+ ruby: "http://www.rubydoc.info/gems/selenium-webdriver/Selenium/WebDriver/Driver:execute_script"
+ php: "https://github.com/appium/php-client/" # TODO PHP documentation link
+ csharp: "https://github.com/appium/appium-dotnet-driver/" # TODO Dotnet documentation link
+
+ # Driver support by platform
+ driver_support:
+ ios:
+ xcuitest: true
+ uiautomation: true
+ android:
+ uiautomator2: true
+ uiautomator: true
+ mac:
+ mac: true
+ windows:
+ windows: true
+ client_support:
+ java: true
+ python: true
+ ruby: true
+ php: true
+ csharp: true
+ javascript_wd: true
+ javascript_wdio: true
+
+
+ # Information about the HTTP endpoints
+ endpoint:
+ url: /wd/hub/session/:session_id/execute
+ method: GET
+ url_parameters:
+ - name: session_id
+ description: ID of the session to route the command to
+ json_parameters:
+ - name: script
+ type: string
+ description: The mobile command to execute
+ - name: args
+ type: array
+ description: The JSON serializable arguments
+ response:
+ - type: any
+ description: The command result
+
+ # Links to specifications. Should link to at least one specification
+ specifications:
+ w3c: https://www.w3.org/TR/webdriver/#dfn-execute-script
+ jsonwp: https://github.com/SeleniumHQ/selenium/wiki/JsonWireProtocol#sessionsessionidexecute
+
\ No newline at end of file

MODIFY
docs/en/about-appium/api.md
docs/en/about-appium/api.md
<li>
<a href='/docs/en/commands/status.md'>Status</a>
</li>
+ <li>
+ <a href='/docs/en/commands/mobile-command.md'>Execute Mobile Command</a>
+ </li>
<li>
Session<ul> <li>
<a href='/docs/en/commands/session/create.md'>Create</a>

ADD
docs/en/commands/mobile-command.md
+[//]: # (DO NOT EDIT THIS FILE! This is an auto-generated file. Editing for this document happens in /commands-yml/commands/mobile-command.yml)
+
+# Execute Mobile Command
+
+Execute a native mobile command
+## Example Usage
+
+```java
+// Java
+// java
+JavascriptExecutor js = (JavascriptExecutor) driver;
+HashMap<String, String> scrollObject = new HashMap<String, String>();
+scrollObject.put("direction", "down");
+js.executeScript("mobile: scroll", scrollObject);
+
+```
+
+```python
+# Python
+self.driver.execute_script("mobile: scroll", {'direction': 'down'})
+
+```
+
+```javascript
+// Javascript
+// webdriver.io example
+var result = browser.execute('mobile: scroll', {direction: 'down'})
+
+
+
+// wd example
+await driver.execute('mobile: scroll', {direction: 'down'});
+
+```
+
+```ruby
+# Ruby
+@driver.execute_script("mobile: scroll", { "direction" => "down"})
+
+```
+
+```php
+# PHP
+// TODO PHP sample
+
+```
+
+```csharp
+// 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>)`
+
+List of available commands:
+
+### IOS
+| Command | Description | Argument | Argument Example |
+| ------- | ----------- | -------- | ---------------- |
+| mobile:viewportScreenshot | Like [screenshot](/commands/session/screenshot/) but only includes contents of viewport | <none> | <none> |
+
+### IOS (XCUITest Only)
+* [IOS XCTest Mobile Gestures](/writing-running-appium/ios/ios-xctest-mobile-gestures)
+* [Advanced Applications Managemenet Commands For iOS with WebDriverAgent/XCTest Backend](/writing-running-appium/ios/ios-xctest-mobile-apps-management)
+* [IOS Pasteboard Commands](/writing-running-appium/ios/ios-xctest-pasteboard/)
+* [IOS Predicate Guide](/writing-running-appium/ios/ios-predicate/)
+* [IOS TouchID](/writing-running-appium/ios/ios-touch-id/)
+* [IOS Install Certificate](/writing-running-appium/ios/ios-xctest-install-certificate.md)
+
+| Command | Description | Argument | Argument Example |
+| ------- | ----------- | -------- | ---------------- |
+| mobile:startPerfRecord | Starts performance profiling for the device under test | <none> | |
+| mobile:stopPerfRecord | Stops performance profiling for the device under test | <none> | |
+| 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. | <none> | |
+| mobile:stopLogsBroadcast | Stops the iOS system logs broadcasting websocket server started by `mobile:startLogsBroadcast` | <none> | |
+
+### Android
+| Command | Description | Argument | Argument Example |
+| ------- | ----------- | -------- | ---------------- |
+| mobile:shell | Execute [ADB shell](https://developer.android.com/studio/command-line/adb#shellcommands) commands (requires [server flag](/writing-running-appium/server-args/#server-flags) `--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 | <none> | <none> |
+| mobile:stopLogsBroadcast | Stops the logcat broadcasting websocket server started by `mobile:startLogsBroadcast` | <none> | <none> |
+
+### 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](/commands/session/screenshot/) but only includes contents of viewport | <none> | <none> |
+| mobile:deepLink | Opens a deep-link URL for testing [Instant Apps](https://support.google.com/googleplay/answer/7240211?hl=en) | `{url, package}` | `{url: "https://www.site.com/", package: "com.site.SomeAndroidPackage"}` |
+
+
+## Support
+
+### Appium Server
+
+|Platform|Driver|Platform Versions|Appium Version|Driver Version|
+|--------|----------------|------|--------------|--------------|
+| iOS | [XCUITest](/docs/en/drivers/ios-xcuitest.md) | 9.3+ | 1.6.0+ | All |
+| | [UIAutomation](/docs/en/drivers/ios-uiautomation.md) | 8.0 to 9.3 | All | All |
+| Android | [UiAutomator2](/docs/en/drivers/android-uiautomator2.md) | ?+ | 1.6.0+ | All |
+| | [UiAutomator](/docs/en/drivers/android-uiautomator.md) | 4.2+ | All | All |
+| Mac | [Mac](/docs/en/drivers/mac.md) | ?+ | 1.6.4+ | All |
+| Windows | [Windows](/docs/en/drivers/windows.md) | 10+ | 1.6.0+ | All |
+
+### Appium Clients
+
+|Language|Support|Documentation|
+|--------|-------|-------------|
+|[Java](https://github.com/appium/java-client/releases/latest)| All | [seleniumhq.github.io](https://seleniumhq.github.io/selenium/docs/api/java/org/openqa/selenium/remote/RemoteWebDriver.html#executeScript-java.lang.String-java.lang.Object...-) |
+|[Python](https://github.com/appium/python-client/releases/latest)| All | [selenium-python.readthedocs.io](http://selenium-python.readthedocs.io/api.html#selenium.webdriver.remote.webdriver.WebDriver.execute_script) |
+|[Javascript (WebdriverIO)](http://webdriver.io/index.html)| All | [webdriver.io](http://webdriver.io/api/protocol/execute.html) |
+|[Javascript (WD)](https://github.com/admc/wd/releases/latest)| All | [github.com](https://github.com/admc/wd/blob/master/lib/commands.js#L102) |
+|[Ruby](https://github.com/appium/ruby_lib/releases/latest)| All | [www.rubydoc.info](http://www.rubydoc.info/gems/selenium-webdriver/Selenium/WebDriver/Driver:execute_script) |
+|[PHP](https://github.com/appium/php-client/releases/latest)| All | [github.com](https://github.com/appium/php-client/) |
+|[C#](https://github.com/appium/appium-dotnet-driver/releases/latest)| All | [github.com](https://github.com/appium/appium-dotnet-driver/) |
+
+## 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 script to execute |
+| args | `array` | The script arguments |
+
+### Response
+
+The script result (`any`)
+
+## See Also
+
+* [W3C Specification](https://www.w3.org/TR/webdriver/#dfn-execute-script)
+* [JSONWP Specification](https://github.com/SeleniumHQ/selenium/wiki/JsonWireProtocol#sessionsessionidexecute)

MODIFY
docs/en/commands/web/execute.md
docs/en/commands/web/execute.md
@@ -31,7 +31,7 @@ console.log(result.value); // outputs: 10
// wd example
-await driver.safeAsync('document.title');
+await driver.execute('document.title');
```

MODIFY
docs/toc.js
docs/toc.js
@@ -22,6 +22,7 @@ module.exports = {
]],
["Commands", ["commands",
["Status", "status.md"],
+ ["Execute Mobile Command", "mobile-command.md"],
["Session", ["session",
["Create", "create.md"],
["End", "delete.md"],

Document `executeMobile` commands (#10614)