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


                          
                                     
                    

                                            
                                    

         
             

                             

         






                                                 
                                                                                                      






                                                                                                   
           


       
module ActionDispatch
  module SystemTesting
    class Driver # :nodoc:
      def initialize(name, **options)
        @name = name
        @browser = options[:using]
        @screen_size = options[:screen_size]
        @options = options[:options]
      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 }.merge(@options)).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