File tree Expand file tree Collapse file tree 4 files changed +17
-34
lines changed
spec/integration/selenium/webdriver/bidi Expand file tree Collapse file tree 4 files changed +17
-34
lines changed Original file line number Diff line number Diff line change @@ -320,23 +320,11 @@ def ref
320320 attr_reader :bridge
321321
322322 def create_bridge ( caps :, url :, http_client : nil )
323- if caps [ 'webSocketUrl' ]
324- ws_options =
325- {
326- response_timeout : caps [ :'ws:response_timeout' ] ,
327- response_interval : caps [ :'ws:response_interval' ]
328- } . compact
329-
330- klass = Remote ::BiDiBridge
331- bridge_opts = { http_client : http_client , url : url , ws_options : ws_options }
332- else
333- klass = Remote ::Bridge
334- bridge_opts = { http_client : http_client , url : url }
335- end
323+ klass = caps [ 'webSocketUrl' ] ? Remote ::BiDiBridge : Remote ::Bridge
336324
337- klass . new ( ** bridge_opts ) . tap do | bridge |
338- bridge . create_session ( caps )
339- end
325+ bridge = klass . new ( http_client : http_client , url : url )
326+ bridge . create_session ( caps )
327+ bridge
340328 end
341329
342330 def service_url ( service )
Original file line number Diff line number Diff line change @@ -26,7 +26,7 @@ class Options
2626
2727 GRID_OPTIONS = %i[ enable_downloads ] . freeze
2828
29- WEBSOCKET_OPTIONS = %i[ ws:response_timeout ws:response_interval ] . freeze
29+ WEBSOCKET_OPTIONS = %i[ web_socket_timeout web_socket_interval ] . freeze
3030
3131 class << self
3232 attr_reader :driver_path
@@ -110,6 +110,8 @@ def as_json(*)
110110
111111 downloads = options . delete ( :enable_downloads )
112112 options [ 'se:downloadsEnabled' ] = downloads unless downloads . nil?
113+ options [ 'ws:response_timeout' ] = options . delete ( :web_socket_timeout ) if options [ :web_socket_timeout ]
114+ options [ 'ws:response_interval' ] = options . delete ( :web_socket_interval ) if options [ :web_socket_interval ]
113115 w3c_options = process_w3c_options ( options )
114116
115117 browser_options = self . class ::CAPABILITIES . each_with_object ( { } ) do |( capability_alias , capability_name ) , hash |
Original file line number Diff line number Diff line change @@ -23,15 +23,16 @@ module Remote
2323 class BiDiBridge < Bridge
2424 attr_reader :bidi
2525
26- def initialize ( url :, http_client : nil , ws_options : { } )
27- super ( url : url , http_client : http_client )
28- @ws_options = ws_options
29- end
30-
3126 def create_session ( capabilities )
3227 super
3328 socket_url = @capabilities [ :web_socket_url ]
34- @bidi = Selenium ::WebDriver ::BiDi . new ( url : socket_url , options : @ws_options )
29+
30+ ws_options = {
31+ response_timeout : capabilities [ 'ws:responseTimeout' ] ,
32+ response_interval : capabilities [ 'ws:responseInterval' ]
33+ } . compact
34+
35+ @bidi = Selenium ::WebDriver ::BiDi . new ( url : socket_url , options : ws_options )
3536 end
3637
3738 def get ( url )
Original file line number Diff line number Diff line change @@ -133,21 +133,13 @@ class BiDi
133133 expect ( driver . execute_script ( 'return document.hasFocus();' ) ) . to be_truthy
134134 end
135135
136- it 'times out if a bidi command takes too long to receive a response ' do
137- reset_driver! ( web_socket_url : true , 'ws:response_timeout' : 1 ) do |driver |
136+ it 'times out if a command takes too long' do
137+ reset_driver! ( web_socket_url : true , web_socket_timeout : 0.1 , web_socket_interval : 1 ) do |driver |
138138 expect {
139- driver . navigate . to url_for ( 'sleep?time=2' )
139+ driver . navigate . to url_for ( 'sleep?time=0. 2' )
140140 } . to raise_error ( Selenium ::WebDriver ::Error ::TimeoutError )
141141 end
142142 end
143-
144- it 'does not time out if a bidi command is fast enough' do
145- reset_driver! ( web_socket_url : true , 'ws:response_timeout' : 5 ) do |driver |
146- expect {
147- driver . navigate . to url_for ( 'sleep?time=1' )
148- } . not_to raise_error
149- end
150- end
151143 end
152144 end # BiDi
153145 end # WebDriver
You can’t perform that action at this time.
0 commit comments