[//]: # "DO NOT EDIT THIS FILE! This is an auto-generated file. Editing for this document happens in /commands-yml/commands/mobile-command.yml"
# 運行移動端的指令
運行一條本地移動端的指令
[//]: # "DO NOT EDIT THIS FILE! This is an auto-generated file. Editing for this document happens in /commands-yml/commands/mobile-command.yml"
## 使用示例
```java
// Java
driver.executeScript("mobile: scroll", ImmutableMap.of("direction", "down"));
```
```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
# ruby_lib example
execute_script("mobile: scroll", { "direction" => "down"})
# ruby_lib_core example
@driver.execute_script("mobile: scroll", { "direction" => "down"})
```
```php
# PHP
// TODO PHP sample
```
```csharp
// C#
driver.ExecuteScript("mobile:scroll", new Dictionary<string, string> { { "direction", "down" } });
```
[//]: # "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: <commandName>", <JSON serializable argument>)`
(有關語法的更多詳細信息,請參見[執行腳本]((../commands/web/execute.md))).
可用指令列表如下:
### IOS
| 指令 | 描述 | 參數 | 參數示例 |
| ------- | ----------- | -------- | ---------------- |
| `mobile:viewportScreenshot` | 類似于[屏幕截圖]((../commands/session/screenshot.md)),但僅包含當前視圖窗口的內容 | <none> | <none> |
### IOS (只適用于 XCUITest )
| Command | Description | Argument | Argument Example |
| ------- | ----------- | -------- | ---------------- |
| `mobile:startPerfRecord` | 開始對被測設備進行性能分析 | <none> | |
| `mobile:stopPerfRecord` | 停止對被測設備進行性能分析 | <none> | |
| `mobile:startLogsBroadcast` | 啟動IOS系統廣播日志,輸出地址為`/ws/session/:sessionId:/appium/device/syslog` | <none> | |
| `mobile:stopLogsBroadcast` | 停止已啟動的IOS系統廣播日志 | <none> | |
| `mobile:swipe` | 可以參考 [Automating Mobile Gestures For iOS With WebDriverAgent/XCTest Backend](../writing-running-appium/ios/ios-xctest-mobile-gestures.md#mobile-swipe) | | |
| `mobile:scroll` | 可以參考 [Automating Mobile Gestures For iOS With WebDriverAgent/XCTest Backend](../writing-running-appium/ios/ios-xctest-mobile-gestures.md#mobile-scroll) | | |
| `mobile:pinch` | 可以參考 [Automating Mobile Gestures For iOS With WebDriverAgent/XCTest Backend](../writing-running-appium/ios/ios-xctest-mobile-gestures.md#mobile-pinch) | | |
| `mobile:doubleTap` | 可以參考 [Automating Mobile Gestures For iOS With WebDriverAgent/XCTest Backend](../writing-running-appium/ios/ios-xctest-mobile-gestures.md#mobile-doubleTap) | | |
| `mobile:touchAndHold` | 可以參考 [Automating Mobile Gestures For iOS With WebDriverAgent/XCTest Backend](../writing-running-appium/ios/ios-xctest-mobile-gestures.md#mobile-touchAndHold) | | |
| `mobile:twoFingerTap` | 可以參考 [Automating Mobile Gestures For iOS With WebDriverAgent/XCTest Backend](../writing-running-appium/ios/ios-xctest-mobile-gestures.md#mobile-twoFingerTap) | | |
| `mobile:tapWithNumberOfTaps` | 可以參考 [Automating Mobile Gestures For iOS With WebDriverAgent/XCTest Backend](../writing-running-appium/ios/ios-xctest-mobile-gestures.md#mobile-tapWithNumberOfTaps) | | |
| `mobile:tap` | 可以參考 [Automating Mobile Gestures For iOS With WebDriverAgent/XCTest Backend](../writing-running-appium/ios/ios-xctest-mobile-gestures.md#mobile-tap) | | |
| `mobile:dragFromToForDuration` | 可以參考 [Automating Mobile Gestures For iOS With WebDriverAgent/XCTest Backend](../writing-running-appium/ios/ios-xctest-mobile-gestures.md#mobile-dragFromToForDuration) | | |
| `mobile:selectPickerWheelValue` | 可以參考 [Automating Mobile Gestures For iOS With WebDriverAgent/XCTest Backend](../writing-running-appium/ios/ios-xctest-mobile-gestures.md#mobile-selectPickerWheelValue) | | |
| `mobile:alert` | 可以參考 [Automating Mobile Gestures For iOS With WebDriverAgent/XCTest Backend](../writing-running-appium/ios/ios-xctest-mobile-gestures.md#mobile-alert) | | |
| `mobile:installApp` | 可以參考 [XCUITest Mobile App Managemenet](../writing-running-appium/ios/ios-xctest-mobile-apps-management.md#mobile-installapp) | | |
| `mobile:removeApp` | 可以參考 [XCUITest Mobile App Managemenet](../writing-running-appium/ios/ios-xctest-mobile-apps-management.md#mobile-removeapp) | | |
| `mobile:isAppInstalled` | 可以參考 [XCUITest Mobile App Managemenet](../writing-running-appium/ios/ios-xctest-mobile-apps-management.md#mobile-isappinstalled) | | |
| `mobile:launchApp` | 可以參考 [XCUITest Mobile App Managemenet](../writing-running-appium/ios/ios-xctest-mobile-apps-management.md#mobile-launchapp) | | |
| `mobile:terminateApp` | 可以參考 [XCUITest Mobile App Managemenet](../writing-running-appium/ios/ios-xctest-mobile-apps-management.md#mobile-terminateapp) | | |
| `mobile:activateApp` | 可以參考 [XCUITest Mobile App Managemenet](../writing-running-appium/ios/ios-xctest-mobile-apps-management.md#mobile-activateapp) | | |
| `mobile:queryAppState` | 可以參考 [XCUITest Mobile App Managemenet](../writing-running-appium/ios/ios-xctest-mobile-apps-management.md#mobile-queryappstate) | | |
| `mobile:setPasteboard` | 可以參考 [IOS Pasteboard Guide](../writing-running-appium/ios/ios-xctest-pasteboard.md#mobile-setpasteboard) | | |
| `mobile:getPasteboard` | 可以參考 [IOS Pasteboard Guide](../writing-running-appium/ios/ios-xctest-pasteboard.md#mobile-getpasteboard) | | |
| `mobile:installCertificate` | 可以參考 [IOS Pasteboard Guide](../writing-running-appium/ios/ios-xctest-install-certificate.md) | | |
| `mobile:getContexts` | 獲取有效的contexts, 以及與每個Webview關聯的url和標題(請參閱 [獲取context](../commands/context/get-contexts.md))。從Appium 1.17.0版本開始,如果 提供了 `waitForWebviewMs` , Appium 將會支持有效的時間內的等待來獲取Webviews。 | `{waitForWebviewMs}` | `{waitForWebviewMs: 5000}` |
| `mobile:batteryInfo` | 從被測設備讀取電池信息 | <none> | <none> |
| `mobile:pressButton` | 按下物理按鈕。可用的按鈕選項包括:主頁,提高音量和降低音量。真實設備支持所有三個按鈕,而模擬器僅支持主屏幕。 | `{name}` | `{name: "home"}` |
| `mobile:enrollBiometric` | 使用 [生物傳感器](https://developer.apple.com/design/human-interface-guidelines/ios/user-interaction/authentication/#face-id-and-touch-id) 打開(或關閉)IOS模擬器 | `{isEnabled}` | `{isEnabled: true}` |
| `mobile:sendBiometricMatch` | 將匹配或不匹配的生物特征輸入發送到IOS模擬器。 'type' 必須是 `touchId` 或者 `faceId`. Match是一個布爾值,指示它是匹配輸入還是不匹配輸入。 | `{type, match}` | `{type: "touchId", match: true}` |
| `mobile:isBiometricEnrolled` | 檢查是否已注冊IOS模擬器。如果已注冊,則返回true; 否則返回false。 |||
| `mobile:clearKeychains` | 清除IOS模擬器的密碼鑰匙 |||
| `mobile:siriCommand` | 向Siri發送命令 | `{text}` | `{text: "What time is it?"}` |
| `mobile:source` | 該端點允許從WDA作為字符串(也位于Web上下文中)從WDA檢索當前的本機頁面源。可能的輸出格式是: `xml` ( `getPageSource` 指令也是一樣的), `json` (與xml格式相同的樹結構,但表示為JSON) 和`description` ( 通過XCTest輸出的本地調試). 可選的排除的Attributes數組允許提供屬性名稱,這些名稱將從生成的xml樹中排除。 這可能會顯著提高頁面源檢索的性能,尤其是如果排除了visible屬性。 | `{format, excludedAttributes}` | `{format: 'description'}` `{format: 'xml', excludedAttributes: ['visible']}` |
| `mobile:activeAppInfo` | 獲取當前活動應用程序的信息,例如bundleId和流程參數 | <none> | <none> |
| `mobile:deviceInfo` | 獲取設備信息,如語言環境和時區。時區默認為TZ數據庫格式,例如America / New York,上一個為Apple名稱,例如US / New York | <none> | <none> |
| `mobile:rotateElement` | 將觸摸兩次的旋轉手勢發送到給定的元素。有關更多詳細信息,請參見[rotate:withVelocity](https://developer.apple.com/documentation/xctest/xcuielement/1618665-rotate) | `{element, rotation, velocity}` | `{element: 2, rotation: π/2, velocity: 1.5}` |
| `mobile:deleteFile` | 刪除被測設備上的文件。遠程路徑值應符合 [Pushing/Pulling Files](../writing-running-appium/ios/ios-xctest-file-movement.md) | `{remotePath}` | `{remotePath: 'path/to/file'}` |
| `mobile:deleteFolder` | 刪除被測設備上的文件夾。遠程路徑值應符合 [Pushing/Pulling Files](../writing-running-appium/ios/ios-xctest-file-movement.md) | `{remotePath}` | `{remotePath: '@io.appium.example:documents/path/to/folder'}` |
| `mobile:getPermission` | 獲取模擬器上的應用程序權限狀態。這個需要 https://github.com/wix/AppleSimulatorUtils |||
| `mobile:setPermission` | 從Xcode 11.4開始,需要通過`xcrun simctl privacy` 設置權限。`key`是`xcrun simctl privacy` 列表中的服務, `value` 是 `yes`(允許), `no`(撤銷) or `unset`(重啟).它適用于模擬器。 | `{bundleId, {key: value}}`| `{bundleId: 'io.appium.example', {'location-always': 'yes', calendar: 'no'}` |
| `mobile:getAppearance` | 獲取設備的UI外觀樣式通過 `xcrun simctl ui`. 它會返回 `light`, `dark`, `unknown` or `unsupported` ( IOS 12以下). |||
| `mobile:setAppearance` |設置設備的UI外觀樣式 通過`xcrun simctl ui` 或者siri 指令|`{style}`|`{style: 'dark'}`|
| `mobile:getDeviceTime` | 獲取被測設備的時間。 https://momentjs.com/docs/ 是受支持的日期時間格式說明符的完整列表。默認是ISO-8601的格式`YYYY-MM-DDTHH:mm:ssZ` | `{format}` | `{format: 'YYYY-MM'}` |
| `mobile:startAudioRecording` | 開始錄制音頻流。閱讀 [Audio Capture From iOS Simulators and Real Devices](../writing-running-appium/ios/audio-capture.md) 以獲得更多細節 | | |
| `mobile:stopAudioRecording` | 停止并存儲錄制的音頻流。 閱讀[Audio Capture From iOS Simulators and Real Devices](../writing-running-appium/ios/audio-capture.md) 以獲得更多細節 | | |
### Android
| 指令 | 描述 | 參數 | 參數示例 |
| ------- | ----------- | -------- | ---------------- |
| `mobile:shell` | 執行 [ADB shell](https://developer.android.com/studio/command-line/adb#shellcommands) 命令(需要啟動[insecure feature](../writing-running-appium/security.md) `adb_shell` ) | 閱讀 [this page](../writing-running-appium/android/android-shell.md) | `{'command': 'echo', 'args': ['arg1', 'arg2']}` |
| `mobile:startLogsBroadcast` | 啟動IOS系統廣播日志,輸出地址`/ws/session/:sessionId:/appium/device/logcat` | <none> | <none> |
| `mobile:stopLogsBroadcast` | 停止已啟動的IOS系統廣播日志 | <none> | <none> |
| `mobile:performEditorAction` | 在焦點輸入字段上執行給定的編輯器操作。支持以下操作名稱:`normal, unspecified, none, go, search, send, next, done, previous`. | `{action}` | `{action: "previous"}`|
| `mobile:getPermissions` | 獲取權限列表: `denied`, `granted` or `requested`. | `{type, appPackage}` | `{type: "granted", appPackage: "io.appium.android.apis"}`|
| `mobile:changePermissions` | 授予或撤消權限。 | `{action, appPackage, permissions}` | `{action: "grant", appPackage: "io.appium.android.apis", permissions: "android.permission.READ_CONTACTS"}`, `{action: "revoke", appPackage: "io.appium.android.apis", permissions: ["android.permission.READ_CONTACTS", "android.permission.CAMERA"]}` |
| `mobile:getNotifications` | 在狀態欄通知中以JSON格式獲取項目列表。 請通過“設置”>“應用和通知”>“特殊應用訪問”打開“通知訪問”(實際路徑取決于設備型號)。請閱讀[Appium Pro](https://appiumpro.com/editions/106-retrieving-status-bar-notifications-for-android-devices)以獲得更多詳細信息。 | <none> | <none> |
| `mobile: listSms` | 以[JSON format](https://github.com/appium/io.appium.settings#sms)獲取SMS消息列表. | <none> | <none> |
| `mobile:type` | 將Unicode文本發送到焦點元素。 | `{text}` | `{text: "happy testing"}` |
| `mobile:getDeviceTime` | 獲取被測設備的時間。 https://momentjs.com/docs/ 是受支持的日期時間格式說明符的完整列表。默認是ISO-8601的格式`YYYY-MM-DDTHH:mm:ssZ` | `{format}` | `{format: 'YYYY-MM'}` |
| `mobile:deleteFile` | 刪除被測設備上的文件。遠程路徑值應為完整路徑或應用程序ID的文件。 | `{remotePath}` | `{remotePath: '@io.appium.example/path/in/bundle'}`, `{remotePath: '/tmp/data/file'}` |
| `mobile:startService` | 從Appium 1.18.0開始,通過調用am start-service或am start-foreground-service啟動給定服務。 intent參數是強制性的。 user是應該為其啟動服務的用戶的ID(默認情況下使用當前用戶ID)。如果前臺設置為true,則該服務將在前臺啟動。 | `{intent, user, foreground}` | `{intent: 'my.app/my.activity', foreground: true}` |
| `mobile:stopService` | 從Appium 1.18.0開始,通過在后臺調用am stop-service停止給定服務。 intent參數是強制性的。 user是應該停止服務的用戶的ID(默認情況下使用當前用戶ID)。 | `{intent, user}` | `{intent: 'my.app/my.activity'}` |
### Android (UiAutomator2 only)
| 命令 | 描述 | 參數 | 參數示例 |
| ------- | ----------- | -------- | ---------------- |
| `mobile:batteryInfo` | 從被測設備讀取電池信息 | <none> | <none> |
| `mobile:acceptAlert` | 接受屏幕彈窗 | 單擊的可選按鈕標簽 | <none> |
| `mobile:dismissAlert` | 取消屏幕上的警報 | Optional button label to click on | <none> |
| `mobile:scrollBackTo` | 從一個元素滾動到另一個元素 | `{elementId, elementToId}` | `{elementId: 2, elementToId: 1}` |
| `mobile:scroll` | 從Appium 1.18.0開始,滾動給定的可滾動元素,直到可以看到按策略和選擇器指定的元素標識符為止。可選的max Swipes屬性可以限制滾動動作的數量。它接受一個可選的元素屬性,該屬性應該是元素標識符并且可以滾動。如果沒有此屬性,Appium將選擇第一個當前可用的可滾動容器。請閱讀[appium-uiautomator2-driver](https://github.com/appium/appium-uiautomator2-driver/blob/master/lib/commands/general.js)中的“移動滾動”部分以了解更多詳細信息 | `{element, strategy, selector, maxSwipes}` | `{strategy: 'accessibility id', selector: 'target content description'}` |
| `mobile:viewportScreenshot` | 類似于[屏幕截圖]((../commands/session/screenshot.md)),但僅包含當前視圖窗口的內容 | <none> | <none> |
| `mobile:viewportRect` | 返回自Appium 1.18.0開始的視圖窗口的坐標和大小。返回類型是[general.js](https://github.com/appium/appium-uiautomator2-driver/blob/master/lib/commands/general.js)中定義的Rectangle。 | <none> | <none> |
| `mobile:deepLink` | 打開深層鏈接URL 測試效果:[Instant Apps](https://support.google.com/googleplay/answer/7240211?hl=en) | `{url, package}` | `{url: "https://www.site.com/", package: "com.site.SomeAndroidPackage"}` |
| `mobile:deviceInfo` | 獲取設備信息,例如制造商,型號,時區和區域設置。閱讀獲取[GetDeviceInfo](https://github.com/appium/appium-uiautomator2-server/blob/master/app/src/main/java/io/appium/uiautomator2/handler/GetDeviceInfo.java)以獲取更多詳細信息。 | <none> | <none> |
| `mobile:type` | 將給定的Unicode字符串鍵入焦點字段。 Unicode鍵盤功能和發送鍵的組合可替代文本字段內容。 W3C操作中的[send keys](https://appium.io../commands/element/actions/send-keys/)僅適用于ASCII。此命令可幫助此類情況將unicode文本內容附加到焦點字段中。 | `{text}` | `{text: 'happy testing'}` |
### Android (Espresso only)
| 指令 | 描述 | 參數 | 參數示例 |
| ------- | ----------- | -------- | ---------------- |
| `mobile:swipe` | 執行 ["swipe" view action](https://developer.android.com/reference/android/support/test/espresso/action/ViewActions.html#swipeDown()) | `{element, direction}` | `{element: 2, direction: "down|up|left|right"}` |
| `mobile:swipe` | 執行["GeneralSwipeAction"](https://developer.android.com/reference/androidx/test/espresso/action/GeneralSwipeAction) | `{element, swiper, startCoordinates, endCoordinates, precisionDescriber}` | `{element: 3, swiper: "FAST|SLOW", startCoordinates: 'BOTTOM_RIGHT', endCoordinates: 'TOP_RIGHT', precisionDescriber: 'FINGER'}` |
| `mobile:clickAction` | 執行["ClickAction"](https://developer.android.com/reference/androidx/test/espresso/action/GeneralClickAction) | `{element, tapper, coordinatesProvider, precisionDescriber, inputDevice, buttonState}` | `{element: 2, tapper: 'Long', coordinatesProvider: 'BOTTOM_RIGHT', precisionDescriber: 'Thumb', inputDevice: 0, buttonState: 0}` |
| `mobile:isToastVisible` | 檢查是否有toast. 文本是必選參數。 Regexp是可選的。如果Regexp為true,則將文本解析為正則表達式模式。 is Regexp默認為false。如果文本存在,則返回true,否則返回false。 | `{text, isRegexp}` | `{ text: 'A toast' }`, `{ text: '^regex$', isRegexp: true } `|
| `mobile:openDrawer` | 在[gravity](https://developer.android.com/reference/android/view/Gravity)作用下通過[DrawerAction](https://developer.android.com/reference/android/support/test/espresso/contrib/DrawerActions)打開抽屜。`gravity` is 可選的. 默認值為[GravityCompat.START](https://developer.android.com/reference/android/support/v4/view/GravityCompat.html#START). 此方法將阻塞直到抽屜完全關閉。如果抽屜已經關閉,則無法進行任何操作。 | `{element, gravity}` | `{ element: element_id }`, `{ element: element_id, gravity: 3 }` |
| `mobile:closeDrawer` | 在[gravity](https://developer.android.com/reference/android/view/Gravity)作用下通過[DrawerAction](https://developer.android.com/reference/android/support/test/espresso/contrib/DrawerActions)關閉抽屜。`gravity` is 可選的. 默認值為[GravityCompat.START](https://developer.android.com/reference/android/support/v4/view/GravityCompat.html#START). 此方法將阻塞直到抽屜完全關閉。如果抽屜已經關閉,則無法進行任何操作。 | `{element, gravity}` | `{ element: element_id }`, `{ element: elementId, gravity: 3 }` |
| `mobile:setDate` | 通過[PickerActions#setDate](https://developer.android.com/reference/android/support/test/espresso/contrib/PickerActions.html#setDate(int,%20int,%20int))#[DataPicker](https://developer.android.com/reference/android/widget/DatePicker)設置日期。 | `{element, year, monthOfYear, dayOfMonth}` | `{element: elementId, year: 2018, monthOfYear: 12, dayOfMonth: 1}` |
| `mobile:setTime` | 通過 [PickerActions#setTime](https://developer.android.com/reference/android/support/test/espresso/contrib/PickerActions.html#setTime(int,%20int)) #[TimePicker](https://developer.android.com/reference/android/widget/TimePicker)設置時間。 | `{element, hours, minutes}` | `{element: elementId, hours: 12, minutes: 10}` |
| `mobile:navigateTo` | 通過“[NavigationViewActions#navigateTo](https://developer.android.com/reference/android/support/test/espresso/contrib/NavigationViewActions.html#navigateTo(int))”導航到“[NavigationView](https://developer.android.com/reference/android/support/design/widget/NavigationView)”的操作。該視圖必須是“導航視圖”類型,在屏幕上可見并在屏幕上顯示的“抽屜布局”的子級。 | `{element, menuItemId}` | `{element: elementId, menuItemId: 1}` |
| `mobile:scrollToPage` | 通過[ViewPagerActions](https://developer.android.com/reference/android/support/test/espresso/contrib/ViewPagerActions)導航到[ViewPager](https://developer.android.com/reference/android/support/v4/view/ViewPager)。 `scrollTo` 必須是其中的一種 `first`, `last`, `left`, `right`. 如果提供了 `scrollTo` 和`scrollToPage` ,則 scrollTo是默認的 | `{scrollTo, scrollToPage, smoothScroll}` | `{element: elementId, scrollTo: 'left', smoothScroll: true}`, `{element: elementId, scrollToPage: 2}`|
| `mobile:backdoor` | 調用Android應用中定義的任意方法。這些方法必須在Java中是公共的,并且必須在Kotlin中是開放的。 您要調用的方法`target` 是 `activity`, `application` 或者 `element`. `methods` `element` 是必須的如果`target` 是 `element`.在[here](https://github.com/appium/appium-espresso-driver/blob/master/lib/commands/general.js)閱讀移動后門方法的文檔字符串以獲取更多詳細信息 | `{target, methods, element}` | `{target: 'activity', methods: [{name: 'method1'}, {name: 'method2', args: [{value: 'hello appium', type: 'java.lang.String'}] }] }`, `{target: 'element', element: elementId, [{name: 'getTypeface'}, {name: 'isItalic'}]}` |
| `mobile:flashElement` | 在屏幕上閃爍一個元素,以可視方式確認您正在使用正確的元素。可以選擇設置持續時間Millis(以毫秒為單位)并重復動畫計數 | `{element, durationMillis, repeatCount}` | `{element: "1234-abcd-5678", durationMillis: 1000, repeatCount: 10}` |
| `mobile:uiautomator` | 使用uiautomator2 API進行多進程測試。策略可以是以下之一: "clazz", "res", "text", "textContains", "textEndsWith", "textStartsWith","desc", "descContains", "descEndsWith", "descStartsWith" and "pkg", taken from uiautomator [By class](https://developer.android.com/reference/androidx/test/uiautomator/By). `action` 可以是以下之一: "click", "longClick", "getText", "getContentDescription", "getClassName","getResourceName", "getVisibleBounds", "getVisibleCenter", "getApplicationPackage","getChildCount", "clear", "isCheckable", "isChecked", "isClickable", "isEnabled","isFocusable", "isFocused", "isLongClickable", "isScrollable" and "isSelected", taken from uiautomator [UiObject2](https://developer.android.com/reference/androidx/test/uiautomator/UiObject2). `index`是可選的,如果未給出,將返回所有匹配結果 | `{strategy, locator, index, action}` | `{strategy: 'clazz', locator: 'android.widget.TextView', index: 2, action: "getText"}` |
| `mobile:webAtoms` | 運行一連串的[webatoms](https://developer.android.com/training/testing/espresso/web)與Element和perform是基本的鏈項目。請參考[issue](https://github.com/appium/appium-espresso-driver/pull/380)和[Sample test code](https://github.com/appium/ruby_lib_core/blob/c9062c4b744263d790c7de17263cbd4645cdefc6/test/functional/android/android/mobile_commands_test.rb#L196-L239)作為參考。 | `{webviewElement, forceJavascriptEnabled, methodChain}` | (webdriverio) `{ webviewElement: webviewEl.value, forceJavascriptEnabled: true, methodChain: [...]}` |
| `mobile:dismissAutofill` | 在Android O +中禁用自動填充對話框 | `{element}` | `{element: elementId}` |
| `mobile:deviceInfo` | 獲取設備信息,例如制造商,型號,時區和區域設置。 閱讀[GetDeviceInfo](https://github.com/appium/appium-espresso-driver/blob/master/espresso-server/app/src/androidTest/java/io/appium/espressoserver/lib/handlers/GetDeviceInfo.kt) 獲取更多細節。 | <none> | <none> |
[//]: # "DO NOT EDIT THIS FILE! This is an auto-generated file. Editing for this document happens in /commands-yml/commands/mobile-command.yml"
## 支持
[//]: # "DO NOT EDIT THIS FILE! This is an auto-generated file. Editing for this document happens in /commands-yml/commands/mobile-command.yml"
### Appium Server
|平臺|Driver|Platform Versions|Appium Version|Driver Version|
|--------|----------------|------|--------------|--------------|
| iOS | [XCUITest](../drivers/ios-xcuitest.md) | 9.3+ | 1.6.0+ | All |
| | [UIAutomation](../drivers/ios-uiautomation.md) | 8.0 to 9.3 | All | All |
| Android | [Espresso](../drivers/android-espresso.md) | ?+ | 1.9.0+ | All |
| | [UiAutomator2](../drivers/android-uiautomator2.md) | ?+ | 1.6.0+ | All |
| | [UiAutomator](../drivers/android-uiautomator.md) | 4.3+ | All | All |
| Mac | [Mac](../drivers/mac.md) | ?+ | 1.6.4+ | All |
| Windows | [Windows](../drivers/windows.md) | 10+ | 1.6.0+ | All |
[//]: # "DO NOT EDIT THIS FILE! This is an auto-generated file. Editing for this document happens in /commands-yml/commands/mobile-command.yml"
### Appium Clients
|語言|支持|文檔|
|--------|-------|-------------|
|[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 | |
|[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](https://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/) |
[//]: # "DO NOT EDIT THIS FILE! This is an auto-generated file. Editing for this document happens in /commands-yml/commands/mobile-command.yml"
## HTTP API 技術
[//]: # "DO NOT EDIT THIS FILE! This is an auto-generated file. Editing for this document happens in /commands-yml/commands/mobile-command.yml"
### Endpoint
`POST /session/:session_id/execute`
[//]: # "DO NOT EDIT THIS FILE! This is an auto-generated file. Editing for this document happens in /commands-yml/commands/mobile-command.yml"
### URL 參數
|名稱|描述|
|----|-----------|
|session_id|ID of the session to route the command to|
[//]: # "DO NOT EDIT THIS FILE! This is an auto-generated file. Editing for this document happens in /commands-yml/commands/mobile-command.yml"
### JSON 參數
|名稱|類型|描述|
|----|----|-----------|
| script | `string` | The mobile command to execute |
| args | `array` | The JSON serializable arguments |
[//]: # "DO NOT EDIT THIS FILE! This is an auto-generated file. Editing for this document happens in /commands-yml/commands/mobile-command.yml"
### 返回值
指令結果 (`any`)
[//]: # "DO NOT EDIT THIS FILE! This is an auto-generated file. Editing for this document happens in /commands-yml/commands/mobile-command.yml"
## 參考
* [W3C Specification](https://www.w3.org/TR/webdriver/#dfn-execute-script)
* [JSONWP Specification](https://github.com/SeleniumHQ/selenium/wiki/JsonWireProtocol#sessionsessionidexecute)
- 關于TesterHome和MTSC
- 關于Appium
- 簡介
- Appium 客戶端
- 入門指南
- 已支持的平臺
- API 文檔
- Appium驅動
- XCUITest (iOS)
- XCUITest Real Devices (iOS)
- UIAutomation (iOS)
- UIAutomation Safari Launcher (iOS)
- UIAutomator (Android)
- UIAutomator2 (Android)
- Espresso (Android)
- Windows
- Mac
- Appium命令
- Status
- Execute Mobile Command
- Session
- Create
- End
- Get Session Capabilities
- Go Back
- Screenshot
- Source
- Timeouts
- Timeouts
- Implicit Wait
- Async Script
- Orientation
- Get Orientation
- Set Orientation
- Geolocation
- Get Geolocation
- Set Geolocation
- Logs
- Get Log Types
- Get Logs
- Events
- Log event
- Get events
- Settings
- Update Settings
- Get Device Settings
- Settings
- Update Settings
- Get Device Settings
- Execute Driver Script
- Device
- Activity
- Start Activity
- Current Activity
- Current Package
- App
- Install App
- Is App Installed
- Launch App
- Background App
- Close App
- Reset App
- Remove App
- Activate App
- Terminate App
- Get App State
- Get App Strings
- End Test Coverage
- Clipboard
- Get Clipboard
- Set Clipboard
- Emulator
- Power AC
- Power Capacity
- Files
- Push File
- Pull File
- Pull Folder
- Interactions
- Shake
- Lock
- Unlock
- Is Locked
- Rotate
- Keys
- Press keycode
- Long press keycode
- Hide Keyboard
- Is Keyboard Shown
- Network
- Toggle Airplane Mode
- Toggle Data
- Toggle WiFi
- Toggle Location Services
- Send SMS
- GSM Call
- GSM Signal
- GSM Voice
- Network Speed
- Performance Data
- Get Performance Data
- Performance Data Types
- Screen Recording
- Start Screen Recording
- Stop Screen Recording
- Simulator
- Perform Touch ID
- Toggle Touch ID Enrollment
- System
- Open Notifications
- System Bars
- System Time
- Display density
- Authentication
- Finger Print
- Element
- Find Element
- Find Elements
- Actions
- Click
- Send Keys
- Clear
- Attributes
- Text
- Name
- Attribute
- Selected
- Enabled
- Displayed
- Location
- Size
- Rect
- CSS Property
- Location in View
- Other
- Submit
- Active Element
- Equals Element
- Context
- Get Context
- Get All Contexts
- Set Context
- Interactions
- Mouse
- Move To
- Click
- Double Click
- Button Down
- Button Up
- Touch
- Single Tap
- Double Tap
- Move
- Touch Down
- Touch Up
- Long Press
- Scroll
- Flick
- Multi Touch Perform
- Touch Perform
- W3C Actions
- Web
- Window
- Set Window
- Close Window
- Get Handle
- Get Handles
- Get Title
- Get Window Size
- Set Window Size
- Get Window Position
- Set Window Position
- Maximize Window
- Navigation
- Go to URL
- Get URL
- Back
- Forward
- Refresh
- Storage
- Get All Cookies
- Set Cookie
- Delete Cookie
- Delete All Cookies
- Frame
- Switch to Frame
- Switch to Parent Frame
- Execute Async
- Execute
- 編寫 & 運行Appium腳本
- Running Tests
- Desired Capabilities
- The --default-capabilities flag
- Finding Elements
- Touch Actions
- CLI Arguments
- Server Security
- Web/Web Views
- Mobile Web Testing
- Automating Hybrid Apps
- Using ios-webkit-debug-proxy
- Using Chromedriver
- Image Comparison
- iOS
- Low-Level Insights on iOS Input Events
- XCUITest Mobile Gestures
- XCUITest Mobile App Management
- iOS Pasteboard Guide
- iOS Predicate Guide
- iOS Touch ID Guide
- iOS Install Certificate
- tvOS support
- Pushing/Pulling files
- Audio Capture
- Android
- Low-Level Insights on Android Input Events
- UiSelector Guide
- Espresso Datamatcher Guide
- Android Code Coverage Guide
- Activities Startup Troubleshooting Guide
- How To Execute Shell Commands On The Remote Device
- Android Device Screen Streaming
- How To Emulate IME Actions Generation
- How To Test Android App Bundle
- Other
- Reset Strategies
- Network Connection Guide
- Using Unicode with Appium
- Troubleshooting
- Tutorial
- Swipe Tutorial
- Screen
- Element
- Partial screen
- Simple
- Multiple scroll views
- Add scroll layout
- Tricks and Tips
- Screen
- Element
- Element search
- Fast
- Slow
- Guide
- 進階概念
- 定位圖像中的元素
- 使用定位元素的插件
- 遷移到 XCUITest
- 在 Appium 中使用 Selenium Grid
- Appium Logs Filtering
- 跨域 iframes
- 使用自定義 WDA 服務器
- 使用不同版本的 Xcode 運行
- The Event Timings API
- 并行測試的設置
- The Settings API
- Memory Collection
- 向Appium項目做貢獻
- 從源代碼運行 Appium
- 開發者概述
- 標準開發命令
- Appium 風格指南
- 如何編寫文檔
- Appium 包結構
- 鳴謝