use playwright driver
This commit is contained in:
parent
7b1c882498
commit
142c789e76
5 changed files with 29 additions and 0 deletions
3
.github/workflows/ci.yml
vendored
3
.github/workflows/ci.yml
vendored
|
@ -137,6 +137,9 @@ jobs:
|
||||||
- name: Setup the app runtime and dependencies
|
- name: Setup the app runtime and dependencies
|
||||||
uses: ./.github/actions/ci-setup-rails
|
uses: ./.github/actions/ci-setup-rails
|
||||||
|
|
||||||
|
- name: Setup playwright
|
||||||
|
run: bunx playwright install chromium
|
||||||
|
|
||||||
- name: Pre-compile assets
|
- name: Pre-compile assets
|
||||||
uses: ./.github/actions/ci-setup-assets
|
uses: ./.github/actions/ci-setup-assets
|
||||||
|
|
||||||
|
|
1
Gemfile
1
Gemfile
|
@ -19,6 +19,7 @@ gem 'anchored'
|
||||||
gem 'bcrypt'
|
gem 'bcrypt'
|
||||||
gem 'bootsnap', '>= 1.4.4', require: false # Reduces boot times through caching; required in config/boot.rb
|
gem 'bootsnap', '>= 1.4.4', require: false # Reduces boot times through caching; required in config/boot.rb
|
||||||
gem 'browser'
|
gem 'browser'
|
||||||
|
gem 'capybara-playwright-driver'
|
||||||
gem 'charlock_holmes'
|
gem 'charlock_holmes'
|
||||||
gem 'chartkick'
|
gem 'chartkick'
|
||||||
gem 'chunky_png'
|
gem 'chunky_png'
|
||||||
|
|
|
@ -157,6 +157,10 @@ GEM
|
||||||
capybara-email (3.0.2)
|
capybara-email (3.0.2)
|
||||||
capybara (>= 2.4, < 4.0)
|
capybara (>= 2.4, < 4.0)
|
||||||
mail
|
mail
|
||||||
|
capybara-playwright-driver (0.5.2)
|
||||||
|
addressable
|
||||||
|
capybara
|
||||||
|
playwright-ruby-client (>= 1.16.0)
|
||||||
capybara-screenshot (1.0.26)
|
capybara-screenshot (1.0.26)
|
||||||
capybara (>= 1.0, < 4)
|
capybara (>= 1.0, < 4)
|
||||||
launchy
|
launchy
|
||||||
|
@ -483,6 +487,9 @@ GEM
|
||||||
pdf-core (0.9.0)
|
pdf-core (0.9.0)
|
||||||
pg (1.5.6)
|
pg (1.5.6)
|
||||||
phonelib (0.8.8)
|
phonelib (0.8.8)
|
||||||
|
playwright-ruby-client (1.46.0)
|
||||||
|
concurrent-ruby (>= 1.1.6)
|
||||||
|
mime-types (>= 3.0)
|
||||||
prawn (2.4.0)
|
prawn (2.4.0)
|
||||||
pdf-core (~> 0.9.0)
|
pdf-core (~> 0.9.0)
|
||||||
ttfunk (~> 1.7)
|
ttfunk (~> 1.7)
|
||||||
|
@ -899,6 +906,7 @@ DEPENDENCIES
|
||||||
browser
|
browser
|
||||||
capybara
|
capybara
|
||||||
capybara-email
|
capybara-email
|
||||||
|
capybara-playwright-driver
|
||||||
capybara-screenshot
|
capybara-screenshot
|
||||||
charlock_holmes
|
charlock_holmes
|
||||||
chartkick
|
chartkick
|
||||||
|
|
|
@ -20,6 +20,7 @@ FileUtils.chdir APP_ROOT do
|
||||||
# Install JavaScript dependencies
|
# Install JavaScript dependencies
|
||||||
system! 'bun --version'
|
system! 'bun --version'
|
||||||
system! 'bun install'
|
system! 'bun install'
|
||||||
|
system! 'bunx playwright install chromium'
|
||||||
|
|
||||||
if ENV["UPDATE_WEBDRIVER"]
|
if ENV["UPDATE_WEBDRIVER"]
|
||||||
puts "\n== Updating webdrivers =="
|
puts "\n== Updating webdrivers =="
|
||||||
|
|
|
@ -24,6 +24,14 @@ def setup_driver(app, download_path, options)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Capybara.register_driver :playwright do |app|
|
||||||
|
Capybara::Playwright::Driver.new(app,
|
||||||
|
browser_type: (ENV['PLAYWRIGHT_BROWSER'] || 'chromium').to_sym, # :chromium (default) or :firefox, :webkit
|
||||||
|
headless: ENV['NO_HEADLESS'].blank?,
|
||||||
|
locale: Rails.application.config.i18n.default_locale,
|
||||||
|
downloadsPath: Capybara.save_path)
|
||||||
|
end
|
||||||
|
|
||||||
Capybara.register_driver :chrome do |app|
|
Capybara.register_driver :chrome do |app|
|
||||||
options = Selenium::WebDriver::Chrome::Options.new
|
options = Selenium::WebDriver::Chrome::Options.new
|
||||||
options.add_argument('--no-sandbox') unless ENV['SANDBOX']
|
options.add_argument('--no-sandbox') unless ENV['SANDBOX']
|
||||||
|
@ -62,6 +70,10 @@ Capybara::Screenshot.prune_strategy = :keep_last_run
|
||||||
Capybara::Screenshot.register_driver :chrome do |driver, path|
|
Capybara::Screenshot.register_driver :chrome do |driver, path|
|
||||||
driver.save_screenshot(path)
|
driver.save_screenshot(path)
|
||||||
end
|
end
|
||||||
|
# Tell Capybara::Screenshot how to take screenshots when using the playwright driver
|
||||||
|
Capybara::Screenshot.register_driver :playwright do |driver, path|
|
||||||
|
driver.save_screenshot(path)
|
||||||
|
end
|
||||||
|
|
||||||
RSpec.configure do |config|
|
RSpec.configure do |config|
|
||||||
config.before(:each, type: :system) do
|
config.before(:each, type: :system) do
|
||||||
|
@ -69,6 +81,10 @@ RSpec.configure do |config|
|
||||||
end
|
end
|
||||||
|
|
||||||
config.before(:each, type: :system, js: true) do
|
config.before(:each, type: :system, js: true) do
|
||||||
|
driven_by :playwright
|
||||||
|
end
|
||||||
|
|
||||||
|
config.before(:each, type: :system, chrome: true) do
|
||||||
driven_by :chrome
|
driven_by :chrome
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue