Skip to content

Commit 2e81a31

Browse files
committed
first try
1 parent a8052bc commit 2e81a31

10 files changed

Lines changed: 6 additions & 224 deletions

File tree

lib/appium_lib_core.rb

Lines changed: 0 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -22,43 +22,6 @@
2222
require_relative 'appium_lib_core/support/event_firing_bridge'
2323

2424
module Appium
25-
# convert the top level keys to symbols.
26-
#
27-
# @param [Hash] hash Hash value to make symbolise
28-
#
29-
# @example
30-
#
31-
# opts = Appium.symbolize_keys(opts)
32-
#
33-
def self.symbolize_keys(hash, nested: false, enable_deprecation_msg: true)
34-
# FIXME: As https://github.com/appium/ruby_lib/issues/945, we must remove this implicit string to symbol.
35-
# But appium_lib_core's some capability handling expect to be symbol, so we should test to remove
36-
# the methods which expect the symbol first.
37-
raise ::Appium::Core::Error::ArgumentError, 'symbolize_keys requires a hash' unless hash.is_a? Hash
38-
39-
hash.each_with_object({}) do |pair, acc|
40-
key = begin
41-
if enable_deprecation_msg && !(pair[0].is_a? Symbol)
42-
::Appium::Logger.warn("[Deprecation] The key '#{pair[0]}' must be a symbol while currently it " \
43-
"is #{pair[0].class.name}. Please define the key as a Symbol. " \
44-
'Converting it to Symbol for now.')
45-
end
46-
47-
pair[0].to_sym
48-
rescue StandardError => e
49-
::Appium::Logger.warn(e.message)
50-
pair[0]
51-
end
52-
53-
value = pair[1]
54-
acc[key] = if nested
55-
value.is_a?(Hash) ? symbolize_keys(value, nested: false, enable_deprecation_msg: false) : value
56-
else
57-
value
58-
end
59-
end
60-
end
61-
6225
module Core
6326
# @see Appium::Core::Driver.for
6427
def self.for(opts = {})

lib/appium_lib_core/common/base/capabilities.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@ class Capabilities < ::Selenium::WebDriver::Remote::Capabilities
2424
# standard options like chrome and firefox etc. So, the implementation should differ from
2525
# other browsers. But here should inherit `Options` to follow Selenium.
2626

27-
# Method override
28-
# FIXME: when we drop "symbolize_keys", this can be removed.
27+
# Override Selenium's convert_key to prevent camelCase conversion.
28+
# Appium capability names should be preserved as-is (e.g., :some_capability stays "some_capability",
29+
# not converted to "someCapability" as Selenium's default would do).
2930
def convert_key(key)
3031
case key
3132
when String
3233
key.to_s
3334
when Symbol
34-
# here do not convert to camel case
3535
key.to_s
3636
else
3737
raise ::Appium::Core::Error::ArgumentError, "expected String or Symbol, got #{key.inspect}:#{key.class}"

lib/appium_lib_core/driver.rb

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,12 @@ module Ios
3636
# This options affects only client side as <code>:appium_lib</code> key.<br>
3737
# Read {::Appium::Core::Driver} about each attribute
3838
class Options
39-
attr_reader :custom_url, :default_wait,
39+
attr_reader :custom_url,
4040
:port, :wait_timeout, :wait_interval, :listener,
4141
:direct_connect, :enable_idempotency_header
4242

4343
def initialize(appium_lib_opts)
4444
@custom_url = appium_lib_opts.fetch :server_url, nil
45-
@default_wait = appium_lib_opts.fetch :wait, nil
4645
@enable_idempotency_header = appium_lib_opts.fetch :enable_idempotency_header, true
4746

4847
@direct_connect = appium_lib_opts.fetch :direct_connect, true
@@ -133,11 +132,6 @@ class Driver
133132
# @return [String]
134133
attr_reader :custom_url
135134

