mirror of https://github.com/rails/rails
Add support for Playwright as a driver for system tests
This commit is contained in:
parent
6db58ed7b6
commit
72c5270e45
|
@ -1,3 +1,7 @@
|
|||
* Add support for Playwright as a driver for system tests.
|
||||
|
||||
*Yuki Nishijima*
|
||||
|
||||
* Rename `fixture_file_upload` method to `file_fixture_upload`
|
||||
|
||||
Declare an alias to preserve the backwards compatibility of `fixture_file_upload`
|
||||
|
|
|
@ -30,7 +30,7 @@ module ActionDispatch
|
|||
|
||||
private
|
||||
def registerable?
|
||||
[:selenium, :cuprite, :rack_test].include?(@driver_type)
|
||||
[:selenium, :cuprite, :rack_test, :playwright].include?(@driver_type)
|
||||
end
|
||||
|
||||
def register
|
||||
|
@ -41,6 +41,7 @@ module ActionDispatch
|
|||
when :selenium then register_selenium(app)
|
||||
when :cuprite then register_cuprite(app)
|
||||
when :rack_test then register_rack_test(app)
|
||||
when :playwright then register_playwright(app)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -63,6 +64,17 @@ module ActionDispatch
|
|||
Capybara::RackTest::Driver.new(app, respect_data_method: true, **@options)
|
||||
end
|
||||
|
||||
def register_playwright(app)
|
||||
screen = { width: @screen_size[0], height: @screen_size[1] } if @screen_size
|
||||
options = {
|
||||
screen: screen,
|
||||
viewport: screen,
|
||||
**@options
|
||||
}.compact
|
||||
|
||||
Capybara::Playwright::Driver.new(app, **options)
|
||||
end
|
||||
|
||||
def setup
|
||||
Capybara.current_driver = name
|
||||
end
|
||||
|
|
|
@ -60,6 +60,14 @@ class DriverTest < ActiveSupport::TestCase
|
|||
assert_equal ({ js_errors: false }), driver.instance_variable_get(:@options)
|
||||
end
|
||||
|
||||
test "initializing the driver with Playwright" do
|
||||
driver = ActionDispatch::SystemTesting::Driver.new(:playwright, screen_size: [1400, 1400], options: { headless: true })
|
||||
|
||||
assert_equal :playwright, driver.instance_variable_get(:@driver_type)
|
||||
assert_equal [1400, 1400], driver.instance_variable_get(:@screen_size)
|
||||
assert_equal ({ headless: true }), driver.instance_variable_get(:@options)
|
||||
end
|
||||
|
||||
test "define extra capabilities using chrome" do
|
||||
driver = ActionDispatch::SystemTesting::Driver.new(:selenium, screen_size: [1400, 1400], using: :chrome) do |option|
|
||||
option.add_argument("start-maximized")
|
||||
|
|
Loading…
Reference in New Issue