Sha256: da5e3ad6f7a004e2c343ca83c38034834f490192f917fbc31fd0e1c36e09fce5
Contents?: true
Size: 1.22 KB
Versions: 3
Compression:
Stored size: 1.22 KB
Contents
# frozen_string_literal: true module Rspeckled module Selenium module Drivers class Firefox attr_reader :downloads_directory def initialize(options) self.downloads_directory = options.fetch(:downloads_directory) end def driver(app) ::Capybara::Selenium::Driver.new(app, :browser => :firefox, :profile => profile, :options => options) end def headless(app) ::Capybara::Selenium::Driver.new(app, :browser => :firefox, :profile => profile, :options => headless_options) end private def downloads_directory=(dir) ::Dir.mkdir(dir) unless ::Dir.exist?(dir) @downloads_directory = dir end def profile ::Selenium::WebDriver::Firefox::Profile.new.tap do |profile| profile['browser.download.dir'] = downloads_directory profile['browser.download.folderList'] = 2 profile['browser.helperApps.neverAsk.saveToDisk'] = 'images/jpeg, application/pdf, application/octet-stream' profile['pdfjs.disabled'] = true end end def options ::Selenium::WebDriver::Firefox::Options.new end def headless_options options.dup.tap do |browser_options| browser_options.add_argument('--headless') end end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems