appium_lib_core 5.0.0.beta3 → 5.0.0.beta4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7d181fc3278538381590906e61508d9a2200e59f531ba60204e69a5703adc4c7
4
- data.tar.gz: a599869012ce5c6644686fe08faa3f56da739aad5f8c9d429495b4791a51c113
3
+ metadata.gz: 6bc30b79d80c1606288087e36a6ed024c3be91ffbc6c5b8b04c9c9c1537d1d9e
4
+ data.tar.gz: 06b4f5cdbadb770ce7ce4eecd3fcdaf78c002c13982b6a0573e30a0c3aee9d02
5
5
  SHA512:
6
- metadata.gz: 3cde51ee7eba948cba06c82f6bb3e3d496fb8f7d68c0d9f92c9e76de86909df27bfe1ec312e7ed8e58225fcaa09b46b317977a530d431e24455d5e1cd349646a
7
- data.tar.gz: bbd2c4940a57a8e8e601fbe01d13d5d67bb42c5ca7ff36fde5ea94d7099784df4e3afe74a4cdf2400cb0d16d5e37b74971d88054b381498743cd04d6abeb99fe
6
+ metadata.gz: c68d806651e436131ebd91c9f9b520a8de1a95ad82ee67988c7f475b6ce2c016b50fa15e1ee4f0813f55d59e5237bea34c209096436807ba7f8eb2ac9afbb123
7
+ data.tar.gz: 3982388d81e2d3d59b51cde803e5e83521772700fc8a82d0733ba650c25b2f46578bb9490113a8792a5b5e24d22488110ff3a6e727cb8d22a210c6bf4fb8632e
data/CHANGELOG.md CHANGED
@@ -10,11 +10,17 @@ Read `release_notes.md` for commit level details.
10
10
 
11
11
  ### Deprecations
12
12
 
13
- ## [5.0.0.beta1]
13
+ ## [5.0.0.beta]
14
14
 
15
15
  - Update base selenium webdriver version to `4.0.0.beta2`
16
16
  - Support only W3C spec
17
17
  - Support Ruby 2.5+
18
+ - Raises `::Appium::Core::Error::ArgumentError` instead of `ArgumentError` for this library specific argument errors
19
+
20
+ ## [4.6.0] - 2021-06-03
21
+
22
+ ### Enhancements
23
+ - Add `Appium::Core::Base::Driver#add_command` to allow you to add your own command
18
24
 
19
25
  ## [4.5.0] - 2021-03-14
20
26
 
@@ -22,11 +28,6 @@ Read `release_notes.md` for commit level details.
22
28
  - Add `speed` argument for `Appium::Core::Base::Driver#set_location` since Appium 1.21.0
23
29
  - Add `multiple` and `match_neighbour_threshold` arguments for `Appium::Core::Base::Driver#find_image_occurrence`
24
30
 
25
- ### Bug fixes
26
-
27
- ### Deprecations
28
-
29
-
30
31
  ## [4.4.1(4.4.0)] - 2021-02-15(2021-02-13)
31
32
 
32
33
  ### Enhancements
