appium_lib_core 5.5.0 → 5.5.1

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: 5568507385da95987810f6234f38634ed832f09c328b42f340ed8f012eb979e3
4
- data.tar.gz: f1e8d745816ef89c07a1f19adca47a4fbf6889cc533b3c50c671df749b55d084
3
+ metadata.gz: 36c3e5d802524fd73d0bd2f3f4c383dc8ca315b5fab8d91126aa38360023513e
4
+ data.tar.gz: 3133b9cacbc2ccb65d44be5abc2ead266e70b84603a37d33f4697d71e5a28320
5
5
  SHA512:
6
- metadata.gz: '0508a3eeabfab5868052600c767ef21ad93ac5d5efed1deab030966e5e6125d07e98bffb2ca5b5c2aababa20cf140643b7e086c90b315dc3040627d3f70357fa'
7
- data.tar.gz: 0b3e01eac1d50376d0c9bb669f8360587113472ccb5706473e64b0d349a19267c6723d5ce3d4db01ca658fe4df2b2d79a98f6d66946f0426a285241732939b8f
6
+ metadata.gz: 606343375d1a70d5b0d3f6c8b3a01d5bb4cb3b7668bfe622bae0ba3d35ca57997c1dd1b081934cade812a74bce250fa8fd0d3328d98dd94da451a34677021ef3
7
+ data.tar.gz: 7315f007b57556ba24d615aea8fc48d05808a89f6cb408b400a560e5ea032827b732b20c15f3682e36abe48f3d30fcfd6896368e21a479e1adecf73b30459cc3
data/CHANGELOG.md CHANGED
@@ -10,6 +10,16 @@ Read `release_notes.md` for commit level details.
10
10
 
11
11
  ### Deprecations
12
12
 
13
+ ## [5.5.1] - 2022-10-10
14
+
15
+ ### Bug fixes
16
+ - Keep converting String to Symbol for `capabilities`, `caps` and `appium_lib` for the backward compatibility
17
+ - Wrong `automationName` and `platformName` detection in this library before starting a session
18
+
19
+ ### Deprecations
20
+ - Converting `capabilities`, `caps` and `appium_lib` from String to Symbol
21
+ - They are expected to be Symbol. Nothing affects existing users who already give the above keys as Symbol for `Appium::Core.for`.
22
+
13
23
  ## [5.5.0] - 2022-10-09
14
24
 
15
25
  ### Bug fixes
@@ -17,10 +17,6 @@ module Appium
17
17
  module Error
18
18
  class CoreError < StandardError; end
19
19
 
20
- # Capability related errors
21
- class NoCapabilityError < CoreError; end
22
- class CapabilityStructureError < CoreError; end
23
-
24
20
  # Appium related errors
25
21
  class NotSupportedAppiumServer < CoreError; end
26
22
  class NoSuchElementError < CoreError; end
@@ -293,6 +293,12 @@ module Appium
293
293
  @delegate_target = self # for testing purpose
294
294
  @automation_name = nil # initialise before 'set_automation_name'
295
295
 
296
+ # TODO: Remove when we implement Options
297
+ # The symbolize_keys is to keep compatiility for the legacy code, which allows capabilities to give 'string' as the key.
298
+ # The toplevel `caps`, `capabilities` and `appium_lib` are expected to be symbol.
299
+ # FIXME: First, please try to remove `nested: true` to `nested: false`.
300
+ opts = Appium.symbolize_keys(opts, nested: true)
301
+
296
302
  @custom_url = opts.delete :url
297
303
  @caps = get_caps(opts)
298
304
 
@@ -486,14 +492,24 @@ module Appium
486
492
 
487
493
  private
488
494
 
495
+ def convert_to_symbol(value)
496
+ if value.nil?
497
+ value
498
+ else
499
+ value.to_sym
500
+ end
501
+ end
502
+
489
503
  # @private
490
504
  def extend_for(device:, automation_name:) # rubocop:disable Metrics/CyclomaticComplexity
491
505
  extend Appium::Core
492
506
  extend Appium::Core::Device
493
507
 
494
- case device
508
+ sym_automation_name = convert_to_symbol(automation_name)
509
+
510
+ case convert_to_symbol(device)
495
511
  when :android
496
- case automation_name
512
+ case sym_automation_name
497
513
  when :espresso
498
514
  ::Appium::Core::Android::Espresso::Bridge.for self
499
515
  when :uiautomator2
@@ -504,7 +520,7 @@ module Appium
504
520
  ::Appium::Core::Android::Uiautomator1::Bridge.for self
505
521
  end
506
522
  when :ios, :tvos
507
- case automation_name
523
+ case sym_automation_name
508
524
  when :safari
509
525
  ::Appium::Logger.debug('SafariDriver for iOS')
510
526
  when :xcuitest
@@ -513,7 +529,7 @@ module Appium
513
529
  ::Appium::Core::Ios::Uiautomation::Bridge.for self
514
530
  end
515
531
  when :mac
516
- case automation_name
532
+ case sym_automation_name
517
533
  when :safari
518
534
  ::Appium::Logger.debug('SafariDriver for macOS')
