Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions lib/playwright.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
# namespace declaration
module Playwright; end

require 'json'

# concurrent-ruby
require 'concurrent'

Expand Down Expand Up @@ -139,7 +141,7 @@ def stop
# end
#
# @experimental
module_function def connect_to_browser_server(ws_endpoint, browser_type: 'chromium', &block)
module_function def connect_to_browser_server(ws_endpoint, browser_type: 'chromium', browser_opts: {}, &block)
known_browser_types = ['chromium', 'firefox', 'webkit']
unless known_browser_types.include?(browser_type)
raise ArgumentError, "Unknown browser type: #{browser_type}. Known types are: #{known_browser_types.join(', ')}"
Expand All @@ -150,7 +152,8 @@ def stop

transport = WebSocketTransport.new(
ws_endpoint: ws_endpoint,
headers: { 'x-playwright-browser' => browser_type },
headers: { 'x-playwright-browser' => browser_type,
'x-playwright-launch-options' => JSON.generate(browser_opts) },
)
connection = Connection.new(transport)
connection.mark_as_remote
Expand Down