Sha256: 2ddefd868c1ddfb10265a95523001111f6695955be015747412b9bd2286b6c85

Contents?: true

Size: 966 Bytes

Versions: 6

Compression:

Stored size: 966 Bytes

Contents

# frozen_string_literal: true

module Wayfarer
  module Networking
    class Selenium
      include Strategy

      MOCK_STATUS_CODE = 200
      MOCK_RESPONSE_HEADERS = {}.freeze

      def create
        ::Selenium::WebDriver.for(Wayfarer.config.selenium.driver, **options)
      end

      def destroy(instance)
        instance.quit
      end

      def navigate(instance, url)
        instance.navigate.to(url)
      end

      def live(instance)
        success(url: instance.current_url,
                body: instance.page_source,
                status_code: MOCK_STATUS_CODE,
                headers: MOCK_RESPONSE_HEADERS)
      end

    private

      def options
        Wayfarer.config.selenium.options.merge(http_client: http_client)
      end

      def http_client
        ::Selenium::WebDriver::Remote::Http::Default.new.tap do |client|
          client.read_timeout = Wayfarer.config.selenium.client_timeout
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
wayfarer-0.4.6 lib/wayfarer/networking/selenium.rb
wayfarer-0.4.5 lib/wayfarer/networking/selenium.rb
wayfarer-0.4.4 lib/wayfarer/networking/selenium.rb
wayfarer-0.4.3 lib/wayfarer/networking/selenium.rb
wayfarer-0.4.2 lib/wayfarer/networking/selenium.rb
wayfarer-0.4.1 lib/wayfarer/networking/selenium.rb