DEV Community

Discussion on: The complete guide to setup a CI/CD for Rails 6+ on Gitlab

Collapse
 
colindresj profile image
JC

Hi,

I tried with that container version, but I'm still getting the same problem.

Thread Thread
 
zimski profile image
CHADDA Chakib

Are you sure that your system test is trying to connect with the remote chrome hosted inside the selenium container.

I think your issue is that the tests is trying to run in the local container and gets this error because there is no chrome installed in the build container.

Make sure that is used

 driver_options[:url] = ENV['selenium_remote_url'] if ENV['selenium_remote_url']
Thread Thread
 
colindresj profile image
JC

My application_system_test_case.rb looks like this:

require "test_helper"
require "socket"

def prepare_options
  driver_options = {
    desired_capabilities: {
      chromeOptions: {
        args: %w[headless disable-gpu disable-dev-shm-usage] # preserve memory & cpu consumption
      }
    }
  }

  driver_options[:url] = ENV["selenium_remote_url"] if ENV["selenium_remote_url"]

  driver_options
end

class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
  driven_by :selenium, using: :chrome, screen_size: [1400, 1400], options: prepare_options
end

And within the configure block ofconfig/environments/test.rb I have:

  net = Socket.ip_address_list.detect{|addr| addr.ipv4_private? }
  ip = net.nil? ? 'localhost' : net.ip_address
  config.domain = ip
  config.action_mailer.default_url_options = { :host => config.domain }

  Capybara.server_port = 8200
  Capybara.server_host = ip