@@ -13,6 +13,41 @@ module Ios
13
13
autoload :Xcuitest , 'appium_lib_core/ios_xcuitest'
14
14
end
15
15
16
+ # This options affects only client side as <code>:appium_lib</code> key.<br>
17
+ # Read {::Appium::Core::Driver} about each attribute
18
+ class Options
19
+ attr_reader :custom_url , :default_wait , :export_session , :export_session_path ,
20
+ :port , :wait_timeout , :wait_interval , :listener ,
21
+ :direct_connect
22
+
23
+ def initialize ( appium_lib_opts )
24
+ @custom_url = appium_lib_opts . fetch :server_url , nil
25
+ @default_wait = appium_lib_opts . fetch :wait , Driver ::DEFAULT_IMPLICIT_WAIT
26
+
27
+ # bump current session id into a particular file
28
+ @export_session = appium_lib_opts . fetch :export_session , false
29
+ @export_session_path = appium_lib_opts . fetch :export_session_path , default_tmp_appium_lib_session
30
+
31
+ @direct_connect = appium_lib_opts . fetch :direct_connect , false
32
+
33
+ @port = appium_lib_opts . fetch :port , Driver ::DEFAULT_APPIUM_PORT
34
+
35
+ # timeout and interval used in ::Appium::Comm.wait/wait_true
36
+ @wait_timeout = appium_lib_opts . fetch :wait_timeout , ::Appium ::Core ::Wait ::DEFAULT_TIMEOUT
37
+ @wait_interval = appium_lib_opts . fetch :wait_interval , ::Appium ::Core ::Wait ::DEFAULT_INTERVAL
38
+
39
+ # to pass it in Selenium.new.
40
+ # `listener = opts.delete(:listener)` is called in Selenium::Driver.new
41
+ @listener = appium_lib_opts . fetch :listener , nil
42
+ end
43
+
44
+ private
45
+
46
+ def default_tmp_appium_lib_session
47
+ ::Appium ::Core ::Base . platform . windows? ? 'C:\\\\Windows\\Temp\\appium_lib_session' : '/tmp/appium_lib_session'
48
+ end
49
+ end
50
+
16
51
class Driver
17
52
include Waitable
18
53
# Selenium webdriver capabilities
@@ -43,7 +78,8 @@ class Driver
43
78
# @return [String] By default, session id is exported in '/tmp/appium_lib_session'
44
79
attr_reader :export_session_path
45
80
46
- # Default wait time for elements to appear in Appium server side. Defaults to {::Appium::Core::Driver::DEFAULT_IMPLICIT_WAIT}.<br>
81
+ # Default wait time for elements to appear in Appium server side.
82
+ # Defaults to {::Appium::Core::Driver::DEFAULT_IMPLICIT_WAIT}.<br>
47
83
# Provide <code>{ appium_lib: { wait: 30 } }</code> to {::Appium::Core.for}
48
84
# @return [Integer]
49
85
attr_reader :default_wait
@@ -77,7 +113,9 @@ class Driver
77
113
78
114
# <b>[Experimental feature]</b><br>
79
115
# Enable an experimental feature updating Http client endpoint following below keys by Appium/Selenium server.<br>
80
- # If your Selenium/Appium server decorates the new session capabilities response with the following keys:
116
+ # This works with {Appium::Core::Base::Http::Default}.
117
+ #
118
+ # If your Selenium/Appium server decorates the new session capabilities response with the following keys:<br>
81
119
# - <code>directConnectProtocol</code>
82
120
# - <code>directConnectHost</code>
83
121
# - <code>directConnectPort</code>
@@ -88,8 +126,15 @@ class Driver
88
126
# @return [Bool]
89
127
attr_reader :direct_connect
90
128
91
- # Creates a new global driver and extend particular methods to <code>target</code>
129
+ # Creates a new driver and extend particular methods
92
130
# @param [Hash] opts A options include capabilities for the Appium Server and for the client.
131
+ # @option opts [Hash] :caps Appium capabilities. Prior than :desired_capabilities
132
+ # @option opts [Hash] :desired_capabilities The same as :caps.
133
+ # This param is for compatibility with Selenium WebDriver format
134
+ # @option opts [Appium::Core::Options] :appium_lib Capabilities affect only ruby client
135
+ # @option opts [String] :url The same as :custom_url in :appium_lib.
136
+ # This param is for compatibility with Selenium WebDriver format
137
+ #
93
138
# @return [Driver]
94
139
#
95
140
# @example
@@ -465,25 +510,25 @@ def set_app_path
465
510
end
466
511
467
512
# @private
513
+ # Below capabilities are set only for client side.
468
514
def set_appium_lib_specific_values ( appium_lib_opts )
469
- @custom_url ||= appium_lib_opts . fetch :server_url , nil
470
- @default_wait = appium_lib_opts . fetch :wait , DEFAULT_IMPLICIT_WAIT
515
+ opts = Options . new appium_lib_opts
471
516
472
- # bump current session id into a particular file
473
- @export_session = appium_lib_opts . fetch :export_session , false
474
- @export_session_path = appium_lib_opts . fetch :export_session_path , default_tmp_appium_lib_session
517
+ @custom_url ||= opts . custom_url # Keep existence capability if it's already provided
475
518
476
- @direct_connect = appium_lib_opts . fetch :direct_access , false
519
+ @default_wait = opts . default_wait
477
520
478
- @port = appium_lib_opts . fetch :port , DEFAULT_APPIUM_PORT
521
+ @export_session = opts . export_session
522
+ @export_session_path = opts . export_session_path
479
523
480
- # timeout and interval used in ::Appium::Comm.wait/wait_true
481
- @wait_timeout = appium_lib_opts . fetch :wait_timeout , ::Appium ::Core ::Wait ::DEFAULT_TIMEOUT
482
- @wait_interval = appium_lib_opts . fetch :wait_interval , ::Appium ::Core ::Wait ::DEFAULT_INTERVAL
524
+ @port = opts . port
483
525
484
- # to pass it in Selenium.new.
485
- # `listener = opts.delete(:listener)` is called in Selenium::Driver.new
486
- @listener = appium_lib_opts . fetch :listener , nil
526
+ @wait_timeout = opts . wait_timeout
527
+ @wait_interval = opts . wait_interval
528
+
529
+ @listener = opts . listener
530
+
531
+ @direct_connect = opts . direct_connect
487
532
end
488
533
489
534
# @private
@@ -512,11 +557,6 @@ def set_automation_name_if_nil
512
557
end
513
558
end
514
559
515
- # @private
516
- def default_tmp_appium_lib_session
517
- ::Appium ::Core ::Base . platform . windows? ? 'C:\\\\Windows\\Temp\\appium_lib_session' : '/tmp/appium_lib_session'
518
- end
519
-
520
560
# @private
521
561
def write_session_id ( session_id , export_path = '/tmp/appium_lib_session' )
522
562
export_path . tr! ( '/' , '\\' ) if ::Appium ::Core ::Base . platform . windows?
0 commit comments