Skip to content

Commit 24876e6

Browse files
committed
Merge PR #48950
2 parents ae20b0d + 72c5270 commit 24876e6

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

actionpack/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
* Add support for Playwright as a driver for system tests.
2+
3+
*Yuki Nishijima*
4+
15
* Fix `HostAuthorization` potentially displaying the value of the
26
X_FORWARDED_HOST header when the HTTP_HOST header is being blocked.
37

actionpack/lib/action_dispatch/system_testing/driver.rb

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def use
3030

3131
private
3232
def registerable?
33-
[:selenium, :cuprite, :rack_test].include?(@driver_type)
33+
[:selenium, :cuprite, :rack_test, :playwright].include?(@driver_type)
3434
end
3535

3636
def register
@@ -41,6 +41,7 @@ def register
4141
when :selenium then register_selenium(app)
4242
when :cuprite then register_cuprite(app)
4343
when :rack_test then register_rack_test(app)
44+
when :playwright then register_playwright(app)
4445
end
4546
end
4647
end
@@ -63,6 +64,17 @@ def register_rack_test(app)
6364
Capybara::RackTest::Driver.new(app, respect_data_method: true, **@options)
6465
end
6566

67+
def register_playwright(app)
68+
screen = { width: @screen_size[0], height: @screen_size[1] } if @screen_size
69+
options = {
70+
screen: screen,
71+
viewport: screen,
72+
**@options
73+
}.compact
74+
75+
Capybara::Playwright::Driver.new(app, **options)
76+
end
77+
6678
def setup
6779
Capybara.current_driver = name
6880
end

actionpack/test/dispatch/system_testing/driver_test.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,14 @@ class DriverTest < ActiveSupport::TestCase
6060
assert_equal ({ js_errors: false }), driver.instance_variable_get(:@options)
6161
end
6262

63+
test "initializing the driver with Playwright" do
64+
driver = ActionDispatch::SystemTesting::Driver.new(:playwright, screen_size: [1400, 1400], options: { headless: true })
65+
66+
assert_equal :playwright, driver.instance_variable_get(:@driver_type)
67+
assert_equal [1400, 1400], driver.instance_variable_get(:@screen_size)
68+
assert_equal ({ headless: true }), driver.instance_variable_get(:@options)
69+
end
70+
6371
test "define extra capabilities using chrome" do
6472
driver = ActionDispatch::SystemTesting::Driver.new(:selenium, screen_size: [1400, 1400], using: :chrome) do |option|
6573
option.add_argument("start-maximized")

0 commit comments

Comments
 (0)