Class: Selenium::WebDriver::Remote::BiDiBridge
| Relationships & Source Files | |
| Super Chains via Extension / Inclusion / Inheritance | |
|
Class Chain:
self,
Bridge
|
|
|
Instance Chain:
|
|
| Inherits: |
Selenium::WebDriver::Remote::Bridge
|
| Defined in: | rb/lib/selenium/webdriver/remote/bidi_bridge.rb |
Constant Summary
-
READINESS_STATE =
# File 'rb/lib/selenium/webdriver/remote/bidi_bridge.rb', line 29{ 'none' => :none, 'eager' => :interactive, 'normal' => :complete }.freeze
Bridge - Inherited
Class Attribute Summary
Bridge - Inherited
Class Method Summary
Bridge - Inherited
Instance Attribute Summary
- #bidi readonly
- #connection readonly
Bridge - Inherited
| #alert=, #bidi?, #capabilities, #file_detector, #http, | |
| #timeouts | timeouts. |
| #timeouts= | |
Instance Method Summary
- #close
- #create_session(capabilities)
- #get(url)
- #go_back
- #go_forward
- #install_web_extension(path)
- #quit
- #refresh
- #uninstall_web_extension(id)
- #browsing_context private
- #readiness_state private
- #validated_socket_url private
- #web_extension private
-
#web_extension_data(path)
private
A directory only resolves on the machine running the browser, so upload it to the remote end and reference the returned path; archives and base64 bytes travel inline.
Bridge - Inherited
::Selenium::WebDriver::Atoms - Included
Constructor Details
This class inherits a constructor from Selenium::WebDriver::Remote::Bridge
Instance Attribute Details
#bidi (readonly)
[ GitHub ]# File 'rb/lib/selenium/webdriver/remote/bidi_bridge.rb', line 27
attr_reader :bidi, :connection
#connection (readonly)
[ GitHub ]# File 'rb/lib/selenium/webdriver/remote/bidi_bridge.rb', line 27
attr_reader :bidi, :connection
Instance Method Details
#browsing_context (private)
[ GitHub ]# File 'rb/lib/selenium/webdriver/remote/bidi_bridge.rb', line 100
def browsing_context @browsing_context ||= BiDi::Protocol::BrowsingContext.new(connection) end
#close
[ GitHub ]# File 'rb/lib/selenium/webdriver/remote/bidi_bridge.rb', line 86
def close execute(:close_window).tap { |handles| bidi.close if handles.empty? } end
#create_session(capabilities)
[ GitHub ]# File 'rb/lib/selenium/webdriver/remote/bidi_bridge.rb', line 35
def create_session(capabilities) super begin @bidi = Selenium::WebDriver::BiDi.new(url: validated_socket_url) # Reuse the BiDi object's socket as the connection until the bridge owns it directly. @connection = @bidi.ws rescue StandardError quit raise end end
#get(url)
[ GitHub ]# File 'rb/lib/selenium/webdriver/remote/bidi_bridge.rb', line 58
def get(url) browsing_context.navigate(context: window_handle, url: url, wait: readiness_state) nil end
#go_back
[ GitHub ]# File 'rb/lib/selenium/webdriver/remote/bidi_bridge.rb', line 63
def go_back browsing_context.traverse_history(context: window_handle, delta: -1) nil end
#go_forward
[ GitHub ]# File 'rb/lib/selenium/webdriver/remote/bidi_bridge.rb', line 68
def go_forward browsing_context.traverse_history(context: window_handle, delta: 1) nil end
#install_web_extension(path)
[ GitHub ]# File 'rb/lib/selenium/webdriver/remote/bidi_bridge.rb', line 48
def install_web_extension(path) result = web_extension.install(extension_data: web_extension_data(path)) WebExtension.new(result.extension) end
#quit
[ GitHub ]# File 'rb/lib/selenium/webdriver/remote/bidi_bridge.rb', line 78
def quit bidi&.close rescue *QUIT_ERRORS nil ensure super end
#readiness_state (private)
[ GitHub ]# File 'rb/lib/selenium/webdriver/remote/bidi_bridge.rb', line 117
def readiness_state READINESS_STATE.fetch(capabilities[:page_load_strategy] || 'normal') end
#refresh
[ GitHub ]# File 'rb/lib/selenium/webdriver/remote/bidi_bridge.rb', line 73
def refresh browsing_context.reload(context: window_handle, wait: readiness_state) nil end
#uninstall_web_extension(id)
[ GitHub ]# File 'rb/lib/selenium/webdriver/remote/bidi_bridge.rb', line 53
def uninstall_web_extension(id) web_extension.uninstall(extension: id) nil end
#validated_socket_url (private)
# File 'rb/lib/selenium/webdriver/remote/bidi_bridge.rb', line 92
def validated_socket_url url = @capabilities[:web_socket_url] return url if url.is_a?(String) && url.start_with?('ws://', 'wss://') raise Error::WebDriverError, "BiDi was enabled, but the remote end did not return a valid webSocketUrl: #{url.inspect}." end
#web_extension (private)
[ GitHub ]# File 'rb/lib/selenium/webdriver/remote/bidi_bridge.rb', line 104
def web_extension @web_extension ||= BiDi::Protocol::WebExtension.new(connection) end
#web_extension_data(path) (private)
A directory only resolves on the machine running the browser, so upload it to the remote end and reference the returned path; archives and base64 bytes travel inline.
# File 'rb/lib/selenium/webdriver/remote/bidi_bridge.rb', line 110
def web_extension_data(path) return web_extension.extension_base64_encoded(value: encode_extension(path)) unless File.directory?(path) path = upload(path) if respond_to?(:upload) web_extension.extension_path(path: path) end