2022-01-01 13:38:12 +00:00
|
|
|
# Copyright (C) 2012-2022 Zammad Foundation, https://zammad-foundation.org/
|
2021-06-01 12:20:20 +00:00
|
|
|
|
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
|
2021-10-18 13:46:03 +00:00
|
|
|
options = Selenium::WebDriver::Chrome::Options.new(
|
2022-03-04 13:49:17 +00:00
|
|
|
logging_prefs: {
|
2018-12-19 14:47:15 +00:00
|
|
|
browser: 'ALL'
|
|
|
|
},
|
2022-03-04 13:49:17 +00:00
|
|
|
prefs: {
|
2021-10-18 13:46:03 +00:00
|
|
|
'intl.accept_languages' => 'en-US',
|
|
|
|
'profile.default_content_setting_values.notifications' => 1, # ALLOW notifications
|
2020-09-02 13:17:45 +00:00
|
|
|
},
|
2022-03-04 13:49:17 +00:00
|
|
|
# Disable the "Chrome is controlled by automation software" info bar.
|
|
|
|
excludeSwitches: ['enable-automation'],
|
2018-12-19 14:47:15 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
options = {
|
2021-10-18 13:46:03 +00:00
|
|
|
browser: :chrome,
|
|
|
|
options: options
|
2018-12-19 14:47:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ENV['REMOTE_URL'].present?
|
|
|
|
options[:browser] = :remote
|
|
|
|
options[:url] = ENV['REMOTE_URL']
|
2022-03-04 13:49:17 +00:00
|
|
|
options[:options].headless!
|
2018-12-19 14:47:15 +00:00
|
|
|
end
|
|
|
|
|
2021-11-04 13:40:58 +00:00
|
|
|
ENV['FAKE_SELENIUM_LOGIN_USER_ID'] = nil
|
|
|
|
|
2021-10-19 08:26:40 +00:00
|
|
|
Capybara::Selenium::Driver.new(app, **options).tap do |driver|
|
|
|
|
# Selenium 4 installs a default file_detector which finds wrong files/directories such as zammad/test.
|
2021-10-20 10:08:58 +00:00
|
|
|
driver.browser.file_detector = nil if ENV['REMOTE_URL'].present?
|
2021-10-19 08:26:40 +00:00
|
|
|
end
|
2018-12-19 14:47:15 +00:00
|
|
|
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
|
|
|
|
|
|
|
options = {
|
2021-10-18 13:46:03 +00:00
|
|
|
browser: :firefox,
|
|
|
|
options: Selenium::WebDriver::Firefox::Options.new(profile: profile),
|
2018-12-19 14:47:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if ENV['REMOTE_URL'].present?
|
|
|
|
options[:browser] = :remote
|
|
|
|
options[:url] = ENV['REMOTE_URL']
|
2022-03-04 13:49:17 +00:00
|
|
|
options[:options].headless!
|
2018-12-19 14:47:15 +00:00
|
|
|
end
|
|
|
|
|
2021-11-04 13:40:58 +00:00
|
|
|
ENV['FAKE_SELENIUM_LOGIN_USER_ID'] = nil
|
|
|
|
|
2021-10-19 08:26:40 +00:00
|
|
|
Capybara::Selenium::Driver.new(app, **options).tap do |driver|
|
|
|
|
# Selenium 4 installs a default file_detector which finds wrong files/directories such as zammad/test.
|
2021-10-20 10:08:58 +00:00
|
|
|
driver.browser.file_detector = nil if ENV['REMOTE_URL'].present?
|
2021-10-19 08:26:40 +00:00
|
|
|
end
|
2018-12-19 14:47:15 +00:00
|
|
|
end
|