aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/system_testing/browser.rb
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/lib/action_dispatch/system_testing/browser.rb')
-rw-r--r--actionpack/lib/action_dispatch/system_testing/browser.rb50
1 files changed, 36 insertions, 14 deletions
diff --git a/actionpack/lib/action_dispatch/system_testing/browser.rb b/actionpack/lib/action_dispatch/system_testing/browser.rb
index 14ea06459d..10e6888ab3 100644
--- a/actionpack/lib/action_dispatch/system_testing/browser.rb
+++ b/actionpack/lib/action_dispatch/system_testing/browser.rb
@@ -1,26 +1,48 @@
-require "action_dispatch/system_testing/driver"
+# frozen_string_literal: true
module ActionDispatch
module SystemTesting
- class Browser < Driver # :nodoc:
- def initialize(name, screen_size)
- super(name)
+ class Browser # :nodoc:
+ attr_reader :name
+
+ def initialize(name)
@name = name
- @screen_size = screen_size
end
- def use
- register
- super
+ def type
+ case name
+ when :headless_chrome
+ :chrome
+ when :headless_firefox
+ :firefox
+ else
+ name
+ end
+ end
+
+ def options
+ case name
+ when :headless_chrome
+ headless_chrome_browser_options
+ when :headless_firefox
+ headless_firefox_browser_options
+ end
end
private
- def register
- Capybara.register_driver @name do |app|
- Capybara::Selenium::Driver.new(app, browser: @name).tap do |driver|
- driver.browser.manage.window.size = Selenium::WebDriver::Dimension.new(*@screen_size)
- end
- end
+ def headless_chrome_browser_options
+ options = Selenium::WebDriver::Chrome::Options.new
+ options.args << "--headless"
+ options.args << "--disable-gpu"
+
+ options
+ end
+
+ def headless_firefox_browser_options
+ options = Selenium::WebDriver::Firefox::Options.new
+ options.args << "-headless"
+
+ options
end
end
end