Sha256: 0251ea44ce30dd253d12df4fd71d6f845bbb0f1398429d4951aa063123605cd7

Contents?: true

Size: 1.14 KB

Versions: 3

Compression:

Stored size: 1.14 KB

Contents

# frozen_string_literal: true

module ActionDispatch
  module SystemTesting
    class Browser # :nodoc:
      attr_reader :name

      def initialize(name)
        @name = name
      end

      def type
        case name
        when :headless_chrome
          :chrome
        when :headless_firefox
          :firefox
        else
          name
        end
      end

      def options
        case name
        when :headless_chrome
          headless_chrome_browser_options
        when :headless_firefox
          headless_firefox_browser_options
        end
      end

      def capabilities
        @option ||=
          case type
          when :chrome
            ::Selenium::WebDriver::Chrome::Options.new
          when :firefox
            ::Selenium::WebDriver::Firefox::Options.new
          end
      end

      private
        def headless_chrome_browser_options
          capabilities.args << "--headless"
          capabilities.args << "--disable-gpu" if Gem.win_platform?

          capabilities
        end

        def headless_firefox_browser_options
          capabilities.args << "-headless"

          capabilities
        end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
actionpack-6.0.0.rc1 lib/action_dispatch/system_testing/browser.rb
actionpack-6.0.0.beta3 lib/action_dispatch/system_testing/browser.rb
actionpack-6.0.0.beta2 lib/action_dispatch/system_testing/browser.rb