Skip to content

Commit

Permalink
refactoring a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
KazuCocoa committed Aug 2, 2024
1 parent 711e317 commit 8d7994c
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions lib/appium_lib_core/driver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -624,7 +624,6 @@ def extend_for(device:, automation_name:) # rubocop:disable Metrics/CyclomaticCo

# @private
def get_caps(opts)
# TODO: drop symbols
Core::Base::Capabilities.new(opts[:caps] || opts[:capabilities] || {})
end

Expand All @@ -635,8 +634,7 @@ def get_appium_lib_opts(opts)

# @private
def get_app
# return symbols only
@caps[:app] || @caps['app'] || @caps[:'appium:app'] || @caps['appium:app']
get_cap 'app'
end

# @private
Expand Down Expand Up @@ -680,16 +678,15 @@ def set_appium_lib_specific_values(appium_lib_opts)
# @private
def set_appium_device
# https://code.google.com/p/selenium/source/browse/spec-draft.md?repo=mobile
@device = @caps[:platformName] || @caps['platformName']
@device = get_cap 'platformName'
return @device unless @device

@device = convert_to_symbol(convert_downcase(@device))
end

# @private
def set_automation_name
candidate = @caps[:automationName] || @caps['automationName'] ||
@caps[:'appium:automationName'] || @caps['appium:automationName']
candidate = get_cap 'automationName'
@automation_name = candidate if candidate
@automation_name = convert_to_symbol(convert_downcase(@automation_name)) if @automation_name
end
Expand All @@ -708,6 +705,14 @@ def set_automation_name_if_nil
end
@automation_name = convert_to_symbol automation_name
end

def get_cap(name)
name_with_prefix = "appium:#{name}"
@caps[convert_to_symbol name] ||
@caps[name] ||
@caps[convert_to_symbol name_with_prefix] ||
@caps[name_with_prefix]
end
end # class Driver
end # module Core
end # module Appium

0 comments on commit 8d7994c

Please sign in to comment.