Ubuntu 18.04 LTS Ruby 2.6.5 selenium-webdriver 3.142.7
When using selenium-webdriver with ruby, if you put the driver file in the directory where the path is in linux, you can use the driver without specifying the driver path. I will summarize the method with notes at that time.
This time, I will use the Chrome driver as an example. From the following, proceed assuming that the driver is installed.
First, look at the environment variables to see which directories are in your path.
$ printenv PATH /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
The directories that are in the path are displayed, separated by ":". This time I put the driver file in "usr / local / bin".
/usr/local/bin$ ls chromedriver
If you call the chrome driver with selenium in this state, you can use it without specifying the path.
require 'selenium-webdriver' d = Selenium::WebDriver.for :chrome d.get('http://****')
If the driver file name is not "chromedriver", an error will occur at runtime. I installed the driver for ver.83, so I saved it as "chromedriver83" when installing the driver, but I stumbled upon an error.
/usr/local/bin$ ls chromedriver83
Error when running script
Unable to find chromedriver. Please download the server from (Selenium::WebDriver::Error::WebDriverError)
I'm told I can't find the chrome driver
If you want to specify the driver path in the script, you can use a different file name.
require 'selenium-webdriver' Selenium::WebDriver::Chrome::Service.driver_path = '/usr/local/bin/chromedriver83' d = Selenium::WebDriver.for :chrome d.get('http://****')
By the way, with this method, it doesn't matter if the path is passed or not.