519
535
  when :gecko
@@ -525,7 +541,7 @@ module Appium
525
541
  ::Appium::Logger.debug('macOS Native')
526
542
  end
527
543
  when :windows
528
- case automation_name
544
+ case sym_automation_name
529
545
  when :gecko
530
546
  ::Appium::Logger.debug('Gecko Driver for Windows')
531
547
  else
@@ -535,7 +551,7 @@ module Appium
535
551
  # https://github.com/Samsung/appium-tizen-driver
536
552
  ::Appium::Logger.debug('tizen')
537
553
  else
538
- case automation_name
554
+ case sym_automation_name
539
555
  when :youiengine
540
556
  # https://github.com/YOU-i-Labs/appium-youiengine-driver
541
557
  ::Appium::Logger.debug('YouiEngine')
@@ -567,6 +583,7 @@ module Appium
567
583
  # The path can be local, HTTP/S, Windows Share and other path like 'sauce-storage:'.
568
584
  # Use @caps[:app] without modifications if the path isn't HTTP/S or local path.
569
585
  def set_app_path
586
+ # FIXME: maybe `:app` should check `app` as well.
570
587
  return unless @caps && @caps[:app] && !@caps[:app].empty?
571
588
  return if @caps[:app] =~ URI::DEFAULT_PARSER.make_regexp
572
589
 
@@ -605,7 +622,8 @@ module Appium
605
622
  # @private
606
623
  def set_appium_device
607
624
  # https://code.google.com/p/selenium/source/browse/spec-draft.md?repo=mobile
608
- @device = @caps[:platformName]
625
+ # TODO: check if the Appium.symbolize_keys(opts, nested: false) enoug with this
626
+ @device = @caps[:platformName] || @caps['platformName']
609
627
  return @device unless @device
610
628
 
611
629
  @device = @device.is_a?(Symbol) ? @device.downcase : @device.downcase.strip.intern
@@ -613,7 +631,9 @@ module Appium
613
631
 
614
632
  # @private
615
633
  def set_automation_name
616
- @automation_name = @caps[:automationName] if @caps[:automationName]
634
+ # TODO: check if the Appium.symbolize_keys(opts, nested: false) enoug with this
635
+ candidate = @caps[:automationName] || @caps['automationName']
636
+ @automation_name = candidate if candidate
617
637
  @automation_name = if @automation_name
618
638
  @automation_name.is_a?(Symbol) ? @automation_name.downcase : @automation_name.downcase.strip.intern
619
639
  end
@@ -14,7 +14,7 @@
14
14
 
15
15
  module Appium
16
16
  module Core
17
- VERSION = '5.5.0' unless defined? ::Appium::Core::VERSION
18
- DATE = '2022-10-09' unless defined? ::Appium::Core::DATE
17
+ VERSION = '5.5.1' unless defined? ::Appium::Core::VERSION
18
+ DATE = '2022-10-10' unless defined? ::Appium::Core::DATE
19
19
  end
20
20
  end
@@ -21,16 +21,25 @@ require_relative 'appium_lib_core/device'
21
21
  require_relative 'appium_lib_core/element'
22
22
 
23
23
  module Appium
24
- # convert all keys (including nested) to symbols
24
+ # @private
25
+ #
26
+ # convert the top level keys to symbols.
25
27
  #
26
- # based on deep_symbolize_keys & deep_transform_keys from rails
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
- def self.symbolize_keys(hash)
29
+ def self.symbolize_keys(hash, nested: false, enable_deprecation_msg: true)
30
+ # FIXME: As https://github.com/appium/ruby_lib/issues/945, we must remove this implicit string to symbol.
31
+ # But appium_lib_core's some capability handling expect to be symbol, so we should test to remove
32
+ # the mehotds which expect the symbol first.
30
33
  raise ::Appium::Core::Error::ArgumentError, 'symbolize_keys requires a hash' unless hash.is_a? Hash
31
34
 
32
35
  hash.each_with_object({}) do |pair, acc|
33
36
  key = begin
37
+ if enable_deprecation_msg && !(pair[0].is_a? Symbol)
38
+ ::Appium::Logger.warn("[Deprecation] The key '#{pair[0]}' must be a symbol while currently it " \
39
+ "is #{pair[0].class.name}. Please define the key as a Symbol. " \
40
+ 'Converting it to Symbol for now.')
41
+ end
42
+
34
43
  pair[0].to_sym
35
44
  rescue StandardError => e
36
45
  ::Appium::Logger.warn(e.message)
@@ -38,7 +47,11 @@ module Appium
38
47
  end
39
48
 
40
49
  value = pair[1]
41
- acc[key] = value.is_a?(Hash) ? symbolize_keys(value) : value
50
+ acc[key] = if nested
51
+ value.is_a?(Hash) ? symbolize_keys(value, nested: false, enable_deprecation_msg: true) : value
52
+ else
53
+ value
54
+ end
42
55
  end
43
56
  end
44
57
 
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.5.0
4
+ version: 5.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kazuaki MATSUO
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-10-09 00:00:00.000000000 Z
11
+ date: 2022-10-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: selenium-webdriver