Omari Wilson
Omari Wilson

Reputation: 41

Webdrivers::BrowserNotFound: Failed to find Chrome binary

I am trying to run a system test and keep running in this error:

rails aborted! Webdrivers::BrowserNotFound: Failed to find Chrome binary. /home/hasani/PROJECTS/hasani_pos/test/application_system_test_case.rb:4:in <class:ApplicationSystemTestCase>' /home/hasani/PROJECTS/hasani_pos/test/application_system_test_case.rb:3:in ' /home/hasani/PROJECTS/hasani_pos/test/system/items_test.rb:1:in <main>' /home/hasani/PROJECTS/hasani_pos/bin/rails:5:in <top (required)>' /home/hasani/PROJECTS/hasani_pos/bin/spring:10:in block in <top (required)>' /home/hasani/PROJECTS/hasani_pos/bin/spring:7:in <top (required)>' Tasks: TOP => test:system (See full trace by running task with --trace)

items_test.rb

require "application_system_test_case"

class ItemsTest < ApplicationSystemTestCase
  test "visiting the index" do
    visit '/items'
    assert_selector "h1", text: "Items"
  end

  test "creating an item" do
    visit '/items'
    click_on "Create Item"
    assert_template 'new'
  end
end

test_helper.rb

ENV['RAILS_ENV'] ||= 'test'
require_relative "../config/environment"
require "rails/test_help"
require "minitest/reporters"
require 'capybara/rails'
require 'capybara/minitest'
require 'webdrivers'
Minitest::Reporters.use!

class ActiveSupport::TestCase
  # Run tests in parallel with specified workers
  parallelize(workers: :number_of_processors)

  # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
  fixtures :all

  def is_logged_in?
    !session[:user_id].nil?
  end

  # Make the Capybara DSL available in all integration tests
  include Capybara::DSL
  # Make `assert_*` methods behave like Minitest assertions
  include Capybara::Minitest::Assertions

  # Reset sessions and driver between tests
  teardown do
    Capybara.reset_sessions!
    Capybara.use_default_driver
  end
end

index.html.erb

<%= provide(:title, 'Item Index') %>
<h1>Item Index</h1>
  
  <a href="/add" class="btn btn-primary">Create Item</a>
  
  <div class="row">
    <div class="col-md-6 col-md-offset-3">
      <table>
        <tr>
          <thead>
            <th>Name</th>
            <th>Description</th>
            <th>Price</th>
          </thead>
        </tr>
        <% @items.each do |item| %>
          <tr>
            <td><%= item.name %></td>
            <td><%= item.description %></td>
            <td><%= item.price %></td>
            <td>
              <%= link_to "Edit", edit_item_path(item) %>
              <%= link_to "Delete", 
                          item_path(item), method: :delete, 
                          "data-confirm": "Are you sure you want to delete?" %>
            </td>
          </tr>
        <% end %>  
      </table>
    </div>
  </div>

new.html.erb

<h1>Create Item</h1>

<div class="row">
  <div class="col-md-6 col-md-offset-3">
    <%= form_for(@item) do |f| %>
    <%= render 'shared/error_msg' %>  

      <%= f.label :name %>
      <%= f.text_field :name %>
   
      <%= f.label :description %>
      <%= f.text_area :description %>
      
      <%= f.label :price %>
      <%= f.number_field :price %>
      
      <%= f.submit "Create Item", class: "btn btn-primary" %>
    <% end %>
  </div>
</div>

Upvotes: 4

Views: 8210

Answers (2)

Harry Wood
Harry Wood

Reputation: 2351

It means webdriver is unable to find google chrome. Do you have the browser installed?

For minimal ubuntu development you only need this package:

sudo apt-get install chromium-chromedriver

Or later versions can be downloaded (set-up tips)

Upvotes: 12

Aleksis Zalitis
Aleksis Zalitis

Reputation: 121

Basically what the error says is that the webdriver is unable to find google chrome. Make sure you have installed it in the correct place on your machine.

This issue goes into more detail about it, with the exception of being ruby over python:

Upvotes: 2

Related Questions