lib/rspeckled/plugins/capybara.rb in rspeckled-0.0.33 vs lib/rspeckled/plugins/capybara.rb in rspeckled-0.0.34
- old
+ new
@@ -16,15 +16,53 @@
begin
require 'capybara/rspec'
require 'capybara/rails'
if defined?(Capybara::Driver::Base)
+ downloads_directory = "#{Dir.pwd}/tmp/downloads/"
+ Dir.mkdir(downloads_directory) unless Dir.exist?(downloads_directory)
+
+ chrome_options = {
+ 'chromeOptions' => {
+ 'prefs' => {
+ 'profile.default_content_settings.popups' => 0,
+ 'download.default_directory' => downloads_directory,
+ },
+ 'args' => %w{
+ window-size=1920,1200
+ },
+ },
+ }
+
Capybara.register_driver :chrome do |app|
- Capybara::Selenium::Driver.new(app, :browser => :chrome)
+ Capybara::Selenium::Driver.new(
+ app,
+ :browser => :chrome,
+ :desired_capabilities => Selenium::WebDriver::Remote::Capabilities.chrome(chrome_options)
+ )
end
+ headless_chrome_options = chrome_options.dup
+ headless_chrome_options['chromeOptions']['binary'] = '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome'
+ headless_chrome_options['chromeOptions']['args'] << 'headless'
+ headless_chrome_options['chromeOptions']['args'] << 'disable-gpu'
+
+ Capybara.register_driver :headless_chrome do |app|
+ Capybara::Selenium::Driver.new(
+ app,
+ :browser => :chrome,
+ :desired_capabilities => Selenium::WebDriver::Remote::Capabilities.chrome(headless_chrome_options)
+ )
+ end
+
+ firefox_profile = Selenium::WebDriver::Firefox::Profile.new
+ firefox_profile['browser.download.dir'] = downloads_directory
+ firefox_profile['browser.download.folderList'] = 2
+ firefox_profile['browser.helperApps.neverAsk.saveToDisk'] = 'images/jpeg, application/pdf, application/octet-stream'
+ firefox_profile['pdfjs.disabled'] = true
+
Capybara.register_driver :firefox do |app|
- Capybara::Selenium::Driver.new(app, :browser => :firefox)
+ Capybara::Selenium::Driver.new(app, :browser => :firefox, :profile => firefox_profile)
end
if defined?(Selenium::WebDriver)
Selenium::WebDriver.logger.output = 'log/selenium.log'
end