@@ -124,14 +124,10 @@ def position
124124 @browser . command ( "Browser.getWindowBounds" , windowId : window_id ) . fetch ( "bounds" ) . values_at ( "left" , "top" )
125125 end
126126
127- def position = ( *args )
128- if args . size == 1
129- left = args [ 0 ] [ :left ]
130- top = args [ 0 ] [ :top ]
131- else
132- raise "Use like: browser.position = { left: 1, right: 2}"
133- end
134- @browser . command ( "Browser.setWindowBounds" , windowId : window_id , bounds : { left : left , top : top } )
127+ def position = ( options )
128+ @browser . command ( "Browser.setWindowBounds" ,
129+ windowId : window_id ,
130+ bounds : { left : options [ :left ] , top : options [ :top ] } )
135131 end
136132
137133 def refresh
@@ -279,7 +275,7 @@ def prepare_page
279275
280276 response = command ( "Page.getNavigationHistory" )
281277 if response . dig ( "entries" , 0 , "transitionType" ) != "typed"
282- # If we create page by clicking links, submiting forms and so on it
278+ # If we create page by clicking links, submitting forms and so on it
283279 # opens a new window for which `frameStoppedLoading` event never
284280 # occurs and thus search for nodes cannot be completed. Here we check
285281 # the history and if the transitionType for example `link` then
@@ -304,13 +300,15 @@ def inject_extensions
304300 def history_navigate ( delta :)
305301 history = command ( "Page.getNavigationHistory" )
306302 index , entries = history . values_at ( "currentIndex" , "entries" )
303+ entry = entries [ index + delta ]
307304
308- if entry = entries [ index + delta ]
309- # Potential wait because of network event
310- command ( "Page.navigateToHistoryEntry" , wait : Mouse ::CLICK_WAIT ,
311- slowmoable : true ,
312- entryId : entry [ "id" ] )
313- end
305+ return unless entry
306+
307+ # Potential wait because of network event
308+ command ( "Page.navigateToHistoryEntry" ,
309+ wait : Mouse ::CLICK_WAIT ,
310+ slowmoable : true ,
311+ entryId : entry [ "id" ] )
314312 end
315313
316314 def combine_url! ( url_or_path )
0 commit comments