class Capybara::Playwright::BrowserRunner::PlaywrightCreate

Public Class Methods

new(options) click to toggle source
# File lib/capybara/playwright/browser_runner.rb, line 54
def initialize(options)
  @playwright_cli_executable_path = options[:playwright_cli_executable_path] || 'npx playwright'
  @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

Public Instance Methods

playwright_browser() click to toggle source
# File lib/capybara/playwright/browser_runner.rb, line 69
def playwright_browser
  browser_type = playwright_execution.playwright.send(@browser_type)
  browser_options = @browser_options.value
  browser_type.launch(**browser_options)
end
playwright_execution() click to toggle source
# File lib/capybara/playwright/browser_runner.rb, line 63
def playwright_execution
  @playwright_execution ||= ::Playwright.create(
    playwright_cli_executable_path: @playwright_cli_executable_path,
  )
end