class Selenium::WebDriver::BiDi::BrowsingContext
Implements the browsingContext Module of the WebDriver-BiDi specification
@api private
Constants
- READINESS_STATE
Public Class Methods
Source
# File lib/selenium/webdriver/bidi/browsing_context.rb, line 35 def initialize(bridge) @bridge = bridge @bidi = @bridge.bidi page_load_strategy = bridge.capabilities[:page_load_strategy] @readiness = READINESS_STATE[page_load_strategy] end
TODO: store current window handle in bridge object instead of always calling it
Public Instance Methods
Source
# File lib/selenium/webdriver/bidi/browsing_context.rb, line 78 def close(context_id: nil) context_id ||= @bridge.window_handle @bidi.send_cmd('browsingContext.close', context: context_id) end
Closes the browsing context.
@param [String] context_id The ID of the context to close.
Defaults to the window handle of the current context.
Source
# File lib/selenium/webdriver/bidi/browsing_context.rb, line 91 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
Create a new browsing context.
@param [Symbol] type The type of browsing context to create.
Valid options are :tab and :window with :window being the default
@param [String] context_id The reference context for the new browsing context.
Defaults to the current window handle.
@return [String] The context ID of the created browsing context.
Source
# File lib/selenium/webdriver/bidi/browsing_context.rb, line 68 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
Reloads the browsing context. @param [String, NilClass] context_id The ID of the context to reload.
Defaults to the window handle of the current context.
@param [Boolean] ignore_cache Whether to bypass the cache when reloading.
Defaults to false.
Source
# File lib/selenium/webdriver/bidi/browsing_context.rb, line 58 def traverse_history(delta, context_id: nil) context_id ||= @bridge.window_handle @bidi.send_cmd('browsingContext.traverseHistory', context: context_id, delta: delta) end
Traverses the browsing context history by a given delta.
@param delta [Integer] The number of steps to traverse.
Positive values go forwards, negative values go backwards.
@param context_id [String, NilClass] The ID of the context to traverse.
Defaults to the window handle of the current context.