Helper methods for writing cross platform (iOS, Android) tests in Ruby using Appium. Note that user waits should not exceed 120 seconds if they're going to run on Sauce Labs.
Make sure you're using Ruby 1.9.3+ with upgraded rubygems and bundler.
node server.js
Update rubygems and bundler.
gem update --system ;\
gem update bundlerInstall the latest gem release.
gem uninstall -aIx appium_lib ;\
gem install --no-rdoc --no-ri appium_librequire 'rubygems'
require 'appium_lib'
# Start iOS driver
# use appium's specific capability names
appium_capabilities = { launchTimeout: 123 }
# there are also built in capabilities such as device that don't require 'raw'
caps = { device: :ios, app_path: '/Users/user/woven/ruby_lib_ios/UICatalog.app', raw: appium_capabilities }
Appium::Driver.new(caps).start_driver
# Start Android driver
apk = {
device: :android,
app_path: '/path/to/the.apk',
app_package: 'com.example.pkg',
app_activity: '.act.Start',
app_wait_activity: '.act.Start'
}
Appium::Driver.new(apk).start_driver
# Define the methods on all objects.
# Note that this can also be scoped to limit the potential for conflicts.
# Example: Appium.promote_appium_methods ::Minitest::Spec
# Another alternative is to not promote at all. Instead access methods via $driver
Appium.promote_appium_methods Object# Example of automating Settings preinstalled app on Android
# Find these values using arc then type current_app
apk = {
device: :android,
app_path: '',
app_package: 'com.android.settings',
app_activity: '.Settings',
app_wait_activity: '.Settings'
}
Appium::Driver.new(apk).start_driverno_resetIf true, the app will not be resetfull_resetIf true, the app will be uninstalled. When false, fast reset is activated.
APP_PATHPath to the .app folder
APP_PATHPath to the apkAPP_PACKAGEThe APK's packageAPP_ACTIVITYActivity to startAPP_WAIT_ACTIVITYOptional. Activity to wait for.
APP_NAMEName of the test runSAUCE_USERNAMESauce usernameSAUCE_ACCESS_KEYSauce API key
- Does
adb kill-server; adb deviceslist an active Android device? - Have you defined the proper env vars?
APP_PATH, APP_PACKAGE, APP_ACTIVITY, APP_WAIT_ACTIVITY - Are you running appium from source?
node server.js