diff --git a/lib/webdrivers/chrome_finder.rb b/lib/webdrivers/chrome_finder.rb index 68710b49..b3265c35 100644 --- a/lib/webdrivers/chrome_finder.rb +++ b/lib/webdrivers/chrome_finder.rb @@ -23,7 +23,11 @@ def win_location directories.each do |dir| envs.each do |root| option = "#{ENV[root]}\\#{dir}\\#{file}" - return option if File.exist?(option) + if File.exist?(option) # rubocop:disable Style/Next + return jruby_path(option) if RUBY_PLATFORM == 'java' + + return option + end end end end @@ -64,6 +68,16 @@ def linux_version(location) def mac_version(location) System.call("#{Shellwords.escape location} --version")&.strip end + + private + + # Escapes spaces and parentheses in given path + # for JRuby on Windows. Fixes #41 and #130. + def jruby_path(path) + path.gsub(' ', '` ') + .gsub('(', '`(') + .gsub(')', '`)') + end end end end