Module: Panda::Core::Testing::CupriteSetup
- Defined in:
- lib/panda/core/testing/support/system/cuprite_setup.rb
Class Attribute Summary collapse
-
.console_logger ⇒ Object
Returns the value of attribute console_logger.
Class Method Summary collapse
- .base_options ⇒ Object
- .ci_browser_options ⇒ Object
- .register_panda_cuprite_driver(name: :panda_cuprite, window_size: [1280, 720]) ⇒ Object
- .setup! ⇒ Object
Class Attribute Details
.console_logger ⇒ Object
Returns the value of attribute console_logger.
14 15 16 |
# File 'lib/panda/core/testing/support/system/cuprite_setup.rb', line 14 def console_logger @console_logger end |
Class Method Details
.base_options ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/panda/core/testing/support/system/cuprite_setup.rb', line 17 def self. ci_default_timeout = 30 ci_default_process_timeout = 120 default_timeout = ENV["CI"] ? ci_default_timeout : 5 default_process_timeout = ENV["CI"] ? ci_default_process_timeout : 10 cuprite_timeout = ENV["CUPRITE_TIMEOUT"]&.to_i || ENV["FERRUM_TIMEOUT"]&.to_i || default_timeout process_timeout_value = ENV["CUPRITE_PROCESS_TIMEOUT"]&.to_i || ENV["FERRUM_PROCESS_TIMEOUT"]&.to_i || default_process_timeout puts "[Cuprite Config] timeout = #{cuprite_timeout}, process_timeout = #{process_timeout_value}" if ENV["CI"] || ENV["DEBUG"] puts "[Cuprite Config] ENV: CUPRITE_TIMEOUT=#{ENV["CUPRITE_TIMEOUT"].inspect}, CUPRITE_PROCESS_TIMEOUT=#{ENV["CUPRITE_PROCESS_TIMEOUT"].inspect}" if ENV["CI"] || ENV["DEBUG"] browser_path = ENV["BROWSER_PATH"] || Panda::Core::Testing::Support::System::ChromePath.resolve { browser_path: browser_path, window_size: [1440, 1000], inspector: ENV["INSPECTOR"].in?(%w[y 1 yes true]), headless: !ENV["HEADLESS"].in?(%w[n 0 no false]), slowmo: ENV["SLOWMO"]&.to_f || 0, timeout: cuprite_timeout, js_errors: true, ignore_default_browser_options: false, process_timeout: process_timeout_value, wait_for_network_idle: false, pending_connection_errors: ENV["CI"] != "true", max_conns: 1, restart_if: {crashes: true, attempts: 2}, browser_options: { "no-sandbox": nil, "disable-gpu": nil, "disable-sync": nil, "disable-translate": nil, "no-first-run": nil, "ignore-certificate-errors": nil, "allow-insecure-localhost": nil, "enable-features": "NetworkService,NetworkServiceInProcess", "disable-blink-features": "AutomationControlled", "no-dbus": nil, "log-level": ENV["CI"] ? "0" : "3" } } end |
.ci_browser_options ⇒ Object
66 67 68 69 70 71 72 73 74 |
# File 'lib/panda/core/testing/support/system/cuprite_setup.rb', line 66 def self. { "disable-web-security" => nil, "allow-file-access-from-files" => nil, "allow-file-access" => nil, "disable-dev-shm-usage" => nil, # Sets shared memory in /tmp; don't use if lots of /dev/shm space "no-sandbox" => nil } end |
.register_panda_cuprite_driver(name: :panda_cuprite, window_size: [1280, 720]) ⇒ Object
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/panda/core/testing/support/system/cuprite_setup.rb', line 76 def self.register_panda_cuprite_driver(name: :panda_cuprite, window_size: [1280, 720]) = .dup [:window_size] = window_size [:browser_options] = [:browser_options].dup [:browser_options]["user-data-dir"] = Dir.mktmpdir("cuprite-profile") if ENV["CI"] == "true" # Covers both act and GitHub Actions [:browser_options].merge!() end [:logger] = console_logger if console_logger Capybara.register_driver name do |app| Capybara::Cuprite::Driver.new(app, **) end end |
.setup! ⇒ Object
93 94 95 96 97 98 |
# File 'lib/panda/core/testing/support/system/cuprite_setup.rb', line 93 def self.setup! register_panda_cuprite_driver(name: :panda_cuprite, window_size: [1280, 720]) register_panda_cuprite_driver(name: :panda_cuprite_mobile, window_size: [375, 667]) Capybara.default_driver = :panda_cuprite Capybara.javascript_driver = :panda_cuprite end |