Sha256: 7c3321580d4c58e2e8ed0952f65fd135bc533e9212d0522b38735078b9fcdde5
Contents?: true
Size: 1.13 KB
Versions: 2
Compression:
Stored size: 1.13 KB
Contents
# frozen_string_literal: true module Rspeckled module Selenium module Drivers class Chrome attr_reader :downloads_directory def initialize(options) self.downloads_directory = options.fetch(:downloads_directory) end def driver(app) ::Capybara::Selenium::Driver.new( app, browser: :chrome, options: options, ) end def headless(app) ::Capybara::Selenium::Driver.new( app, browser: :chrome, options: headless_options, ) end private def downloads_directory=(dir) ::Dir.mkdir(dir) unless ::Dir.exist?(dir) @downloads_directory = dir end def options browser_options = ::Selenium::WebDriver::Chrome::Options.new browser_options.add_preference(:profile, prompt_for_download: { popups: 0 }) browser_options.add_preference(:download, default_directory: downloads_directory) browser_options.add_argument('--window-size=1920,1200') browser_options end def headless_options options.dup.tap do |browser_options| browser_options.add_argument('--headless') browser_options.add_argument('--disable-gpu') end end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rspeckled-2.1.1 | lib/rspeckled/plugins/extensions/selenium/drivers/chrome.rb |
rspeckled-2.1.0 | lib/rspeckled/plugins/extensions/selenium/drivers/chrome.rb |