Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/yusukeiwaki/capybara-playwright-driver
Playwright driver for Capybara
https://github.com/yusukeiwaki/capybara-playwright-driver
Last synced: about 6 hours ago
JSON representation
Playwright driver for Capybara
- Host: GitHub
- URL: https://github.com/yusukeiwaki/capybara-playwright-driver
- Owner: YusukeIwaki
- License: mit
- Created: 2021-04-22T14:08:54.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2024-12-21T08:00:06.000Z (21 days ago)
- Last Synced: 2025-01-04T13:21:29.709Z (7 days ago)
- Language: Ruby
- Size: 228 KB
- Stars: 159
- Watchers: 5
- Forks: 16
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
[![Gem Version](https://badge.fury.io/rb/capybara-playwright-driver.svg)](https://badge.fury.io/rb/capybara-playwright-driver)
# π Playwright driver for Capybara
Make it easy to introduce Playwright into your Rails application.
```ruby
gem 'capybara-playwright-driver'
```**NOTE**: If you want to use Playwright-native features (such as auto-waiting, various type of locators, ...), [consider using playwright-ruby-client directly](https://playwright-ruby-client.vercel.app/docs/article/guides/rails_integration_with_null_driver).
## Examples
```ruby
require 'capybara-playwright-driver'# setup
Capybara.register_driver(:playwright) do |app|
Capybara::Playwright::Driver.new(app, browser_type: :firefox, headless: false)
end
Capybara.default_max_wait_time = 15
Capybara.default_driver = :playwright
Capybara.save_path = 'tmp/capybara'# run
Capybara.app_host = 'https://github.com'
visit '/'
first('div.search-input-container').click
fill_in('query-builder-test', with: 'Capybara')## [REMARK] We can use Playwright-native selector and action, instead of Capybara DSL.
# first('[aria-label="Capybara, Search all of GitHub"]').click
page.driver.with_playwright_page do |page|
page.get_by_label('Capybara, Search all of GitHub').click
endall('[data-testid="results-list"] h3').each do |li|
#puts "#{li.all('a').first.text} by Capybara"
puts "#{li.with_playwright_element_handle { |handle| handle.text_content }} by Playwright"
end
```Refer the [documentation](https://playwright-ruby-client.vercel.app/docs/article/guides/rails_integration) for more detailed configuration.
## License
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
## 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](https://github.com/[USERNAME]/capybara-playwright/blob/master/CODE_OF_CONDUCT.md).