@@ -40,22 +40,15 @@ class Capabilities
40
40
:unhandled_prompt_behavior ,
41
41
:strict_file_interactability ,
42
42
43
- # remote-specific
44
- :remote_session_id ,
45
-
46
- # TODO: (AR) deprecate compatibility with OSS-capabilities
47
- :implicit_timeout ,
48
- :page_load_timeout ,
49
- :script_timeout
43
+ # remote-specific (webdriver.remote.sessionid)
44
+ :remote_session_id
50
45
] . freeze
51
46
52
47
KNOWN . each do |key |
53
48
define_method key do
54
49
@capabilities . fetch ( key )
55
50
end
56
51
57
- next if key == :proxy
58
-
59
52
define_method "#{ key } =" do |value |
60
53
@capabilities [ key ] = value
61
54
end
@@ -89,16 +82,10 @@ def edge(opts = {})
89
82
alias_method :microsoftedge , :edge
90
83
91
84
def firefox ( opts = { } )
92
- opts [ :browser_version ] = opts . delete ( :version ) if opts . key? ( :version )
93
- opts [ :platform_name ] = opts . delete ( :platform ) if opts . key? ( :platform )
94
- opts [ :timeouts ] = { }
95
- opts [ :timeouts ] [ 'implicit' ] = opts . delete ( :implicit_timeout ) if opts . key? ( :implicit_timeout )
96
- opts [ :timeouts ] [ 'pageLoad' ] = opts . delete ( :page_load_timeout ) if opts . key? ( :page_load_timeout )
97
- opts [ :timeouts ] [ 'script' ] = opts . delete ( :script_timeout ) if opts . key? ( :script_timeout )
98
- opts . delete ( :timeouts ) if opts [ :timeouts ] . empty?
99
- new ( { browser_name : 'firefox' } . merge ( opts ) )
85
+ new ( {
86
+ browser_name : 'firefox'
87
+ } . merge ( opts ) )
100
88
end
101
-
102
89
alias_method :ff , :firefox
103
90
104
91
def safari ( opts = { } )
@@ -135,12 +122,7 @@ def first_match(*capabilities)
135
122
136
123
def json_create ( data )
137
124
data = data . dup
138
-
139
125
caps = new
140
- ( KNOWN - %i[ timeouts proxy ] ) . each do |cap |
141
- data_value = camel_case ( cap )
142
- caps [ cap ] = data . delete ( data_value ) if data . key? ( data_value )
143
- end
144
126
145
127
process_timeouts ( caps , data . delete ( 'timeouts' ) )
146
128
@@ -154,6 +136,11 @@ def json_create(data)
154
136
caps [ :remote_session_id ] = data . delete ( 'webdriver.remote.sessionid' )
155
137
end
156
138
139
+ KNOWN . each do |cap |
140
+ data_value = camel_case ( cap )
141
+ caps [ cap ] = data . delete ( data_value ) if data . key? ( data_value )
142
+ end
143
+
157
144
# any remaining pairs will be added as is, with no conversion
158
145
caps . merge! ( data )
159
146
@@ -225,6 +212,34 @@ def proxy=(proxy)
225
212
end
226
213
end
227
214
215
+ def timeouts
216
+ @capabilities [ :timeouts ] ||= { }
217
+ end
218
+
219
+ def implicit_timeout
220
+ timeouts [ :implicit ]
221
+ end
222
+
223
+ def implicit_timeout = ( timeout )
224
+ timeouts [ :implicit ] = timeout
225
+ end
226
+
227
+ def page_load_timeout
228
+ timeouts [ :page_load ] || timeouts [ :pageLoad ]
229
+ end
230
+
231
+ def page_load_timeout = ( timeout )
232
+ timeouts [ :page_load ] = timeout
233
+ end
234
+
235
+ def script_timeout
236
+ timeouts [ :script ]
237
+ end
238
+
239
+ def script_timeout = ( timeout )
240
+ timeouts [ :script ] = timeout
241
+ end
242
+
228
243
#
229
244
# @api private
230
245
#
0 commit comments