2018-12-19 14:47:15 +00:00
|
|
|
# This file registers the custom Zammad chrome and firefox drivers.
|
|
|
|
# The options check if a REMOTE_URL ENV is given and change the
|
|
|
|
# configurations accordingly.
|
|
|
|
|
|
|
|
Capybara.register_driver(:zammad_chrome) do |app|
|
|
|
|
|
|
|
|
# Turn on browser logs
|
|
|
|
capabilities = Selenium::WebDriver::Remote::Capabilities.chrome(
|
2020-09-02 13:17:45 +00:00
|
|
|
loggingPrefs: {
|
2018-12-19 14:47:15 +00:00
|
|
|
browser: 'ALL'
|
|
|
|
},
|
2020-09-02 13:17:45 +00:00
|
|
|
chromeOptions: {
|
|
|
|
prefs: {
|
2021-03-16 15:24:09 +00:00
|
|
|
'intl.accept_languages' => 'en-US',
|
|
|
|
'profile.default_content_setting_values.notifications' => 1, # ALLOW notifications
|
2020-09-02 13:17:45 +00:00
|
|
|
},
|
|
|
|
},
|
2018-12-19 14:47:15 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
options = {
|
|
|
|
browser: :chrome,
|
|
|
|
desired_capabilities: capabilities,
|
|
|
|
}
|
|
|
|
|
|
|
|
if ENV['REMOTE_URL'].present?
|
|
|
|
options[:browser] = :remote
|
|
|
|
options[:url] = ENV['REMOTE_URL']
|
|
|
|
end
|
|
|
|
|
|
|
|
Capybara::Selenium::Driver.new(app, options)
|
|
|
|
end
|
|
|
|
|
|
|
|
Capybara.register_driver(:zammad_firefox) do |app|
|
|
|
|
|
|
|
|
profile = Selenium::WebDriver::Firefox::Profile.new
|
|
|
|
profile['intl.locale.matchOS'] = false
|
|
|
|
profile['intl.accept_languages'] = 'en-US'
|
|
|
|
profile['general.useragent.locale'] = 'en-US'
|
2021-03-16 15:24:09 +00:00
|
|
|
profile['permissions.default.desktop-notification'] = 1 # ALLOW notifications
|
2018-12-19 14:47:15 +00:00
|
|
|
|
|
|
|
capabilities = Selenium::WebDriver::Remote::Capabilities.firefox(
|
|
|
|
firefox_profile: profile,
|
|
|
|
)
|
|
|
|
|
|
|
|
options = {
|
|
|
|
browser: :firefox,
|
|
|
|
desired_capabilities: capabilities,
|
|
|
|
}
|
|
|
|
|
|
|
|
if ENV['REMOTE_URL'].present?
|
|
|
|
options[:browser] = :remote
|
|
|
|
options[:url] = ENV['REMOTE_URL']
|
|
|
|
end
|
|
|
|
|
|
|
|
Capybara::Selenium::Driver.new(app, options)
|
|
|
|
end
|