selenium_driver.rb 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. # This file registers the custom Zammad chrome and firefox drivers.
  2. # The options check if a REMOTE_URL ENV is given and change the
  3. # configurations accordingly.
  4. Capybara.register_driver(:zammad_chrome) do |app|
  5. # Turn on browser logs
  6. capabilities = Selenium::WebDriver::Remote::Capabilities.chrome(
  7. loggingPrefs: {
  8. browser: 'ALL'
  9. },
  10. )
  11. options = {
  12. browser: :chrome,
  13. desired_capabilities: capabilities,
  14. }
  15. if ENV['REMOTE_URL'].present?
  16. options[:browser] = :remote
  17. options[:url] = ENV['REMOTE_URL']
  18. end
  19. Capybara::Selenium::Driver.new(app, options)
  20. end
  21. Capybara.register_driver(:zammad_firefox) do |app|
  22. profile = Selenium::WebDriver::Firefox::Profile.new
  23. profile['intl.locale.matchOS'] = false
  24. profile['intl.accept_languages'] = 'en-US'
  25. profile['general.useragent.locale'] = 'en-US'
  26. capabilities = Selenium::WebDriver::Remote::Capabilities.firefox(
  27. firefox_profile: profile,
  28. )
  29. options = {
  30. browser: :firefox,
  31. desired_capabilities: capabilities,
  32. }
  33. if ENV['REMOTE_URL'].present?
  34. options[:browser] = :remote
  35. options[:url] = ENV['REMOTE_URL']
  36. end
  37. Capybara::Selenium::Driver.new(app, options)
  38. end