YusukeIwaki / capybara-playwright-driver

Playwright driver for Capybara
MIT License
153 stars 13 forks source link

How to specify Playwright configuration? #82

Open adamreisnz opened 1 month ago

adamreisnz commented 1 month ago

Hello, thanks for making this Playwright/Capybara driver!

I might be doing something wrong, but I'm having a hard time to figure out how to pass basic Playwright configuration when initializing the driver.

For example, I would like to modify the testIdAttribute configuration param. When normally using Playwright, you would define this in your config like so:

export default defineConfig({
  use: {
    testIdAttribute: 'test-id',
  },
})

How does this translate to the Capybara driver? How can I include these settings when initalizing?

Capybara.register_driver :playwright do |app|
  Capybara::Playwright::Driver.new(app,
    playwright_cli_executable_path: './node_modules/.bin/playwright',
    browser_type: ENV["PLAYWRIGHT_BROWSER"]&.to_sym || :chromium,
    headless: true,
    timeout: 10
  )
end

Or better yet, can the Capybara driver use my local playwright.config.js somehow?

I could not find any answers in the documentation.

crespire commented 1 month ago

Following, as my issue #81 is also related to passing options to the underlying Playwright driver.