Sha256: 92fa315b29556e483f77c45e69ea9839070ca418163ca04087e17637663c45ea

Contents?: true

Size: 1.41 KB

Versions: 3

Compression:

Stored size: 1.41 KB

Contents

# Mobile Command

Appium has `mobile:` command.
We can invoke them via `execute_script` command with `mobile:` arguments.

- root:
    - https://github.com/appium/appium/blob/master/commands-yml/commands/mobile-command.yml
- Android:
    - https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/android
- iOS:
    - https://github.com/appium/appium/tree/master/docs/en/writing-running-appium/ios


```ruby
# Android shell : https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/android/android-shell.md
args = { command: 'echo', args: 'list' }
@driver.execute_script 'mobile: shell', args # Run `adb shell echo 'list'`

# iOS performance : https://github.com/appium/appium/blob/master/docs/en/writing-running-appium/ios/ios-xctest-performance.md
args = { timeout: 60 * 1000, profileName: 'Activity Monitor' }
@driver.execute_script 'mobile: startPerfRecord', args

@driver.execute_script 'mobile: stopPerfRecord', { profileName: 'Activity Monitor' }
```

Mobile commands return their error messages. As a selenium client, it usually handles as unknown error.
To handle it, we would recommend you to handle the error based on the error message.

```ruby
error = assert_raises ::Selenium::WebDriver::Error::UnknownError do
  _, element_id = el.ref
  @driver.execute_script 'mobile: scrollToPage', { element: element_id, scrollToPage: -100 }
end
assert error.message.include? 'be a non-negative integer'
```

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
appium_lib_core-5.0.0.rc3 docs/mobile_command.md
appium_lib_core-5.0.0.rc2 docs/mobile_command.md
appium_lib_core-5.0.0.rc1 docs/mobile_command.md