Class: Unobtainium::Drivers::Appium Private
- Inherits:
-
Object
- Object
- Unobtainium::Drivers::Appium
- 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
-
.create(_, options) ⇒ Object
private
Create and return a driver instance.
-
.ensure_preconditions(_, _) ⇒ Object
private
Ensure that the driver’s preconditions are fulfilled.
-
.matches?(label) ⇒ Boolean
private
Return true if the given label matches this driver implementation, false otherwise.
-
.resolve_options(label, options) ⇒ Object
private
Sanitize options, and expand the :browser key, if present.
Methods included from Support::Utility
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(_, ) # :nocov: # Determine compatibility option compat = .fetch(:webdriver_compatibility, true) .delete(:webdriver_compatibility) # Create & return proxy driver = ::Appium::Driver.new() 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.}: 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.
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 (label, ) # Normalize label and options normalized = normalize_label(label) = ::Collapsium::UberHash.new( || {}) # Merge 'caps' and 'desired_capabilities', letting the former win [:caps] = ::Collapsium::UberHash.new(['desired_capabilities']) .recursive_merge([:desired_capabilities]) .recursive_merge([:caps]) .delete(:desired_capabilities) .delete('desired_capabilities') # The label specifies the platform, if no other platform is given. if not ['caps.platformName'] ['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 = ['appium_lib.server_url'] if set_url and ['url'] and not set_url == ['url'] warn "You have the remote URL '#{set_url}' set in your options, "\ "so we're not replacing it with '#{['url']}'!" elsif not set_url ['appium_lib.server_url'] = ['url'] end # If no app is given, but a browser is requested, we can supplement # some information = supplement_browser() return normalized, end |