@@ -32,6 +32,7 @@ class BrowsingContext
3232 } . freeze
3333
3434 # TODO: store current window handle in bridge object instead of always calling it
35+ # @rbs (Selenium::WebDriver::Remote::BiDiBridge) -> void
3536 def initialize ( bridge )
3637 @bridge = bridge
3738 @bidi = @bridge . bidi
@@ -44,6 +45,7 @@ def initialize(bridge)
4445 # @param url [String] The URL to navigate to.
4546 # @param context_id [String, NilClass] The ID of the browsing context to navigate in.
4647 # Defaults to the window handle of the current context.
48+ # @rbs (String, ?context_id: nil) -> Hash[untyped, untyped]
4749 def navigate ( url , context_id : nil )
4850 context_id ||= @bridge . window_handle
4951 @bidi . send_cmd ( 'browsingContext.navigate' , context : context_id , url : url , wait : @readiness )
@@ -55,6 +57,7 @@ def navigate(url, context_id: nil)
5557 # Positive values go forwards, negative values go backwards.
5658 # @param context_id [String, NilClass] The ID of the context to traverse.
5759 # Defaults to the window handle of the current context.
60+ # @rbs (Integer, ?context_id: nil) -> Hash[untyped, untyped]
5861 def traverse_history ( delta , context_id : nil )
5962 context_id ||= @bridge . window_handle
6063 @bidi . send_cmd ( 'browsingContext.traverseHistory' , context : context_id , delta : delta )
@@ -65,6 +68,7 @@ def traverse_history(delta, context_id: nil)
6568 # Defaults to the window handle of the current context.
6669 # @param [Boolean] ignore_cache Whether to bypass the cache when reloading.
6770 # Defaults to false.
71+ # @rbs (?context_id: nil, ?ignore_cache: bool) -> Hash[untyped, untyped]
6872 def reload ( context_id : nil , ignore_cache : false )
6973 context_id ||= @bridge . window_handle
7074 params = { context : context_id , ignore_cache : ignore_cache , wait : @readiness }
@@ -75,6 +79,7 @@ def reload(context_id: nil, ignore_cache: false)
7579 #
7680 # @param [String] context_id The ID of the context to close.
7781 # Defaults to the window handle of the current context.
82+ # @rbs (?context_id: String) -> void
7883 def close ( context_id : nil )
7984 context_id ||= @bridge . window_handle
8085 @bidi . send_cmd ( 'browsingContext.close' , context : context_id )
@@ -88,23 +93,27 @@ def close(context_id: nil)
8893 # Defaults to the current window handle.
8994 #
9095 # @return [String] The context ID of the created browsing context.
96+ # @rbs (?type: nil, ?context_id: nil) -> String
9197 def create ( type : nil , context_id : nil )
9298 type ||= :window
9399 context_id ||= @bridge . window_handle
94100 result = @bidi . send_cmd ( 'browsingContext.create' , type : type . to_s , referenceContext : context_id )
95101 result [ 'context' ]
96102 end
97103
104+ # @rbs (?context_id: nil, ?width: Integer, ?height: Integer, ?device_pixel_ratio: Float) -> void
98105 def set_viewport ( context_id : nil , width : nil , height : nil , device_pixel_ratio : nil )
99106 context_id ||= @bridge . window_handle
100107 params = { context : context_id , viewport : { width :, height :} , device_pixel_ratio :}
101108 @bidi . send_cmd ( 'browsingContext.setViewport' , **params )
102109 end
103110
111+ # @rbs (String, ?accept: bool, ?text: nil | String) -> void
104112 def handle_user_prompt ( context_id , accept : true , text : nil )
105113 @bidi . send_cmd ( 'browsingContext.handleUserPrompt' , context : context_id , accept : accept , text : text )
106114 end
107115
116+ # @rbs (?context_id: nil) -> void
108117 def activate ( context_id : nil )
109118 context_id ||= @bridge . window_handle
110119 @bidi . send_cmd ( 'browsingContext.activate' , context : context_id )
0 commit comments