" Failed to find Chrome binary." in system spec gitlab-ci

Viewed 459

Context:

  • Rails 6.0.3.4
  • Ruby 2.7.1

In my gitlab CI, I run a system spec using RSpec and Selenium. The test runs well locally but throw the following error in gitlab CI

Failure/Error: driven_by :selenium, using: :chrome
     Webdrivers::BrowserNotFound:
       Failed to find Chrome binary.
     # ./spec/rails_helper.rb:35:in `block (2 levels) in '

Could anyone kindly advise me how to fix this error ?


Here is my .gitlab-ci.yml

image: "ruby:2.7.1-buster"

cache:
  key: ${CI_COMMIT_REF_SLUG}
  paths:
    - vendor/bundle
    - .bundle
    - node_modules/
    - .yarn

stages:
  - build
  - test

variables:
  POSTGRES_HOST: xxxx
  POSTGRES_USER: xxxx
  POSTGRES_DB: xxxx
  POSTGRES_PASSWORD: xxxx

before_script:
  - gem install bundler
  - bundle install -j $(nproc) --deployment

job_0_build:
  stage: build
  script:
    - ruby -v

job_3_tests:
  stage: test
  cache:
    paths:
    - node_modules/
    - .yarn
  services:
    - postgres:12.1
  before_script:
    - apt-get update -qq && apt-get install -y -qq nodejs
    - curl -o- -L https://yarnpkg.com/install.sh | bash
    - export PATH="$HOME/.yarn/bin:$HOME/.config/yarn/global/node_modules/.bin:$PATH"
    - yarn install --cache-folder .yarn
    - yarn --version
    - gem install bundler
    - bundle install -j $(nproc) --deployment
  script:
    - bundle exec rake assets:precompile RAILS_ENV=test
    - bundle exec rspec

Here is an extraction of my Gemfile.lock on (I think) relevant gems, I can provide others if you find useful

    selenium-webdriver (3.142.7)
      childprocess (>= 0.5, < 4.0)
      rubyzip (>= 1.2.2)
    chromedriver-helper (2.1.1)
      archive-zip (~> 0.10)
      nokogiri (~> 1.8)
    capybara (3.33.0)
      addressable
      mini_mime (>= 0.1.3)
      nokogiri (~> 1.8)
      rack (>= 1.6.0)
      rack-test (>= 0.6.3)
      regexp_parser (~> 1.5)
      xpath (~> 3.2)
    webdrivers (4.4.1)
      nokogiri (~> 1.6)
      rubyzip (>= 1.3.0)
      selenium-webdriver (>= 3.0, < 4.0)
0 Answers
Related