Sha256: 69fb711174f4f849cce818bf54eded9c783a0ba3a537eeb5b96ac0e7eb5ef877
Contents?: true
Size: 1.9 KB
Versions: 16
Compression:
Stored size: 1.9 KB
Contents
# frozen_string_literal: true require 'aranha/selenium/driver_factory/base' module Aranha module Selenium class DriverFactory class Firefox < ::Aranha::Selenium::DriverFactory::Base def build ::Selenium::WebDriver.for( :firefox, options: build_options, desired_capabilities: build_capabilities ) end private def build_args r = [] r << '--headless' if headless? r end def build_capabilities if accept_insecure_certs? ::Selenium::WebDriver::Remote::Capabilities.firefox(accept_insecure_certs: true) else ::Selenium::WebDriver::Remote::Capabilities.firefox end end def build_options r = ::Selenium::WebDriver::Firefox::Options.new(args: build_args, prefs: build_preferences) build_profile.if_present { |v| r.profile = v } r end def build_preferences r = { 'browser.download.dir' => downloads_dir, 'browser.download.folderList' => 2, 'browser.helperApps.neverAsk.saveToDisk' => auto_download_mime_types.join(';'), 'pdfjs.disabled' => true } r['general.useragent.override'] = user_agent if user_agent.present? r end def build_profile if profile_name.present? ::Selenium::WebDriver::Firefox::Profile.from_name(v) elsif profile_dir.present? ::FileUtils.mkdir_p(profile_dir) ::Selenium::WebDriver::Firefox::Profile.new(profile_dir) end end def auto_download_mime_types ::File.read( ::File.join(__dir__, 'firefox_auto_download_mime_types') ).each_line.map(&:strip) end end end end end
Version data entries
16 entries across 16 versions & 2 rubygems