class Selenium::WebDriver::BiDi::BrowsingContext
@api private
Implements the browsingContext Module of the WebDriver-BiDi specification
def activate(context_id: nil)
def activate(context_id: nil) context_id ||= @bridge.window_handle @bidi.send_cmd('browsingContext.activate', context: context_id) end
def close(context_id: nil)
-
context_id
(String
) -- The ID of the context to close.
def close(context_id: nil) context_id ||= @bridge.window_handle @bidi.send_cmd('browsingContext.close', context: context_id) end
def create(type: nil, context_id: nil)
-
(String)
- The context ID of the created browsing context.
Parameters:
-
context_id
(String
) -- The reference context for the new browsing context. -
type
(Symbol
) -- The type of browsing context to create.
def create(type: nil, context_id: nil) type ||= :window context_id ||= @bridge.window_handle result = @bidi.send_cmd('browsingContext.create', type: type.to_s, referenceContext: context_id) result['context'] end
def handle_user_prompt(context_id, accept: true, text: nil)
def handle_user_prompt(context_id, accept: true, text: nil) @bidi.send_cmd('browsingContext.handleUserPrompt', context: context_id, accept: accept, text: text) end
def initialize(bridge)
def initialize(bridge) @bridge = bridge @bidi = @bridge.bidi page_load_strategy = bridge.capabilities[:page_load_strategy] @readiness = READINESS_STATE[page_load_strategy] end
def navigate(url, context_id: nil)
-
context_id
(String, NilClass
) -- The ID of the browsing context to navigate in. -
url
(String
) -- The URL to navigate to.
def navigate(url, context_id: nil) context_id ||= @bridge.window_handle @bidi.send_cmd('browsingContext.navigate', context: context_id, url: url, wait: @readiness) end
def reload(context_id: nil, ignore_cache: false)
-
ignore_cache
(Boolean
) -- Whether to bypass the cache when reloading. -
context_id
(String, NilClass
) -- The ID of the context to reload.
def reload(context_id: nil, ignore_cache: false) context_id ||= @bridge.window_handle params = {context: context_id, ignore_cache: ignore_cache, wait: @readiness} @bidi.send_cmd('browsingContext.reload', **params) end
def set_viewport(context_id: nil, width: nil, height: nil, device_pixel_ratio: nil)
def set_viewport(context_id: nil, width: nil, height: nil, device_pixel_ratio: nil) context_id ||= @bridge.window_handle params = {context: context_id, viewport: {width:, height:}, device_pixel_ratio:} @bidi.send_cmd('browsingContext.setViewport', **params) end
def traverse_history(delta, context_id: nil)
-
context_id
(String, NilClass
) -- The ID of the context to traverse. -
delta
(Integer
) -- The number of steps to traverse.
def traverse_history(delta, context_id: nil) context_id ||= @bridge.window_handle @bidi.send_cmd('browsingContext.traverseHistory', context: context_id, delta: delta) end