🎭 Playwright driver for Capybara
gem 'capybara-playwright-driver'
Examples
require 'capybara-playwright-driver'
# setup
.register_driver(:playwright) do |app|
::Playwright::Driver.new(app, browser_type: :firefox, headless: false)
end
.default_max_wait_time = 15
.default_driver = :playwright
.save_path = 'tmp/capybara'
# run
.app_host = 'https://github.com'
visit '/'
fill_in('q', with: 'Capybara')
## [REMARK] Use Playwright-native Page instead of flaky Capybara's selector/action.
# find('a[data-item-type="global_search"]').click
page.driver.with_playwright_page do |page|
page.click('a[data-item-type="global_search"]')
end
all('.repo-list-item').each do |li|
puts "#{li.all('a').first.text} by Capybara"
puts "#{li.with_playwright_element_handle { |handle| handle.query_selector('a').text_content }} by Playwright"
end
License
The gem is available as open source under the terms of the MIT License.
Code of Conduct
Everyone interacting in the Capybara::Playwright project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.