data/README.md CHANGED
@@ -11,6 +11,7 @@ This library wraps [selenium-webdriver](https://github.com/SeleniumHQ/selenium/w
11
11
  # Documentation
12
12
 
13
13
  - http://www.rubydoc.info/github/appium/ruby_lib_core
14
+ - You can find working API examples in test code, [test/functional](test/functional)
14
15
 
15
16
  # Related library
16
17
  - https://github.com/appium/ruby_lib
@@ -120,7 +121,7 @@ $ IGNORE_VERSION_SKIP=true CI=true bundle exec rake test:func:android
120
121
  $ ruby test.rb
121
122
  ```
122
123
 
123
- More examples are in [test/functional](test/functional)
124
+ More examples are in [test/functional](test/functional)
124
125
 
125
126
  ### Capabilities
126
127
 
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
22
22
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
23
  spec.require_paths = ['lib']
24
24
 
25
- spec.add_runtime_dependency 'selenium-webdriver', '4.0.0.beta3'
25
+ spec.add_runtime_dependency 'selenium-webdriver', '4.0.0.beta4'
26
26
  spec.add_runtime_dependency 'faye-websocket', '~> 0.11.0'
27
27
 
28
28
  spec.add_development_dependency 'bundler', '>= 1.14'
@@ -30,7 +30,7 @@ Gem::Specification.new do |spec|
30
30
  spec.add_development_dependency 'yard', '~> 0.9.11'
31
31
  spec.add_development_dependency 'minitest', '~> 5.0'
32
32
  spec.add_development_dependency 'minitest-reporters', '~> 1.1'
33
- spec.add_development_dependency 'webmock', '~> 3.12.1'
33
+ spec.add_development_dependency 'webmock', '~> 3.13.0'
34
34
  spec.add_development_dependency 'rubocop', '1.12.0'
35
35
  spec.add_development_dependency 'appium_thor', '~> 1.0'
36
36
  spec.add_development_dependency 'pry'
@@ -27,7 +27,7 @@ module Appium
27
27
  # https://github.com/rails/docrails/blob/a3b1105ada3da64acfa3843b164b14b734456a50/activesupport/lib/active_support/core_ext/hash/keys.rb#L84
28
28
  # @param [Hash] hash Hash value to make symbolise
29
29
  def self.symbolize_keys(hash)
30
- raise ArgumentError, 'symbolize_keys requires a hash' unless hash.is_a? Hash
30
+ raise ::Appium::Core::Error::ArgumentError, 'symbolize_keys requires a hash' unless hash.is_a? Hash
31
31
 
32
32
  hash.each_with_object({}) do |pair, acc|
33
33
  key = begin
@@ -21,7 +21,8 @@ module Appium
21
21
  ::Appium::Core::Device.add_endpoint_method(:finger_print) do
22
22
  def finger_print(finger_id)
23
23
  unless (1..10).cover? finger_id.to_i
24
- raise ArgumentError, "finger_id should be integer between 1 to 10. Not #{finger_id}"
24
+ raise ::Appium::Core::Error::ArgumentError,
25
+ "finger_id should be integer between 1 to 10. Not #{finger_id}"
25
26
  end
26
27
 
27
28
  execute(:finger_print, {}, { fingerprintId: finger_id.to_i })
@@ -36,13 +36,17 @@ module Appium
36
36
  # Prefix for extra capability defined by W3C
37
37
  APPIUM_PREFIX = 'appium:'
38
38
 
39
- # Returns 'unknown' if no specific browser name
39
+ # No 'browserName' means the session is native appium connection
40
+ APPIUM_NATIVE_BROWSER_NAME = 'appium'
41
+
42
+ attr_reader :available_commands
43
+
40
44
  def browser
41
45
  @browser ||= begin
42
46
  name = @capabilities.browser_name
43
47
  name ? name.tr(' ', '_').downcase.to_sym : 'unknown'
44
48
  rescue KeyError
45
- 'unknown'
49
+ APPIUM_NATIVE_BROWSER_NAME
46
50
  end
47
51
  end
48
52
 
@@ -70,16 +74,16 @@ module Appium
70
74
  # core = ::Appium::Core.for(caps)
71
75
  # driver = core.start_driver
72
76
  #
73
- def create_session(desired_capabilities)
74
- caps = add_appium_prefix(desired_capabilities)
77
+ def create_session(capabilities)
78
+ @available_commands = ::Appium::Core::Commands::COMMANDS.dup
79
+
80
+ caps = add_appium_prefix(capabilities)
75
81
  response = execute(:new_session, {}, { capabilities: { firstMatch: [caps] } })
76
82
 
77
83
  @session_id = response['sessionId']
78
- capabilities = response['capabilities']
79
-
80
84
  raise ::Selenium::WebDriver::Error::WebDriverError, 'no sessionId in returned payload' unless @session_id
81
85
 
82
- @capabilities = json_create(capabilities)
86
+ @capabilities = json_create(response['capabilities'])
83
87
  end
84
88
 
85
89
  # Append +appium:+ prefix for Appium following W3C spec
@@ -90,7 +94,7 @@ module Appium
90
94
  def add_appium_prefix(capabilities)
91
95
  w3c_capabilities = ::Selenium::WebDriver::Remote::Capabilities.new
92
96
 
93
- capabilities = capabilities.__send__(:capabilities) unless capabilities.is_a?(Hash)
97
+ capabilities = capabilities.send(:capabilities) unless capabilities.is_a?(Hash)
94
98
 
95
99
  capabilities.each do |name, value|
96
100
  next if value.nil?
@@ -127,8 +131,17 @@ module Appium
127
131
 
128
132
  public
129
133
 
134
+ # command for Appium 2.0.
135
+ def add_command(method:, url:, name:, &block)
136
+ raise ::Appium::Core::Error::ArgumentError, "#{name} is already defined" if @available_commands.key? name
137
+
138
+ @available_commands[name] = [method, url]
139
+
140
+ ::Appium::Core::Device.add_endpoint_method name, &block
141
+ end
142
+
130
143
  def commands(command)
131
- ::Appium::Core::Commands::COMMANDS[command]
144
+ @available_commands[command]
132
145
  end
133
146
 
134
147
  # Returns all available sessions on the Appium server instance
@@ -215,7 +228,7 @@ module Appium
215
228
  # For Appium
216
229
  # override
217
230
  def find_element_by(how, what, parent = nil)
218
- how, what = convert_locators(how, what)
231
+ how, what = convert_locator(how, what)
219
232
 
220
233
  id = if parent
221
234
  execute :find_child_element, { id: parent }, { using: how, value: what }
@@ -228,7 +241,7 @@ module Appium
228
241
  # For Appium
229
242
  # override
230
243
  def find_elements_by(how, what, parent = nil)
231
- how, what = convert_locators(how, what)
244
+ how, what = convert_locator(how, what)
232
245
 
233
246
  ids = if parent
234
247
  execute :find_child_elements, { id: parent }, { using: how, value: what }
@@ -341,9 +354,8 @@ module Appium
341
354
  id['ELEMENT'] || id['element-6066-11e4-a52e-4f735466cecf']
342
355
  end
343
356
 
344
- # Don't convert locators for Appium Client
345
- # TODO: Only for Appium. Ideally, we'd like to keep the selenium-webdriver
346
- def convert_locators(how, what)
357
+ # Don't convert locators for Appium in native context
358
+ def convert_locator(how, what)
347
359
  # case how
348
360
  # when 'class name'
349
361
  # how = 'css selector'
@@ -357,6 +369,14 @@ module Appium
357
369
  # when 'tag name'
358
370
  # how = 'css selector'
359
371
  # end
372
+ #
373
+ # if what.is_a?(Hash)
374
+ # what = what.each_with_object({}) do |(h, w), hash|
375
+ # h, w = convert_locator(h.to_s, w)
376
+ # hash[h] = w
377
+ # end
378
+ # end
379
+
360
380
  [how, what]
361
381
  end
362
382
  end # class Bridge
@@ -0,0 +1,49 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ module Appium
16
+ module Core
17
+ class Base
18
+ #
19
+ # @api private
20
+ #
21
+ class DeviceIME
22
+ # @private this class is private
23
+ def initialize(bridge)
24
+ @bridge = bridge
25
+ end
26
+
27
+ def activate(ime_name)
28
+ @bridge.ime_activate(ime_name)
29
+ end
30
+
31
+ def available_engines
32
+ @bridge.ime_available_engines
33
+ end
34
+
35
+ def active_engine
36
+ @bridge.ime_active_engine
37
+ end
38
+
39
+ def activated?
40
+ @bridge.ime_activated
41
+ end
42
+
43
+ def deactivate
44
+ @bridge.ime_deactivate
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
@@ -13,6 +13,8 @@
13
13
  # limitations under the License.
14
14
 
15
15
  require 'base64'
16
+ require_relative 'device_ime'
17
+ require_relative 'driver_settings'
16
18
  require_relative 'search_context'
17
19
  require_relative 'screenshot'
18
20
  require_relative 'rotable'
@@ -42,8 +44,10 @@ module Appium
42
44
  # Do not use this for general use. Used by flutter driver to get bridge for creating a new element
43
45
  attr_reader :bridge
44
46
 
45
- # Almost same as self.handshake in ::Selenium::WebDriver::Remote::Bridge
46
- #
47
+ def initialize(bridge: nil, listener: nil, **opts)
48
+ super
49
+ end
50
+
47
51
  # Implements protocol handshake which:
48
52
  #
49
53
  # 1. Creates session with driver.
@@ -53,6 +57,7 @@ module Appium
53
57
  # @return [::Appium::Core::Base::Bridge]
54
58
  #
55
59
  def create_bridge(**opts)
60
+ # TODO: probably Appium does not need this.
56
61
  opts[:url] ||= service_url(opts)
57
62
  caps = opts.delete(:capabilities)
58
63
  # NOTE: This is deprecated
@@ -72,7 +77,7 @@ module Appium
72
77
  capabilities = generate_capabilities(cap_array)
73
78
 
74
79
  bridge_opts = { http_client: opts.delete(:http_client), url: opts.delete(:url) }
75
- raise ArgumentError, "Unable to create a driver with parameters: #{opts}" unless opts.empty?
80
+ raise ::Appium::Core::Error::ArgumentError, "Unable to create a driver with parameters: #{opts}" unless opts.empty?
76
81
 
77
82
  bridge = ::Appium::Core::Base::Bridge.new(**bridge_opts)
78
83
 
@@ -106,6 +111,75 @@ module Appium
106
111
  path: path)
107
112
  end
108
113
 
114
+ AVAILABLE_METHODS = [
115
+ :get, :head, :post, :put, :delete,
116
+ :connect, :options, :trace, :patch
117
+ ].freeze
118
+ # Define a new custom method to the driver so that you can define your own method for
119
+ # drivers/plugins in Appium 2.0. Appium 2.0 and its custom drivers/plugins allow you
120
+ # to define custom commands that are not part of W3C spec.
121
+ #
122
+ # @param [Symbol] method HTTP request method as https://www.w3.org/TR/webdriver/#endpoints
123
+ # @param [string] url The url to URL template as https://www.w3.org/TR/webdriver/#endpoints.
124
+ # +:session_id+ is the placeholder of 'session id'.
125
+ # Other place holders can be specified with +:+ prefix like +:id+.
126
+ # Then, the +:id+ will be replaced with a given value as the seconds argument of +execute+
127
+ # @param [Symbol] name The name of method that is called as the driver instance method.
128
+ # @param [Proc] block The block to involve as the method
129
+ # @raise [ArgumentError] If the given +name+ is already defined or +method+ are invalid value.
130
+ #
131
+ # @example
132
+ #
133
+ # @driver.add_command(
134
+ # method: :get,
135
+ # url: 'session/:session_id/path/to/custom/url',
136
+ # name: :test_command
137
+ # )
138
+ # # Send a GET request to 'session/<session id>/path/to/custom/url'
139
+ # @driver.test_command
140
+ #
141
+ #
142
+ # @driver.add_command(
143
+ # method: :post,
144
+ # url: 'session/:session_id/path/to/custom/url',
145
+ # name: :test_command
146
+ # ) do
147
+ # def test_command(argument)
148
+ # execute(:test_command, {}, { dummy: argument })
149
+ # end
150
+ # end
151
+ # # Send a POST request to 'session/<session id>/path/to/custom/url'
152
+ # # with body "{ dummy: 1 }" as JSON object. "1" is the argument.
153
+ # # ':session_id' in the given 'url' is replaced with current 'session id'.
154
+ # @driver.test_command(1)
155
+ #
156
+ # @driver.add_command(
157
+ # method: :post,
158
+ # url: 'session/:session_id/element/:id/custom/action',
159
+ # name: :test_action_command
160
+ # ) do
161
+ # def test_action_command(element_id, action)
162
+ # execute(:test_action_command, {id: element_id}, { dummy_action: action })
163
+ # end
164
+ # end
165
+ # # Send a POST request to 'session/<session id>/element/<element id>/custom/action'
166
+ # # with body "{ dummy_action: #{action} }" as JSON object. "action" is the seconds argument.
167
+ # # ':session_id' in the given url is replaced with current 'session id'.
168
+ # # ':id' in the given url is replaced with the given 'element_id'.
169
+ # e = @driver.find_element :accessibility_id, 'an element'
170
+ # @driver.test_action_command(e.ref, 'action')
171
+ #
172
+ def add_command(method:, url:, name:, &block)
173
+ unless AVAILABLE_METHODS.include? method
174
+ raise ::Appium::Core::Error::ArgumentError, "Available method is either #{AVAILABLE_METHODS}"
175
+ end
176
+
177
+ # TODO: Remove this logger before Appium 2.0 release
178
+ ::Appium::Logger.info '[Experimental] this method is experimental for Appium 2.0. This interface may change.'
179
+
180
+ @bridge.add_command method: method, url: url, name: name, &block
181
+ end
182
+
109
183
  ### Methods for Appium
110
184
 
111
185
  # Lock the device
@@ -188,36 +262,6 @@ module Appium
188
262
  end
189
263
  alias type send_keys
190
264
 
191
- class DriverSettings
192
- # @private this class is private
193
- def initialize(bridge)
194
- @bridge = bridge
195
- end
196
-
197
- # Get appium Settings for current test session.
198
- #
199
- # @example
200
- #
201
- # @driver.settings.get
202
- #
203
- def get
204
- @bridge.get_settings
205
- end
206
-
207
- # Update Appium Settings for current test session
208
- #
209
- # @param [Hash] settings Settings to update, keys are settings, values to value to set each setting to
210
- #
211
- # @example
212
- #
213
- # @driver.settings.update({'allowInvisibleElements': true})
214
- #
215
- def update(settings)
216
- @bridge.update_settings(settings)
217
- end
218
- end
219
- private_constant :DriverSettings
220
-
221
265
  # Returns an instance of DriverSettings to call get/update.
222
266
  #
223
267
  # @example
@@ -226,7 +270,7 @@ module Appium
226
270
  # @driver.settings.update('allowInvisibleElements': true)
227
271
  #
228
272
  def settings
229
- @driver_settings ||= DriverSettings.new(@bridge) # rubocop:disable Naming/MemoizedInstanceVariableName
273
+ @settings ||= DriverSettings.new(@bridge)
230
274
  end
231
275
 
232
276
  # Get appium Settings for current test session.
@@ -257,34 +301,6 @@ module Appium
257
301
  end
258
302
  alias update_settings settings=
259
303
 
260
- class DeviceIME
261
- # @private this class is private
262
- def initialize(bridge)
263
- @bridge = bridge
264
- end
265
-
266
- def activate(ime_name)
267
- @bridge.ime_activate(ime_name)
268
- end
269
-
270
- def available_engines
271
- @bridge.ime_available_engines
272
- end
273
-
274
- def active_engine
275
- @bridge.ime_active_engine
276
- end
277
-
278
- def activated?
279
- @bridge.ime_activated
280
- end
281
-
282
- def deactivate
283
- @bridge.ime_deactivate
284
- end
285
- end
286
- private_constant :DeviceIME
287
-
288
304
  # Returns an instance of DeviceIME
289
305
  #
290
306
  # @return [Appium::Core::Base::Driver::DeviceIME]
@@ -298,7 +314,7 @@ module Appium
298
314
  # @driver.ime.deactivate #=> Deactivate current IME engine
299
315
  #
300
316
  def ime
301
- @device_ime ||= DeviceIME.new(@bridge) # rubocop:disable Naming/MemoizedInstanceVariableName
317
+ @ime ||= DeviceIME.new(@bridge)
302
318
  end
303
319
 
304
320
  # Android only. Make an engine that is available active.
@@ -861,7 +877,7 @@ module Appium
861
877
  # @driver.perform_actions [f1, f2] #=> 'nil' if the action succeed
862
878
  #
863
879
  def perform_actions(data)
864
- raise ArgumentError, "'#{data}' must be Array" unless data.is_a? Array
880
+ raise ::Appium::Core::Error::ArgumentError, "'#{data}' must be Array" unless data.is_a? Array
865
881
 
866
882
  @bridge.send_actions data.map(&:encode).compact
867
883
  data.each(&:clear_actions)
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+
15
+ module Appium
16
+ module Core
17
+ class Base
18
+ #
19
+ # @api private
20
+ #
21
+ class DriverSettings
22
+ # @private this class is private
23
+ def initialize(bridge)
24
+ @bridge = bridge
25
+ end
26
+
27
+ # Get appium Settings for current test session.
28
+ #
29
+ # @example
30
+ #
31
+ # @driver.settings.get
32
+ #
33
+ def get
34
+ @bridge.get_settings
35
+ end
36
+
37
+ # Update Appium Settings for current test session
38
+ #
39
+ # @param [Hash] settings Settings to update, keys are settings, values to value to set each setting to
40
+ #
41
+ # @example
42
+ #
43
+ # @driver.settings.update({'allowInvisibleElements': true})
44
+ #
45
+ def update(settings)
46
+ @bridge.update_settings(settings)
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
@@ -30,7 +30,7 @@ module Appium
30
30
  end
31
31
 
32
32
  def network_connection_type=(connection_type)
33
- raise ArgumentError, 'Invalid connection type' unless valid_type? connection_type
33
+ raise ::Appium::Core::Error::ArgumentError, 'Invalid connection type' unless valid_type? connection_type
34
34
 
35
35
  connection_value = type_to_values[connection_type]
36
36
 
@@ -30,7 +30,7 @@ module Appium
30
30
  #
31
31
  def rotation=(orientation)
32
32
  unless ORIENTATIONS.include?(orientation)
33
- raise ArgumentError, "expected #{ORIENTATIONS.inspect}, got #{orientation.inspect}"
33
+ raise ::Appium::Core::Error::ArgumentError, "expected #{ORIENTATIONS.inspect}, got #{orientation.inspect}"
34
34
  end
35
35
 
36
36
  bridge.screen_orientation = orientation.to_s.upcase
@@ -159,7 +159,10 @@ module Appium
159
159
 
160
160
  def _set_by_from_finders(how)
161
161
  by = FINDERS[how.to_sym]
162
- raise ArgumentError, "cannot find element by #{how.inspect}. Available finders are #{FINDERS.keys}." unless by
162
+ unless by
163
+ raise ::Appium::Core::Error::ArgumentError,
164
+ "cannot find element by #{how.inspect}. Available finders are #{FINDERS.keys}."
165
+ end
163
166
 
164
167
  by
165
168
  end
@@ -171,16 +174,18 @@ module Appium
171
174
  when 1
172
175
  arg = args.first
173
176
 
174
- raise ArgumentError, "expected #{arg.inspect}:#{arg.class} to respond to #shift" unless arg.respond_to?(:shift)
177
+ unless arg.respond_to?(:shift)
178
+ raise ::Appium::Core::Error::ArgumentError, "expected #{arg.inspect}:#{arg.class} to respond to #shift"
179
+ end
175
180
 
176
181
  # this will be a single-entry hash, so use #shift over #first or #[]
177
182
  arr = arg.dup.shift
178
183
 
179
- raise ArgumentError, "expected #{arr.inspect} to have 2 elements" unless arr.size == 2
184
+ raise ::Appium::Core::Error::ArgumentError, "expected #{arr.inspect} to have 2 elements" unless arr.size == 2
180
185
 
181
186
  arr
182
187
  else
183
- raise ArgumentError, "wrong number of arguments (#{args.size} for 2)"
188
+ raise ::Appium::Core::Error::ArgumentError, "wrong number of arguments (#{args.size} for 2)"
184
189
  end
185
190
  end
186
191
  end # module SearchContext
@@ -25,8 +25,8 @@ module Appium
25
25
  end
26
26
 
27
27
  def press_keycode(key, metastate: [], flags: [])
28
- raise ArgumentError, 'flags should be Array' unless flags.is_a? Array
29
- raise ArgumentError, 'metastates should be Array' unless metastate.is_a? Array
28
+ raise ::Appium::Core::Error::ArgumentError, 'flags should be Array' unless flags.is_a? Array
29
+ raise ::Appium::Core::Error::ArgumentError, 'metastates should be Array' unless metastate.is_a? Array
30
30
 
31
31
  args = { keycode: key }
32
32
  args[:metastate] = metastate.reduce(0) { |acc, meta| acc | meta } unless metastate.empty?
@@ -36,8 +36,8 @@ module Appium
36
36
  end
37
37
 
38
38
  def long_press_keycode(key, metastate: [], flags: [])
39
- raise ArgumentError, 'flags should be Array' unless flags.is_a? Array
40
- raise ArgumentError, 'metastates should be Array' unless metastate.is_a? Array
39
+ raise ::Appium::Core::Error::ArgumentError, 'flags should be Array' unless flags.is_a? Array
40
+ raise ::Appium::Core::Error::ArgumentError, 'metastates should be Array' unless metastate.is_a? Array
41
41
 
42
42
  args = { keycode: key }
43
43
  args[:metastate] = metastate.reduce(0) { |acc, meta| acc | meta } unless metastate.empty?
@@ -27,8 +27,11 @@ module Appium
27
27
 
28
28
  class UnsupportedOperationError < CoreError; end
29
29
 
30
- # Server side error
30
+ # Server side errors
31
31
  class ServerError < CoreError; end
32
+
33
+ # ruby_lib_core library specific errors
34
+ class ArgumentError < CoreError; end
32
35
  end
33
36
  end
34
37
  end
@@ -65,7 +65,10 @@ module Appium
65
65
  end
66
66
 
67
67
  def event=(log_event)
68
- raise ArgumentError('log_event should be Hash like { vendor: "appium", event: "funEvent"}') unless log_event.is_a?(Hash)
68
+ unless log_event.is_a?(Hash)
69
+ raise ::Appium::Core::Error::ArgumentError,
70
+ 'log_event should be Hash like { vendor: "appium", event: "funEvent"}'
71
+ end
69
72
 
70
73
  event vendor: log_event[:vendor], event: log_event[:event]
71
74
  end
@@ -367,11 +367,10 @@ module Appium
367
367
  end
368
368
 
369
369
  begin
370
- # included https://github.com/SeleniumHQ/selenium/blob/43f8b3f66e7e01124eff6a5805269ee441f65707/rb/lib/selenium/webdriver/remote/driver.rb#L29
371
370
  @driver = ::Appium::Core::Base::Driver.new(listener: @listener,
372
- http_client: @http_client,
373
- desired_capabilities: @caps,
374
- url: @custom_url)
371
+ http_client: @http_client,
372
+ desired_capabilities: @caps,
373
+ url: @custom_url)
375
374
 
376
375
  if @direct_connect
377
376
  d_c = DirectConnections.new(@driver.capabilities)
@@ -14,7 +14,7 @@
14
14
 
15
15
  module Appium
16
16
  module Core
17
- VERSION = '5.0.0.beta3' unless defined? ::Appium::Core::VERSION
18
- DATE = '2021-04-15' unless defined? ::Appium::Core::DATE
17
+ VERSION = '5.0.0.beta4' unless defined? ::Appium::Core::VERSION
18
+ DATE = '2021-06-11' unless defined? ::Appium::Core::DATE
19
19
  end
20
20
  end
data/release_notes.md CHANGED
@@ -1,3 +1,17 @@
1
+ #### v4.6.0 2021-06-03
2
+
3
+ - [0dacfab](https://github.com/appium/ruby_lib_core/commit/0dacfab1256e1447e1f7a5974dfcf48ee0a72b9d) Release 4.6.0
4
+ - [b9f015d](https://github.com/appium/ruby_lib_core/commit/b9f015d7dea14964a0733f2385ebcff68da1e18e) feat: allow to add commands dynamically (#325)
5
+ - [3de96ee](https://github.com/appium/ruby_lib_core/commit/3de96eea133ccbcbc5c4d77adc7d67c065a5a38c) chore(deps-dev): update webmock requirement from ~> 3.12.1 to ~> 3.13.0 (#324)
6
+ - [f1a9e79](https://github.com/appium/ruby_lib_core/commit/f1a9e79f3bd4d134e125fc2ed9adcf3d085afc9a) docs: address func test code as working example
7
+ - [eb85b1b](https://github.com/appium/ruby_lib_core/commit/eb85b1b26623436cb0aae95a00fef7bc2d795520) remove ; in a test
8
+ - [1632637](https://github.com/appium/ruby_lib_core/commit/1632637fd872c0b80dfb97b8514ada6a7164eebf) chore(deps-dev): update rubocop requirement from = 1.11.0 to = 1.12.0 (#321)
9
+ - [b9e47aa](https://github.com/appium/ruby_lib_core/commit/b9e47aa9b02f060ffa91e8410ab97dc87d3640a4) docs: add docstring
10
+ - [954a2fe](https://github.com/appium/ruby_lib_core/commit/954a2feebb768a55b496a2614d9e4dd8b702fc1e) chore(deps-dev): update rubocop requirement from = 1.8.1 to = 1.11.0 (#316)
11
+ - [a5b9651](https://github.com/appium/ruby_lib_core/commit/a5b9651aa349c10bd9759fedac6f09e27012a5e5) chore(deps-dev): update webmock requirement from ~> 3.11.0 to ~> 3.12.1 (#319)
12
+ - [485c096](https://github.com/appium/ruby_lib_core/commit/485c096273178aa5e21f28d93545fd127cbb8735) test: add assertion
13
+
14
+
1
15
  #### v4.5.0 2021-03-14
2
16
 
3
17
  - [656230e](https://github.com/appium/ruby_lib_core/commit/656230e688ed86414c06efaa73bce7359933cc91) Release 4.5.0
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: appium_lib_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 5.0.0.beta3
4
+ version: 5.0.0.beta4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kazuaki MATSUO
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-04-15 00:00:00.000000000 Z
11
+ date: 2021-06-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: selenium-webdriver
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 4.0.0.beta3
19
+ version: 4.0.0.beta4
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 4.0.0.beta3
26
+ version: 4.0.0.beta4
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: faye-websocket
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -114,14 +114,14 @@ dependencies:
114
114
  requirements:
115
115
  - - "~>"
116
116
  - !ruby/object:Gem::Version
117
- version: 3.12.1
117
+ version: 3.13.0
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
122
  - - "~>"
123
123
  - !ruby/object:Gem::Version
124
- version: 3.12.1
124
+ version: 3.13.0
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: rubocop
127
127
  requirement: !ruby/object:Gem::Requirement
@@ -257,7 +257,9 @@ files:
257
257
  - lib/appium_lib_core/common/base.rb
258
258
  - lib/appium_lib_core/common/base/bridge.rb
259
259
  - lib/appium_lib_core/common/base/capabilities.rb
260
+ - lib/appium_lib_core/common/base/device_ime.rb
260
261
  - lib/appium_lib_core/common/base/driver.rb
262
+ - lib/appium_lib_core/common/base/driver_settings.rb
261
263
  - lib/appium_lib_core/common/base/has_location.rb
262
264
  - lib/appium_lib_core/common/base/has_network_connection.rb
263
265
  - lib/appium_lib_core/common/base/http_default.rb
@@ -323,7 +325,7 @@ homepage: https://github.com/appium/ruby_lib_core/
323
325
  licenses:
324
326
  - Apache-2.0
325
327
  metadata: {}
326
- post_install_message:
328
+ post_install_message:
327
329
  rdoc_options: []
328
330
  require_paths:
329
331
  - lib
@@ -338,8 +340,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
338
340
  - !ruby/object:Gem::Version
339
341
  version: 1.3.1
340
342
  requirements: []
341
- rubygems_version: 3.1.2
342
- signing_key:
343
+ rubygems_version: 3.2.15
344
+ signing_key:
343
345
  specification_version: 4
344
346
  summary: Minimal Ruby library for Appium.
345
347
  test_files: []