Class: Selenium::WebDriver::BiDi::BrowsingContext Private
- Inherits:
-
Object
- Object
- Selenium::WebDriver::BiDi::BrowsingContext
- Defined in:
- lib/selenium/webdriver/bidi/browsing_context.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Implements the browsingContext Module of the WebDriver-BiDi specification
Constant Summary collapse
- READINESS_STATE =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
{ 'none' => 'none', 'eager' => 'interactive', 'normal' => 'complete' }.freeze
Instance Method Summary collapse
-
#close(context_id: nil) ⇒ Object
private
Closes the browsing context.
-
#create(type: nil, context_id: nil) ⇒ String
private
Create a new browsing context.
-
#initialize(bridge) ⇒ BrowsingContext
constructor
private
TODO: store current window handle in bridge object instead of always calling it.
-
#navigate(url, context_id: nil) ⇒ Object
private
Navigates to the specified URL in the given browsing context.
-
#reload(context_id: nil, ignore_cache: false) ⇒ Object
private
Reloads the browsing context.
-
#traverse_history(delta, context_id: nil) ⇒ Object
private
Traverses the browsing context history by a given delta.
Constructor Details
#initialize(bridge) ⇒ BrowsingContext
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
TODO: store current window handle in bridge object instead of always calling it
35 36 37 38 39 40 |
# 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 |
Instance Method Details
#close(context_id: nil) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Closes the browsing context.
78 79 80 81 |
# 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 |
#create(type: nil, context_id: nil) ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Create a new browsing context.
91 92 93 94 95 96 |
# 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 |
#navigate(url, context_id: nil) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Navigates to the specified URL in the given browsing context.
47 48 49 50 |
# File 'lib/selenium/webdriver/bidi/browsing_context.rb', line 47 def navigate(url, context_id: nil) context_id ||= @bridge.window_handle @bidi.send_cmd('browsingContext.navigate', context: context_id, url: url, wait: @readiness) end |
#reload(context_id: nil, ignore_cache: false) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Reloads the browsing context.
68 69 70 71 72 |
# 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 |
#traverse_history(delta, context_id: nil) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Traverses the browsing context history by a given delta.
58 59 60 61 |
# 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 |