123456789_123456789_123456789_123456789_123456789_

Class: Selenium::WebDriver::BiDi::BrowsingContext Private

Do not use. This class is for internal use only.
Relationships & Source Files
Inherits: Object
Defined in: rb/lib/selenium/webdriver/bidi/browsing_context.rb

Overview

Implements the browsingContext Module of the WebDriver-BiDi specification

Constant Summary

Class Method Summary

Instance Method Summary

Constructor Details

.new(bridge) ⇒ BrowsingContext

TODO: store current window handle in bridge object instead of always calling it

[ GitHub ]

  
# File 'rb/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

Instance Method Details

#close(context_id: nil)

Closes the browsing context.

Parameters:

  • context_id (String)

    The ID of the context to close. Defaults to the window handle of the current context.

[ GitHub ]

  
# File 'rb/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

#create(type: nil, context_id: nil) ⇒ String

Create a new browsing context.

Parameters:

  • type (Symbol)

    The type of browsing context to create. Valid options are :tab and :window with :window being the default

  • context_id (String)

    The reference context for the new browsing context. Defaults to the current window handle.

Returns:

  • (String)

    The context ID of the created browsing context.

[ GitHub ]

  
# File 'rb/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

#reload(context_id: nil, ignore_cache: false)

Reloads the browsing context.

Parameters:

  • context_id (String, NilClass)

    The ID of the context to reload. Defaults to the window handle of the current context.

  • ignore_cache (Boolean)

    Whether to bypass the cache when reloading. Defaults to false.

[ GitHub ]

  
# File 'rb/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

#traverse_history(delta, context_id: nil)

Traverses the browsing context history by a given delta.

Parameters:

  • delta (Integer)

    The number of steps to traverse. Positive values go forwards, negative values go backwards.

  • context_id (String, NilClass)

    The ID of the context to traverse. Defaults to the window handle of the current context.

[ GitHub ]

  
# File 'rb/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