SeleniumHQ/selenium · error · Error::WebDriverError
not a file: #{path.inspect}
Error message
not a file: #{path.inspect} What it means
assert_file raises WebDriverError when the given path does not exist as a regular file. It is used to validate driver executable paths before launch (assert_executable calls it first). A directory, a missing path, or a broken symlink all trigger this error.
Source
Thrown at rb/lib/selenium/webdriver/common/platform.rb:136
`cygpath #{flags.join ' '} "#{path}"`.strip
end
def unix_path(path)
path.tr(File::ALT_SEPARATOR, File::SEPARATOR)
end
def windows_path(path)
path.tr(File::SEPARATOR, File::ALT_SEPARATOR)
end
def make_writable(file)
File.chmod 0o766, file
end
def assert_file(path)
return if File.file? path
raise Error::WebDriverError, "not a file: #{path.inspect}"
end
def assert_executable(path)
assert_file(path)
return if File.executable? path
raise Error::WebDriverError, "not executable: #{path.inspect}"
end
def exit_hook
pid = Process.pid
at_exit { yield if Process.pid == pid }
end
def localhost
info = Socket.getaddrinfo 'localhost', 80, Socket::AF_INET, Socket::SOCK_STREAMView on GitHub (pinned to aa36b38e69)
Solutions
- Verify the path exists with File.file?(path) and correct it.
- Let Selenium Manager auto-manage the driver by not setting a manual driver_path.
- Use an absolute path to avoid working-directory ambiguity.
- Ensure the driver binary is downloaded to the configured location in CI.
Example fix
# before Selenium::WebDriver::Chrome::Service.driver_path = '/wrong/path/chromedriver' # after (let Selenium Manager handle it) Selenium::WebDriver::Chrome::Service.driver_path = nil # or point to the real file Selenium::WebDriver::Chrome::Service.driver_path = '/usr/local/bin/chromedriver'
Defensive patterns
Strategy: validation
Validate before calling
raise ArgumentError, "driver not found at #{path}" unless path && File.file?(path) Type guard
def driver_file?(path) !path.nil? && File.file?(path) end
Try / catch
begin
Selenium::WebDriver::Chrome::Service.driver_path = path
Selenium::WebDriver.for(:chrome)
rescue Selenium::WebDriver::Error::WebDriverError => e
raise unless e.message.include?('not a file')
Selenium::WebDriver.for(:chrome) # let Selenium Manager auto-resolve
end Prevention
- Prefer letting Selenium Manager auto-manage the driver path.
- Use absolute paths and verify with File.file? before assignment.
- Ensure CI images download the driver to a known, stable location.
When it happens
Trigger: Pointing a Service or DriverFinder at a path that does not exist. Setting driver path via Selenium::WebDriver::Chrome::Service.driver_path= to a wrong location. Passing a directory path where a binary file is expected.
Common situations: Driver binary not downloaded/installed. Typo in the configured path. Path is correct on one machine but missing in CI. Using a relative path that resolves differently.
Related errors
- not executable: #{path.inspect}
- could not find extension at #{path.inspect}
- could not find extension at #{path.inspect}
- unknown os: #{host_os.inspect}
- unable to translate 'localhost' for TCP + IPv4
AI-assisted analysis of SeleniumHQ/selenium@aa36b38e69 (2026-08-14).
Data as JSON: /api/errors/d94c9bcd06d36520.
Report an issue: GitHub.