aboutsummaryrefslogblamecommitdiffstats
path: root/actionpack/lib/action_dispatch/system_testing/driver.rb
blob: 72d132d64f2d64f3daece762d36337ea4ecc2faf (plain) (tree)
1
2
3
4
5
6
7
8
9


                          
                                     
                    

                                            

         
             

                             

         














                                                                                                   
           


       
module ActionDispatch
  module SystemTesting
    class Driver # :nodoc:
      def initialize(name, **options)
        @name = name
        @browser = options[:using]
        @screen_size = options[:screen_size]
      end

      def use
        register if selenium?
        setup
      end

      private
        def selenium?
          @name == :selenium
        end

        def register
          Capybara.register_driver @name do |app|
            Capybara::Selenium::Driver.new(app, browser: @browser).tap do |driver|
              driver.browser.manage.window.size = Selenium::WebDriver::Dimension.new(*@screen_size)
            end
          end
        end

        def setup
          Capybara.current_driver = @name
        end
    end
  end
end