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 Continue to use functionality from existing driver.navigate method
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
- #activate(context_id: nil) ⇒ Object private
-
#close(context_id: nil) ⇒ Object
private
Closes the browsing context.
-
#create(type: nil, context_id: nil) ⇒ String
private
Create a new browsing context.
- #handle_user_prompt(context_id, accept: true, text: nil) ⇒ Object private
-
#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.
- #set_viewport(context_id: nil, width: nil, height: nil, device_pixel_ratio: nil) ⇒ Object private
-
#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
36 37 38 39 40 41 |
# File 'lib/selenium/webdriver/bidi/browsing_context.rb', line 36 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
#activate(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.
109 110 111 112 |
# File 'lib/selenium/webdriver/bidi/browsing_context.rb', line 109 def activate(context_id: nil) context_id ||= @bridge.window_handle @bidi.send_cmd('browsingContext.activate', context: context_id) end |
#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.
79 80 81 82 |
# File 'lib/selenium/webdriver/bidi/browsing_context.rb', line 79 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.
92 93 94 95 96 97 |
# File 'lib/selenium/webdriver/bidi/browsing_context.rb', line 92 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 |
#handle_user_prompt(context_id, accept: true, text: 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.
105 106 107 |
# File 'lib/selenium/webdriver/bidi/browsing_context.rb', line 105 def handle_user_prompt(context_id, accept: true, text: nil) @bidi.send_cmd('browsingContext.handleUserPrompt', context: context_id, accept: accept, text: text) 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.
48 49 50 51 |
# File 'lib/selenium/webdriver/bidi/browsing_context.rb', line 48 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.
69 70 71 72 73 |
# File 'lib/selenium/webdriver/bidi/browsing_context.rb', line 69 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 |
#set_viewport(context_id: nil, width: nil, height: nil, device_pixel_ratio: 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.
99 100 101 102 103 |
# File 'lib/selenium/webdriver/bidi/browsing_context.rb', line 99 def (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 |
#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.
59 60 61 62 |
# File 'lib/selenium/webdriver/bidi/browsing_context.rb', line 59 def traverse_history(delta, context_id: nil) context_id ||= @bridge.window_handle @bidi.send_cmd('browsingContext.traverseHistory', context: context_id, delta: delta) end |