Solution 1 - Selenium::WebDriver::Chrome.driver_path=

There is a Selenium::WebDriver::Chrome.driver_path= method that allows specifying of the chromedriver binary:

require 'watir'

# Specify the driver path
chromedriver_path = File.join(File.absolute_path('../..', File.dirname(__FILE__)),"browsers","chromedriver.exe")
Selenium::WebDriver::Chrome.driver_path = chromedriver_path

# Start the browser as normal
b = Watir::Browser.new :chrome
b.goto 'www.google.com'
b.close

Solution 2 - Specify :driver_path during browser initialization

As an alternative, you can also specify the driver path when initializing the browser. This is a bit nicer in that you do not need to have Selenium code, but would be repetitive if you initialize the browser in different places.

# Determine the driver path
chromedriver_path = File.join(File.absolute_path('../..', File.dirname(__FILE__)),"browsers","chromedriver.exe")

# Initialize the browser with the driver path
browser = Watir::Browser.new :chrome, driver_path: chromedriver_path

Solution 3 - Update ENV['PATH']

When I had originally answered this question, for whatever reason, I had not been able to get the above solution to work. Setting the value did not appear to be used when Selenium-WebDriver started the driver in. While the first solution is the recommended approach, this is an alternative.

Another option is to programmatically add the desired directory to the path, which is stored in the ENV['PATH']. You can see in the Selenium::WebDriver::Platform that the binary is located by checking if the executable exists in any of the folders in the path (from version 2.44.0):

def find_binary(*binary_names)
  paths = ENV['PATH'].split(File::PATH_SEPARATOR)
  binary_names.map! { |n| "#{n}.exe" } if windows?

  binary_names.each do |binary_name|
    paths.each do |path|
      exe = File.join(path, binary_name)
      return exe if File.executable?(exe)
    end
  end

  nil
end

To specify the folder that includes the binary, you simply need to change the ENV['PATH'] (to append the directory):

require 'watir'

# Determine the directory containing chromedriver.exe
chromedriver_directory = File.join(File.absolute_path('../..', File.dirname(__FILE__)),"browsers")

# Add that directory to the path
ENV['PATH'] = "#{ENV['PATH']}#{File::PATH_SEPARATOR}#{chromedriver_directory}"

# Start the browser as normal
b = Watir::Browser.new :chrome
b.goto 'www.google.com'
b.close

nbulaj/ruby-chromedriver: Ruby 2.x, Chrome / Chrome ... - GitHub

https://github.com/nbulaj/ruby-chromedriver

Ruby 2.x, Chrome / Chrome driver, NodeJS on Docker for Cucumber specs - nbulaj/ruby-chromedriver.

Running Selenium with Headless Chrome in Ruby

https://intoli.com/blog/running-selenium-with-headless-chrome-in-ruby/

Sep 6, 2017 ... A guide to setting up Selenium with Ruby to work with Google Chrome in headless mode.

Selenium webdriver, chromeDriver and Ruby on Windows | by ...

https://medium.com/@amdcaruso/selenium-webdriver-chromedriver-ruby-on-windows-1688132cbe3

Jul 20, 2017 ... Below you can find a script for MacOS and Windows on how to install Selenium- web driver, Chrome Driver and Ruby. Please note I chose a ...

How to specify the location of the chromedriver binary - Stack Overflow

https://stackoverflow.com/questions/27719345/how-to-specify-the-location-of-the-chromedriver-binary

I am on Windows 7, Using Ruby version 1.9.3p551 and I am referring to tutorial http://watirwebdriver.com/chrome/. How do I tell Watir (and ...

chromedriver-helper | RubyGems.org | your community gem host

https://rubygems.org/gems/chromedriver-helper/versions/1.0.0

Easy installation and use of chromedriver, the Chromium project's selenium webdriver adapter. ... RubyGems.org is the Ruby community's gem hosting service.

Capabilities & ChromeOptions - ChromeDriver - WebDriver for ...

https://chromedriver.chromium.org/capabilities

This is supported by Python, Ruby, etc. While it is also available in Java, its usage in Java is deprecated. Using the ChromeOptions class. You can create an  ...

setting up chrome-driver path in ruby · GitHub

https://gist.github.com/mubbashir/9776740

setting up chrome-driver path in ruby. GitHub Gist: instantly share code, notes, and snippets.

ChromeDriver - WebDriver for Chrome

https://chromedriver.chromium.org/

ChromeDriver is available for Chrome on Android and Chrome on Desktop (Mac, Linux, Windows and ChromeOS). You can view the current implementation ...

nbulai/ruby-chromedriver

https://hub.docker.com/r/nbulai/ruby-chromedriver

x, Chrome / Chrome driver, NodeJS on Docker for Capybara/Cucumber specs. Based on official Ruby 2.x image and uses stable Chrome official repository. Uses ...

Debian -- Details of package ruby-chromedriver-helper in buster

https://packages.debian.org/buster/ruby-chromedriver-helper

chromedriver-helper installs an executable, chromedriver-helper, in your gem path, and configures Selenium to invoke it as the web driver. This script will, if ...