From 0903df20c1c535325e0254265277f876046fbc9d Mon Sep 17 00:00:00 2001 From: Ariel Rzezak Date: Tue, 31 Dec 2024 12:21:28 -0300 Subject: [PATCH] Add playwright driver This PR adds support for the playwright driver. --- lib/capybara-screenshot.rb | 4 ++++ spec/unit/saver_spec.rb | 13 +++++++++++++ 2 files changed, 17 insertions(+) diff --git a/lib/capybara-screenshot.rb b/lib/capybara-screenshot.rb index 7d32560..a007f36 100644 --- a/lib/capybara-screenshot.rb +++ b/lib/capybara-screenshot.rb @@ -198,6 +198,10 @@ def self.capybara_tmp_path=(path) register_driver(:cuprite) do |driver, path| driver.render(path, :full => true) end + + register_driver(:playwright) do |driver, path| + driver.save_screenshot(path) + end end # Register filename prefix formatters diff --git a/spec/unit/saver_spec.rb b/spec/unit/saver_spec.rb index 7408b41..408e7ff 100644 --- a/spec/unit/saver_spec.rb +++ b/spec/unit/saver_spec.rb @@ -311,6 +311,19 @@ end end + describe "with playwright driver" do + before do + allow(capybara_mock).to receive(:current_driver).and_return(:playwright) + end + + it 'saves driver render' do + expect(driver_mock).to receive(:save_screenshot).with(screenshot_path) + + saver.save + expect(saver).to be_screenshot_saved + end + end + describe "with webkit driver" do before do allow(capybara_mock).to receive(:current_driver).and_return(:webkit)