136-
# Default wait time for elements to appear in Appium server side.
137-
# Provide <code>{ appium_lib: { wait: 30 } }</code> to {::Appium::Core.for}
138-
# @return [Integer]
139-
attr_reader :default_wait
140-
141135
# Appium's server port. 4723 is by default. Defaults to {::Appium::Core::Driver::DEFAULT_APPIUM_PORT}.<br>
142136
# Provide <code>{ appium_lib: { port: 8080 } }</code> to {::Appium::Core.for}.
143137
# <code>:custom_url</code> is prior than <code>:port</code> if <code>:custom_url</code> is set.
@@ -213,7 +207,6 @@ class Driver
213207
# },
214208
# appium_lib: {
215209
# port: 8080,
216-
# wait: 0,
217210
# wait_timeout: 20,
218211
# wait_interval: 0.3,
219212
# listener: nil,
@@ -234,7 +227,6 @@ class Driver
234227
# },
235228
# appium_lib: {
236229
# server_url: 'http://custom-host:8080/wd/hub',
237-
# wait: 0,
238230
# wait_timeout: 20,
239231
# wait_interval: 0.3,
240232
# listener: nil,
@@ -254,7 +246,6 @@ class Driver
254246
# app: '/path/to/MyiOS.app'
255247
# },
256248
# appium_lib: {
257-
# wait: 0,
258249
# wait_timeout: 20,
259250
# wait_interval: 0.3,
260251
# listener: nil,
@@ -376,7 +367,6 @@ def setup_for_new_session(opts = {})
376367
# app: '/path/to/MyiOS.app'
377368
# },
378369
# appium_lib: {
379-
# wait: 20,
380370
# wait_timeout: 20,
381371
# wait_interval: 0.3,
382372
# }
@@ -430,8 +420,6 @@ def start_driver(server_url: nil,
430420
@http_client.delete_additional_header Appium::Core::Base::Http::RequestHeaders::KEYS[:idempotency]
431421
end
432422

433-
set_implicit_wait_by_default(@default_wait)
434-
435423
@driver
436424
end
437425

@@ -478,18 +466,6 @@ def get_http_client(http_client: nil, open_timeout: nil, read_timeout: nil)
478466
http_client || Appium::Core::Base::Http::Default.new(open_timeout: open_timeout, read_timeout: read_timeout)
479467
end
480468

481-
# Ignore setting default wait if the target driver has no implementation
482-
def set_implicit_wait_by_default(wait)
483-
return if @default_wait.nil?
484-
485-
@driver.manage.timeouts.implicit_wait = wait
486-
rescue ::Selenium::WebDriver::Error::UnknownError => e
487-
raise ::Appium::Core::Error::ServerError, e.message unless e.message.include?('The operation requested is not yet implemented')
488-
489-
::Appium::Logger.debug(e.message)
490-
{}
491-
end
492-
493469
# Returns the server's version info. This method calls +driver.remote_status+ internally
494470
#
495471
# @return [Hash]
@@ -652,8 +628,6 @@ def set_appium_lib_specific_values(appium_lib_opts)
652628
@custom_url ||= opts.custom_url # Keep existence capability if it's already provided
653629
@enable_idempotency_header = opts.enable_idempotency_header
654630

655-
@default_wait = opts.default_wait
656-
657631
@port = opts.port
658632

659633
@wait_timeout = opts.wait_timeout

sig/lib/appium_lib_core.rbs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
module Appium
2-
def self.symbolize_keys: (Hash[untyped, untyped] hash, ?nested: bool, ?enable_deprecation_msg: bool)
3-
-> Hash[Symbol, untyped]
4-
52
module Core
63
def self.for: (Hash[Symbol, untyped] opts) -> Driver
74
end

sig/lib/appium_lib_core/driver.rbs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ module Appium
2020
class Options
2121
@custom_url: String
2222

23-
@default_wait: Integer
24-
2523
@enable_idempotency_header: bool
2624

2725
@direct_connect: bool
@@ -36,8 +34,6 @@ module Appium
3634

3735
attr_reader custom_url: String
3836

39-
attr_reader default_wait: Integer
40-
4137
attr_reader port: Integer
4238

4339
attr_reader wait_timeout: Integer
@@ -98,8 +94,6 @@ module Appium
9894

9995
@enable_idempotency_header: bool
10096

101-
@default_wait: Integer
102-
10397
@port: Integer
10498

10599
@wait_timeout: Integer
@@ -124,8 +118,6 @@ module Appium
124118

125119
attr_reader custom_url: String
126120

127-
attr_reader default_wait: Integer
128-
129121
attr_reader port: Integer
130122

131123
DEFAULT_APPIUM_PORT: Integer
@@ -167,8 +159,6 @@ module Appium
167159

168160
def get_http_client: (?http_client: untyped?, ?open_timeout: untyped?, ?read_timeout: untyped?) -> untyped
169161

170-
def set_implicit_wait_by_default: (untyped wait) -> untyped
171-
172162
def appium_server_version: () -> Hash[String, String]
173163

174164
private

test/functional/android/webdriver/device_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ def test_dismiss_alert
117117

118118
def test_implicit_wait
119119
# checking no method error
120-
assert(@driver.manage.timeouts.implicit_wait = @@core.default_wait)
120+
assert(@driver.manage.timeouts.implicit_wait = 0)
121121
end
122122

123123
# Not so stable on CI

test/functional/android/webdriver/w3c_actions_test.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def test_tap_scroll
6060
@driver.find_element(:accessibility_id, 'Custom')
6161
end
6262
end
63-
@driver.manage.timeouts.implicit_wait = @@core.default_wait
63+
@driver.manage.timeouts.implicit_wait = 0
6464
end
6565

6666
def test_double_tap

test/test_helper.rb

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,6 @@ def android(activity_name = nil)
353353
uiautomator2ServerLaunchTimeout: 60_000 # ms
354354
},
355355
appium_lib: {
356-
wait: 5,
357356
wait_timeout: 20,
358357
wait_interval: 1
359358
}
@@ -381,7 +380,6 @@ def android_direct
381380
{
382381
capabilities: android[:capabilities],
383382
appium_lib: {
384-
wait: 30,
385383
wait_timeout: 20,
386384
wait_interval: 1,
387385
direct_connect: true
@@ -497,10 +495,6 @@ def android_mock_create_session_w3c
497495
stub_request(:post, 'http://127.0.0.1:4723/session')
498496
.to_return(headers: HEADER, status: 200, body: response)
499497

500-
stub_request(:post, "#{SESSION}/timeouts")
501-
.with(body: { implicit: 5_000 }.to_json)
502-
.to_return(headers: HEADER, status: 200, body: { value: nil }.to_json)
503-
504498
driver = @core.start_driver
505499
assert_equal ::Appium::Core::Base::Driver, driver.class
506500
assert_equal ::Appium::Core::Base::Bridge, driver.bridge.class
@@ -516,24 +510,6 @@ def android_mock_create_session_w3c
516510
},
517511
times: 1
518512
)
519-
520-
assert_requested(
521-
:post,
522-
"#{SESSION}/timeouts",
523-
headers: {
524-
'Content-Type' => 'application/json; charset=UTF-8',
525-
'User-Agent' => /appium\/ruby_lib_core\/.+/
526-
},
527-
body: { implicit: 5_000 }.to_json,
528-
times: 1
529-
)
530-
assert_not_requested(
531-
:post,
532-
"#{SESSION}/timeouts",
533-
headers: { 'X-Idempotency-Key' => /.+/ },
534-
body: { implicit: 5_000 }.to_json,
535-
times: 1
536-
)
537513
driver
538514
end
539515

@@ -554,10 +530,6 @@ def android_chrome_mock_create_session_w3c
554530
stub_request(:post, 'http://127.0.0.1:4723/session')
555531
.to_return(headers: HEADER, status: 200, body: response)
556532

557-
stub_request(:post, "#{SESSION}/timeouts")
558-
.with(body: { implicit: 5_000 }.to_json)
559-
.to_return(headers: HEADER, status: 200, body: { value: nil }.to_json)
560-
561533
driver = @core.start_driver
562534

563535
assert_equal({}, driver.send(:bridge).http.additional_headers)
@@ -571,24 +543,6 @@ def android_chrome_mock_create_session_w3c
571543
},
572544
times: 1
573545
)
574-
575-
assert_requested(
576-
:post,
577-
"#{SESSION}/timeouts",
578-
headers: {
579-
'Content-Type' => 'application/json; charset=UTF-8',
580-
'User-Agent' => /appium\/ruby_lib_core\/.+/
581-
},
582-
body: { implicit: 5_000 }.to_json,
583-
times: 1
584-
)
585-
assert_not_requested(
586-
:post,
587-
"#{SESSION}/timeouts",
588-
headers: { 'X-Idempotency-Key' => /.+/ },
589-
body: { implicit: 5_000 }.to_json,
590-
times: 1
591-
)
592546
driver
593547
end
594548

test/unit/appium_lib_core_test.rb

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -20,50 +20,6 @@ def test_version
2020
assert !::Appium::Core::VERSION.nil?
2121
end
2222

23-
# TODO: Should be removed in the future
24-
def test_symbolize_keys
25-
result = ::Appium.symbolize_keys({ 'a' => 1, b: 2 })
26-
assert_equal({ a: 1, b: 2 }, result)
27-
end
28-
29-
def test_not_symbolize_keys_nested1
30-
result = ::Appium.symbolize_keys(
31-
{ 'caps': { 'automationName' => 'xcuitest', platformName: :ios } }, nested: true
32-
)
33-
assert_equal({ caps: { automationName: 'xcuitest', platformName: :ios } }, result)
34-
end
35-
36-
def test_not_symbolize_keys_nested2
37-
result = ::Appium.symbolize_keys(
38-
{ 'caps': { 'automationName' => 'xcuitest', platformName: :ios, other_caps: { 'something1': 1, something2: 2 } } },
39-
nested: true
40-
)
41-
assert_equal(
42-
{ caps: { automationName: 'xcuitest', platformName: :ios, other_caps: { 'something1': 1, something2: 2 } } },
43-
result
44-
)
45-
end
46-
47-
def test_not_symbolize_keys_nested3
48-
result = ::Appium.symbolize_keys(
49-
{ 'caps': { 'automationName' => 'xcuitest', platformName: :ios, other_caps: { 'something1': 1, something2: 2 } } },
50-
nested: false
51-
)
52-
assert_equal(
53-
{ caps: { 'automationName' => 'xcuitest', platformName: :ios, other_caps: { 'something1': 1, something2: 2 } } },
54-
result
55-
)
56-
end
57-
58-
# TODO: Should be removed in the future
59-
def test_symbolize_keys_raise_argument_error
60-
e = assert_raises ::Appium::Core::Error::ArgumentError do
61-
::Appium.symbolize_keys('no hash value')
62-
end
63-
64-
assert_equal 'symbolize_keys requires a hash', e.message
65-
end
66-
6723
def test_core_instance_variables
6824
opts = {
6925
url: 'http://custom-host:8080/wd/hub/path',

0 commit comments

Comments
 (0)