GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — ruby_lib/docs/docs.md at master · appium/ruby_lib

Expand file tree

/

docs.md

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
133 lines (106 loc) · 3.83 KB
/

docs.md

Copy path

File metadata and controls

133 lines (106 loc) · 3.83 KB
Raw
Copy raw file
Download raw file
Outline
Edit and raw actions

Documentation

API Doc of Ruby Client

  • This library: http://www.rubydoc.info/github/appium/ruby_lib
  • Core: http://www.rubydoc.info/github/appium/ruby_lib_core
  • Ruby selenium-webdriver

General

  • Appium
  • Supported platforms
  • All methods supported by Appium
    • Fundamental Commands: http://appium.io/docs/en/commands/status/ etc
  • MiniTest Expectations

Driver types in Ruby Client

# 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_driver

Example

Example 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 = Appium::Driver.new({caps: apk}, false)
appium.start_driver
appium.find_element(:id, 'target') # use the wrapper for subsequent commands

Example 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 :portrait
  • appium_server_version Discover the Appium rev running on the server.
  • element.send_keys "msg" Sends keys to currently active element

APIs

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.rect # position and size; location_rel was removed in core 14
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)

--

Driver

  • start_driver will restart the driver.
  • x will quit the driver and exit Pry.
  • execute_script calls @driver.execute_script
  • find_element calls @driver.find_element
  • find_elements calls @driver.find_elements
  • no_wait will set implicit wait to 0. @driver.manage.timeouts.implicit_wait = 0
  • set_wait will set implicit wait to default seconds. @driver.manage.timeouts.implicit_wait = default
  • set_wait(timeout_seconds) will set implicit wait to desired timeout. @driver.manage.timeouts.implicit_wait = timeout
  • .click to tap an element.
  • .send_keys or .type to type on an element.

Cucumber Sauce Integration

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|
  # Keep @appium_driver from setup and capture the ID before closing its session.
  session_id = @appium_driver.session_id
  @appium_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 session_id, passed
  end
end
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.