- This library: http://www.rubydoc.info/github/appium/ruby_lib
- Core: http://www.rubydoc.info/github/appium/ruby_lib_core
- Ruby selenium-webdriver
- Appium
- Supported platforms
- All methods supported by Appium
- Fundamental Commands: http://appium.io/docs/en/commands/status/ etc
- MiniTest Expectations
# Appium specific driver with helpers available extending Standard Appium Driver.
@appium_driver = Appium::Driver.new @options, false
# Standard Appium Driver extends Selenium WebDriver.
@selenium_driver = @appium_driver.start_driverExample of automating the built in Android settings.
# run Pry, and paste the following
apk = {
platformName: 'android',
deviceName: :nexus,
appPackage: 'com.android.settings',
appActivity: '.Settings',
appWaitActivity: '.Settings'
}
Appium::Driver.new({caps: apk}, false).start_driverExample use of Appium's mobile gesture.
Long click on an ImageView in Android.
last_image = find_elements(:class, 'ImageView').last
long_press(element: last_image)
Rotate examples. The behaviour is depends on devices.
driver.rotate :landscape
driver.rotate :portraitappium_server_versionDiscover the Appium rev running on the server.element.send_keys "msg"Sends keys to currently active element
e.name # button, text
e.value # secure, textfield
e.type 'some text' # type text into textfield
e.clear # clear textfield
e.tag_name # calls .type (patch.rb)
e.text
e.size
e.location
e.location_rel
e.click
e.send_keys 'keys to send'
e.displayed? # true or false depending if the element is visible
e.selected? # is the tab selected?
e.attribute('checked') # is the checkbox checked?
# alert example without helper methods
alert = @driver.switch_to.alert
alert.text
alert.accept
alert.dismiss
# Secure textfield example.
#
# Find using default value
s = textfield 'Password'
# Enter password
s.send_keys 'hello'
# Check value
s.value == ios_password('hello'.length)--
start_driverwill restart the driver.xwill quit the driver and exit Pry.execute_scriptcalls@driver.execute_scriptfind_elementcalls@driver.find_elementfind_elementscalls@driver.find_elementsno_waitwill set implicit wait to 0.@driver.manage.timeouts.implicit_wait = 0set_waitwill set implicit wait to default seconds.@driver.manage.timeouts.implicit_wait = defaultset_wait(timeout_seconds)will set implicit wait to desired timeout.@driver.manage.timeouts.implicit_wait = timeout.clickto tap an element..send_keysor.typeto type on an element.
Reset after each test and when done report the result to Sauce after quiting the driver.
require 'rest_client' # https://github.com/archiloque/rest-client
require 'json' # for .to_json
require 'sauce_whisk'
After do |scenario|
# end the test session, ignoring any exceptions.
ignore { $driver.driver_quit }
user = ENV['SAUCE_USERNAME']
key = ENV['SAUCE_ACCESS_KEY']
if user && !user.empty? && key && !key.empty?
passed = ! scenario.failed?
SauceWhisk::Jobs.change_status $driver.driver.session_id, passed
end
end