@@ -92,15 +92,12 @@ def close
92
92
end
93
93
94
94
def resize ( width : nil , height : nil , fullscreen : false )
95
- result = @browser . command ( "Browser.getWindowForTarget" , targetId : @target_id )
96
- @window_id , @bounds = result . values_at ( "windowId" , "bounds" )
97
-
98
95
if fullscreen
99
96
width , height = document_size
100
- @browser . command ( "Browser.setWindowBounds" , windowId : @window_id , bounds : { windowState : "fullscreen" } )
97
+ set_window_bounds ( windowState : "fullscreen" )
101
98
else
102
- @browser . command ( "Browser.setWindowBounds" , windowId : @window_id , bounds : { windowState : "normal" } )
103
- @browser . command ( "Browser.setWindowBounds" , windowId : @window_id , bounds : { width : width , height : height , windowState : "normal" } )
99
+ set_window_bounds ( windowState : "normal" )
100
+ set_window_bounds ( width : width , height : height )
104
101
end
105
102
106
103
command ( "Emulation.setDeviceMetricsOverride" , slowmoable : true ,
@@ -140,6 +137,14 @@ def bypass_csp(value = true)
140
137
enabled
141
138
end
142
139
140
+ def window_id
141
+ @browser . command ( "Browser.getWindowForTarget" , targetId : @target_id ) [ "windowId" ]
142
+ end
143
+
144
+ def set_window_bounds ( bounds = { } )
145
+ @browser . command ( "Browser.setWindowBounds" , windowId : window_id , bounds : bounds )
146
+ end
147
+
143
148
def command ( method , wait : 0 , slowmoable : false , **params )
144
149
iteration = @event . reset if wait > 0
145
150
sleep ( @browser . slowmo ) if slowmoable && @browser . slowmo > 0
0 commit comments