Skip to content

Commit

Permalink
removed a few dupcated methods
Browse files Browse the repository at this point in the history
  • Loading branch information
KazuCocoa committed Jan 22, 2024
1 parent 896f12e commit 4bb2951
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 67 deletions.
54 changes: 1 addition & 53 deletions lib/appium_lib_core/driver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ module Ios
# This options affects only client side as <code>:appium_lib</code> key.<br>
# Read {::Appium::Core::Driver} about each attribute
class Options
attr_reader :custom_url, :default_wait, :export_session, :export_session_path,
attr_reader :custom_url, :default_wait,
:port, :wait_timeout, :wait_interval, :listener,
:direct_connect, :enable_idempotency_header

Expand All @@ -45,10 +45,6 @@ def initialize(appium_lib_opts)
@default_wait = appium_lib_opts.fetch :wait, nil
@enable_idempotency_header = appium_lib_opts.fetch :enable_idempotency_header, true

# bump current session id into a particular file
@export_session = appium_lib_opts.fetch :export_session, false
@export_session_path = appium_lib_opts.fetch :export_session_path, default_tmp_appium_lib_session

@direct_connect = appium_lib_opts.fetch :direct_connect, true

@port = appium_lib_opts.fetch :port, Driver::DEFAULT_APPIUM_PORT
Expand Down Expand Up @@ -137,12 +133,6 @@ class Driver
# @return [String]
attr_reader :custom_url

# Export session id to textfile in /tmp for 3rd party tools. False by default.
# @return [Boolean]
attr_reader :export_session
# @return [String] By default, session id is exported in '/tmp/appium_lib_session'
attr_reader :export_session_path

# Default wait time for elements to appear in Appium server side.
# Provide <code>{ appium_lib: { wait: 30 } }</code> to {::Appium::Core.for}
# @return [Integer]
Expand Down Expand Up @@ -222,7 +212,6 @@ class Driver
# app: '/path/to/MyiOS.app'
# },
# appium_lib: {
# export_session: false,
# port: 8080,
# wait: 0,
# wait_timeout: 20,
Expand All @@ -245,7 +234,6 @@ class Driver
# },
# appium_lib: {
# server_url: 'http://custom-host:8080/wd/hub.com',
# export_session: false,
# wait: 0,
# wait_timeout: 20,
# wait_interval: 0.3,
Expand All @@ -266,7 +254,6 @@ class Driver
# app: '/path/to/MyiOS.app'
# },
# appium_lib: {
# export_session: false,
# wait: 0,
# wait_timeout: 20,
# wait_interval: 0.3,
Expand Down Expand Up @@ -439,9 +426,6 @@ def start_driver(server_url: nil,
d_c = DirectConnections.new(@driver.capabilities)
@driver.update_sending_request_to(protocol: d_c.protocol, host: d_c.host, port: d_c.port, path: d_c.path)
end

# export session
write_session_id(@driver.session_id, @export_session_path) if @export_session
rescue Errno::ECONNREFUSED
raise "ERROR: Unable to connect to Appium. Is the server running on #{@custom_url}?"
end
Expand Down Expand Up @@ -494,9 +478,6 @@ def attach_to(session_id, url: nil, automation_name: nil, platform_name: nil,
existing_session_id: session_id,
automation_name: automation_name,
platform_name: platform_name)

# export session
write_session_id(@driver.session_id, @export_session_path) if @export_session
rescue Errno::ECONNREFUSED
raise "ERROR: Unable to connect to Appium. Is the server running on #{@custom_url}?"
end
Expand Down Expand Up @@ -568,23 +549,6 @@ def appium_server_version
{}
end

# Return the platform version as an array of integers
# @return [Array<Integer>]
#
# @example
#
# @core.platform_version #=> [10,1,1]
#
def platform_version
::Appium::Logger.warn(
'[DEPRECATION] platform_version method will be. ' \
'Please check the platformVersion via @driver.capabilities["platformVersion"] instead.'
)

p_version = @driver.capabilities['platformVersion'] || @driver.session_capabilities['platformVersion']
p_version.split('.').map(&:to_i)
end

private

def convert_to_symbol(value)
Expand Down Expand Up @@ -699,9 +663,6 @@ def set_appium_lib_specific_values(appium_lib_opts)

@default_wait = opts.default_wait

@export_session = opts.export_session
@export_session_path = opts.export_session_path

@port = opts.port

@wait_timeout = opts.wait_timeout
Expand Down Expand Up @@ -743,19 +704,6 @@ def set_automation_name_if_nil
@driver.capabilities['automationName'].downcase.strip.intern
end
end

# @private
def write_session_id(session_id, export_path = '/tmp/appium_lib_session')
::Appium::Logger.warn(
'[DEPRECATION] export_session option will be removed. ' \
'Please save the session id by yourself with #session_id method like @driver.session_id.'
)
export_path = export_path.tr('/', '\\') if ::Appium::Core::Base.platform.windows?
File.write(export_path, session_id)
rescue IOError => e
::Appium::Logger.warn e
nil
end
end # class Driver
end # module Core
end # module Appium
5 changes: 0 additions & 5 deletions test/functional/ios/driver_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,6 @@ def test_appium_server_version
refute_nil v['build']['version']
end

def test_platform_version
# Just make sure the value is not nil
assert @@core.platform_version
end

def test_wait_true
e = @@core.wait_true { @@driver.find_element :accessibility_id, uicatalog }
assert e.name
Expand Down
5 changes: 0 additions & 5 deletions test/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,6 @@ def ios(platform_name = :ios)
'settings[pageSourceExcludedAttributes]': 'visible'
},
appium_lib: {
export_session: true,
wait_timeout: 20,
wait_interval: 1
}
Expand Down Expand Up @@ -291,7 +290,6 @@ def android(activity_name = nil)
uiautomator2ServerLaunchTimeout: 60_000 # ms
},
appium_lib: {
export_session: true,
wait: 5,
wait_timeout: 20,
wait_interval: 1
Expand Down Expand Up @@ -325,7 +323,6 @@ def android_direct
{
capabilities: android[:capabilities],
appium_lib: {
export_session: true,
wait: 30,
wait_timeout: 20,
wait_interval: 1,
Expand Down Expand Up @@ -357,7 +354,6 @@ def android_web
locale: 'US'
},
appium_lib: {
export_session: true,
wait_timeout: 20,
wait_interval: 1
}
Expand All @@ -373,7 +369,6 @@ def windows
app: 'Microsoft.WindowsCalculator_8wekyb3d8bbwe!App'
},
appium_lib: {
export_session: true,
wait_timeout: 20,
wait_interval: 1
}
Expand Down
4 changes: 0 additions & 4 deletions test/unit/driver_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,10 +52,6 @@ def test_with_caps_and_appium_lib
assert_equal driver.core.caps[:automationName], 'xcuitest'
end

def test_verify_session_id_in_the_export_session_path
@core.wait { assert File.size?(@core.export_session_path) }
end

def test_verify_appium_core_base_capabilities_create_capabilities
caps = ::Appium::Core::Base::Capabilities.new(platformName: 'ios',
platformVersion: '11.4',
Expand Down

0 comments on commit 4bb2951

Please sign in to comment.