Class: Unobtainium::Drivers::Appium Private

Inherits:
Object
  • Object
show all
Extended by:
Support::Utility
Defined in:
lib/unobtainium/drivers/appium.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Driver implementation wrapping the appium_lib gem.

Defined Under Namespace

Classes: DriverProxy

Constant Summary collapse

LABELS =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Recognized labels for matching the driver

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

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

Browser matches for some platforms TODO: add many more matches

{
  android: {
    chrome: {
      browserName: 'Chrome',
    },
  },
}.freeze

Class Method Summary collapse

Methods included from Support::Utility

normalize_label

Class Method Details

.create(_, options) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Create and return a driver instance



151
152
153
154
155
156
157
158
159
160
161
162
163
# File 'lib/unobtainium/drivers/appium.rb', line 151

def create(_, options)
  # :nocov:

  # Determine compatibility option
  compat = options.fetch(:webdriver_compatibility, true)
  options.delete(:webdriver_compatibility)

  # Create & return proxy
  driver = ::Appium::Driver.new(options)
  result = DriverProxy.new(driver, compat)
  return result
  # :nocov:
end

.ensure_preconditions(_, _) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Ensure that the driver’s preconditions are fulfilled.



103
104
105
106
107
108
109
# File 'lib/unobtainium/drivers/appium.rb', line 103

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

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

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

Returns:

  • (Boolean)


97
98
99
# File 'lib/unobtainium/drivers/appium.rb', line 97

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

.resolve_options(label, options) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Sanitize options, and expand the :browser key, if present.



113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
# File 'lib/unobtainium/drivers/appium.rb', line 113

def resolve_options(label, options)
  # Normalize label and options
  normalized = normalize_label(label)
  options = ::Collapsium::UberHash.new(options || {})

  # Merge 'caps' and 'desired_capabilities', letting the former win
  options[:caps] =
    ::Collapsium::UberHash.new(options['desired_capabilities'])
                          .recursive_merge(options[:desired_capabilities])
                          .recursive_merge(options[:caps])
  options.delete(:desired_capabilities)
  options.delete('desired_capabilities')

  # The label specifies the platform, if no other platform is given.
  if not options['caps.platformName']
    options['caps.platformName'] = normalized.to_s
  end

  # Make the appium driver behave a little more like Selenium by using
  # the :url key if the normalized label is remote, and setting
  # appropriate options.
  set_url = options['appium_lib.server_url']
  if set_url and options['url'] and not set_url == options['url']
    warn "You have the remote URL '#{set_url}' set in your options, "\
      "so we're not replacing it with '#{options['url']}'!"
  elsif not set_url
    options['appium_lib.server_url'] = options['url']
  end

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

  return normalized, options
end