Class: ActionDispatch::SystemTesting::Driver
Do not use. This class is for internal use only.
Relationships & Source Files | |
Inherits: | Object |
Defined in: | actionpack/lib/action_dispatch/system_testing/driver.rb |
Class Method Summary
Instance Attribute Summary
- #name readonly
- #registerable? ⇒ Boolean readonly private
Instance Method Summary
- #use
- #browser_options private
- #register private
- #register_cuprite(app) private
- #register_playwright(app) private
- #register_rack_test(app) private
- #register_selenium(app) private
- #setup private
Constructor Details
.new(driver_type, **options, &capabilities) ⇒ Driver
# File 'actionpack/lib/action_dispatch/system_testing/driver.rb', line 10
def initialize(driver_type, **, &capabilities) @driver_type = driver_type @screen_size = [:screen_size] @options = [: ] || {} @name = @options.delete(:name) || driver_type @capabilities = capabilities if driver_type == :selenium gem "selenium-webdriver", ">= 4.0.0" require "selenium/webdriver" @browser = Browser.new( [:using]) @browser.preload unless @options[:browser] == :remote else @browser = nil end end
Instance Attribute Details
#name (readonly)
[ GitHub ]# File 'actionpack/lib/action_dispatch/system_testing/driver.rb', line 8
attr_reader :name
#registerable? ⇒ Boolean
(readonly, private)
[ GitHub ]
# File 'actionpack/lib/action_dispatch/system_testing/driver.rb', line 34
def registerable? [:selenium, :cuprite, :rack_test, :playwright].include?(@driver_type) end
Instance Method Details
#browser_options (private)
[ GitHub ]# File 'actionpack/lib/action_dispatch/system_testing/driver.rb', line 51
def @options.merge(options: @browser. ).compact end
#register (private)
[ GitHub ]# File 'actionpack/lib/action_dispatch/system_testing/driver.rb', line 38
def register @browser&.configure(&@capabilities) Capybara.register_driver name do |app| case @driver_type 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
#register_cuprite(app) (private)
[ GitHub ]# File 'actionpack/lib/action_dispatch/system_testing/driver.rb', line 61
def register_cuprite(app) Capybara::Cuprite::Driver.new(app, @options.merge(window_size: @screen_size)) end
#register_playwright(app) (private)
[ GitHub ]# File 'actionpack/lib/action_dispatch/system_testing/driver.rb', line 69
def register_playwright(app) screen = { width: @screen_size[0], height: @screen_size[1] } if @screen_size = { screen: screen, viewport: screen, **@options }.compact Capybara::Playwright::Driver.new(app, ** ) end
#register_rack_test(app) (private)
[ GitHub ]# File 'actionpack/lib/action_dispatch/system_testing/driver.rb', line 65
def register_rack_test(app) Capybara::RackTest::Driver.new(app, respect_data_method: true, **@options) end
#register_selenium(app) (private)
[ GitHub ]#setup (private)
[ GitHub ]# File 'actionpack/lib/action_dispatch/system_testing/driver.rb', line 80
def setup Capybara.current_driver = name end
#use
[ GitHub ]# File 'actionpack/lib/action_dispatch/system_testing/driver.rb', line 27
def use register if registerable? setup end