Class: Capybara::Playwright::BrowserRunner::PlaywrightConnectToPlaywrightServer

Inherits:
Object
  • Object
show all
Defined in:
lib/capybara/playwright/browser_runner.rb

Instance Method Summary collapse

Constructor Details

#initialize(endpoint_url, options) ⇒ PlaywrightConnectToPlaywrightServer

Returns a new instance of PlaywrightConnectToPlaywrightServer.



19
20
21
22
23
24
25
26
# File 'lib/capybara/playwright/browser_runner.rb', line 19

def initialize(endpoint_url, options)
  @ws_endpoint = endpoint_url
  @browser_type = options[:browser_type] || :chromium
  unless %i(chromium firefox webkit).include?(@browser_type)
    raise ArgumentError.new("Unknown browser_type: #{@browser_type}")
  end
  @browser_options = BrowserOptions.new(options)
end

Instance Method Details

#playwright_browserObject



32
33
34
35
36
# File 'lib/capybara/playwright/browser_runner.rb', line 32

def playwright_browser
  browser_type = playwright_execution.playwright.send(@browser_type)
  browser_options = @browser_options.value
  browser_type.launch(**browser_options)
end

#playwright_executionObject



28
29
30
# File 'lib/capybara/playwright/browser_runner.rb', line 28

def playwright_execution
  @playwright_execution ||= ::Playwright.connect_to_playwright_server(@ws_endpoint)
end