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