Sha256: b7545f11d248cf9684341bcb317842178da67ecca072df3ad9af092c707da59d

Contents?: true

Size: 1.02 KB

Versions: 6

Compression:

Stored size: 1.02 KB

Contents

# frozen_string_literal: true

require 'aranha/selenium/driver_factory/base'

module Aranha
  module Selenium
    class DriverFactory
      class Chrome < ::Aranha::Selenium::DriverFactory::Base
        def build
          ::Selenium::WebDriver.for :chrome, options: chrome_options
        end

        private

        def chrome_options
          r = ::Selenium::WebDriver::Chrome::Options.new
          chrome_arguments.each { |arg| r.add_argument(arg) }
          r.add_preference(:download, prompt_for_download: false, default_directory: downloads_dir)
          r
        end

        def chrome_arguments
          r = %w[--disable-popup-blocking --disable-translate
                 --disable-blink-features=AutomationControlled]
          r << '--ignore-certificate-errors' if accept_insecure_certs?
          r << '--headless' if headless?
          r << "--user-agent=#{user_agent}" if user_agent.present?
          r << "--user-data-dir=#{profile_dir}" if profile_dir.present?
          r
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
aranha-selenium-0.6.0 lib/aranha/selenium/driver_factory/chrome.rb
aranha-selenium-0.5.0 lib/aranha/selenium/driver_factory/chrome.rb
aranha-selenium-0.4.2 lib/aranha/selenium/driver_factory/chrome.rb
aranha-selenium-0.4.1 lib/aranha/selenium/driver_factory/chrome.rb
aranha-selenium-0.4.0 lib/aranha/selenium/driver_factory/chrome.rb
aranha-selenium-0.3.0 lib/aranha/selenium/driver_factory/chrome.rb