Class: Unobtainium::Drivers::Appium

Inherits:
Object
  • Object
show all
Defined in:
lib/unobtainium/drivers/appium.rb

Overview

Driver implementation wrapping the appium_lib gem.

Constant Summary collapse

LABELS =

Recognized labels for matching the driver

{
  appium: [],
  ios: [:iphone, :ipad],
  android: [],
}.freeze
BROWSER_MATCHES =

Browser matches for some platforms TODO: add many more matches

{
  android: {
    chrome: {
      appPackage: 'com.android.chrome',
      appActivity: 'com.google.android.apps.chrome.Main',
    },
  },
}.freeze

Class Method Summary collapse

Class Method Details

.create(label, options) ⇒ Object

Create and return a driver instance



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/unobtainium/drivers/appium.rb', line 53

def create(label, options)
  # The label specifies the platform, if no other platform is given.
  normalized = normalize_label(label)

  if not options.is_a? Hash
    options = {}
  end
  if not options['caps'].is_a? Hash
    options['caps'] = {}
  end

  if options['caps']['platformName'].nil?
    options['caps']['platformName'] = normalized.to_s
  end

  # If no app is given, but a browser is requested, we can supplement
  # some information
  options = supplement_browser(options)

  # Create the driver
  driver = ::Appium::Driver.new(options).start_driver
  return driver
end

.ensure_preconditions(_, _) ⇒ Object

Ensure that the driver’s preconditions are fulfilled.



43
44
45
46
47
48
49
# File 'lib/unobtainium/drivers/appium.rb', line 43

def ensure_preconditions(_, _)
  require 'appium_lib'
rescue LoadError => err
  raise LoadError, "#{err.message}: you need to add "\
        "'appium_lib' to your Gemfile to use this driver!",
        err.backtrace
end

.matches?(label) ⇒ Boolean

Return true if the given label matches this driver implementation, false otherwise.

Returns:

  • (Boolean)


37
38
39
# File 'lib/unobtainium/drivers/appium.rb', line 37

def matches?(label)
  return nil != normalize_label(label)
end